Projects
osmocom:latest
open5gs
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 3
View file
open5gs_2.4.9.dsc -> open5gs_2.4.10.dsc
Changed
@@ -2,7 +2,7 @@ Source: open5gs Binary: open5gs-common, open5gs-mme, open5gs-sgwc, open5gs-smf, open5gs-amf, open5gs-sgwu, open5gs-upf, open5gs-hss, open5gs-pcrf, open5gs-nrf, open5gs-ausf, open5gs-udm, open5gs-pcf, open5gs-nssf, open5gs-bsf, open5gs-udr, open5gs, open5gs-dbg Architecture: any -Version: 2.4.9 +Version: 2.4.10 Maintainer: Harald Welte <laforge@gnumonks.org> Uploaders: Sukchan Lee <acetcom@gmail.com> Homepage: https://open5gs.org @@ -30,8 +30,8 @@ open5gs-udr deb net optional arch=any open5gs-upf deb net optional arch=any Checksums-Sha1: - c585dad5c293f2a68383e2180bab44dd3dac99fb 11458408 open5gs_2.4.9.tar.xz + 3106956d8fb9841c8b7c7d9e1b7901ff17f70ef5 11462572 open5gs_2.4.10.tar.xz Checksums-Sha256: - 0cf94d60ada195ed7a06c05c1c14a60446a20eddca0922840475a771bcee8b37 11458408 open5gs_2.4.9.tar.xz + 2982479e69c668310146534d924ae99b1563bd523afda4c586857dbee8e535eb 11462572 open5gs_2.4.10.tar.xz Files: - 2461f19cdf7e4ac1bc2d2f5969faaa88 11458408 open5gs_2.4.9.tar.xz + 8e05392e534352b5a950bc8b575bd0ce 11462572 open5gs_2.4.10.tar.xz
View file
open5gs_2.4.9.tar.xz/.github/workflows/meson-ci.yml -> open5gs_2.4.10.tar.xz/.github/workflows/meson-ci.yml
Changed
@@ -6,11 +6,11 @@ name: Build and Test on MacOS Latest runs-on: macos-latest steps: - - name: Install MongoDB with Package Manager - run: | - brew tap mongodb/brew - brew install mongodb-community - brew services start mongodb-community +# - name: Install MongoDB with Package Manager +# run: | +# brew tap mongodb/brew +# brew install mongodb-community +# brew services start mongodb-community - name: Create the TUN device with the interface name `ogstun`. run: | sudo ifconfig lo0 alias 127.0.0.2 netmask 255.255.255.255 @@ -33,6 +33,7 @@ sudo ifconfig lo0 alias 127.0.0.18 netmask 255.255.255.255 sudo ifconfig lo0 alias 127.0.0.19 netmask 255.255.255.255 sudo ifconfig lo0 alias 127.0.0.20 netmask 255.255.255.255 + sudo ifconfig lo0 alias 127.0.1.10 netmask 255.255.255.255 - name: Install the dependencies for building the source code. run: brew install mongo-c-driver libidn libmicrohttpd nghttp2 bison libusrsctp libtins talloc meson - name: Check out repository code
View file
open5gs_2.4.10.tar.xz/.tarball-version
Added
@@ -0,0 +1 @@ +2.4.10
View file
open5gs_2.4.9.tar.xz/configs/open5gs/amf.yaml.in -> open5gs_2.4.10.tar.xz/configs/open5gs/amf.yaml.in
Changed
@@ -35,7 +35,7 @@ # - ::0 # port: 7777 # -# o SBI Server(https://<all address avaiable>:443) +# o SBI Server(https://<all address available>:443) # sbi: # - tls: # key: amf.key @@ -85,9 +85,42 @@ # l_onoff: true # l_linger: 10 # +# <NF Service> +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - namf-comm +# +# <NF Discovery Query Parameter> +# +# o (Default) If you do not set Query Parameter as shown below, +# +# sbi: +# - addr: 127.0.0.5 +# port: 7777 +# +# - 'service-names' is included. +# +# sbi: +# - addr: 127.0.0.5 +# port: 7777 +# discovery: +# option: +# no_service_names: false +# +# o To remove 'service-names' from URI query parameters in NS Discovery +# no_service_names: true +# +# * For Indirect Communication with Delegated Discovery, +# 'service-names' is always included in the URI query parameter. +# * That is, 'no_service_names' has no effect. +# # <NGAP Server>> # -# o NGAP Server(all address avaiable) +# o NGAP Server(all address available) # ngap: # # o NGAP Server(0.0.0.0:38412) @@ -104,7 +137,7 @@ # - addr: 127.0.0.5 # port: 38413 # -# o NGAP Server(address avaiable in `eth0` interface) +# o NGAP Server(address available in `eth0` interface) # ngap: # dev: eth0 # @@ -317,10 +350,10 @@ # # max: # -# o Maximum Number of UE per AMF/MME +# o Maximum Number of UE # ue: 1024 -# o Maximum Number of gNB/eNB per AMF/MME -# gnb: 64 +# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI) +# peer: 64 # max:
View file
open5gs_2.4.9.tar.xz/configs/open5gs/ausf.yaml.in -> open5gs_2.4.10.tar.xz/configs/open5gs/ausf.yaml.in
Changed
@@ -35,7 +35,7 @@ # - ::0 # port: 7777 # -# o SBI Server(https://<all address avaiable>:443) +# o SBI Server(https://<all address available>:443) # sbi: # - tls: # key: ausf.key @@ -85,6 +85,39 @@ # l_onoff: true # l_linger: 10 # +# <NF Service> +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - nausf-auth +# +# <NF Discovery Query Parameter> +# +# o (Default) If you do not set Query Parameter as shown below, +# +# sbi: +# - addr: 127.0.0.11 +# port: 7777 +# +# - 'service-names' is included. +# +# sbi: +# - addr: 127.0.0.11 +# port: 7777 +# discovery: +# option: +# no_service_names: false +# +# o To remove 'service-names' from URI query parameters in NS Discovery +# no_service_names: true +# +# * For Indirect Communication with Delegated Discovery, +# 'service-names' is always included in the URI query parameter. +# * That is, 'no_service_names' has no effect. +# ausf: sbi: - addr: 127.0.0.11 @@ -152,10 +185,10 @@ # # max: # -# o Maximum Number of UE per AMF/MME +# o Maximum Number of UE # ue: 1024 -# o Maximum Number of gNB/eNB per AMF/MME -# gnb: 64 +# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI) +# peer: 64 # max:
View file
open5gs_2.4.9.tar.xz/configs/open5gs/bsf.yaml.in -> open5gs_2.4.10.tar.xz/configs/open5gs/bsf.yaml.in
Changed
@@ -37,7 +37,7 @@ # - ::0 # port: 7777 # -# o SBI Server(https://<all address avaiable>:443) +# o SBI Server(https://<all address available>:443) # sbi: # - tls: # key: bsf.key @@ -87,6 +87,39 @@ # l_onoff: true # l_linger: 10 # +# <NF Service> +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - nbsf-management +# +# <NF Discovery Query Parameter> +# +# o (Default) If you do not set Query Parameter as shown below, +# +# sbi: +# - addr: 127.0.0.15 +# port: 7777 +# +# - 'service-names' is included. +# +# sbi: +# - addr: 127.0.0.15 +# port: 7777 +# discovery: +# option: +# no_service_names: false +# +# o To remove 'service-names' from URI query parameters in NS Discovery +# no_service_names: true +# +# * For Indirect Communication with Delegated Discovery, +# 'service-names' is always included in the URI query parameter. +# * That is, 'no_service_names' has no effect. +# bsf: sbi: - addr: 127.0.0.15 @@ -154,10 +187,10 @@ # # max: # -# o Maximum Number of UE per AMF/MME +# o Maximum Number of UE # ue: 1024 -# o Maximum Number of gNB/eNB per AMF/MME -# gnb: 64 +# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI) +# peer: 64 # max:
View file
open5gs_2.4.9.tar.xz/configs/open5gs/hss.yaml.in -> open5gs_2.4.10.tar.xz/configs/open5gs/hss.yaml.in
Changed
@@ -45,9 +45,9 @@ # # max: # -# o Maximum Number of UE per AMF/MME +# o Maximum Number of UE # ue: 1024 -# o Maximum Number of gNB/eNB per AMF/MME -# gnb: 64 +# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI) +# peer: 64 # max:
View file
open5gs_2.4.9.tar.xz/configs/open5gs/mme.yaml.in -> open5gs_2.4.10.tar.xz/configs/open5gs/mme.yaml.in
Changed
@@ -26,7 +26,7 @@ # # <S1AP Server>> # -# o S1AP Server(all address avaiable) +# o S1AP Server(all address available) # s1ap: # # o S1AP Server(0.0.0.0:36412) @@ -43,7 +43,7 @@ # - addr: 127.0.0.2 # port: 36413 # -# o S1AP Server(address avaiable in `eth0` interface) +# o S1AP Server(address available in `eth0` interface) # s1ap: # dev: eth0 # @@ -86,7 +86,7 @@ # # <GTP-C Server>> # -# o GTP-C Server(all address avaiable) +# o GTP-C Server(all address available) # gtpc: # # o GTP-C Server(127.0.0.2:2123, ::1:2123) @@ -391,10 +391,10 @@ # # max: # -# o Maximum Number of UE per AMF/MME +# o Maximum Number of UE # ue: 1024 -# o Maximum Number of gNB/eNB per AMF/MME -# gnb: 64 +# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI) +# peer: 64 # max:
View file
open5gs_2.4.9.tar.xz/configs/open5gs/nrf.yaml.in -> open5gs_2.4.10.tar.xz/configs/open5gs/nrf.yaml.in
Changed
@@ -1,5 +1,3 @@ -db_uri: mongodb://localhost/open5gs - # # logger: # @@ -38,7 +36,7 @@ # - ::0 # port: 7777 # -# o SBI Server(https://<all address avaiable>:443) +# o SBI Server(https://<all address available>:443) # sbi: # tls: # key: nrf.key @@ -77,6 +75,16 @@ # l_onoff: true # l_linger: 10 # +# <NF Service> +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - nnrf-nfm +# - nnrf-disc +# nrf: sbi: addr: @@ -101,10 +109,10 @@ # # max: # -# o Maximum Number of UE per AMF/MME +# o Maximum Number of UE # ue: 1024 -# o Maximum Number of gNB/eNB per AMF/MME -# gnb: 64 +# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI) +# peer: 64 # max:
View file
open5gs_2.4.9.tar.xz/configs/open5gs/nssf.yaml.in -> open5gs_2.4.10.tar.xz/configs/open5gs/nssf.yaml.in
Changed
@@ -35,7 +35,7 @@ # - ::0 # port: 7777 # -# o SBI Server(https://<all address avaiable>:443) +# o SBI Server(https://<all address available>:443) # sbi: # - tls: # key: nssf.key @@ -85,7 +85,7 @@ # l_onoff: true # l_linger: 10 # -# <List of avaiable Network Slice Instance(NSI)> +# <List of available Network Slice Instance(NSI)> # # o One NSI # - NRFhttp://::1:7777/nnrf-nfm/v1/nf-instances @@ -134,6 +134,40 @@ # so_linger: # l_onoff: true # l_linger: 10 +# +# <NF Service> +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - nnssf-nsselection +# +# <NF Discovery Query Parameter> +# +# o (Default) If you do not set Query Parameter as shown below, +# +# sbi: +# - addr: 127.0.0.14 +# port: 7777 +# +# - 'service-names' is included. +# +# sbi: +# - addr: 127.0.0.14 +# port: 7777 +# discovery: +# option: +# no_service_names: false +# +# o To remove 'service-names' from URI query parameters in NS Discovery +# no_service_names: true +# +# * For Indirect Communication with Delegated Discovery, +# 'service-names' is always included in the URI query parameter. +# * That is, 'no_service_names' has no effect. +# nssf: sbi: - addr: 127.0.0.14 @@ -194,10 +228,10 @@ # # max: # -# o Maximum Number of UE per AMF/MME +# o Maximum Number of UE # ue: 1024 -# o Maximum Number of gNB/eNB per AMF/MME -# gnb: 64 +# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI) +# peer: 64 # max:
View file
open5gs_2.4.9.tar.xz/configs/open5gs/pcf.yaml.in -> open5gs_2.4.10.tar.xz/configs/open5gs/pcf.yaml.in
Changed
@@ -37,7 +37,7 @@ # - ::0 # port: 7777 # -# o SBI Server(https://<all address avaiable>:443) +# o SBI Server(https://<all address available>:443) # sbi: # - tls: # key: pcf.key @@ -87,6 +87,46 @@ # l_onoff: true # l_linger: 10 # +# <NF Service> +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - npcf-am-policy-control +# - npcf-smpolicycontrol +# - npcf-policyauthorization +# +# == NOTE == +# Placing npcf-smpolicycontrol and pcf-policyauthorization +# in different NFs is not supported. Both npcf-smpolicycontrol +# and pcf-policyauthorization should be placed in the same NF. +# +# <NF Discovery Query Parameter> +# +# o (Default) If you do not set Query Parameter as shown below, +# +# sbi: +# - addr: 127.0.0.13 +# port: 7777 +# +# - 'service-names' is included. +# +# sbi: +# - addr: 127.0.0.13 +# port: 7777 +# discovery: +# option: +# no_service_names: false +# +# o To remove 'service-names' from URI query parameters in NS Discovery +# no_service_names: true +# +# * For Indirect Communication with Delegated Discovery, +# 'service-names' is always included in the URI query parameter. +# * That is, 'no_service_names' has no effect. +# pcf: sbi: - addr: 127.0.0.13 @@ -154,10 +194,10 @@ # # max: # -# o Maximum Number of UE per AMF/MME +# o Maximum Number of UE # ue: 1024 -# o Maximum Number of gNB/eNB per AMF/MME -# gnb: 64 +# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI) +# peer: 64 # max:
View file
open5gs_2.4.9.tar.xz/configs/open5gs/pcrf.yaml.in -> open5gs_2.4.10.tar.xz/configs/open5gs/pcrf.yaml.in
Changed
@@ -42,9 +42,9 @@ # # max: # -# o Maximum Number of UE per AMF/MME +# o Maximum Number of UE # ue: 1024 -# o Maximum Number of gNB/eNB per AMF/MME -# gnb: 64 +# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI) +# peer: 64 # max:
View file
open5gs_2.4.9.tar.xz/configs/open5gs/scp.yaml.in -> open5gs_2.4.10.tar.xz/configs/open5gs/scp.yaml.in
Changed
@@ -38,7 +38,7 @@ # - ::0 # port: 7777 # -# o SBI Server(https://<all address avaiable>:443) +# o SBI Server(https://<all address available>:443) # sbi: # - tls: # key: scp.key @@ -96,26 +96,30 @@ # - addr: 127.0.1.11 # port: 7777 # -# <Discovery> +# <For Indirect Communication with Delegated Discovery> # -# o NF Discovery and Selection -# for indirect communication with Delegated Discovery; +# o (Default) If you do not set Delegated Discovery as shown below, # -# o delegated: -# o auto: (Default) -# Use next-hop SCP if next-hop SCP avaiable. Otherwise NRF is used. -# => App fails if both next-hop SCP and NRF are unavailable. -# o yes: Use next-hop SCP always. -# => App fails if no next-hop SCP available. -# o no: Don't use next-hop SCP server. -# => App fails if no NRF available. +# next_scp: +# sbi: +# - addr: 127.0.1.10 +# port: 7777 +# +# - Use SCP if SCP avaiable. Otherwise NRF is used. +# => App fails if both NRF and SCP are unavailable. # # next_scp: -# sbi: -# - addr: 127.0.1.11 -# port: 7777 -# discovery: -# delegated: auto|yes|no +# sbi: +# - addr: 127.0.1.10 +# port: 7777 +# discovery: +# delegated: auto +# +# o To use SCP always => App fails if no SCP available. +# delegated: yes +# +# o Don't use SCP server => App fails if no NRF available. +# delegated: no # scp: sbi: @@ -184,10 +188,10 @@ # # max: # -# o Maximum Number of UE per AMF/MME +# o Maximum Number of UE # ue: 1024 -# o Maximum Number of gNB/eNB per AMF/MME -# gnb: 64 +# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI) +# peer: 64 # max:
View file
open5gs_2.4.9.tar.xz/configs/open5gs/sgwc.yaml.in -> open5gs_2.4.10.tar.xz/configs/open5gs/sgwc.yaml.in
Changed
@@ -142,10 +142,10 @@ # # max: # -# o Maximum Number of UE per AMF/MME +# o Maximum Number of UE # ue: 1024 -# o Maximum Number of gNB/eNB per AMF/MME -# gnb: 64 +# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI) +# peer: 64 # o Maximum Number of GTP peer nodes per SGWC/SMF # gtp_peer: 64 #
View file
open5gs_2.4.9.tar.xz/configs/open5gs/sgwu.yaml.in -> open5gs_2.4.10.tar.xz/configs/open5gs/sgwu.yaml.in
Changed
@@ -131,10 +131,10 @@ # # max: # -# o Maximum Number of UE per AMF/MME +# o Maximum Number of UE # ue: 1024 -# o Maximum Number of gNB/eNB per AMF/MME -# gnb: 64 +# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI) +# peer: 64 # max:
View file
open5gs_2.4.9.tar.xz/configs/open5gs/smf.yaml.in -> open5gs_2.4.10.tar.xz/configs/open5gs/smf.yaml.in
Changed
@@ -35,7 +35,7 @@ # - ::0 # port: 7777 # -# o SBI Server(https://<all address avaiable>:443) +# o SBI Server(https://<all address available>:443) # sbi: # - tls: # key: smf.key @@ -85,6 +85,40 @@ # l_onoff: true # l_linger: 10 # +# <NF Service> +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - nsmf-pdusession +# +# <NF Discovery Query Parameter> +# +# o (Default) If you do not set Query Parameter as shown below, +# +# sbi: +# - addr: 127.0.0.4 +# port: 7777 +# +# - 'service-names' is included. +# +# sbi: +# - addr: 127.0.0.4 +# port: 7777 +# discovery: +# option: +# no_service_names: false +# +# o To remove 'service-names' from URI query parameters in NS Discovery +# no_service_names: true +# +# * For Indirect Communication with Delegated Discovery, +# 'service-names' is always included in the URI query parameter. +# * That is, 'no_service_names' has no effect. +# +# # <PFCP Server> # # o PFCP Server(127.0.0.4:8805, ::1:8805) @@ -527,10 +561,10 @@ # # max: # -# o Maximum Number of UE per AMF/MME +# o Maximum Number of UE # ue: 1024 -# o Maximum Number of gNB/eNB per AMF/MME -# gnb: 64 +# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI) +# peer: 64 # o Maximum Number of GTP peer nodes per SGWC/SMF # gtp_peer: 64 #
View file
open5gs_2.4.9.tar.xz/configs/open5gs/udm.yaml.in -> open5gs_2.4.10.tar.xz/configs/open5gs/udm.yaml.in
Changed
@@ -35,7 +35,7 @@ # - ::0 # port: 7777 # -# o SBI Server(https://<all address avaiable>:443) +# o SBI Server(https://<all address available>:443) # sbi: # - tls: # key: udm.key @@ -85,6 +85,41 @@ # l_onoff: true # l_linger: 10 # +# <NF Service> +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - nudm-sdm +# - nudm-uecm +# - nudm-ueau +# +# <NF Discovery Query Parameter> +# +# o (Default) If you do not set Query Parameter as shown below, +# +# sbi: +# - addr: 127.0.0.12 +# port: 7777 +# +# - 'service-names' is included. +# +# sbi: +# - addr: 127.0.0.12 +# port: 7777 +# discovery: +# option: +# no_service_names: false +# +# o To remove 'service-names' from URI query parameters in NS Discovery +# no_service_names: true +# +# * For Indirect Communication with Delegated Discovery, +# 'service-names' is always included in the URI query parameter. +# * That is, 'no_service_names' has no effect. +# udm: sbi: - addr: 127.0.0.12 @@ -152,10 +187,10 @@ # # max: # -# o Maximum Number of UE per AMF/MME +# o Maximum Number of UE # ue: 1024 -# o Maximum Number of gNB/eNB per AMF/MME -# gnb: 64 +# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI) +# peer: 64 # max:
View file
open5gs_2.4.9.tar.xz/configs/open5gs/udr.yaml.in -> open5gs_2.4.10.tar.xz/configs/open5gs/udr.yaml.in
Changed
@@ -37,7 +37,7 @@ # - ::0 # port: 7777 # -# o SBI Server(https://<all address avaiable>:443) +# o SBI Server(https://<all address available>:443) # sbi: # - tls: # key: udr.key @@ -87,6 +87,39 @@ # l_onoff: true # l_linger: 10 # +# <NF Service> +# +# o NF Service Name(Default : all NF services available) +# service_name: +# +# o NF Service Name(Only some NF services are available) +# service_name: +# - nudr-dr +# +# <NF Discovery Query Parameter> +# +# o (Default) If you do not set Query Parameter as shown below, +# +# sbi: +# - addr: 127.0.0.20 +# port: 7777 +# +# - 'service-names' is included. +# +# sbi: +# - addr: 127.0.0.20 +# port: 7777 +# discovery: +# option: +# no_service_names: false +# +# o To remove 'service-names' from URI query parameters in NS Discovery +# no_service_names: true +# +# * For Indirect Communication with Delegated Discovery, +# 'service-names' is always included in the URI query parameter. +# * That is, 'no_service_names' has no effect. +# udr: sbi: - addr: 127.0.0.20 @@ -154,10 +187,10 @@ # # max: # -# o Maximum Number of UE per AMF/MME +# o Maximum Number of UE # ue: 1024 -# o Maximum Number of gNB/eNB per AMF/MME -# gnb: 64 +# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI) +# peer: 64 # max:
View file
open5gs_2.4.9.tar.xz/configs/open5gs/upf.yaml.in -> open5gs_2.4.10.tar.xz/configs/open5gs/upf.yaml.in
Changed
@@ -205,10 +205,10 @@ # # max: # -# o Maximum Number of UE per AMF/MME +# o Maximum Number of UE # ue: 1024 -# o Maximum Number of gNB/eNB per AMF/MME -# gnb: 64 +# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI) +# peer: 64 # max:
View file
open5gs_2.4.9.tar.xz/configs/sample.yaml.in -> open5gs_2.4.10.tar.xz/configs/sample.yaml.in
Changed
@@ -105,6 +105,31 @@ connect: - identity: pcrf.localdomain addr: 127.0.0.9 + +# +# <For Indirect Communication with Delegated Discovery> +# +# o (Default) If you do not set Delegated Discovery as shown below, +# +# sbi: +# - addr: 127.0.0.5 +# port: 7777 +# +# - Use SCP if SCP avaiable. Otherwise NRF is used. +# => App fails if both NRF and SCP are unavailable. +# +# sbi: +# - addr: 127.0.0.5 +# port: 7777 +# discovery: +# delegated: auto +# +# o To use SCP always => App fails if no SCP available. +# delegated: yes +# +# o Don't use SCP server => App fails if no NRF available. +# delegated: no +# amf: sbi: - addr: 127.0.0.5 @@ -233,26 +258,6 @@ # l_onoff: true # l_linger: 10 # -# <Discovery> -# -# o NF Discovery and Selection -# for indirect communication with Delegated Discovery; -# -# o delegated: -# o auto: (Default) -# Use SCP if SCP avaiable. Otherwise NRF is used. -# => App fails if both NRF and SCP are unavailable. -# o yes: Use SCP always. -# => App fails if no SCP available. -# o no: Don't use SCP server. -# => App fails if no NRF available. -# -# scp: -# sbi: -# - addr: 127.0.1.10 -# port: 7777 -# discovery: -# delegated: auto|yes|no # scp: sbi:
View file
open5gs_2.4.9.tar.xz/configs/systemd/99-open5gs.network -> open5gs_2.4.10.tar.xz/configs/systemd/99-open5gs.network
Changed
@@ -6,4 +6,5 @@ Address=2001:db8:cafe::1/48 Link +MTUBytes=1400 RequiredForOnline=false
View file
open5gs_2.4.9.tar.xz/debian/changelog -> open5gs_2.4.10.tar.xz/debian/changelog
Changed
@@ -1,3 +1,27 @@ +open5gs (2.4.10) unstable; urgency=medium + + * Bug Fixed + + -- Sukchan Lee <acetcom@gmail.com> Fri, 09 Sep 2022 09:36:48 +0900 + +open5gs (2.4.10~jammy) jammy; urgency=medium + + * Bug Fixed + + -- Sukchan Lee <acetcom@gmail.com> Fri, 09 Sep 2022 09:35:23 +0900 + +open5gs (2.4.10~focal) focal; urgency=medium + + * Bug Fixed + + -- Sukchan Lee <acetcom@gmail.com> Fri, 09 Sep 2022 09:34:00 +0900 + +open5gs (2.4.10~bionic) bionic; urgency=medium + + * Bug Fixed + + -- Sukchan Lee <acetcom@gmail.com> Fri, 09 Sep 2022 09:30:16 +0900 + open5gs (2.4.9) unstable; urgency=medium * Bug Fixed
View file
open5gs_2.4.9.tar.xz/debian/control -> open5gs_2.4.10.tar.xz/debian/control
Changed
@@ -31,7 +31,7 @@ Package: open5gs-common Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${shlibs:Depends}, +Depends: ${shlibs:Depends}, ${misc:Depends} Description: 5G Core and EPC (Shared Files) Open5GS is a C-language implementation of 5G Core and EPC @@ -43,7 +43,7 @@ Package: open5gs-mme Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${shlibs:Depends}, +Depends: ${shlibs:Depends}, ${misc:Depends}, open5gs-common (= ${binary:Version}) Description: MME (Mobility Management Entity) @@ -58,7 +58,7 @@ Package: open5gs-sgwc Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${shlibs:Depends}, +Depends: ${shlibs:Depends}, ${misc:Depends}, open5gs-common (= ${binary:Version}) Description: SGW-C (Serving Gateway - Control Plane) @@ -72,7 +72,7 @@ Package: open5gs-smf Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${shlibs:Depends}, +Depends: ${shlibs:Depends}, ${misc:Depends}, open5gs-common (= ${binary:Version}) Description: SMF (Session Management Function) @@ -84,7 +84,7 @@ Package: open5gs-amf Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${shlibs:Depends}, +Depends: ${shlibs:Depends}, ${misc:Depends}, open5gs-common (= ${binary:Version}) Description: AMF (Access and Mobility Management Function) @@ -96,7 +96,7 @@ Package: open5gs-sgwu Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${shlibs:Depends}, +Depends: ${shlibs:Depends}, ${misc:Depends}, open5gs-common (= ${binary:Version}) Description: SGW-U (Serving Gateway - User Plane) @@ -110,7 +110,7 @@ Package: open5gs-upf Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${shlibs:Depends}, +Depends: ${shlibs:Depends}, ${misc:Depends}, udev, open5gs-common (= ${binary:Version}) @@ -123,7 +123,7 @@ Package: open5gs-hss Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${shlibs:Depends}, +Depends: ${shlibs:Depends}, ${misc:Depends}, mongodb-org | mongodb, open5gs-common (= ${binary:Version}) @@ -140,7 +140,7 @@ Package: open5gs-pcrf Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${shlibs:Depends}, +Depends: ${shlibs:Depends}, ${misc:Depends}, mongodb-org | mongodb, open5gs-common (= ${binary:Version}) @@ -156,7 +156,7 @@ Package: open5gs-nrf Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${shlibs:Depends}, +Depends: ${shlibs:Depends}, ${misc:Depends}, open5gs-common (= ${binary:Version}) Description: NRF (Network Repository Function) @@ -168,7 +168,7 @@ Package: open5gs-ausf Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${shlibs:Depends}, +Depends: ${shlibs:Depends}, ${misc:Depends}, open5gs-common (= ${binary:Version}) Description: AUSF (Authentication Server Function) @@ -180,7 +180,7 @@ Package: open5gs-udm Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${shlibs:Depends}, +Depends: ${shlibs:Depends}, ${misc:Depends}, open5gs-common (= ${binary:Version}) Description: UDM (Unified Data Management) @@ -192,7 +192,7 @@ Package: open5gs-pcf Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${shlibs:Depends}, +Depends: ${shlibs:Depends}, ${misc:Depends}, open5gs-common (= ${binary:Version}) Description: PCF (Policy Control Function) @@ -204,7 +204,7 @@ Package: open5gs-nssf Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${shlibs:Depends}, +Depends: ${shlibs:Depends}, ${misc:Depends}, open5gs-common (= ${binary:Version}) Description: NSSF (Network Slice Selection Function) @@ -216,7 +216,7 @@ Package: open5gs-bsf Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${shlibs:Depends}, +Depends: ${shlibs:Depends}, ${misc:Depends}, open5gs-common (= ${binary:Version}) Description: BSF (Binding Support Function) @@ -228,7 +228,7 @@ Package: open5gs-udr Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${shlibs:Depends}, +Depends: ${shlibs:Depends}, ${misc:Depends}, open5gs-common (= ${binary:Version}) Description: UDR (Unified Data Repository) @@ -240,7 +240,7 @@ Package: open5gs Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${misc:Depends}, +Depends: ${misc:Depends}, open5gs-common (= ${binary:Version}), open5gs-mme (= ${binary:Version}), open5gs-sgwc (= ${binary:Version}), @@ -266,7 +266,7 @@ Package: open5gs-dbg Architecture: any Multi-Arch: same -Depends: osmocom-latest, ${misc:Depends}, +Depends: ${misc:Depends}, open5gs (= ${binary:Version}) Description: Debug symbols for Open5GS Open5GS is a C-language implementation of 5G Core and EPC
View file
open5gs_2.4.9.tar.xz/debian/open5gs-common.postinst -> open5gs_2.4.10.tar.xz/debian/open5gs-common.postinst
Changed
@@ -20,17 +20,17 @@ case "$1" in configure) - # create a open5gs group and user - if ! getent passwd open5gs >/dev/null; then - adduser --system --disabled-password --disabled-login \ - --home /var/run/open5gs --no-create-home \ - --quiet --group open5gs - fi - for dir in /var/log/open5gs; do - if ! dpkg-statoverride --list "$dir" >/dev/null 2>&1; then - dpkg-statoverride --update --add open5gs open5gs 0755 "$dir" - fi - done + # create a open5gs group and user + if ! getent passwd open5gs >/dev/null; then + adduser --system --disabled-password --disabled-login \ + --home /var/run/open5gs --no-create-home \ + --quiet --group open5gs + fi + for dir in /var/log/open5gs; do + if ! dpkg-statoverride --list "$dir" >/dev/null 2>&1; then + dpkg-statoverride --update --add open5gs open5gs 0755 "$dir" + fi + done ;; abort-upgrade|abort-remove|abort-deconfigure)
View file
open5gs_2.4.9.tar.xz/debian/open5gs-upf.postinst -> open5gs_2.4.10.tar.xz/debian/open5gs-upf.postinst
Changed
@@ -20,20 +20,20 @@ case "$1" in configure) - if test "x`sysctl -n net.ipv6.conf.all.disable_ipv6`" = x1; then - echo "net.ipv6.conf.all.disable_ipv6=0" > /etc/sysctl.d/30-open5gs.conf - sysctl -p /etc/sysctl.d/30-open5gs.conf - fi - if test "x`systemctl is-enabled systemd-networkd`" = xdisabled; then - systemctl enable systemd-networkd - fi - if test -d "/run/systemd"; then - deb-systemd-invoke restart systemd-networkd - fi - if test -f /etc/sysctl.d/30-open5gs.conf && grep "ogstun" /proc/net/dev > /dev/null; then - echo "net.ipv6.conf.ogstun.disable_ipv6=0" > /etc/sysctl.d/30-open5gs.conf - sysctl -p /etc/sysctl.d/30-open5gs.conf - fi + if test "x`sysctl -n net.ipv6.conf.all.disable_ipv6`" = x1; then + echo "net.ipv6.conf.all.disable_ipv6=0" > /etc/sysctl.d/30-open5gs.conf + sysctl -p /etc/sysctl.d/30-open5gs.conf + fi + if test "x`systemctl is-enabled systemd-networkd`" = xdisabled; then + systemctl enable systemd-networkd + fi + if test -d "/run/systemd"; then + deb-systemd-invoke restart systemd-networkd + fi + if test -f /etc/sysctl.d/30-open5gs.conf && grep "ogstun" /proc/net/dev > /dev/null; then + echo "net.ipv6.conf.ogstun.disable_ipv6=0" > /etc/sysctl.d/30-open5gs.conf + sysctl -p /etc/sysctl.d/30-open5gs.conf + fi ;; abort-upgrade|abort-remove|abort-deconfigure)
View file
open5gs_2.4.9.tar.xz/debian/open5gs-upf.postrm -> open5gs_2.4.10.tar.xz/debian/open5gs-upf.postrm
Changed
@@ -24,7 +24,7 @@ if grep "ogstun" /proc/net/dev > /dev/null; then ip tuntap del name ogstun mode tun fi - rm -f /etc/sysctl.d/30-open5gs.conf + rm -f /etc/sysctl.d/30-open5gs.conf ;; remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
View file
open5gs_2.4.9.tar.xz/docs/_docs/guide/01-quickstart.md -> open5gs_2.4.10.tar.xz/docs/_docs/guide/01-quickstart.md
Changed
@@ -379,8 +379,8 @@ Enter the subscriber details of your SIM cards using this tool, to save the subscriber profile in the HSS and UDR MongoDB database backend. If you are using test SIMs, the details are normally printed on the card. -**Tip:** Subscribers added with this tool immediately register in the Open5GS HSS/ UDR without the need to restart any daemon. -{: .notice--info} +**Note:** Subscribers added with this tool immediately register in the Open5GS HSS/UDR without the need to restart any daemon. However, if you use the WebUI to change subscriber profile, you must restart the Open5GS AMF/MME daemon for the changes to take effect. +{: .notice--warning} #### Adding a route for the UE to have WAN connectivity {#UEInternet}
View file
open5gs_2.4.9.tar.xz/docs/_docs/guide/02-building-open5gs-from-sources.md -> open5gs_2.4.10.tar.xz/docs/_docs/guide/02-building-open5gs-from-sources.md
Changed
@@ -97,8 +97,8 @@ ```diff $ diff -u /etc/open5gs/amf.yaml.old /etc/open5gs/amf.yaml ---- amf.yaml 2020-09-05 20:52:28.652234967 -0400 -+++ amf.yaml.new 2020-09-05 20:55:07.453114885 -0400 +--- amf.yaml 2020-09-05 20:52:28.652234967 -0400 ++++ amf.yaml.new 2020-09-05 20:55:07.453114885 -0400 @@ -165,23 +165,23 @@ - addr: 127.0.0.5 port: 7777 @@ -136,8 +136,8 @@ Modify install/etc/open5gs/upf.yaml(https://github.com/{{ site.github_username }}/open5gs/blob/main/configs/open5gs/upf.yaml.in) to set the GTP-U and PFCP IP address. ```diff $ diff -u /etc/open5gs/upf.yaml.old /etc/open5gs/upf.yaml ---- upf.yaml 2020-09-05 20:52:28.652234967 -0400 -+++ upf.yaml.new 2020-09-05 20:52:55.279052142 -0400 +--- upf.yaml 2020-09-05 20:52:28.652234967 -0400 ++++ upf.yaml.new 2020-09-05 20:52:55.279052142 -0400 @@ -137,9 +137,7 @@ pfcp: - addr: 127.0.0.7 @@ -156,8 +156,8 @@ ```diff $ diff -u /etc/open5gs/mme.yaml.old /etc/open5gs/mme.yaml ---- mme.yaml 2020-09-05 20:52:28.648235143 -0400 -+++ mme.yaml.new 2020-09-05 20:56:05.434484208 -0400 +--- mme.yaml 2020-09-05 20:52:28.648235143 -0400 ++++ mme.yaml.new 2020-09-05 20:56:05.434484208 -0400 @@ -204,20 +204,20 @@ mme: freeDiameter: /home/acetcom/Documents/git/open5gs/install/etc/freeDiameter/mme.conf @@ -190,8 +190,8 @@ Modify install/etc/open5gs/sgwu.yaml(https://github.com/{{ site.github_username }}/open5gs/blob/main/configs/open5gs/sgwu.yaml.in) to set the GTP-U IP address. ```diff $ diff -u /etc/open5gs/sgwu.yaml.old /etc/open5gs/sgwu.yaml ---- sgwu.yaml 2020-09-05 20:50:39.393022566 -0400 -+++ sgwu.yaml.new 2020-09-05 20:51:06.667838823 -0400 +--- sgwu.yaml 2020-09-05 20:50:39.393022566 -0400 ++++ sgwu.yaml.new 2020-09-05 20:51:06.667838823 -0400 @@ -51,7 +51,7 @@ # sgwu: @@ -425,7 +425,7 @@ 3. Fill the IMSI, security context(K, OPc, AMF), and APN of the subscriber. 4. Click `SAVE` Button -**Tip:** This addition immediately affects Open5GS without restarting any daemon. +**Note:** Subscribers added with this tool immediately register in the Open5GS HSS/UDR without the need to restart any daemon. However, if you use the WebUI to change subscriber profile, you must restart the Open5GS AMF/MME daemon for the changes to take effect. {: .notice--warning} ### IP routing + NAT for UE internet connectivity
View file
open5gs_2.4.9.tar.xz/docs/_docs/guide/03-splitting-network-functions.md -> open5gs_2.4.10.tar.xz/docs/_docs/guide/03-splitting-network-functions.md
Changed
@@ -56,8 +56,8 @@ ```diff $ diff -u /etc/open5gs/mme.yaml.old /etc/open5gs/mme.yaml ---- mme.yaml.old 2020-08-22 11:36:40.512418765 -0400 -+++ mme.yaml 2020-08-22 11:36:27.081466682 -0400 +--- mme.yaml.old 2020-08-22 11:36:40.512418765 -0400 ++++ mme.yaml 2020-08-22 11:36:27.081466682 -0400 @@ -204,20 +204,20 @@ mme: freeDiameter: /home/acetcom/Documents/git/open5gs/install/etc/freeDiameter/mme.conf @@ -113,8 +113,8 @@ Modify install/etc/open5gs/smf.yaml(https://github.com/{{ site.github_username }}/open5gs/blob/main/configs/open5gs/smf.yaml.in) to set the PFCP IP address. ```diff $ diff -u /etc/open5gs/smf.yaml.old /etc/open5gs/smf.yaml ---- smf.yaml.old 2020-08-22 11:37:39.990816411 -0400 -+++ smf.yaml 2020-08-22 11:38:18.647999952 -0400 +--- smf.yaml.old 2020-08-22 11:37:39.990816411 -0400 ++++ smf.yaml 2020-08-22 11:38:18.647999952 -0400 @@ -187,8 +187,7 @@ - addr: 127.0.0.4 - addr: ::1 @@ -141,8 +141,8 @@ ```diff diff -u /etc/open5gs/amf.yaml.old /etc/open5gs/amf.yaml ---- amf.yaml.old 2020-06-21 23:34:14.643114779 -0400 -+++ amf.yaml 2020-06-21 23:34:28.718482095 -0400 +--- amf.yaml.old 2020-06-21 23:34:14.643114779 -0400 ++++ amf.yaml 2020-06-21 23:34:28.718482095 -0400 @@ -67,25 +67,25 @@ - addr: 127.0.0.5 port: 7777 @@ -183,8 +183,8 @@ Modify install/etc/open5gs/sgwu.yaml(https://github.com/{{ site.github_username }}/open5gs/blob/main/configs/open5gs/sgwu.yaml.in) to set the GTP-U and PFCP IP address. ```diff $ diff -u /etc/open5gs/sgwu.yaml.old /etc/open5gs/sgwu.yaml ---- sgwu.yaml.old 2020-08-22 11:41:09.214670723 -0400 -+++ sgwu.yaml 2020-08-22 11:41:27.433937124 -0400 +--- sgwu.yaml.old 2020-08-22 11:41:09.214670723 -0400 ++++ sgwu.yaml 2020-08-22 11:41:27.433937124 -0400 @@ -51,9 +51,9 @@ # sgwu: @@ -202,8 +202,8 @@ Modify install/etc/open5gs/upf.yaml(https://github.com/{{ site.github_username }}/open5gs/blob/main/configs/open5gs/upf.yaml.in) to set the GTP-U and PFCP IP address. ```diff $ diff -u /etc/open5gs/upf.yaml.old /etc/open5gs/upf.yaml ---- upf.yaml.old 2020-08-22 11:42:57.781750067 -0400 -+++ upf.yaml 2020-08-22 11:43:13.268901616 -0400 +--- upf.yaml.old 2020-08-22 11:42:57.781750067 -0400 ++++ upf.yaml 2020-08-22 11:43:13.268901616 -0400 @@ -59,11 +59,9 @@ # upf:
View file
open5gs_2.4.9.tar.xz/docs/_docs/troubleshoot/01-simple-issues.md -> open5gs_2.4.10.tar.xz/docs/_docs/troubleshoot/01-simple-issues.md
Changed
@@ -176,8 +176,8 @@ ```diff $ diff -u /etc/open5gs/amf.yaml.old /etc/open5gs/amf.yaml ---- amf.yaml.old 2020-08-22 12:26:56.132213488 -0400 -+++ amf.yaml 2020-08-22 12:27:04.135901201 -0400 +--- amf.yaml.old 2020-08-22 12:26:56.132213488 -0400 ++++ amf.yaml 2020-08-22 12:27:04.135901201 -0400 @@ -20,6 +20,7 @@ # logger:
View file
open5gs_2.4.9.tar.xz/docs/_docs/troubleshoot/02-now-in-github-issues.md -> open5gs_2.4.10.tar.xz/docs/_docs/troubleshoot/02-now-in-github-issues.md
Changed
@@ -96,63 +96,63 @@ > use open5gs > db.subscribers.find().pretty() { - "_id" : ObjectId("60969fe79459f8b40d8d3f68"), - "imsi" : "999700000000001", - "__v" : 0, - "access_restriction_data" : 32, - "ambr" : { - "uplink" : { - "value" : 1, - "unit" : 3 - }, - "downlink" : { - "value" : 1, - "unit" : 3 - } - }, - "network_access_mode" : 2, - "security" : { - "k" : "465b5ce8b199b49faa5f0a2ee238a6bc", - "amf" : "8000", - "op" : null, - "opc" : "e8ed289deba952e4283b54e88e6183ca", - "sqn" : NumberLong(97) - }, - "slice" : - { - "sst" : 1, - "default_indicator" : true, - "_id" : ObjectId("60969fe7de8743b3c7b1a973"), - "session" : - { - "name" : "internet", - "type" : 3, - "_id" : ObjectId("60969fe7de8743b3c7b1a974"), - "pcc_rule" : , - "ambr" : { - "uplink" : { - "value" : 1, - "unit" : 3 - }, - "downlink" : { - "value" : 1, - "unit" : 3 - } - }, - "qos" : { - "index" : 9, - "arp" : { - "priority_level" : 8, - "pre_emption_capability" : 1, - "pre_emption_vulnerability" : 1 - } - } - } - - } - , - "subscribed_rau_tau_timer" : 12, - "subscriber_status" : 0 + "_id" : ObjectId("60969fe79459f8b40d8d3f68"), + "imsi" : "999700000000001", + "__v" : 0, + "access_restriction_data" : 32, + "ambr" : { + "uplink" : { + "value" : 1, + "unit" : 3 + }, + "downlink" : { + "value" : 1, + "unit" : 3 + } + }, + "network_access_mode" : 2, + "security" : { + "k" : "465b5ce8b199b49faa5f0a2ee238a6bc", + "amf" : "8000", + "op" : null, + "opc" : "e8ed289deba952e4283b54e88e6183ca", + "sqn" : NumberLong(97) + }, + "slice" : + { + "sst" : 1, + "default_indicator" : true, + "_id" : ObjectId("60969fe7de8743b3c7b1a973"), + "session" : + { + "name" : "internet", + "type" : 3, + "_id" : ObjectId("60969fe7de8743b3c7b1a974"), + "pcc_rule" : , + "ambr" : { + "uplink" : { + "value" : 1, + "unit" : 3 + }, + "downlink" : { + "value" : 1, + "unit" : 3 + } + }, + "qos" : { + "index" : 9, + "arp" : { + "priority_level" : 8, + "pre_emption_capability" : 1, + "pre_emption_vulnerability" : 1 + } + } + } + + } + , + "subscribed_rau_tau_timer" : 12, + "subscriber_status" : 0 } ``` @@ -163,43 +163,43 @@ > use open5gs > db.subscribers.find().pretty() { - "_id" : ObjectId("609715fda08851a0744e6ae7"), - "imsi" : "999700000021309", - "__v" : 0, - "access_restriction_data" : 32, - "ambr" : { - "downlink" : NumberLong(1024000), - "uplink" : NumberLong(1024000) - }, - "network_access_mode" : 2, - "pdn" : - { - "apn" : "internet", - "_id" : ObjectId("609715fd455bcd38c884ce85"), - "pcc_rule" : , - "ambr" : { - "downlink" : NumberLong(1024000), - "uplink" : NumberLong(1024000) - }, - "qos" : { - "qci" : 9, - "arp" : { - "priority_level" : 8, - "pre_emption_vulnerability" : 1, - "pre_emption_capability" : 0 - } - }, - "type" : 0 - } - , - "security" : { - "k" : "70D49A71DD1A2B806A25ABE0EF749F1E", - "amf" : "8000", - "op" : null, - "opc" : "6F1BF53D624B3A43AF6592854E2444C7" - }, - "subscribed_rau_tau_timer" : 12, - "subscriber_status" : 0 + "_id" : ObjectId("609715fda08851a0744e6ae7"), + "imsi" : "999700000021309", + "__v" : 0, + "access_restriction_data" : 32, + "ambr" : { + "downlink" : NumberLong(1024000), + "uplink" : NumberLong(1024000) + }, + "network_access_mode" : 2, + "pdn" : + { + "apn" : "internet", + "_id" : ObjectId("609715fd455bcd38c884ce85"), + "pcc_rule" : , + "ambr" : { + "downlink" : NumberLong(1024000), + "uplink" : NumberLong(1024000) + }, + "qos" : { + "qci" : 9, + "arp" : { + "priority_level" : 8, + "pre_emption_vulnerability" : 1, + "pre_emption_capability" : 0 + } + }, + "type" : 0 + } + , + "security" : { + "k" : "70D49A71DD1A2B806A25ABE0EF749F1E", + "amf" : "8000", + "op" : null, + "opc" : "6F1BF53D624B3A43AF6592854E2444C7" + }, + "subscribed_rau_tau_timer" : 12, + "subscriber_status" : 0 } ``` @@ -226,12 +226,12 @@ > db.subscribers.find().pretty() { ... - "slice" : - { - "sst" : 1, - "default_indicator" : true, - "_id" : ObjectId("60969fe7de8743b3c7b1a973"), - "session" : + "slice" : + { + "sst" : 1, + "default_indicator" : true, + "_id" : ObjectId("60969fe7de8743b3c7b1a973"), + "session" : ... } ``` @@ -476,8 +476,8 @@ ```diff $ diff -u /etc/systemd/network/99-open5gs.network /etc/systemd/network/99-open5gs.network.new ---- /etc/systemd/network/99-open5gs.network 2020-09-17 09:29:09.137392040 -0400 -+++ /etc/systemd/network/99-open5gs.network.new 2020-09-17 09:29:03.375719620 -0400 +--- /etc/systemd/network/99-open5gs.network 2020-09-17 09:29:09.137392040 -0400 ++++ /etc/systemd/network/99-open5gs.network.new 2020-09-17 09:29:03.375719620 -0400 @@ -2,5 +2,5 @@ Name=ogstun @@ -501,8 +501,8 @@ ```diff $ diff -u smf.yaml smf.yaml.new ---- smf.yaml 2020-09-17 09:31:16.547882093 -0400 -+++ smf.yaml.new 2020-09-17 09:32:18.267726844 -0400 +--- smf.yaml 2020-09-17 09:31:16.547882093 -0400 ++++ smf.yaml.new 2020-09-17 09:32:18.267726844 -0400 @@ -190,7 +190,7 @@ - addr: 127.0.0.4 - addr: ::1 @@ -516,8 +516,8 @@ ```diff $ diff -u upf.yaml upf.yaml.new ---- upf.yaml 2020-09-17 09:31:16.547882093 -0400 -+++ upf.yaml.new 2020-09-17 09:32:25.199619989 -0400 +--- upf.yaml 2020-09-17 09:31:16.547882093 -0400 ++++ upf.yaml.new 2020-09-17 09:32:25.199619989 -0400 @@ -139,7 +139,7 @@ gtpu: - addr: 127.0.0.7 @@ -766,8 +766,8 @@ ```diff $ diff -u oldtables newtables ---- oldtables 2019-06-01 23:43:50.354974226 +0900 -+++ newtables 2019-06-01 23:44:16.110931684 +0900 +--- oldtables 2019-06-01 23:43:50.354974226 +0900 ++++ newtables 2019-06-01 23:44:16.110931684 +0900 @@ -8,6 +8,7 @@ -A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER -A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER @@ -1273,10 +1273,10 @@ $ export LD_LIBRARY_PATH=/home/acetcom/Documents/git/open5gs/install/lib/x86_64-linux-gnu $ ldd ./install/bin/open5gs-amfd ... - libogsapp.so.1 => /home/acetcom/Documents/git/open5gs/install/lib/x86_64-linux-gnu/libogsapp.so.1 (0x00007f161ab51000) - libogscore.so.1 => /home/acetcom/Documents/git/open5gs/install/lib/x86_64-linux-gnu/libogscore.so.1 (0x00007f161a922000) - libogssctp.so.1 => /home/acetcom/Documents/git/open5gs/install/lib/x86_64-linux-gnu/libogssctp.so.1 (0x00007f161a71d000) - libogss1ap.so.1 => /home/acetcom/Documents/git/open5gs/install/lib/x86_64-linux-gnu/libogss1ap.so.1 (0x00007f161a519000) + libogsapp.so.1 => /home/acetcom/Documents/git/open5gs/install/lib/x86_64-linux-gnu/libogsapp.so.1 (0x00007f161ab51000) + libogscore.so.1 => /home/acetcom/Documents/git/open5gs/install/lib/x86_64-linux-gnu/libogscore.so.1 (0x00007f161a922000) + libogssctp.so.1 => /home/acetcom/Documents/git/open5gs/install/lib/x86_64-linux-gnu/libogssctp.so.1 (0x00007f161a71d000) + libogss1ap.so.1 => /home/acetcom/Documents/git/open5gs/install/lib/x86_64-linux-gnu/libogss1ap.so.1 (0x00007f161a519000) ... ```
View file
open5gs_2.4.9.tar.xz/docs/_docs/tutorial/01-your-first-lte.md -> open5gs_2.4.10.tar.xz/docs/_docs/tutorial/01-your-first-lte.md
Changed
@@ -190,7 +190,7 @@ IMSI ICCID ACC PIN1 PUK1 PIN2 PUK2 Ki OPC ADM1 KIC1 KID1 KIK1 ... -999700000017408 8988211000000174089 0100 3623 84724035 8774 57473966 B1233463AB9BC2AD2DB1830EB6417E7B 625150E2A943E3353DD23554101CAFD4 47190711 C865CAA0A54542333929B29B116F4375 7D7F65DCD99003C0A0D5D31CA3E5253E 5B27983AF628FC3FCB36B89300012944 +999700000017408 8988211000000174089 0100 3623 84724035 8774 57473966 B1233463AB9BC2AD2DB1830EB6417E7B 625150E2A943E3353DD23554101CAFD4 47190711 C865CAA0A54542333929B29B116F4375 7D7F65DCD99003C0A0D5D31CA3E5253E 5B27983AF628FC3FCB36B89300012944 ``` Here's my subscriber information from above. @@ -222,12 +222,15 @@ 3. Fill the IMSI, security context(K, OPc, AMF), and APN of the subscriber. 4. Click `SAVE` Button +**Note:** Subscribers added with this tool immediately register in the Open5GS HSS/UDR without the need to restart any daemon. However, if you use the WebUI to change subscriber profile, you must restart the Open5GS AMF/MME daemon for the changes to take effect. +{: .notice--warning} + Modify install/etc/open5gs/mme.yaml(https://github.com/{{ site.github_username }}/open5gs/blob/main/configs/open5gs/mme.yaml.in) to set the S1AP IP address, PLMN ID, and TAC. ```diff $ diff -u /etc/open5gs/mme.yaml.old /etc/open5gs/mme.yaml ---- mme.yaml.old 2020-08-22 12:07:32.755250028 -0400 -+++ mme.yaml 2020-08-22 12:08:17.309320211 -0400 +--- mme.yaml.old 2020-08-22 12:07:32.755250028 -0400 ++++ mme.yaml 2020-08-22 12:08:17.309320211 -0400 @@ -208,20 +208,20 @@ mme: freeDiameter: /home/acetcom/Documents/git/open5gs/install/etc/freeDiameter/mme.conf @@ -260,8 +263,8 @@ Modify install/etc/open5gs/sgwu.yaml(https://github.com/{{ site.github_username }}/open5gs/blob/main/configs/open5gs/sgwu.yaml.in) to set the GTP-U IP address. ```diff $ diff -u /etc/open5gs/sgwu.yaml.old /etc/open5gs/sgwu.yaml ---- sgwu.yaml.old 2020-08-22 12:08:44.782880778 -0400 -+++ sgwu.yaml 2020-08-22 12:06:49.809299514 -0400 +--- sgwu.yaml.old 2020-08-22 12:08:44.782880778 -0400 ++++ sgwu.yaml 2020-08-22 12:06:49.809299514 -0400 @@ -82,7 +82,7 @@ # sgwu: @@ -335,8 +338,8 @@ ```diff $ diff -u enb.conf.example enb.conf --- enb.conf.example 2022-01-19 20:30:13.612993155 +0900 -+++ enb.conf 2022-01-19 21:04:15.674419300 +0900 +-- enb.conf.example 2022-01-19 20:30:13.612993155 +0900 ++++ enb.conf 2022-01-19 21:04:15.674419300 +0900 @@ -20,9 +20,9 @@ ##################################################################### enb @@ -372,8 +375,8 @@ ```diff $ diff -u rr.conf.example rr.conf --- rr.conf.example 2022-01-19 20:30:13.620992794 +0900 -+++ rr.conf 2022-01-19 21:05:21.959044145 +0900 +-- rr.conf.example 2022-01-19 20:30:13.620992794 +0900 ++++ rr.conf 2022-01-19 21:05:21.959044145 +0900 @@ -55,10 +55,10 @@ { // rf_port = 0; @@ -406,8 +409,8 @@ If you are not using GPS-DO, you can just comment out `device_args` as shown below. ```diff $ diff -u enb.conf enb.conf.no_gps_do ---- enb.conf 2022-01-19 21:08:32.941527373 +0900 -+++ enb.conf.no_gps_do 2022-01-19 21:10:18.612581261 +0900 +--- enb.conf 2022-01-19 21:08:32.941527373 +0900 ++++ enb.conf.no_gps_do 2022-01-19 21:10:18.612581261 +0900 @@ -81,7 +81,7 @@ # Example for ZMQ-based operation with TCP transport for I/Q samples
View file
open5gs_2.4.9.tar.xz/docs/_docs/tutorial/02-VoLTE-setup.md -> open5gs_2.4.10.tar.xz/docs/_docs/tutorial/02-VoLTE-setup.md
Changed
@@ -307,9 +307,9 @@ Password: testpasswd Server: ims.mnc001.mcc001.3gppnetwork.org (Created DNS Domain Name or IP to which IMS components are bound to, visible interface IP address) Optional Settings: - Authentication username: test - Outbound proxy address: 172.24.15.30 (Floating IP of VM in case of OpenStack or else no need to fill in case of physical machine) - Transport type: UDP + Authentication username: test + Outbound proxy address: 172.24.15.30 (Floating IP of VM in case of OpenStack or else no need to fill in case of physical machine) + Transport type: UDP ``` In Phone 2: @@ -319,9 +319,9 @@ Password: testpasswd Server: ims.mnc001.mcc001.3gppnetwork.org (Created DNS Domain Name or IP to which IMS components are bound to, visible interface IP address) Optional Settings: - Authentication username: test2 - Outbound proxy address: 172.24.15.30 (Floating IP of VM in case of OpenStack or else no need to fill in case of physical machine) - Transport type: UDP + Authentication username: test2 + Outbound proxy address: 172.24.15.30 (Floating IP of VM in case of OpenStack or else no need to fill in case of physical machine) + Transport type: UDP ``` - Set "Receive incoming calls" option to enabled state in both phones @@ -566,8 +566,8 @@ // the all-0's placeholder. //forwarders { - // Put here the IP address of other DNS server which could be used if name cannot be resolved with DNS server running in this machine (Optional) - //10.4.128.2; + // Put here the IP address of other DNS server which could be used if name cannot be resolved with DNS server running in this machine (Optional) + //10.4.128.2; //}; //======================================================================== @@ -1068,8 +1068,8 @@ ``` root@epc-ims:~# cat /etc/hosts -127.0.0.1 localhost -127.0.0.1 epc-ims +127.0.0.1 localhost +127.0.0.1 epc-ims ``` #### 20. Add IMS subscription use in FoHSS as follows from the Web GUI @@ -1078,7 +1078,7 @@ ``` Login to the HSS web console. -Navigate to the User Identities page +Navigate to the User Identities page Create the IMSU Click IMS Subscription / Create Enter:
View file
open5gs_2.4.9.tar.xz/docs/_pages/docs.md -> open5gs_2.4.10.tar.xz/docs/_pages/docs.md
Changed
@@ -37,14 +37,19 @@ - @nickvsnetworking - My first 5G Core : Open5GS and UERANSIM(http://nickvsnetworking.com/my-first-5g-core-open5gs-and-ueransim/) - - Backing up and restoring Open5GS(https://nickvsnetworking.com/backing-up-and-restoring-open5gs/) - - Open5Gs Without NAT(https://nickvsnetworking.com/open5gs-without-nat/) - Sending SMS in Open5GS LTE Networks using the SGs Interface and OsmoMSC(https://nickvsnetworking.com/sending-sms-in-open5gs-lte-networks-using-the-sgs-interface-and-osmomsc-with-smsos/) - OsmoMSC and Open5GS MME – SGs Interface for CSCF / InterRAT Handover(https://nickvsnetworking.com/osmomsc-and-open5gs-mme-sgs-interface-for-cscf-interran-handover/) - Static IPs for UEs(http://nickvsnetworking.com/open5gs-epc-static-ip-addresses-for-ues-apns-subscribers/) + - Open5GS without NAT(https://nickvsnetworking.com/open5gs-without-nat/) + - Basics of EPC/LTE Online Charging (OCS)(https://nickvsnetworking.com/basics-of-epc-lte-online-charging-ocs/) + - Backing up and Restoring Open5GS(https://nickvsnetworking.com/backing-up-and-restoring-open5gs/) + - Diameter Routing Agents - Part 1(https://nickvsnetworking.com/diameter-routing-agents-why-you-need-them-and-how-to-build-them-part-1/), Part 2(https://nickvsnetworking.com/diameter-routing-agents-why-you-need-them-and-how-to-build-them-part-2-routing/), Part 3(https://nickvsnetworking.com/diameter-routing-agents-part-3-building-a-dra-with-freediameter/) - @s5uishida - Open5GS EPC & OpenAirInterface UE/RAN Sample configuration(https://github.com/s5uishida/open5gs_epc_oai_sample_config) - Open5GS 5GC & UERANSIM UE/RAN Sample Configuration(https://github.com/s5uishida/open5gs_5gc_ueransim_sample_config) - Open5GS & UERANSIM - Select nearby UPF according to the connected gNodeB(https://github.com/s5uishida/open5gs_5gc_ueransim_nearby_upf_sample_config) - VoLTE and SMS Configuration for docker_open5gs(https://github.com/s5uishida/docker_open5gs_volte_sms_config) + - Select UPF based on S-NSSAI(https://github.com/s5uishida/open5gs_5gc_ueransim_snssai_upf_sample_config) + - SCP Indirect communication Model C(https://github.com/s5uishida/open5gs_5gc_ueransim_scp_model_c_sample_config) + - Monitoring Metrics with Prometheus(https://github.com/s5uishida/open5gs_5gc_ueransim_metrics_sample_config)
View file
open5gs_2.4.10.tar.xz/docs/_posts/2022-09-09-release-v2.4.10.md
Added
@@ -0,0 +1,43 @@ +--- +title: "v2.4.10 - Service-name based NF Discovery" +date: 2022-09-09 09:43:00 +0900 +categories: + - Release +tags: + - News + - Release +head_inline: "<style> ul { padding-bottom: 1em; } .blue { color: blue; }</style>" +--- + +#### New Features +- CONF Service-name based NF Discovery -- f020732(https://github.com/open5gs/open5gs/commit/f020732ce9f60217dfcd0b7e9ba5c8949db966d5), 9f98d42(https://github.com/open5gs/open5gs/commit/9f98d421a081a5edc3a525d1cf2504b8b6cf059e), 5295c10(https://github.com/open5gs/open5gs/commit/5295c108adc2fc5ae97ee5007760334ef7a6297b) + +#### Enhancements +- SBI Move state machine from src to lib directory -- e6a14cb(https://github.com/open5gs/open5gs/commit/e6a14cb73debbdc21e91499b75dde3d71a5aa02b) +- SBI Increased the MAX stream number from UE * 16 -- db37bc8(https://github.com/open5gs/open5gs/commit/db37bc894459df38661bdf98891938ec3513bc72), ec9fe7b(https://github.com/open5gs/open5gs/commit/ec9fe7b31d0253003244be498e8f963da63e7657), 603a746(https://github.com/open5gs/open5gs/commit/603a746f49c68b06ab5d8b3ceeca3afde987cab5) +- Diameter Improve S6A interface (#1676(https://github.com/open5gs/open5gs/pull/1676), #1698(https://github.com/open5gs/open5gs/pull/1698), #1714(https://github.com/open5gs/open5gs/pull/1714)) -- jmasterfunk84(https://github.com/jmasterfunk84) + +#### Security Issues +- PFCP Fixed security protection -- CVE-2022-39063(https://cve.report/CVE-2022-39063), d99491a(https://github.com/open5gs/open5gs/commit/d99491aca5304460d3929b37bf26e064efd86686), 444e182(https://github.com/open5gs/open5gs/commit/444e1822887a78d3c3ef1f0bcaad9ee10ac951c3) + +#### Bug Fixes +- SBI Fixed memory leak and CPU usage 100% -- 7231daf(https://github.com/open5gs/open5gs/commit/7231dafbf12c2009ec6fe740686342e2c5d245a2), c716a12(https://github.com/open5gs/open5gs/commit/c716a1294a6120f4100ba2efa9039f6168d74ce7) +- Metrics Fixed double-free on application exit load error (#1717(https://github.com/open5gs/open5gs/issues/1717)) -- bmeglicit(https://github.com/bmeglicit) +- NRF Fixed library load error -- 9b10d70(https://github.com/open5gs/open5gs/commit/9b10d70c7730ba86800b85fe05260c5bb072d91e) +- SMF Fixed abort on app exit when no diameter configuration -- (#1710(https://github.com/open5gs/open5gs/issues/1710)) -- bmeglicit(https://github.com/bmeglicit) +- MME Fixed crash on sending SMS between UEs -- (#1701(https://github.com/open5gs/open5gs/issues/1701)) -- salibeh(https://github.com/salibeh) +- MME Fixed GTP transaction crash if it has already been removed during paging-- (#1696(https://github.com/open5gs/open5gs/issues/1696)) -- vsbc2010(https://github.com/vsbc2010) + +#### Specification Compliance +- 5GC Handle APN/DNN names as case-insensitive (#1747(https://github.com/open5gs/open5gs/pull/1747)) -- jmasterfunk84(https://github.com/jmasterfunk84) +- AMF Accept Deregistration Notification from UDM only for registered UE -- (#1737(https://github.com/open5gs/open5gs/pull/1737)) -- bmeglicit(https://github.com/bmeglicit) +- SBI Send NF discovery query with service-names delimited with comma -- (#1730(https://github.com/open5gs/open5gs/pull/1730)) -- bmeglicit(https://github.com/bmeglicit) +- Gx Handle upCnxState=ACTIVATION by later replaying with 200 instead of 204 (#1729(https://github.com/open5gs/open5gs/pull/1729)) -- mitmitmitm(https://github.com/mitmitmitm) +- MME Fixed buffer overflow in S6A IDR(#1728(https://github.com/open5gs/open5gs/pull/1728)) -- mitmitmitm(https://github.com/mitmitmitm) +- Gx Added 3GPP-Charging-Characteristics if received on S5/8c (#1724(https://github.com/open5gs/open5gs/pull/1724)) -- lynxis(https://github.com/lynxis) +- S5c/Gn Fix PCO IE sent in response its presence in request (#1691(https://github.com/open5gs/open5gs/pull/1691)) -- herlesupreeth(https://github.com/herlesupreeth) +- Diameter Fixed the path of Nnrf_NFManagement Service (#1683(https://github.com/open5gs/open5gs/issues/1683)) -- s5uishida(https://github.com/s5uishida) +- Diameter Fixed AVP Occurring Too Many Times (#1680(https://github.com/open5gs/open5gs/pull/1680)) -- jmasterfunk84(https://github.com/jmasterfunk84) + +Download -- v2.4.10.tar.gz(https://github.com/open5gs/open5gs/archive/v2.4.10.tar.gz) +{: .notice--info}
View file
open5gs_2.4.9.tar.xz/lib/app/ogs-app.h -> open5gs_2.4.10.tar.xz/lib/app/ogs-app.h
Changed
@@ -20,7 +20,7 @@ #ifndef OGS_APP_H #define OGS_APP_H -#include "ogs-core.h" +#include "proto/ogs-proto.h" #define OGS_APP_INSIDE
View file
open5gs_2.4.9.tar.xz/lib/app/ogs-context.c -> open5gs_2.4.10.tar.xz/lib/app/ogs-context.c
Changed
@@ -71,22 +71,25 @@ self.pool.bearer = self.pool.sess * OGS_MAX_NUM_OF_BEARER; self.pool.tunnel = self.pool.bearer * MAX_NUM_OF_TUNNEL; -#define OGS_MAX_NUM_OF_NF_SUBSCRIPTION 4 /* Num of Subscription per NF */ - self.pool.nf_service = self.max.gnb * OGS_MAX_NUM_OF_NF_SERVICE; - #define POOL_NUM_PER_UE 16 -#define POOL_NUM_PER_GNB 8 self.pool.timer = self.max.ue * POOL_NUM_PER_UE; self.pool.message = self.max.ue * POOL_NUM_PER_UE; self.pool.event = self.max.ue * POOL_NUM_PER_UE; self.pool.socket = self.max.ue * POOL_NUM_PER_UE; self.pool.subscription = self.max.ue * POOL_NUM_PER_UE; self.pool.xact = self.max.ue * POOL_NUM_PER_UE; + self.pool.stream = self.max.ue * POOL_NUM_PER_UE; - self.pool.nf = self.max.gnb; + self.pool.nf = self.max.peer; +#define NF_SERVICE_PER_NF_INSTANCE 16 + self.pool.nf_service = self.pool.nf * NF_SERVICE_PER_NF_INSTANCE; + + self.pool.gtp_node = self.pool.nf; + if (self.max.gtp_peer) + self.pool.gtp_node = self.max.gtp_peer; -#define MAX_CSMAP_POOL 128 - self.pool.csmap = MAX_CSMAP_POOL; /* Num of TAI-LAI Mapping Table */ + /* Num of TAI-LAI Mapping Table */ + self.pool.csmap = self.pool.nf; #define MAX_NUM_OF_IMPU 8 self.pool.impi = self.max.ue; @@ -167,23 +170,13 @@ #define USRSCTP_LOCAL_UDP_PORT 9899 self.usrsctp.udp_port = USRSCTP_LOCAL_UDP_PORT; - self.sctp.heartbit_interval = 5000; /* 5 seconds */ - self.sctp.sack_delay = 200; /* 200 ms */ - self.sctp.rto_initial = 3000; /* 3 seconds */ - self.sctp.rto_min = 1000; /* 1 seconds */ - self.sctp.rto_max = 5000; /* 5 seconds */ - self.sctp.max_num_of_ostreams = OGS_DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS; - self.sctp.max_num_of_istreams = 65535; - self.sctp.max_attempts = 4; - self.sctp.max_initial_timeout = 8000; /* 8 seconds */ - self.sockopt.no_delay = true; -#define MAX_NUM_OF_UE 1024 /* Num of UE per AMF/MME */ -#define MAX_NUM_OF_GNB 64 /* Num of gNB per AMF/MME */ +#define MAX_NUM_OF_UE 1024 /* Num of UEs */ +#define MAX_NUM_OF_PEER 64 /* Num of Peer */ - self.max.gnb = MAX_NUM_OF_GNB; self.max.ue = MAX_NUM_OF_UE; + self.max.peer = MAX_NUM_OF_PEER; ogs_pkbuf_default_init(&self.pool.defconfig); @@ -376,48 +369,6 @@ } else ogs_warn("unknown key `%s`", sockopt_key); } - } else if (!strcmp(root_key, "sctp")) { - ogs_yaml_iter_t sctp_iter; - ogs_yaml_iter_recurse(&root_iter, &sctp_iter); - while (ogs_yaml_iter_next(&sctp_iter)) { - const char *sctp_key = ogs_yaml_iter_key(&sctp_iter); - ogs_assert(sctp_key); - if (!strcmp(sctp_key, "heartbit_interval")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) self.sctp.heartbit_interval = atoi(v); - } else if (!strcmp(sctp_key, "sack_delay")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) self.sctp.sack_delay = atoi(v); - } else if (!strcmp(sctp_key, "rto_initial")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) self.sctp.rto_initial = atoi(v); - } else if (!strcmp(sctp_key, "rto_min")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) self.sctp.rto_min = atoi(v); - } else if (!strcmp(sctp_key, "rto_max")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) self.sctp.rto_max = atoi(v); - } else if (!strcmp(sctp_key, "max_num_of_ostreams")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) - self.sctp.max_num_of_ostreams = atoi(v); - } else if (!strcmp(sctp_key, "max_num_of_istreams")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) - self.sctp.max_num_of_istreams = atoi(v); - } else if (!strcmp(sctp_key, "max_attempts")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) self.sctp.max_attempts = atoi(v); - } else if (!strcmp(sctp_key, "max_initial_timeout")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) - self.sctp.max_initial_timeout = atoi(v); - } else if (!strcmp(sctp_key, "usrsctp_udp_port")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) self.usrsctp.udp_port = atoi(v); - } else - ogs_warn("unknown key `%s`", sctp_key); - } } else if (!strcmp(root_key, "max")) { ogs_yaml_iter_t max_iter; ogs_yaml_iter_recurse(&root_iter, &max_iter); @@ -427,10 +378,14 @@ if (!strcmp(max_key, "ue")) { const char *v = ogs_yaml_iter_value(&max_iter); if (v) self.max.ue = atoi(v); - } else if (!strcmp(max_key, "gnb") || + } else if (!strcmp(max_key, "peer") || + !strcmp(max_key, "enb")) { + const char *v = ogs_yaml_iter_value(&max_iter); + if (v) self.max.peer = atoi(v); + } else if (!strcmp(max_key, "gtp_peer") || !strcmp(max_key, "enb")) { const char *v = ogs_yaml_iter_value(&max_iter); - if (v) self.max.gnb = atoi(v); + if (v) self.max.gtp_peer = atoi(v); } else ogs_warn("unknown key `%s`", max_key); }
View file
open5gs_2.4.9.tar.xz/lib/app/ogs-context.h -> open5gs_2.4.10.tar.xz/lib/app/ogs-context.h
Changed
@@ -86,24 +86,12 @@ } sockopt; struct { - int heartbit_interval; - int sack_delay; - int rto_initial; - int rto_min; - int rto_max; - int max_num_of_ostreams; - int max_num_of_istreams; - int max_attempts; - int max_initial_timeout; - } sctp; - - struct { int udp_port; } usrsctp; struct { uint64_t ue; - uint64_t gnb; + uint64_t peer; uint64_t gtp_peer; } max; @@ -124,8 +112,10 @@ uint64_t socket; uint64_t subscription; uint64_t xact; + uint64_t stream; uint64_t nf; + uint64_t gtp_node; uint64_t csmap;
View file
open5gs_2.4.9.tar.xz/lib/asn1c/common/asn_internal.h -> open5gs_2.4.10.tar.xz/lib/asn1c/common/asn_internal.h
Changed
@@ -40,7 +40,7 @@ #define REALLOC(oldptr, size) realloc(oldptr, size) #define FREEMEM(ptr) free(ptr) #else -#include "ogs-core.h" +#include "proto/ogs-proto.h" static ogs_inline void *ogs_asn_malloc(size_t size, const char *file_line) {
View file
open5gs_2.4.9.tar.xz/lib/core/meson.build -> open5gs_2.4.10.tar.xz/lib/core/meson.build
Changed
@@ -256,7 +256,6 @@ ogs-hash.h ogs-misc.h ogs-getopt.h - ogs-3gpp-types.h abts.h ogs-abort.c @@ -292,7 +291,6 @@ ogs-hash.c ogs-misc.c ogs-getopt.c - ogs-3gpp-types.c ogs-core.c abts.c '''.split())
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-conv.c -> open5gs_2.4.10.tar.xz/lib/core/ogs-conv.c
Changed
@@ -54,15 +54,16 @@ void *ogs_hex_to_ascii(void *in, int in_len, void *out, int out_len) { - char *p; + char *p, *last; int i = 0, l, off = 0; p = out; + last = p + out_len; p0 = 0; l = (in_len - off) > out_len ? out_len : in_len - off; for (i = 0; i < l; i++) { - p += sprintf(p, "%02x", ((char*)in)off+i & 0xff); + p = ogs_slprintf(p, last, "%02x", ((char*)in)off+i & 0xff); } return out; @@ -232,25 +233,3 @@ return x; } - -void ogs_extract_digit_from_string(char *digit, char *string) -{ - bool extracting = false; - int i = 0; - - ogs_assert(string); - ogs_assert(digit); - - while (*string && i < OGS_MAX_IMSI_BCD_LEN) { - if (*string >= '0' && *string <= '9') { - *digit++ = *string; - extracting = true; - } else if (extracting == true) { - break; - } - string++; - i++; - } - - *digit = 0; -}
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-conv.h -> open5gs_2.4.10.tar.xz/lib/core/ogs-conv.h
Changed
@@ -49,8 +49,6 @@ ogs_uint24_t ogs_uint24_from_string(char *str); uint64_t ogs_uint64_from_string(char *str); -void ogs_extract_digit_from_string(char *digit, char *string); - #ifdef __cplusplus } #endif
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-core.h -> open5gs_2.4.10.tar.xz/lib/core/ogs-core.h
Changed
@@ -62,7 +62,6 @@ #include "core/ogs-hash.h" #include "core/ogs-misc.h" #include "core/ogs-getopt.h" -#include "core/ogs-3gpp-types.h" #undef OGS_CORE_INSIDE
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-errno.c -> open5gs_2.4.10.tar.xz/lib/core/ogs-errno.c
Changed
@@ -24,7 +24,7 @@ char *ogs_strerror(ogs_err_t err, char *buf, size_t size) { #if defined(_WIN32) - /* + /* * The following code is stolen from APR Library * http://svn.apache.org/repos/asf/apr/apr/trunk/misc/unix/errorcodes.c */
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-fsm.c -> open5gs_2.4.10.tar.xz/lib/core/ogs-fsm.c
Changed
@@ -34,69 +34,116 @@ const char *OGS_FSM_NAME_ENTRY_SIG = "ENTRY"; const char *OGS_FSM_NAME_EXIT_SIG = "EXIT"; -void ogs_fsm_init(void *sm, void *event) +static void fsm_entry(ogs_fsm_t *sm, ogs_fsm_handler_t state, fsm_event_t *e) { - ogs_fsm_t *s = sm; + ogs_assert(sm); + ogs_assert(state); + + if (e) { + e->id = OGS_FSM_ENTRY_SIG; + (*state)(sm, e); + } else { + (*state)(sm, &entry_event); + } +} + +static void fsm_exit(ogs_fsm_t *sm, ogs_fsm_handler_t state, fsm_event_t *e) +{ + ogs_assert(sm); + ogs_assert(state); + + if (e) { + e->id = OGS_FSM_EXIT_SIG; + (*state)(sm, e); + } else { + (*state)(sm, &exit_event); + } +} + +static void fsm_change( + ogs_fsm_t *sm, + ogs_fsm_handler_t oldstate, + ogs_fsm_handler_t newstate, + fsm_event_t *e) +{ + ogs_assert(sm); + ogs_assert(oldstate); + ogs_assert(newstate); + + fsm_exit(sm, oldstate, e); + fsm_entry(sm, newstate, e); +} + +void ogs_fsm_init(void *fsm, void *init, void *fini, void *event) +{ + ogs_fsm_t *sm = fsm; fsm_event_t *e = event; - ogs_assert(s); - if (s->init != NULL) { - (*s->init)(s, e); - if (s->init != s->state) { - if (e) { - e->id = OGS_FSM_ENTRY_SIG; - (*s->state)(s, e); - } else { - (*s->state)(s, &entry_event); - } + ogs_assert(sm); + + sm->init = sm->state = init; + sm->fini = fini; + + if (sm->init) { + (*sm->init)(sm, e); + + if (sm->init != sm->state) { + ogs_assert(sm->state); + fsm_entry(sm, sm->state, e); } } } -void ogs_fsm_dispatch(void *sm, void *event) +void ogs_fsm_tran(void *fsm, void *state, void *event) { - ogs_fsm_t *s = sm; + ogs_fsm_t *sm = fsm; fsm_event_t *e = event; - ogs_assert(s); - ogs_fsm_handler_t tmp = s->state; + ogs_fsm_handler_t tmp = NULL; + + ogs_assert(sm); + + tmp = sm->state; + ogs_assert(tmp); + + sm->state = state; + ogs_assert(sm->state); + + if (sm->state != tmp) + fsm_change(fsm, tmp, sm->state, e); +} + +void ogs_fsm_dispatch(void *fsm, void *event) +{ + ogs_fsm_t *sm = fsm; + fsm_event_t *e = event; + ogs_fsm_handler_t tmp = NULL; + + ogs_assert(sm); + + tmp = sm->state; + ogs_assert(tmp); if (e) - (*tmp)(s, e); + (*tmp)(sm, e); - if (s->state != tmp) { - if (e) { - e->id = OGS_FSM_EXIT_SIG; - (*tmp)(s, e); - } else { - (*tmp)(s, &exit_event); - } - if (e) { - e->id = OGS_FSM_ENTRY_SIG; - (*s->state)(s, e); - } else { - (*s->state)(s, &entry_event); - } - } + if (sm->state != tmp) + fsm_change(fsm, tmp, sm->state, e); } -void ogs_fsm_fini(void *sm, void *event) +void ogs_fsm_fini(void *fsm, void *event) { - ogs_fsm_t *s = sm; + ogs_fsm_t *sm = fsm; fsm_event_t *e = event; - ogs_assert(s); - if (s->fini != s->state) { - if (e) { - e->id = OGS_FSM_EXIT_SIG; - (*s->state)(s, e); - } else { - (*s->state)(s, &exit_event); - } - } + ogs_assert(sm); + + if (sm->fini != sm->state) { + ogs_assert(sm->state); + fsm_exit(sm, sm->state, e); - if (s->fini != NULL) { - (*s->fini)(s, e); + if (sm->fini) + (*sm->fini)(sm, e); } - s->state = s->init; + sm->init = sm->state = sm->fini = NULL; }
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-fsm.h -> open5gs_2.4.10.tar.xz/lib/core/ogs-fsm.h
Changed
@@ -46,16 +46,10 @@ ogs_fsm_handler_t state; } ogs_fsm_t; -#define ogs_fsm_create(__s, __i, __f) \ - (((__s)->init = (__s)->state = (ogs_fsm_handler_t)(__i)), \ - (__s)->fini = (ogs_fsm_handler_t)(__f)) - -#define ogs_fsm_delete(__s) \ - ((__s)->init = (__s)->state = (__s)->fini = NULL) - -void ogs_fsm_init(void *sm, void *event); -void ogs_fsm_dispatch(void *sm, void *event); -void ogs_fsm_fini(void *sm, void *event); +void ogs_fsm_init(void *fsm, void *init, void *fini, void *event); +void ogs_fsm_tran(void *fsm, void *state, void *event); +void ogs_fsm_dispatch(void *fsm, void *event); +void ogs_fsm_fini(void *fsm, void *event); #define OGS_FSM_TRAN(__s, __target) \ ((ogs_fsm_t *)__s)->state = (ogs_fsm_handler_t)(__target)
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-kqueue.c -> open5gs_2.4.10.tar.xz/lib/core/ogs-kqueue.c
Changed
@@ -52,8 +52,8 @@ struct kqueue_context_s { int kqueue; - struct kevent *change_list; - struct kevent *event_list; + struct kevent *change_list; + struct kevent *event_list; int nchanges, nevents; }; @@ -66,12 +66,12 @@ ogs_assert(context); pollset->context = context; - context->change_list = ogs_calloc( + context->change_list = ogs_calloc( pollset->capacity, sizeof(struct kevent)); ogs_assert(context->change_list); - context->event_list = ogs_calloc( + context->event_list = ogs_calloc( pollset->capacity, sizeof(struct kevent)); - ogs_assert(context->change_list); + ogs_assert(context->change_list); context->nchanges = 0; context->nevents = pollset->capacity; @@ -89,8 +89,8 @@ context = pollset->context; ogs_assert(context); - ogs_free(context->change_list); - ogs_free(context->event_list); + ogs_free(context->change_list); + ogs_free(context->event_list); close(context->kqueue); @@ -215,75 +215,75 @@ return OGS_TIMEUP; } - for (i = 0; i < n; i++) { + for (i = 0; i < n; i++) { ogs_poll_t *poll = NULL; short when = 0; if (context->event_listi.flags & EV_ERROR) { - switch (context->event_listi.data) { + switch (context->event_listi.data) { - /* Can occur on delete if we are not currently - * watching any events on this fd. That can - * happen when the fd was closed and another - * file was opened with that fd. */ - case ENOENT: - /* Can occur for reasons not fully understood - * on FreeBSD. */ - case EINVAL: - continue; + /* Can occur on delete if we are not currently + * watching any events on this fd. That can + * happen when the fd was closed and another + * file was opened with that fd. */ + case ENOENT: + /* Can occur for reasons not fully understood + * on FreeBSD. */ + case EINVAL: + continue; #if defined(__FreeBSD__) - /* - * This currently occurs if an FD is closed - * before the EV_DELETE makes it out via kevent(). - * The FreeBSD capabilities code sees the blank - * capability set and rejects the request to - * modify an event. - * - * To be strictly correct - when an FD is closed, - * all the registered events are also removed. - * Queuing EV_DELETE to a closed FD is wrong. - * The event(s) should just be deleted from - * the pending changelist. - */ - case ENOTCAPABLE: - continue; + /* + * This currently occurs if an FD is closed + * before the EV_DELETE makes it out via kevent(). + * The FreeBSD capabilities code sees the blank + * capability set and rejects the request to + * modify an event. + * + * To be strictly correct - when an FD is closed, + * all the registered events are also removed. + * Queuing EV_DELETE to a closed FD is wrong. + * The event(s) should just be deleted from + * the pending changelist. + */ + case ENOTCAPABLE: + continue; #endif - /* Can occur on a delete if the fd is closed. */ - case EBADF: - /* XXXX On NetBSD, we can also get EBADF if we - * try to add the write side of a pipe, but - * the read side has already been closed. - * Other BSDs call this situation 'EPIPE'. It - * would be good if we had a way to report - * this situation. */ - continue; - /* These two can occur on an add if the fd was one side - * of a pipe, and the other side was closed. */ - case EPERM: - case EPIPE: - /* Report read events, if we're listening for - * them, so that the user can learn about any - * add errors. (If the operation was a - * delete, then udata should be cleared.) */ - if (context->event_listi.udata) { - /* The operation was an add: - * report the error as a read. */ - when |= OGS_POLLIN; - break; - } else { - /* The operation was a del: - * report nothing. */ - continue; - } + /* Can occur on a delete if the fd is closed. */ + case EBADF: + /* XXXX On NetBSD, we can also get EBADF if we + * try to add the write side of a pipe, but + * the read side has already been closed. + * Other BSDs call this situation 'EPIPE'. It + * would be good if we had a way to report + * this situation. */ + continue; + /* These two can occur on an add if the fd was one side + * of a pipe, and the other side was closed. */ + case EPERM: + case EPIPE: + /* Report read events, if we're listening for + * them, so that the user can learn about any + * add errors. (If the operation was a + * delete, then udata should be cleared.) */ + if (context->event_listi.udata) { + /* The operation was an add: + * report the error as a read. */ + when |= OGS_POLLIN; + break; + } else { + /* The operation was a del: + * report nothing. */ + continue; + } - /* Other errors shouldn't occur. */ - default: + /* Other errors shouldn't occur. */ + default: ogs_error("kevent() error : flags = 0x%x, errno = %d", context->event_listi.flags, (int)context->event_listi.data); - return OGS_ERROR; - } + return OGS_ERROR; + } } else if (context->event_listi.filter == EVFILT_READ) { when |= OGS_POLLIN; } else if (context->event_listi.filter == EVFILT_WRITE) { @@ -316,7 +316,7 @@ int rc; struct kqueue_context_s *context = NULL; struct kevent kev; - struct timespec timeout = { 0, 0 }; + struct timespec timeout = { 0, 0 }; ogs_assert(pollset); ogs_assert(pollset); @@ -325,8 +325,8 @@ memset(&kev, 0, sizeof kev); kev.ident = NOTIFY_IDENT; - kev.filter = EVFILT_USER; - kev.flags = EV_ADD | EV_CLEAR; + kev.filter = EVFILT_USER; + kev.flags = EV_ADD | EV_CLEAR; rc = kevent(context->kqueue, &kev, 1, NULL, 0, &timeout); ogs_assert(rc != -1); @@ -337,7 +337,7 @@ int rc; struct kqueue_context_s *context = NULL; struct kevent kev; - struct timespec timeout = { 0, 0 }; + struct timespec timeout = { 0, 0 }; ogs_assert(pollset); ogs_assert(pollset); @@ -346,8 +346,8 @@ memset(&kev, 0, sizeof kev); kev.ident = NOTIFY_IDENT; - kev.filter = EVFILT_USER; - kev.fflags = NOTE_TRIGGER; + kev.filter = EVFILT_USER; + kev.fflags = NOTE_TRIGGER; rc = kevent(context->kqueue, &kev, 1, NULL, 0, &timeout); if (rc == -1) {
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-macros.h -> open5gs_2.4.10.tar.xz/lib/core/ogs-macros.h
Changed
@@ -196,8 +196,8 @@ __switch_p__; \ __switch_p__ = 0, __switch_next__ = 1) { { #define CASE(X) } if (!__switch_next__ || \ - !(__switch_next__ = \ - strcmp(__switch_p__, X))) { + (__switch_next__ = \ + strcmp(__switch_p__, X)) == 0) { #define DEFAULT } { #define END }}} #endif @@ -210,6 +210,14 @@ #define ogs_uint64_to_uint32(x) ((x >= 0xffffffffUL) ? 0xffffffffU : x) +#define OGS_OBJECT_REF(__oBJ) \ + ((__oBJ)->reference_count)++, \ + ogs_debug("REF %d", ((__oBJ)->reference_count)) +#define OGS_OBJECT_UNREF(__oBJ) \ + ogs_debug("UNREF %d", ((__oBJ)->reference_count)), \ + ((__oBJ)->reference_count)-- +#define OGS_OBJECT_IS_REF(__oBJ) ((__oBJ)->reference_count > 1) + #ifdef __cplusplus } #endif
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-pkbuf.c -> open5gs_2.4.10.tar.xz/lib/core/ogs-pkbuf.c
Changed
@@ -245,7 +245,7 @@ } memset(pkbuf, 0, sizeof(*pkbuf)); - cluster->ref++; + OGS_OBJECT_REF(cluster); pkbuf->cluster = cluster; @@ -283,8 +283,9 @@ cluster = pkbuf->cluster; ogs_assert(cluster); - cluster->ref--; - if (cluster->ref == 0) + if (OGS_OBJECT_IS_REF(cluster)) + OGS_OBJECT_UNREF(cluster); + else cluster_free(pool, pkbuf->cluster); ogs_pool_free(&pool->pkbuf, pkbuf); @@ -337,7 +338,7 @@ ogs_assert(newbuf); memcpy(newbuf, pkbuf, sizeof *pkbuf); - newbuf->cluster->ref++; + OGS_OBJECT_REF(newbuf->cluster); ogs_thread_mutex_unlock(&pool->mutex); #endif
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-pkbuf.h -> open5gs_2.4.10.tar.xz/lib/core/ogs-pkbuf.h
Changed
@@ -32,7 +32,7 @@ unsigned char *buffer; unsigned int size; - unsigned int ref; + unsigned int reference_count; } ogs_cluster_t; #if OGS_USE_TALLOC
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-rand.c -> open5gs_2.4.10.tar.xz/lib/core/ogs-rand.c
Changed
@@ -79,7 +79,7 @@ fd = -1; /* force open() again */ } else { - buf = (unsigned char *)buf + rc; + buf = (unsigned char *)buf + rc; buflen -= rc; } } while (buflen > 0); @@ -123,7 +123,7 @@ static void evutil_memclear_(void *mem, size_t len) { - evutil_memset_volatile_(mem, 0, len); + evutil_memset_volatile_(mem, 0, len); } #include "arc4random.c"
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-signal.c -> open5gs_2.4.10.tar.xz/lib/core/ogs-signal.c
Changed
@@ -369,7 +369,7 @@ return OGS_OK; } #elif HAVE_SIGSUSPEND - sigsuspend(&sig_mask); + sigsuspend(&sig_mask); #else #error No sigwait() and no sigsuspend() #endif
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-sockaddr.c -> open5gs_2.4.10.tar.xz/lib/core/ogs-sockaddr.c
Changed
@@ -255,23 +255,23 @@ ogs_sockaddr_t *ogs_link_local_addr(const char *dev, const ogs_sockaddr_t *sa) { #if defined(HAVE_GETIFADDRS) - struct ifaddrs *iflist, *cur; + struct ifaddrs *iflist, *cur; int rc; - rc = getifaddrs(&iflist); + rc = getifaddrs(&iflist); if (rc != 0) { ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno, "getifaddrs failed"); return NULL; } - for (cur = iflist; cur != NULL; cur = cur->ifa_next) { + for (cur = iflist; cur != NULL; cur = cur->ifa_next) { ogs_sockaddr_t *ifa_addr = NULL; ogs_sockaddr_t *addr = NULL; ifa_addr = (ogs_sockaddr_t *)cur->ifa_addr; - if (ifa_addr == NULL) /* may happen with ppp interfaces */ - continue; + if (ifa_addr == NULL) /* may happen with ppp interfaces */ + continue; if (ifa_addr->ogs_sa_family == AF_INET) continue; @@ -293,9 +293,9 @@ freeifaddrs(iflist); return addr; - } + } - freeifaddrs(iflist); + freeifaddrs(iflist); #endif return NULL; }
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-socknode.c -> open5gs_2.4.10.tar.xz/lib/core/ogs-socknode.c
Changed
@@ -112,16 +112,16 @@ { #if defined(HAVE_GETIFADDRS) ogs_socknode_t *node = NULL; - struct ifaddrs *iflist, *cur; + struct ifaddrs *iflist, *cur; int rc; - rc = getifaddrs(&iflist); + rc = getifaddrs(&iflist); if (rc != 0) { ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno, "getifaddrs failed"); return OGS_ERROR; } - for (cur = iflist; cur != NULL; cur = cur->ifa_next) { + for (cur = iflist; cur != NULL; cur = cur->ifa_next) { ogs_sockaddr_t *addr = NULL; if (cur->ifa_flags & IFF_LOOPBACK) @@ -130,8 +130,8 @@ if (cur->ifa_flags & IFF_POINTOPOINT) continue; - if (cur->ifa_addr == NULL) /* may happen with ppp interfaces */ - continue; + if (cur->ifa_addr == NULL) /* may happen with ppp interfaces */ + continue; if (dev && strcmp(dev, cur->ifa_name) != 0) continue; @@ -185,9 +185,9 @@ if (option) node->option = ogs_memdup(option, sizeof *option); - } + } - freeifaddrs(iflist); + freeifaddrs(iflist); return OGS_OK; #elif defined(_WIN32) return OGS_OK; @@ -202,7 +202,7 @@ int ogs_socknode_fill_scope_id_in_local(ogs_sockaddr_t *sa_list) { #if defined(HAVE_GETIFADDRS) - struct ifaddrs *iflist = NULL, *cur; + struct ifaddrs *iflist = NULL, *cur; int rc; ogs_sockaddr_t *addr, *ifaddr;
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-sockopt.h -> open5gs_2.4.10.tar.xz/lib/core/ogs-sockopt.h
Changed
@@ -35,6 +35,7 @@ uint32_t srto_initial; uint32_t srto_min; uint32_t srto_max; +#define OGS_DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS 30 uint16_t sinit_num_ostreams; uint16_t sinit_max_instreams; uint16_t sinit_max_attempts;
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-time.c -> open5gs_2.4.10.tar.xz/lib/core/ogs-time.c
Changed
@@ -78,18 +78,18 @@ #else #define DELTA_EPOCH_IN_MICROSEC 11644473600000000ULL #endif - FILETIME ft; - uint64_t tmp = 0; + FILETIME ft; + uint64_t tmp = 0; - /* - * The const value is shamelessy stolen from - * http://www.boost.org/doc/libs/1_55_0/boost/chrono/detail/inlined/win/chrono.hpp - * - * File times are the number of 100 nanosecond intervals elapsed since - * 12:00 am Jan 1, 1601 UTC. I haven't check the math particularly hard - * - * ... good luck - */ + /* + * The const value is shamelessy stolen from + * http://www.boost.org/doc/libs/1_55_0/boost/chrono/detail/inlined/win/chrono.hpp + * + * File times are the number of 100 nanosecond intervals elapsed since + * 12:00 am Jan 1, 1601 UTC. I haven't check the math particularly hard + * + * ... good luck + */ if (tv) { GetSystemTimeAsFileTime (&ft); @@ -182,7 +182,7 @@ */ uint32_t ogs_time_ntp32_now(void) { - int rc; + int rc; struct timeval tv; rc = ogs_gettimeofday(&tv); @@ -192,13 +192,13 @@ } ogs_time_t ogs_time_from_ntp32(uint32_t ntp_timestamp) { - if (ntp_timestamp < OGS_1970_1900_SEC_DIFF) - return 0; - return (ntp_timestamp - OGS_1970_1900_SEC_DIFF) * OGS_USEC_PER_SEC; + if (ntp_timestamp < OGS_1970_1900_SEC_DIFF) + return 0; + return (ntp_timestamp - OGS_1970_1900_SEC_DIFF) * OGS_USEC_PER_SEC; } uint32_t ogs_time_to_ntp32(ogs_time_t time) { - return (time / OGS_USEC_PER_SEC) + OGS_1970_1900_SEC_DIFF; + return (time / OGS_USEC_PER_SEC) + OGS_1970_1900_SEC_DIFF; } int ogs_timezone(void)
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-timer.c -> open5gs_2.4.10.tar.xz/lib/core/ogs-timer.c
Changed
@@ -70,6 +70,12 @@ ogs_free(manager); } +static ogs_timer_t *ogs_timer_cycle(ogs_timer_mgr_t *manager, ogs_timer_t *timer) +{ + ogs_assert(manager); + return ogs_pool_cycle(&manager->pool, timer); +} + ogs_timer_t *ogs_timer_add( ogs_timer_mgr_t *manager, void (*cb)(void *data), void *data) { @@ -77,7 +83,11 @@ ogs_assert(manager); ogs_pool_alloc(&manager->pool, &timer); - ogs_assert(timer); + if (!timer) { + ogs_fatal("ogs_pool_alloc() failed"); + return NULL; + } + ogs_expect_or_return_val(timer, NULL); memset(timer, 0, sizeof *timer); timer->cb = cb; @@ -88,19 +98,25 @@ return timer; } -void ogs_timer_delete(ogs_timer_t *timer) +void ogs_timer_delete_debug(ogs_timer_t *timer, const char *file_line) { ogs_timer_mgr_t *manager; ogs_assert(timer); manager = timer->manager; ogs_assert(manager); + timer = ogs_timer_cycle(manager, timer); + if (!timer) { + ogs_fatal("ogs_timer_delete() failed in %s", file_line); + ogs_assert_if_reached(); + } ogs_timer_stop(timer); ogs_pool_free(&manager->pool, timer); } -void ogs_timer_start(ogs_timer_t *timer, ogs_time_t duration) +void ogs_timer_start_debug( + ogs_timer_t *timer, ogs_time_t duration, const char *file_line) { ogs_timer_mgr_t *manager = NULL; ogs_assert(timer); @@ -108,6 +124,11 @@ manager = timer->manager; ogs_assert(manager); + timer = ogs_timer_cycle(manager, timer); + if (!timer) { + ogs_fatal("ogs_timer_start() failed in %s", file_line); + ogs_assert_if_reached(); + } if (timer->running == true) ogs_rbtree_delete(&manager->tree, timer); @@ -116,12 +137,18 @@ add_timer_node(&manager->tree, timer, duration); } -void ogs_timer_stop(ogs_timer_t *timer) +void ogs_timer_stop_debug(ogs_timer_t *timer, const char *file_line) { ogs_timer_mgr_t *manager = NULL; ogs_assert(timer); manager = timer->manager; ogs_assert(manager); + timer = ogs_timer_cycle(manager, timer); + ogs_assert(timer); + if (!timer) { + ogs_fatal("ogs_timer_stop() failed in %s", file_line); + ogs_assert_if_reached(); + } if (timer->running == false) return; @@ -178,4 +205,3 @@ this->cb(this->data); } } -
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-timer.h -> open5gs_2.4.10.tar.xz/lib/core/ogs-timer.h
Changed
@@ -46,10 +46,17 @@ ogs_timer_t *ogs_timer_add( ogs_timer_mgr_t *manager, void (*cb)(void *data), void *data); -void ogs_timer_delete(ogs_timer_t *timer); +#define ogs_timer_delete(timer) \ + ogs_timer_delete_debug(timer, OGS_FILE_LINE) +void ogs_timer_delete_debug(ogs_timer_t *timer, const char *file_line); -void ogs_timer_start(ogs_timer_t *timer, ogs_time_t duration); -void ogs_timer_stop(ogs_timer_t *timer); +#define ogs_timer_start(timer, duration) \ + ogs_timer_start_debug(timer, duration, OGS_FILE_LINE) +void ogs_timer_start_debug( + ogs_timer_t *timer, ogs_time_t duration, const char *file_line); +#define ogs_timer_stop(timer) \ + ogs_timer_stop_debug(timer, OGS_FILE_LINE) +void ogs_timer_stop_debug(ogs_timer_t *timer, const char *file_line); ogs_time_t ogs_timer_mgr_next(ogs_timer_mgr_t *manager); void ogs_timer_mgr_expire(ogs_timer_mgr_t *manager);
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-uuid.c -> open5gs_2.4.10.tar.xz/lib/core/ogs-uuid.c
Changed
@@ -162,7 +162,8 @@ { const unsigned char *d = uuid->data; - sprintf(buffer, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" + ogs_snprintf(buffer, OGS_UUID_FORMATTED_LENGTH + 1, + "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" "%02x%02x%02x%02x%02x%02x", d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15);
View file
open5gs_2.4.9.tar.xz/lib/crypt/meson.build -> open5gs_2.4.10.tar.xz/lib/crypt/meson.build
Changed
@@ -52,10 +52,10 @@ version : libogslib_version, c_args : '-DOGS_CRYPT_COMPILATION', include_directories : libcrypt_inc, libinc, - dependencies : libcore_dep, + dependencies : libproto_dep, install : true) libcrypt_dep = declare_dependency( link_with : libcrypt, include_directories : libcrypt_inc, libinc, - dependencies : libcore_dep) + dependencies : libproto_dep)
View file
open5gs_2.4.9.tar.xz/lib/crypt/ogs-crypt.h -> open5gs_2.4.10.tar.xz/lib/crypt/ogs-crypt.h
Changed
@@ -20,7 +20,7 @@ #ifndef OGS_CRYPT_H #define OGS_CRYPT_H -#include "ogs-core.h" +#include "proto/ogs-proto.h" #define OGS_CRYPT_INSIDE
View file
open5gs_2.4.9.tar.xz/lib/dbi/ogs-dbi.h -> open5gs_2.4.10.tar.xz/lib/dbi/ogs-dbi.h
Changed
@@ -20,8 +20,7 @@ #ifndef OGS_DBI_H #define OGS_DBI_H -#include "ogs-core.h" -#include "ogs-crypt.h" +#include "crypt/ogs-crypt.h" #define OGS_DBI_INSIDE
View file
open5gs_2.4.9.tar.xz/lib/diameter/common/config.c -> open5gs_2.4.10.tar.xz/lib/diameter/common/config.c
Changed
@@ -174,31 +174,31 @@ CHECK_FCT_DO( fd_ext_add( fname, cfname ), return OGS_ERROR ); } - return OGS_OK; + return OGS_OK; } int ogs_diam_config_init(ogs_diam_config_t *fd_config) { - char * buf = NULL, *b; - size_t len = 0; - - CHECK_FCT( diam_config_apply(fd_config) ); - - /* The following module use data from the configuration */ - CHECK_FCT( fd_rtdisp_init() ); + char * buf = NULL, *b; + size_t len = 0; + + CHECK_FCT( diam_config_apply(fd_config) ); + + /* The following module use data from the configuration */ + CHECK_FCT( fd_rtdisp_init() ); /* Now, load all dynamic extensions */ CHECK_FCT( fd_ext_load() ); - /* Display configuration */ - b = fd_conf_dump(&buf, &len, NULL); + /* Display configuration */ + b = fd_conf_dump(&buf, &len, NULL); LOG_SPLIT(FD_LOG_NOTICE, NULL, b ?: (char*)"<Error during configuration dump...>", NULL); - free(buf); - - /* Since some extensions might have modified the definitions from the dict_base_protocol, we only load the objects now */ - CHECK_FCT( fd_msg_init() ); - + free(buf); + + /* Since some extensions might have modified the definitions from the dict_base_protocol, we only load the objects now */ + CHECK_FCT( fd_msg_init() ); + return OGS_OK; }
View file
open5gs_2.4.9.tar.xz/lib/diameter/common/init.c -> open5gs_2.4.10.tar.xz/lib/diameter/common/init.c
Changed
@@ -44,7 +44,7 @@ return ret; } - /* Parse the configuration file */ + /* Parse the configuration file */ if (conffile) { CHECK_FCT_DO( fd_core_parseconf(conffile), goto error ); } else { @@ -59,35 +59,35 @@ return 0; error: - CHECK_FCT_DO( fd_core_shutdown(), ); - CHECK_FCT_DO( fd_core_wait_shutdown_complete(), ); + CHECK_FCT_DO( fd_core_shutdown(), ); + CHECK_FCT_DO( fd_core_wait_shutdown_complete(), ); - return -1; + return -1; } int ogs_diam_start(void) { - /* Start the servers */ - CHECK_FCT_DO( fd_core_start(), goto error ); + /* Start the servers */ + CHECK_FCT_DO( fd_core_start(), goto error ); - CHECK_FCT_DO( fd_core_waitstartcomplete(), goto error ); + CHECK_FCT_DO( fd_core_waitstartcomplete(), goto error ); CHECK_FCT( ogs_diam_logger_stats_start() ); return 0; error: - CHECK_FCT_DO( fd_core_shutdown(), ); - CHECK_FCT_DO( fd_core_wait_shutdown_complete(), ); + CHECK_FCT_DO( fd_core_shutdown(), ); + CHECK_FCT_DO( fd_core_wait_shutdown_complete(), ); - return -1; + return -1; } void ogs_diam_final() { ogs_diam_logger_final(); - CHECK_FCT_DO( fd_core_shutdown(), ogs_error("fd_core_shutdown() failed") ); - CHECK_FCT_DO( fd_core_wait_shutdown_complete(), + CHECK_FCT_DO( fd_core_shutdown(), ogs_error("fd_core_shutdown() failed") ); + CHECK_FCT_DO( fd_core_wait_shutdown_complete(), ogs_error("fd_core_wait_shutdown_complete() failed")); }
View file
open5gs_2.4.9.tar.xz/lib/diameter/common/logger.c -> open5gs_2.4.10.tar.xz/lib/diameter/common/logger.c
Changed
@@ -34,27 +34,27 @@ int ogs_diam_logger_init(int mode) { - uint32_t mask_peers = HOOK_MASK( HOOK_PEER_CONNECT_SUCCESS ); + uint32_t mask_peers = HOOK_MASK( HOOK_PEER_CONNECT_SUCCESS ); memset(&self, 0, sizeof(struct ogs_diam_logger_t)); self.mode = mode; - self.duration = 60; /* 60 seconds */ - + self.duration = 60; /* 60 seconds */ + CHECK_FCT( fd_hook_register( mask_peers, ogs_diam_logger_cb, NULL, NULL, &logger_hdl) ); - CHECK_POSIX( pthread_mutex_init(&self.stats_lock, NULL) ); + CHECK_POSIX( pthread_mutex_init(&self.stats_lock, NULL) ); - return 0; + return 0; } void ogs_diam_logger_final() { - CHECK_FCT_DO( fd_thr_term(&fd_stats_th), ); - CHECK_POSIX_DO( pthread_mutex_destroy(&self.stats_lock), ); + CHECK_FCT_DO( fd_thr_term(&fd_stats_th), ); + CHECK_POSIX_DO( pthread_mutex_destroy(&self.stats_lock), ); - if (logger_hdl) { CHECK_FCT_DO( fd_hook_unregister( logger_hdl ), ); } + if (logger_hdl) { CHECK_FCT_DO( fd_hook_unregister( logger_hdl ), ); } } struct ogs_diam_logger_t* ogs_diam_logger_self() @@ -64,8 +64,8 @@ int ogs_diam_logger_stats_start() { - /* Start the statistics thread */ - CHECK_POSIX( pthread_create(&fd_stats_th, NULL, diam_stats_worker, NULL) ); + /* Start the statistics thread */ + CHECK_POSIX( pthread_create(&fd_stats_th, NULL, diam_stats_worker, NULL) ); return 0; } @@ -85,74 +85,74 @@ struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd, void * regdata) { - const char * peer_name = peer ? peer->info.pi_diamid : "<unknown peer>"; - - CHECK_POSIX_DO( pthread_mutex_lock(&mtx), ); + const char * peer_name = peer ? peer->info.pi_diamid : "<unknown peer>"; + + CHECK_POSIX_DO( pthread_mutex_lock(&mtx), ); if (user_handler) { user_handler(type, msg, peer, other, pmd, regdata); } - switch (type) { + switch (type) { /* peers */ - case HOOK_PEER_CONNECT_SUCCESS: - { - char protobuf40; - if (peer) { - CHECK_FCT_DO(fd_peer_cnx_proto_info(peer, protobuf, sizeof(protobuf)), break ); - } else { - protobuf0 = '-'; - protobuf1 = '\0'; - } - ogs_info("CONNECTED TO '%s' (%s):", peer_name, protobuf); - } - break; + case HOOK_PEER_CONNECT_SUCCESS: + { + char protobuf40; + if (peer) { + CHECK_FCT_DO(fd_peer_cnx_proto_info(peer, protobuf, sizeof(protobuf)), break ); + } else { + protobuf0 = '-'; + protobuf1 = '\0'; + } + ogs_info("CONNECTED TO '%s' (%s):", peer_name, protobuf); + } + break; default: ogs_warn("Unknown type(%d)", type); - break; - } - - CHECK_POSIX_DO( pthread_mutex_unlock(&mtx), ); + break; + } + + CHECK_POSIX_DO( pthread_mutex_unlock(&mtx), ); } /* Function to display statistics periodically */ static void * diam_stats_worker(void * arg) { - struct timespec start, now; - struct fd_stats copy; - - /* Get the start time */ - CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &start), ); - - /* Now, loop until canceled */ - while (1) { - /* Display statistics every XX seconds */ - sleep(self.duration); - - /* Now, get the current stats */ - CHECK_POSIX_DO( pthread_mutex_lock(&self.stats_lock), ); - memcpy(©, &self.stats, sizeof(struct fd_stats)); - CHECK_POSIX_DO( pthread_mutex_unlock(&self.stats_lock), ); - - /* Get the current execution time */ - CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &now), ); - - /* Now, display everything */ - ogs_trace("------- fd statistics ---------"); - if (now.tv_nsec >= start.tv_nsec) + struct timespec start, now; + struct fd_stats copy; + + /* Get the start time */ + CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &start), ); + + /* Now, loop until canceled */ + while (1) { + /* Display statistics every XX seconds */ + sleep(self.duration); + + /* Now, get the current stats */ + CHECK_POSIX_DO( pthread_mutex_lock(&self.stats_lock), ); + memcpy(©, &self.stats, sizeof(struct fd_stats)); + CHECK_POSIX_DO( pthread_mutex_unlock(&self.stats_lock), ); + + /* Get the current execution time */ + CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &now), ); + + /* Now, display everything */ + ogs_trace("------- fd statistics ---------"); + if (now.tv_nsec >= start.tv_nsec) { - ogs_trace(" Executing for: %d.%06ld sec", - (int)(now.tv_sec - start.tv_sec), - (long)(now.tv_nsec - start.tv_nsec) / 1000); - } + ogs_trace(" Executing for: %d.%06ld sec", + (int)(now.tv_sec - start.tv_sec), + (long)(now.tv_nsec - start.tv_nsec) / 1000); + } else { - ogs_trace(" Executing for: %d.%06ld sec", - (int)(now.tv_sec - 1 - start.tv_sec), - (long)(now.tv_nsec + 1000000000 - start.tv_nsec) / 1000); - } - + ogs_trace(" Executing for: %d.%06ld sec", + (int)(now.tv_sec - 1 - start.tv_sec), + (long)(now.tv_nsec + 1000000000 - start.tv_nsec) / 1000); + } + if (self.mode & FD_MODE_SERVER) { ogs_trace(" Server: %llu message(s) echoed", copy.nb_echoed); @@ -169,9 +169,9 @@ ogs_trace(" Average: %ld.%06ld sec.", copy.avg / 1000000, copy.avg % 1000000); } - ogs_trace("-------------------------------------"); - } - - return NULL; /* never called */ + ogs_trace("-------------------------------------"); + } + + return NULL; /* never called */ }
View file
open5gs_2.4.9.tar.xz/lib/diameter/common/message.c -> open5gs_2.4.10.tar.xz/lib/diameter/common/message.c
Changed
@@ -19,8 +19,8 @@ #include "ogs-diameter-common.h" -#define CHECK_dict_search( _type, _criteria, _what, _result ) \ - CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); +#define CHECK_dict_search( _type, _criteria, _what, _result ) \ + CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); struct dict_object *ogs_diam_session_id = NULL; struct dict_object *ogs_diam_termination_cause = NULL; @@ -107,17 +107,17 @@ struct avp *avp; union avp_value val; - /* Create an AVP to hold it */ - CHECK_FCT( fd_msg_avp_new( ogs_diam_session_id, 0, &avp ) ); + /* Create an AVP to hold it */ + CHECK_FCT( fd_msg_avp_new( ogs_diam_session_id, 0, &avp ) ); - /* Set its value */ - memset(&val, 0, sizeof(val)); - val.os.data = sid; - val.os.len = sidlen; - CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); + /* Set its value */ + memset(&val, 0, sizeof(val)); + val.os.data = sid; + val.os.len = sidlen; + CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); - /* Add it to the message */ - CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_FIRST_CHILD, avp ) ); + /* Add it to the message */ + CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_FIRST_CHILD, avp ) ); return 0; }
View file
open5gs_2.4.9.tar.xz/lib/diameter/common/ogs-diameter-common.h -> open5gs_2.4.10.tar.xz/lib/diameter/common/ogs-diameter-common.h
Changed
@@ -37,7 +37,7 @@ #pragma GCC diagnostic pop #endif -#include "ogs-core.h" +#include "proto/ogs-proto.h" #define OGS_DIAMETER_INSIDE
View file
open5gs_2.4.9.tar.xz/lib/diameter/common/util.c -> open5gs_2.4.10.tar.xz/lib/diameter/common/util.c
Changed
@@ -24,7 +24,7 @@ struct fd_list *li = NULL; struct fd_app *found = NULL; - CHECK_POSIX( pthread_rwlock_rdlock(&fd_g_peers_rw) ); + CHECK_POSIX( pthread_rwlock_rdlock(&fd_g_peers_rw) ); for (li = fd_g_peers.next; li != &fd_g_peers; li = li->next) { struct peer_hdr *p = (struct peer_hdr *)li->o; int state = fd_peer_get_state(p); @@ -44,7 +44,7 @@ ogs_debug("'%s' STATE%d is NOT open ", p->info.pi_diamid, state); } } - CHECK_POSIX( pthread_rwlock_unlock(&fd_g_peers_rw) ); + CHECK_POSIX( pthread_rwlock_unlock(&fd_g_peers_rw) ); if (found) return true;
View file
open5gs_2.4.9.tar.xz/lib/diameter/cx/message.c -> open5gs_2.4.10.tar.xz/lib/diameter/cx/message.c
Changed
@@ -19,8 +19,8 @@ #include "ogs-diameter-cx.h" -#define CHECK_dict_search( _type, _criteria, _what, _result ) \ - CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); +#define CHECK_dict_search( _type, _criteria, _what, _result ) \ + CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); struct dict_object *ogs_diam_cx_application = NULL;
View file
open5gs_2.4.9.tar.xz/lib/diameter/gx/message.c -> open5gs_2.4.10.tar.xz/lib/diameter/gx/message.c
Changed
@@ -19,8 +19,8 @@ #include "ogs-diameter-gx.h" -#define CHECK_dict_search( _type, _criteria, _what, _result ) \ - CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); +#define CHECK_dict_search( _type, _criteria, _what, _result ) \ + CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); struct dict_object *ogs_diam_gx_application = NULL; @@ -56,6 +56,7 @@ struct dict_object *ogs_diam_gx_called_station_id = NULL; struct dict_object *ogs_diam_gx_default_eps_bearer_qos = NULL; struct dict_object *ogs_diam_gx_3gpp_ms_timezone = NULL; +struct dict_object *ogs_diam_gx_3gpp_charging_characteristics = NULL; struct dict_object *ogs_diam_gx_event_trigger = NULL; struct dict_object *ogs_diam_gx_bearer_control_mode = NULL; struct dict_object *ogs_diam_gx_charging_rule_install = NULL; @@ -112,19 +113,19 @@ CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Framed-IPv6-Prefix", &ogs_diam_gx_framed_ipv6_prefix); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "IP-CAN-Type", &ogs_diam_gx_ip_can_type); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "QoS-Information", &ogs_diam_gx_qos_information); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "QoS-Class-Identifier" , &ogs_diam_gx_qos_class_identifier); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-UL" , &ogs_diam_gx_max_requested_bandwidth_ul); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-DL" , &ogs_diam_gx_max_requested_bandwidth_dl); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Min-Requested-Bandwidth-UL" , &ogs_diam_gx_min_requested_bandwidth_ul); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Min-Requested-Bandwidth-DL" , &ogs_diam_gx_min_requested_bandwidth_dl); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Guaranteed-Bitrate-UL" , &ogs_diam_gx_guaranteed_bitrate_ul); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Guaranteed-Bitrate-DL" , &ogs_diam_gx_guaranteed_bitrate_dl); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Allocation-Retention-Priority" , &ogs_diam_gx_allocation_retention_priority); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "QoS-Class-Identifier" , &ogs_diam_gx_qos_class_identifier); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-UL" , &ogs_diam_gx_max_requested_bandwidth_ul); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-DL" , &ogs_diam_gx_max_requested_bandwidth_dl); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Min-Requested-Bandwidth-UL" , &ogs_diam_gx_min_requested_bandwidth_ul); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Min-Requested-Bandwidth-DL" , &ogs_diam_gx_min_requested_bandwidth_dl); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Guaranteed-Bitrate-UL" , &ogs_diam_gx_guaranteed_bitrate_ul); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Guaranteed-Bitrate-DL" , &ogs_diam_gx_guaranteed_bitrate_dl); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Allocation-Retention-Priority" , &ogs_diam_gx_allocation_retention_priority); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Priority-Level", &ogs_diam_gx_priority_level); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Pre-emption-Capability", &ogs_diam_gx_pre_emption_capability); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Pre-emption-Vulnerability", &ogs_diam_gx_pre_emption_vulnerability); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Aggregate-Max-Bitrate-UL" , &ogs_diam_gx_apn_aggregate_max_bitrate_ul); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Aggregate-Max-Bitrate-DL" , &ogs_diam_gx_apn_aggregate_max_bitrate_dl); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Aggregate-Max-Bitrate-UL" , &ogs_diam_gx_apn_aggregate_max_bitrate_ul); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Aggregate-Max-Bitrate-DL" , &ogs_diam_gx_apn_aggregate_max_bitrate_dl); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-User-Location-Info", &ogs_diam_gx_3gpp_user_location_info); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Called-Station-Id", &ogs_diam_gx_called_station_id); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Default-EPS-Bearer-QoS", &ogs_diam_gx_default_eps_bearer_qos); @@ -133,6 +134,7 @@ CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Event-Trigger", &ogs_diam_gx_event_trigger); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Bearer-Control-Mode", &ogs_diam_gx_bearer_control_mode); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-Charging-Characteristics", &ogs_diam_gx_3gpp_charging_characteristics); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Charging-Rule-Install", &ogs_diam_gx_charging_rule_install); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Charging-Rule-Remove", &ogs_diam_gx_charging_rule_remove); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Charging-Rule-Definition", &ogs_diam_gx_charging_rule_definition); @@ -148,8 +150,8 @@ CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Component-Description", &ogs_diam_gx_media_component_description); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Component-Number", &ogs_diam_gx_media_component_number); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Type", &ogs_diam_gx_media_type); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RR-Bandwidth" , &ogs_diam_gx_rr_bandwidth); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RS-Bandwidth" , &ogs_diam_gx_rs_bandwidth); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RR-Bandwidth" , &ogs_diam_gx_rr_bandwidth); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RS-Bandwidth" , &ogs_diam_gx_rs_bandwidth); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Codec-Data", &ogs_diam_gx_codec_data); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Sub-Component", &ogs_diam_gx_media_sub_component); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Number", &ogs_diam_gx_flow_number);
View file
open5gs_2.4.9.tar.xz/lib/diameter/gx/message.h -> open5gs_2.4.10.tar.xz/lib/diameter/gx/message.h
Changed
@@ -86,6 +86,7 @@ extern struct dict_object *ogs_diam_gx_called_station_id; extern struct dict_object *ogs_diam_gx_default_eps_bearer_qos; extern struct dict_object *ogs_diam_gx_3gpp_ms_timezone; +extern struct dict_object *ogs_diam_gx_3gpp_charging_characteristics; extern struct dict_object *ogs_diam_gx_event_trigger; extern struct dict_object *ogs_diam_gx_bearer_control_mode; extern struct dict_object *ogs_diam_gx_charging_rule_install;
View file
open5gs_2.4.9.tar.xz/lib/diameter/gy/message.c -> open5gs_2.4.10.tar.xz/lib/diameter/gy/message.c
Changed
@@ -20,8 +20,8 @@ #include "ogs-diameter-gy.h" -#define CHECK_dict_search( _type, _criteria, _what, _result ) \ - CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); +#define CHECK_dict_search( _type, _criteria, _what, _result ) \ + CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); struct dict_object *ogs_diam_gy_application = NULL; @@ -86,70 +86,70 @@ int ogs_diam_gy_init(void) { - application_id_t id = OGS_DIAM_GY_APPLICATION_ID; + application_id_t id = OGS_DIAM_GY_APPLICATION_ID; - ogs_assert(ogs_dict_gy_entry(NULL) == 0); + ogs_assert(ogs_dict_gy_entry(NULL) == 0); - CHECK_dict_search(DICT_APPLICATION, APPLICATION_BY_ID, (void *)&id, &ogs_diam_gy_application); + CHECK_dict_search(DICT_APPLICATION, APPLICATION_BY_ID, (void *)&id, &ogs_diam_gy_application); - CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Credit-Control-Request", &ogs_diam_gy_cmd_ccr); - CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Credit-Control-Answer", &ogs_diam_gy_cmd_cca); - CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Re-Auth-Request", &ogs_diam_gy_cmd_rar); - CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Re-Auth-Answer", &ogs_diam_gy_cmd_raa); - - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Request-Type", &ogs_diam_gy_cc_request_type); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Request-Number", &ogs_diam_gy_cc_request_number); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Requested-Action", &ogs_diam_gy_requested_action); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "AoC-Request-Type", &ogs_diam_gy_aoc_request_type); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Multiple-Services-Indicator", &ogs_diam_gy_multiple_services_ind); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Multiple-Services-Credit-Control", &ogs_diam_gy_multiple_services_cc); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Requested-Service-Unit", &ogs_diam_gy_requested_service_unit); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Used-Service-Unit", &ogs_diam_gy_used_service_unit); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Time", &ogs_diam_gy_cc_time); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Total-Octets", &ogs_diam_gy_cc_total_octets); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Input-Octets", &ogs_diam_gy_cc_input_octets); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Output-Octets", &ogs_diam_gy_cc_output_octets); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Service-Specific-Units", &ogs_diam_gy_cc_service_specific_units); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Reporting-Reason", &ogs_diam_gy_reporting_reason); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Service-Identifier", &ogs_diam_gy_service_id); - - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Service-Information", &ogs_diam_gy_service_information); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "PS-Information", &ogs_diam_gy_ps_information); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-Charging-Id", &ogs_diam_gy_3gpp_charging_id); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-PDP-Type", &ogs_diam_gy_3gpp_pdp_type); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "PDP-Address", &ogs_diam_gy_pdp_address); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "SGSN-Address", &ogs_diam_gy_sgsn_address); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "GGSN-Address", &ogs_diam_gy_ggsn_address); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-NSAPI", &ogs_diam_gy_3gpp_nsapi); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-Selection-Mode", &ogs_diam_gy_3gpp_selection_mode); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-Charging-Characteristics", &ogs_diam_gy_3gpp_charging_characteristics); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "User-Equipment-Info", &ogs_diam_gy_user_equipment_info); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "User-Equipment-Info-Type", &ogs_diam_gy_user_equipment_info_type); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "User-Equipment-Info-Value", &ogs_diam_gy_user_equipment_info_value); - - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Feature-List-ID", &ogs_diam_gy_feature_list_id); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Feature-List", &ogs_diam_gy_feature_list); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "QoS-Information", &ogs_diam_gy_qos_information); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "QoS-Class-Identifier" , &ogs_diam_gy_qos_class_identifier); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-UL" , &ogs_diam_gy_max_requested_bandwidth_ul); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-DL" , &ogs_diam_gy_max_requested_bandwidth_dl); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Guaranteed-Bitrate-UL" , &ogs_diam_gy_guaranteed_bitrate_ul); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Guaranteed-Bitrate-DL" , &ogs_diam_gy_guaranteed_bitrate_dl); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Allocation-Retention-Priority" , &ogs_diam_gy_allocation_retention_priority); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Priority-Level", &ogs_diam_gy_priority_level); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Pre-emption-Capability", &ogs_diam_gy_pre_emption_capability); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Pre-emption-Vulnerability", &ogs_diam_gy_pre_emption_vulnerability); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Aggregate-Max-Bitrate-UL" , &ogs_diam_gy_apn_aggregate_max_bitrate_ul); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Aggregate-Max-Bitrate-DL" , &ogs_diam_gy_apn_aggregate_max_bitrate_dl); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-RAT-Type" , &ogs_diam_gy_3gpp_rat_type); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-User-Location-Info", &ogs_diam_gy_3gpp_user_location_info); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Called-Station-Id", &ogs_diam_gy_called_station_id); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-MS-TimeZone", &ogs_diam_gy_3gpp_ms_timezone); + CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Credit-Control-Request", &ogs_diam_gy_cmd_ccr); + CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Credit-Control-Answer", &ogs_diam_gy_cmd_cca); + CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Re-Auth-Request", &ogs_diam_gy_cmd_rar); + CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Re-Auth-Answer", &ogs_diam_gy_cmd_raa); + + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Request-Type", &ogs_diam_gy_cc_request_type); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Request-Number", &ogs_diam_gy_cc_request_number); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Requested-Action", &ogs_diam_gy_requested_action); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "AoC-Request-Type", &ogs_diam_gy_aoc_request_type); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Multiple-Services-Indicator", &ogs_diam_gy_multiple_services_ind); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Multiple-Services-Credit-Control", &ogs_diam_gy_multiple_services_cc); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Requested-Service-Unit", &ogs_diam_gy_requested_service_unit); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Used-Service-Unit", &ogs_diam_gy_used_service_unit); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Time", &ogs_diam_gy_cc_time); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Total-Octets", &ogs_diam_gy_cc_total_octets); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Input-Octets", &ogs_diam_gy_cc_input_octets); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Output-Octets", &ogs_diam_gy_cc_output_octets); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Service-Specific-Units", &ogs_diam_gy_cc_service_specific_units); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Reporting-Reason", &ogs_diam_gy_reporting_reason); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Service-Identifier", &ogs_diam_gy_service_id); + + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Service-Information", &ogs_diam_gy_service_information); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "PS-Information", &ogs_diam_gy_ps_information); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-Charging-Id", &ogs_diam_gy_3gpp_charging_id); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-PDP-Type", &ogs_diam_gy_3gpp_pdp_type); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "PDP-Address", &ogs_diam_gy_pdp_address); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "SGSN-Address", &ogs_diam_gy_sgsn_address); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "GGSN-Address", &ogs_diam_gy_ggsn_address); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-NSAPI", &ogs_diam_gy_3gpp_nsapi); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-Selection-Mode", &ogs_diam_gy_3gpp_selection_mode); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-Charging-Characteristics", &ogs_diam_gy_3gpp_charging_characteristics); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "User-Equipment-Info", &ogs_diam_gy_user_equipment_info); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "User-Equipment-Info-Type", &ogs_diam_gy_user_equipment_info_type); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "User-Equipment-Info-Value", &ogs_diam_gy_user_equipment_info_value); + + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Feature-List-ID", &ogs_diam_gy_feature_list_id); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Feature-List", &ogs_diam_gy_feature_list); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "QoS-Information", &ogs_diam_gy_qos_information); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "QoS-Class-Identifier" , &ogs_diam_gy_qos_class_identifier); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-UL" , &ogs_diam_gy_max_requested_bandwidth_ul); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-DL" , &ogs_diam_gy_max_requested_bandwidth_dl); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Guaranteed-Bitrate-UL" , &ogs_diam_gy_guaranteed_bitrate_ul); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Guaranteed-Bitrate-DL" , &ogs_diam_gy_guaranteed_bitrate_dl); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Allocation-Retention-Priority" , &ogs_diam_gy_allocation_retention_priority); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Priority-Level", &ogs_diam_gy_priority_level); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Pre-emption-Capability", &ogs_diam_gy_pre_emption_capability); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Pre-emption-Vulnerability", &ogs_diam_gy_pre_emption_vulnerability); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Aggregate-Max-Bitrate-UL" , &ogs_diam_gy_apn_aggregate_max_bitrate_ul); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Aggregate-Max-Bitrate-DL" , &ogs_diam_gy_apn_aggregate_max_bitrate_dl); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-RAT-Type" , &ogs_diam_gy_3gpp_rat_type); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-User-Location-Info", &ogs_diam_gy_3gpp_user_location_info); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Called-Station-Id", &ogs_diam_gy_called_station_id); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-MS-TimeZone", &ogs_diam_gy_3gpp_ms_timezone); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Charging-Rule-Base-Name", &ogs_diam_gy_charging_rule_base_name); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flows", &ogs_diam_gy_flows); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Charging-Rule-Base-Name", &ogs_diam_gy_charging_rule_base_name); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flows", &ogs_diam_gy_flows); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-SGSN-MCC-MNC", &ogs_diam_gy_3gpp_sgsn_mcc_mnc); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-SGSN-MCC-MNC", &ogs_diam_gy_3gpp_sgsn_mcc_mnc); - return 0; + return 0; }
View file
open5gs_2.4.9.tar.xz/lib/diameter/rx/message.c -> open5gs_2.4.10.tar.xz/lib/diameter/rx/message.c
Changed
@@ -19,8 +19,8 @@ #include "ogs-diameter-rx.h" -#define CHECK_dict_search( _type, _criteria, _what, _result ) \ - CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); +#define CHECK_dict_search( _type, _criteria, _what, _result ) \ + CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); struct dict_object *ogs_diam_rx_application = NULL; @@ -78,12 +78,12 @@ CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Component-Description", &ogs_diam_rx_media_component_description); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Component-Number", &ogs_diam_rx_media_component_number); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Type", &ogs_diam_rx_media_type); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-UL" , &ogs_diam_rx_max_requested_bandwidth_ul); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-DL" , &ogs_diam_rx_max_requested_bandwidth_dl); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Min-Requested-Bandwidth-UL" , &ogs_diam_rx_min_requested_bandwidth_ul); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Min-Requested-Bandwidth-DL" , &ogs_diam_rx_min_requested_bandwidth_dl); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RR-Bandwidth" , &ogs_diam_rx_rr_bandwidth); - CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RS-Bandwidth" , &ogs_diam_rx_rs_bandwidth); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-UL" , &ogs_diam_rx_max_requested_bandwidth_ul); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-DL" , &ogs_diam_rx_max_requested_bandwidth_dl); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Min-Requested-Bandwidth-UL" , &ogs_diam_rx_min_requested_bandwidth_ul); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Min-Requested-Bandwidth-DL" , &ogs_diam_rx_min_requested_bandwidth_dl); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RR-Bandwidth" , &ogs_diam_rx_rr_bandwidth); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RS-Bandwidth" , &ogs_diam_rx_rs_bandwidth); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Status", &ogs_diam_rx_flow_status); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Codec-Data", &ogs_diam_rx_codec_data); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Sub-Component", &ogs_diam_rx_media_sub_component);
View file
open5gs_2.4.9.tar.xz/lib/diameter/s6a/dict.c -> open5gs_2.4.10.tar.xz/lib/diameter/s6a/dict.c
Changed
@@ -33,62 +33,62 @@ /* The content of this file follows the same structure as dict_base_proto.c */ -#define CHECK_dict_new( _type, _data, _parent, _ref ) \ - CHECK_FCT( fd_dict_new( fd_g_config->cnf_dict, (_type), (_data), (_parent), (_ref)) ); +#define CHECK_dict_new( _type, _data, _parent, _ref ) \ + CHECK_FCT( fd_dict_new( fd_g_config->cnf_dict, (_type), (_data), (_parent), (_ref)) ); -#define CHECK_dict_search( _type, _criteria, _what, _result ) \ - CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); +#define CHECK_dict_search( _type, _criteria, _what, _result ) \ + CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); struct local_rules_definition { - struct dict_avp_request avp_vendor_plus_name; - enum rule_position position; - int min; - int max; + struct dict_avp_request avp_vendor_plus_name; + enum rule_position position; + int min; + int max; }; #define RULE_ORDER( _position ) ((((_position) == RULE_FIXED_HEAD) || ((_position) == RULE_FIXED_TAIL)) ? 1 : 0 ) /* Attention! This version of the macro uses AVP_BY_NAME_AND_VENDOR, in contrast to most other copies! */ -#define PARSE_loc_rules( _rulearray, _parent) { \ - int __ar; \ - for (__ar=0; __ar < sizeof(_rulearray) / sizeof((_rulearray)0); __ar++) { \ - struct dict_rule_data __data = { NULL, \ - (_rulearray)__ar.position, \ - 0, \ - (_rulearray)__ar.min, \ - (_rulearray)__ar.max}; \ - __data.rule_order = RULE_ORDER(__data.rule_position); \ - CHECK_FCT( fd_dict_search( \ - fd_g_config->cnf_dict, \ - DICT_AVP, \ - AVP_BY_NAME_AND_VENDOR, \ - &(_rulearray)__ar.avp_vendor_plus_name, \ - &__data.rule_avp, 0 ) ); \ - if ( !__data.rule_avp ) { \ - TRACE_DEBUG(INFO, "AVP Not found: '%s'", (_rulearray)__ar.avp_vendor_plus_name.avp_name); \ - return ENOENT; \ - } \ - CHECK_FCT_DO( fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &__data, _parent, NULL), \ - { \ - TRACE_DEBUG(INFO, "Error on rule with AVP '%s'", \ - (_rulearray)__ar.avp_vendor_plus_name.avp_name); \ - return EINVAL; \ - } ); \ - } \ +#define PARSE_loc_rules( _rulearray, _parent) { \ + int __ar; \ + for (__ar=0; __ar < sizeof(_rulearray) / sizeof((_rulearray)0); __ar++) { \ + struct dict_rule_data __data = { NULL, \ + (_rulearray)__ar.position, \ + 0, \ + (_rulearray)__ar.min, \ + (_rulearray)__ar.max}; \ + __data.rule_order = RULE_ORDER(__data.rule_position); \ + CHECK_FCT( fd_dict_search( \ + fd_g_config->cnf_dict, \ + DICT_AVP, \ + AVP_BY_NAME_AND_VENDOR, \ + &(_rulearray)__ar.avp_vendor_plus_name, \ + &__data.rule_avp, 0 ) ); \ + if ( !__data.rule_avp ) { \ + TRACE_DEBUG(INFO, "AVP Not found: '%s'", (_rulearray)__ar.avp_vendor_plus_name.avp_name); \ + return ENOENT; \ + } \ + CHECK_FCT_DO( fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &__data, _parent, NULL), \ + { \ + TRACE_DEBUG(INFO, "Error on rule with AVP '%s'", \ + (_rulearray)__ar.avp_vendor_plus_name.avp_name); \ + return EINVAL; \ + } ); \ + } \ } #define enumval_def_u32( _val_, _str_ ) \ - { _str_, { .u32 = _val_ }} + { _str_, { .u32 = _val_ }} #define enumval_def_os( _len_, _val_, _str_ ) \ - { _str_, { .os = { .data = (unsigned char *)_val_, .len = _len_ }}} + { _str_, { .os = { .data = (unsigned char *)_val_, .len = _len_ }}} int ogs_dict_s6a_entry(char *conffile) { struct dict_object *s6a; - TRACE_ENTRY("%p", conffile); + TRACE_ENTRY("%p", conffile); - /* Applications section */ + /* Applications section */ { struct dict_object * vendor; CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_NAME, "3GPP", &vendor, ENOENT)); @@ -96,8 +96,8 @@ CHECK_FCT(fd_dict_new(fd_g_config->cnf_dict, DICT_APPLICATION, &app_data, vendor, &s6a)); } - /* AVP section */ - { + /* AVP section */ + { { /* AIR-Flags AVP - 3GPP TS 29.272 #7.3.201 */ struct dict_avp_data data = { @@ -111,155 +111,155 @@ CHECK_dict_new(DICT_AVP, &data, NULL, NULL); } - /* Terminal Information AVP - 3GPP TS 29.272 #7.3.3 */ - { - struct dict_object * avp; - struct local_rules_definition rules = - { - { { .avp_vendor = 10415, .avp_name = "IMEI" }, RULE_OPTIONAL, -1, 1 }, - { { .avp_vendor = 10415, .avp_name = "3GPP2-MEID" }, RULE_OPTIONAL, -1, 1 }, - { { .avp_vendor = 10415, .avp_name = "Software-Version" }, RULE_OPTIONAL, -1, 1 }, - }; + /* Terminal Information AVP - 3GPP TS 29.272 #7.3.3 */ + { + struct dict_object * avp; + struct local_rules_definition rules = + { + { { .avp_vendor = 10415, .avp_name = "IMEI" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "3GPP2-MEID" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "Software-Version" }, RULE_OPTIONAL, -1, 1 }, + }; CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Terminal-Information", &avp); - PARSE_loc_rules( rules, avp ); - } + PARSE_loc_rules( rules, avp ); + } - /* Requested-EUTRAN-Authentication-Info AVP - 3GPP TS 29.272 #7.3.11 */ - { - struct dict_object * avp; - struct local_rules_definition rules = - { - { { .avp_vendor = 10415, .avp_name = "Number-Of-Requested-Vectors" }, RULE_OPTIONAL, -1, 1 }, - { { .avp_vendor = 10415, .avp_name = "Immediate-Response-Preferred" }, RULE_OPTIONAL, -1, 1 }, - { { .avp_vendor = 10415, .avp_name = "Re-Synchronization-Info" }, RULE_OPTIONAL, -1, 1 }, - }; + /* Requested-EUTRAN-Authentication-Info AVP - 3GPP TS 29.272 #7.3.11 */ + { + struct dict_object * avp; + struct local_rules_definition rules = + { + { { .avp_vendor = 10415, .avp_name = "Number-Of-Requested-Vectors" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "Immediate-Response-Preferred" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "Re-Synchronization-Info" }, RULE_OPTIONAL, -1, 1 }, + }; CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Requested-EUTRAN-Authentication-Info", &avp); - PARSE_loc_rules( rules, avp ); - } + PARSE_loc_rules( rules, avp ); + } - /* Requested-UTRAN-GERAN-Authentication-Info AVP - 3GPP TS 29.272 #7.3.12 */ - { - struct dict_object * avp; - struct local_rules_definition rules = - { - { { .avp_vendor = 10415, .avp_name = "Number-Of-Requested-Vectors" }, RULE_OPTIONAL, -1, 1 }, - { { .avp_vendor = 10415, .avp_name = "Immediate-Response-Preferred" }, RULE_OPTIONAL, -1, 1 }, - { { .avp_vendor = 10415, .avp_name = "Re-Synchronization-Info" }, RULE_OPTIONAL, -1, 1 }, - }; + /* Requested-UTRAN-GERAN-Authentication-Info AVP - 3GPP TS 29.272 #7.3.12 */ + { + struct dict_object * avp; + struct local_rules_definition rules = + { + { { .avp_vendor = 10415, .avp_name = "Number-Of-Requested-Vectors" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "Immediate-Response-Preferred" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "Re-Synchronization-Info" }, RULE_OPTIONAL, -1, 1 }, + }; CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Requested-UTRAN-GERAN-Authentication-Info", &avp); - PARSE_loc_rules( rules, avp ); - } + PARSE_loc_rules( rules, avp ); + } - /* E-UTRAN-Vector - 3GPP TS 29.272 #7.3.18 */ - { - struct dict_object * avp; - struct local_rules_definition rules = - { + /* E-UTRAN-Vector - 3GPP TS 29.272 #7.3.18 */ + { + struct dict_object * avp; + struct local_rules_definition rules = + { { { .avp_vendor = 10415, .avp_name = "Item-Number" }, RULE_OPTIONAL, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "RAND" }, RULE_REQUIRED, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "XRES" }, RULE_REQUIRED, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "AUTN" }, RULE_REQUIRED, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "KASME" }, RULE_REQUIRED, -1, 1 }, - }; + }; CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "E-UTRAN-Vector", &avp); - PARSE_loc_rules( rules, avp ); - } + PARSE_loc_rules( rules, avp ); + } - /* UTRAN-Vector - 3GPP TS 29.272 #7.3.19 */ - { - struct dict_object * avp; - struct local_rules_definition rules = - { + /* UTRAN-Vector - 3GPP TS 29.272 #7.3.19 */ + { + struct dict_object * avp; + struct local_rules_definition rules = + { { { .avp_vendor = 10415, .avp_name = "Item-Number" }, RULE_OPTIONAL, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "RAND" }, RULE_REQUIRED, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "XRES" }, RULE_REQUIRED, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "AUTN" }, RULE_REQUIRED, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "Confidentiality-Key" }, RULE_REQUIRED, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "Integrity-Key" }, RULE_REQUIRED, -1, 1 }, - }; + }; CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "UTRAN-Vector", &avp); - PARSE_loc_rules( rules, avp ); - } + PARSE_loc_rules( rules, avp ); + } - /* GERAN-Vector - 3GPP TS 29.272 #7.3.20 */ - { - struct dict_object * avp; - struct local_rules_definition rules = - { + /* GERAN-Vector - 3GPP TS 29.272 #7.3.20 */ + { + struct dict_object * avp; + struct local_rules_definition rules = + { { { .avp_vendor = 10415, .avp_name = "Item-Number" }, RULE_OPTIONAL, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "RAND" }, RULE_REQUIRED, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "SRES" }, RULE_REQUIRED, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "Kc" }, RULE_REQUIRED, -1, 1 }, - }; + }; CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "GERAN-Vector", &avp); - PARSE_loc_rules( rules, avp ); - } + PARSE_loc_rules( rules, avp ); + } - /* Authentication-Info - 3GPP TS 29.272 #7.3.17 */ - { - struct dict_object * avp; - struct local_rules_definition rules = - { + /* Authentication-Info - 3GPP TS 29.272 #7.3.17 */ + { + struct dict_object * avp; + struct local_rules_definition rules = + { { { .avp_vendor = 10415, .avp_name = "E-UTRAN-Vector" }, RULE_OPTIONAL, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "UTRAN-Vector" }, RULE_OPTIONAL, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "GERAN-Vector" }, RULE_OPTIONAL, -1, 1 }, - }; + }; CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Authentication-Info", &avp); - PARSE_loc_rules( rules, avp ); - } + PARSE_loc_rules( rules, avp ); + } - /* EPS-Subscribed-QoS-Profile AVP - 3GPP TS 29.272 #7.3.37 */ - { - struct dict_object * avp; - struct local_rules_definition rules = - { + /* EPS-Subscribed-QoS-Profile AVP - 3GPP TS 29.272 #7.3.37 */ + { + struct dict_object * avp; + struct local_rules_definition rules = + { { { .avp_vendor = 10415, .avp_name = "QoS-Class-Identifier" }, RULE_REQUIRED, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "Allocation-Retention-Priority" }, RULE_REQUIRED, -1, 1 }, - }; + }; CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "EPS-Subscribed-QoS-Profile", &avp); - PARSE_loc_rules( rules, avp ); - } + PARSE_loc_rules( rules, avp ); + } - /* AMBR AVP - 3GPP TS 29.272 #7.3.41 */ - { - struct dict_object * avp; - struct local_rules_definition rules = - { + /* AMBR AVP - 3GPP TS 29.272 #7.3.41 */ + { + struct dict_object * avp; + struct local_rules_definition rules = + { { { .avp_vendor = 10415, .avp_name = "Max-Requested-Bandwidth-UL" }, RULE_REQUIRED, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "Max-Requested-Bandwidth-DL" }, RULE_REQUIRED, -1, 1 }, - }; + }; CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "AMBR", &avp); - PARSE_loc_rules( rules, avp ); - } + PARSE_loc_rules( rules, avp ); + } - /* Specific-APN-Info AVP - 3GPP TS 29.272 #7.3.82 */ - { - struct dict_object * avp; - struct local_rules_definition rules = - { + /* Specific-APN-Info AVP - 3GPP TS 29.272 #7.3.82 */ + { + struct dict_object * avp; + struct local_rules_definition rules = + { { { .avp_name = "Service-Selection" }, RULE_REQUIRED, -1, 1 }, { { .avp_name = "MIP6-Agent-Info" }, RULE_REQUIRED, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "Visited-Network-Identifier" }, RULE_OPTIONAL, -1, 1 }, - }; + }; CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Specific-APN-Info", &avp); - PARSE_loc_rules( rules, avp ); - } + PARSE_loc_rules( rules, avp ); + } - /* APN-Configuration AVP - 3GPP TS 29.272 #7.3.35 */ - { - struct dict_object * avp; - struct local_rules_definition rules = - { + /* APN-Configuration AVP - 3GPP TS 29.272 #7.3.35 */ + { + struct dict_object * avp; + struct local_rules_definition rules = + { { { .avp_vendor = 10415, .avp_name = "Context-Identifier" }, RULE_REQUIRED, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "Served-Party-IP-Address" }, RULE_OPTIONAL, -1, 2 }, { { .avp_vendor = 10415, .avp_name = "PDN-Type" }, RULE_REQUIRED, -1, 1 }, @@ -275,31 +275,31 @@ { { .avp_vendor = 10415, .avp_name = "APN-OI-Replacement" }, RULE_OPTIONAL, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "SIPTO-Permission" }, RULE_OPTIONAL, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "LIPA-Permission" }, RULE_OPTIONAL, -1, 1 }, - }; + }; CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Configuration", &avp); - PARSE_loc_rules( rules, avp ); - } + PARSE_loc_rules( rules, avp ); + } - /* APN-Configuration-Profile AVP - 3GPP TS 29.272 #7.3.34 */ - { - struct dict_object * avp; - struct local_rules_definition rules = - { + /* APN-Configuration-Profile AVP - 3GPP TS 29.272 #7.3.34 */ + { + struct dict_object * avp; + struct local_rules_definition rules = + { { { .avp_vendor = 10415, .avp_name = "Context-Identifier" }, RULE_REQUIRED, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "All-APN-Configurations-Included-Indicator" }, RULE_REQUIRED, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "APN-Configuration" }, RULE_REQUIRED, -1, -1 }, - }; + }; CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Configuration-Profile", &avp); - PARSE_loc_rules( rules, avp ); - } + PARSE_loc_rules( rules, avp ); + } - /* Subscription-Data AVP - 3GPP TS 29.272 #7.3.2 */ - { - struct dict_object * avp; - struct local_rules_definition rules = - { + /* Subscription-Data AVP - 3GPP TS 29.272 #7.3.2 */ + { + struct dict_object * avp; + struct local_rules_definition rules = + { { { .avp_vendor = 10415, .avp_name = "Subscriber-Status" }, RULE_OPTIONAL, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "MSISDN" }, RULE_OPTIONAL, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "STN-SR" }, RULE_OPTIONAL, -1, 1 }, @@ -326,18 +326,18 @@ { { .avp_vendor = 10415, .avp_name = "VPLMN-LIPA-Allowed" }, RULE_OPTIONAL, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "Relay-Node-Indicator" }, RULE_OPTIONAL, -1, 1 }, { { .avp_vendor = 10415, .avp_name = "MDT-User-Consent" }, RULE_OPTIONAL, -1, 1 }, - }; + }; CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Data", &avp); - PARSE_loc_rules( rules, avp ); - } - }; + PARSE_loc_rules( rules, avp ); + } + }; /* Command section */ { - /* S6A-Update Location Request - 3GPP TS 29.272 #7.2.3 */ + /* S6A-Update Location Request - 3GPP TS 29.272 #7.2.3 */ { - struct dict_object * cmd; + struct dict_object * cmd; struct dict_cmd_data data = { 316, /* Code */ "Update-Location-Request", /* Name */ @@ -372,9 +372,9 @@ PARSE_loc_rules(rules, cmd); } - /* S6A-Update Location Answer - 3GPP TS 29.272 #7.2.4 */ + /* S6A-Update Location Answer - 3GPP TS 29.272 #7.2.4 */ { - struct dict_object * cmd; + struct dict_object * cmd; struct dict_cmd_data data = { 316, /* Code */ "Update-Location-Answer", /* Name */ @@ -402,9 +402,9 @@ PARSE_loc_rules(rules, cmd); } - /* S6A-Authentication-Information-Request - 3GPP TS 29.272 #7.2.4 */ + /* S6A-Authentication-Information-Request - 3GPP TS 29.272 #7.2.4 */ { - struct dict_object * cmd; + struct dict_object * cmd; struct dict_cmd_data data = { 318, /* Code */ "Authentication-Information-Request", /* Name */ @@ -434,9 +434,9 @@ PARSE_loc_rules(rules, cmd); } - /* S6A-Authentication-Information-Answer - 3GPP TS 29.272 #7.2.6 */ + /* S6A-Authentication-Information-Answer - 3GPP TS 29.272 #7.2.6 */ { - struct dict_object * cmd; + struct dict_object * cmd; struct dict_cmd_data data = { 318, /* Code */ "Authentication-Information-Answer", /* Name */ @@ -464,17 +464,17 @@ PARSE_loc_rules(rules, cmd); } - /* Purge-UE-Request (PUR) Command - 3GPP TS 29.272 #7.2.13 */ - { - struct dict_object * cmd; - struct dict_cmd_data data = { - 321, /* Code */ - "Purge-UE-Request", /* Name */ - CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_ERROR, /* Fixed flags */ - CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE /* Fixed flag values */ - }; - struct local_rules_definition rules = - { + /* Purge-UE-Request (PUR) Command - 3GPP TS 29.272 #7.2.13 */ + { + struct dict_object * cmd; + struct dict_cmd_data data = { + 321, /* Code */ + "Purge-UE-Request", /* Name */ + CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_ERROR, /* Fixed flags */ + CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE /* Fixed flag values */ + }; + struct local_rules_definition rules = + { { { .avp_name = "Session-Id" }, RULE_FIXED_HEAD, -1, 1 }, { { .avp_name = "Vendor-Specific-Application-Id" }, RULE_OPTIONAL, -1, 1 }, { { .avp_name = "Auth-Session-State" }, RULE_REQUIRED, -1, 1 }, @@ -491,23 +491,23 @@ #endif { { .avp_name = "Proxy-Info" }, RULE_OPTIONAL, -1, -1 }, { { .avp_name = "Route-Record" }, RULE_OPTIONAL, -1, -1 }, - }; + }; + + CHECK_dict_new( DICT_COMMAND, &data, s6a, &cmd); + PARSE_loc_rules( rules, cmd ); + } - CHECK_dict_new( DICT_COMMAND, &data, s6a, &cmd); - PARSE_loc_rules( rules, cmd ); - } - - /* Purge-UE-Answer (PUA) Command - 3GPP TS 29.272 #7.2.14 */ - { - struct dict_object * cmd; - struct dict_cmd_data data = { - 321, /* Code */ - "Purge-UE-Answer", /* Name */ - CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_ERROR, /* Fixed flags */ - CMD_FLAG_PROXIABLE /* Fixed flag values */ - }; - struct local_rules_definition rules = - { + /* Purge-UE-Answer (PUA) Command - 3GPP TS 29.272 #7.2.14 */ + { + struct dict_object * cmd; + struct dict_cmd_data data = { + 321, /* Code */ + "Purge-UE-Answer", /* Name */ + CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_ERROR, /* Fixed flags */ + CMD_FLAG_PROXIABLE /* Fixed flag values */ + }; + struct local_rules_definition rules = + { { { .avp_name = "Session-Id" }, RULE_FIXED_HEAD, -1, 1 }, { { .avp_name = "Vendor-Specific-Application-Id" }, RULE_OPTIONAL, -1, 1 }, { { .avp_name = "Result-Code" }, RULE_OPTIONAL, -1, 1 }, @@ -520,16 +520,138 @@ { { .avp_name = "Failed-AVP" }, RULE_OPTIONAL, -1, -1 }, { { .avp_name = "Proxy-Info" }, RULE_OPTIONAL, -1, -1 }, { { .avp_name = "Route-Record" }, RULE_OPTIONAL, -1, -1 }, - }; + }; - CHECK_dict_new( DICT_COMMAND, &data, s6a, &cmd); - PARSE_loc_rules( rules, cmd ); - } + CHECK_dict_new( DICT_COMMAND, &data, s6a, &cmd); + PARSE_loc_rules( rules, cmd ); + } + + /* Cancel-Location-Request (CLR) Command - 3GPP TS 29.272 #7.2.7 */ + { + struct dict_object * cmd; + struct dict_cmd_data data = { + 317, /* Code */ + "Cancel-Location-Request", /* Name */ + CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_ERROR, /* Fixed flags */ + CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE /* Fixed flag values */ + }; + struct local_rules_definition rules = + { + { { .avp_name = "Session-Id" }, RULE_FIXED_HEAD, -1, 1 }, + { { .avp_name = "Vendor-Specific-Application-Id" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_name = "Auth-Session-State" }, RULE_REQUIRED, -1, 1 }, + { { .avp_name = "Origin-Host" }, RULE_REQUIRED, -1, 1 }, + { { .avp_name = "Origin-Realm" }, RULE_REQUIRED, -1, 1 }, + { { .avp_name = "Destination-Host" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_name = "Destination-Realm" }, RULE_REQUIRED, -1, 1 }, + { { .avp_name = "User-Name" }, RULE_REQUIRED, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "Supported-Features" }, RULE_OPTIONAL, -1, -1 }, + { { .avp_vendor = 10415, .avp_name = "Cancellation-Type" }, RULE_REQUIRED, -1, -1 }, + { { .avp_vendor = 10415, .avp_name = "CLR-Flags" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_name = "Proxy-Info" }, RULE_OPTIONAL, -1, -1 }, + { { .avp_name = "Route-Record" }, RULE_OPTIONAL, -1, -1 }, + }; + + CHECK_dict_new( DICT_COMMAND, &data, s6a, &cmd); + PARSE_loc_rules( rules, cmd ); + } + + /* Cancel-Location-Answer (CLA) Command - 3GPP TS 29.272 #7.2.8 */ + { + struct dict_object * cmd; + struct dict_cmd_data data = { + 317, /* Code */ + "Cancel-Location-Answer", /* Name */ + CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_ERROR, /* Fixed flags */ + CMD_FLAG_PROXIABLE /* Fixed flag values */ + }; + struct local_rules_definition rules = + { + { { .avp_name = "Session-Id" }, RULE_FIXED_HEAD, -1, 1 }, + { { .avp_name = "Vendor-Specific-Application-Id" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_name = "Result-Code" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_name = "Experimental-Result" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_name = "Auth-Session-State" }, RULE_REQUIRED, -1, 1 }, + { { .avp_name = "Origin-Host" }, RULE_REQUIRED, -1, 1 }, + { { .avp_name = "Origin-Realm" }, RULE_REQUIRED, -1, 1 }, + { { .avp_name = "Failed-AVP" }, RULE_OPTIONAL, -1, -1 }, + { { .avp_name = "Proxy-Info" }, RULE_OPTIONAL, -1, -1 }, + { { .avp_name = "Route-Record" }, RULE_OPTIONAL, -1, -1 }, + }; + + CHECK_dict_new( DICT_COMMAND, &data, s6a, &cmd); + PARSE_loc_rules( rules, cmd ); + } + + /* Insert-Subscriber-Data-Request (IDR) Command - 3GPP TS 29.272 #7.2.9 */ + { + struct dict_object * cmd; + struct dict_cmd_data data = { + 319, /* Code */ + "Insert-Subscriber-Data-Request", /* Name */ + CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_ERROR, /* Fixed flags */ + CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE /* Fixed flag values */ + }; + struct local_rules_definition rules = + { + { { .avp_name = "Session-Id" }, RULE_FIXED_HEAD, -1, 1 }, + { { .avp_name = "Vendor-Specific-Application-Id" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_name = "Auth-Session-State" }, RULE_REQUIRED, -1, 1 }, + { { .avp_name = "Origin-Host" }, RULE_REQUIRED, -1, 1 }, + { { .avp_name = "Origin-Realm" }, RULE_REQUIRED, -1, 1 }, + { { .avp_name = "Destination-Host" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_name = "Destination-Realm" }, RULE_REQUIRED, -1, 1 }, + { { .avp_name = "User-Name" }, RULE_REQUIRED, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "Supported-Features" }, RULE_OPTIONAL, -1, -1 }, + { { .avp_vendor = 10415, .avp_name = "Subscription-Data" }, RULE_REQUIRED, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "IDR-Flags" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_name = "Proxy-Info" }, RULE_OPTIONAL, -1, -1 }, + { { .avp_name = "Route-Record" }, RULE_OPTIONAL, -1, -1 }, + }; + + CHECK_dict_new( DICT_COMMAND, &data, s6a, &cmd); + PARSE_loc_rules( rules, cmd ); + } + + /* Insert-Subscriber-Data-Answer (IDA) Command - 3GPP TS 29.272 #7.2.10 */ + { + struct dict_object * cmd; + struct dict_cmd_data data = { + 319, /* Code */ + "Insert-Subscriber-Data-Answer", /* Name */ + CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_ERROR, /* Fixed flags */ + CMD_FLAG_PROXIABLE /* Fixed flag values */ + }; + struct local_rules_definition rules = + { + { { .avp_name = "Session-Id" }, RULE_FIXED_HEAD, -1, 1 }, + { { .avp_name = "Vendor-Specific-Application-Id" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_name = "Result-Code" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_name = "Experimental-Result" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_name = "Auth-Session-State" }, RULE_REQUIRED, -1, 1 }, + { { .avp_name = "Origin-Host" }, RULE_REQUIRED, -1, 1 }, + { { .avp_name = "Origin-Realm" }, RULE_REQUIRED, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "IMS-Voice-Over-PS-Sessions-Supported" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "Last-UE-Activity-Time" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "RAT-Type" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "IDA-Flags" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "EPS-User-State" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "EPS-Location-Information" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "Local-Time-Zone" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_vendor = 10415, .avp_name = "Supported-Services" }, RULE_OPTIONAL, -1, 1 }, + { { .avp_name = "Failed-AVP" }, RULE_OPTIONAL, -1, -1 }, + { { .avp_name = "Proxy-Info" }, RULE_OPTIONAL, -1, -1 }, + { { .avp_name = "Route-Record" }, RULE_OPTIONAL, -1, -1 }, + }; + + CHECK_dict_new( DICT_COMMAND, &data, s6a, &cmd); + PARSE_loc_rules( rules, cmd ); + } } LOG_D( "Extension 'Dictionary definitions for DCCA 3GPP S6A' initialized"); - return 0; + return 0; } #if 0 /* modified by acetcom */
View file
open5gs_2.4.9.tar.xz/lib/diameter/s6a/message.c -> open5gs_2.4.10.tar.xz/lib/diameter/s6a/message.c
Changed
@@ -19,8 +19,8 @@ #include "ogs-diameter-s6a.h" -#define CHECK_dict_search( _type, _criteria, _what, _result ) \ - CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); +#define CHECK_dict_search( _type, _criteria, _what, _result ) \ + CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); struct dict_object *ogs_diam_s6a_application = NULL; @@ -30,9 +30,16 @@ struct dict_object *ogs_diam_s6a_cmd_ula = NULL; struct dict_object *ogs_diam_s6a_cmd_pur = NULL; struct dict_object *ogs_diam_s6a_cmd_pua = NULL; +struct dict_object *ogs_diam_s6a_cmd_clr = NULL; +struct dict_object *ogs_diam_s6a_cmd_cla = NULL; +struct dict_object *ogs_diam_s6a_cmd_idr = NULL; +struct dict_object *ogs_diam_s6a_cmd_ida = NULL; struct dict_object *ogs_diam_s6a_ulr_flags = NULL; struct dict_object *ogs_diam_s6a_ula_flags = NULL; +struct dict_object *ogs_diam_s6a_clr_flags = NULL; +struct dict_object *ogs_diam_s6a_idr_flags = NULL; +struct dict_object *ogs_diam_s6a_cancellation_type = NULL; struct dict_object *ogs_diam_s6a_subscription_data = NULL; struct dict_object *ogs_diam_s6a_req_eutran_auth_info = NULL; struct dict_object *ogs_diam_s6a_number_of_requested_vectors = NULL; @@ -67,6 +74,11 @@ struct dict_object *ogs_diam_s6a_pre_emption_vulnerability = NULL; struct dict_object *ogs_diam_s6a_pdn_gw_allocation_type = NULL; struct dict_object *ogs_diam_s6a_vplmn_dynamic_address_allowed = NULL; +struct dict_object *ogs_diam_s6a_eps_location_information = NULL; +struct dict_object *ogs_diam_s6a_mme_location_information = NULL; +struct dict_object *ogs_diam_s6a_e_utran_cell_global_identity = NULL; +struct dict_object *ogs_diam_s6a_tracking_area_identity = NULL; +struct dict_object *ogs_diam_s6a_age_of_location_information = NULL; struct dict_object *ogs_diam_s6a_terminal_information = NULL; struct dict_object *ogs_diam_s6a_imei = NULL; @@ -91,9 +103,16 @@ CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Update-Location-Answer", &ogs_diam_s6a_cmd_ula); CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Purge-UE-Request", &ogs_diam_s6a_cmd_pur); CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Purge-UE-Answer", &ogs_diam_s6a_cmd_pua); + CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Cancel-Location-Request", &ogs_diam_s6a_cmd_clr); + CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Cancel-Location-Answer", &ogs_diam_s6a_cmd_cla); + CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Insert-Subscriber-Data-Request", &ogs_diam_s6a_cmd_idr); + CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Insert-Subscriber-Data-Answer", &ogs_diam_s6a_cmd_ida); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "ULR-Flags", &ogs_diam_s6a_ulr_flags); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "ULA-Flags", &ogs_diam_s6a_ula_flags); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CLR-Flags", &ogs_diam_s6a_clr_flags); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "IDR-Flags", &ogs_diam_s6a_idr_flags); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Cancellation-Type", &ogs_diam_s6a_cancellation_type); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "UE-SRVCC-Capability", &ogs_diam_s6a_ue_srvcc_capability); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Requested-EUTRAN-Authentication-Info", &ogs_diam_s6a_req_eutran_auth_info); @@ -134,6 +153,12 @@ CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Access-Restriction-Data", &ogs_diam_s6a_access_restriction_data); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscribed-Periodic-RAU-TAU-Timer", &ogs_diam_s6a_subscribed_rau_tau_timer); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "EPS-Location-Information", &ogs_diam_s6a_eps_location_information); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "MME-Location-Information", &ogs_diam_s6a_mme_location_information); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "E-UTRAN-Cell-Global-Identity", &ogs_diam_s6a_e_utran_cell_global_identity); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Tracking-Area-Identity", &ogs_diam_s6a_tracking_area_identity); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Age-Of-Location-Information", &ogs_diam_s6a_age_of_location_information); + CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Terminal-Information", &ogs_diam_s6a_terminal_information); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "IMEI", &ogs_diam_s6a_imei); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Software-Version", &ogs_diam_s6a_software_version); @@ -141,5 +166,5 @@ CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "MSISDN", &ogs_diam_s6a_msisdn); CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "A-MSISDN", &ogs_diam_s6a_a_msisdn); - return 0; + return 0; }
View file
open5gs_2.4.9.tar.xz/lib/diameter/s6a/message.h -> open5gs_2.4.10.tar.xz/lib/diameter/s6a/message.h
Changed
@@ -76,9 +76,16 @@ extern struct dict_object *ogs_diam_s6a_cmd_ula; extern struct dict_object *ogs_diam_s6a_cmd_pur; extern struct dict_object *ogs_diam_s6a_cmd_pua; +extern struct dict_object *ogs_diam_s6a_cmd_clr; +extern struct dict_object *ogs_diam_s6a_cmd_cla; +extern struct dict_object *ogs_diam_s6a_cmd_idr; +extern struct dict_object *ogs_diam_s6a_cmd_ida; extern struct dict_object *ogs_diam_s6a_ulr_flags; extern struct dict_object *ogs_diam_s6a_ula_flags; +extern struct dict_object *ogs_diam_s6a_clr_flags; +extern struct dict_object *ogs_diam_s6a_idr_flags; +extern struct dict_object *ogs_diam_s6a_cancellation_type; extern struct dict_object *ogs_diam_s6a_subscription_data; extern struct dict_object *ogs_diam_s6a_req_eutran_auth_info; extern struct dict_object *ogs_diam_s6a_number_of_requested_vectors; @@ -113,6 +120,11 @@ extern struct dict_object *ogs_diam_s6a_pre_emption_vulnerability; extern struct dict_object *ogs_diam_s6a_pdn_gw_allocation_type; extern struct dict_object *ogs_diam_s6a_vplmn_dynamic_address_allowed; +extern struct dict_object *ogs_diam_s6a_eps_location_information; +extern struct dict_object *ogs_diam_s6a_mme_location_information; +extern struct dict_object *ogs_diam_s6a_e_utran_cell_global_identity; +extern struct dict_object *ogs_diam_s6a_tracking_area_identity; +extern struct dict_object *ogs_diam_s6a_age_of_location_information; extern struct dict_object *ogs_diam_s6a_terminal_information; extern struct dict_object *ogs_diam_s6a_imei; @@ -140,9 +152,32 @@ ogs_subscription_data_t subscription_data; } ogs_diam_s6a_ula_message_t; +typedef struct ogs_diam_s6a_clr_message_s { +#define OGS_DIAM_S6A_CLR_FLAGS_S6A_S6D_INDICATOR (1) +#define OGS_DIAM_S6A_CLR_FLAGS_REATTACH_REQUIRED (1 << 1) + uint32_t clr_flags; +} ogs_diam_s6a_clr_message_t; + +typedef struct ogs_diam_s6a_idr_message_s { +#define OGS_DIAM_S6A_IDR_FLAGS_UE_REACHABILITY (1) +#define OGS_DIAM_S6A_IDR_FLAGS_TADS_DATA (1 << 1) +#define OGS_DIAM_S6A_IDR_FLAGS_EPS_USER_STATE (1 << 2) +#define OGS_DIAM_S6A_IDR_FLAGS_EPS_LOCATION_INFO (1 << 3) +#define OGS_DIAM_S6A_IDR_FLAGS_CURRENT_LOCATION (1 << 4) +#define OGS_DIAM_S6A_IDR_FLAGS_LOCAL_TZ (1 << 5) +#define OGS_DIAM_S6A_IDR_FLAGS_REMOVE_SMS_REG (1 << 6) +#define OGS_DIAM_S6A_IDR_FLAGS_RAT_TYPE (1 << 7) +#define OGS_DIAM_S6A_IDR_FLAGS_PCSCF_Restoration (1 << 8) + uint32_t idr_flags; + ogs_subscription_data_t subscription_data; +} ogs_diam_s6a_idr_message_t; + typedef struct ogs_diam_s6a_message_s { #define OGS_DIAM_S6A_CMD_CODE_UPDATE_LOCATION 316 +#define OGS_DIAM_S6A_CMD_CODE_CANCEL_LOCATION 317 #define OGS_DIAM_S6A_CMD_CODE_AUTHENTICATION_INFORMATION 318 +#define OGS_DIAM_S6A_CMD_CODE_INSERT_SUBSCRIBER_DATA 319 +#define OGS_DIAM_S6A_CMD_CODE_PURGE_UE 321 uint16_t cmd_code; /* Experimental Result Code */ @@ -157,6 +192,8 @@ uint32_t *err; uint32_t *exp_err; + ogs_diam_s6a_idr_message_t idr_message; + ogs_diam_s6a_clr_message_t clr_message; ogs_diam_s6a_aia_message_t aia_message; ogs_diam_s6a_ula_message_t ula_message; } ogs_diam_s6a_message_t;
View file
open5gs_2.4.9.tar.xz/lib/diameter/s6b/message.c -> open5gs_2.4.10.tar.xz/lib/diameter/s6b/message.c
Changed
@@ -19,8 +19,8 @@ #include "ogs-diameter-s6b.h" -#define CHECK_dict_search( _type, _criteria, _what, _result ) \ - CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); +#define CHECK_dict_search( _type, _criteria, _what, _result ) \ + CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); struct dict_object *ogs_diam_s6b_application = NULL;
View file
open5gs_2.4.9.tar.xz/lib/diameter/swx/message.c -> open5gs_2.4.10.tar.xz/lib/diameter/swx/message.c
Changed
@@ -19,8 +19,8 @@ #include "ogs-diameter-swx.h" -#define CHECK_dict_search( _type, _criteria, _what, _result ) \ - CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); +#define CHECK_dict_search( _type, _criteria, _what, _result ) \ + CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); struct dict_object *ogs_diam_swx_application = NULL;
View file
open5gs_2.4.9.tar.xz/lib/gtp/context.c -> open5gs_2.4.10.tar.xz/lib/gtp/context.c
Changed
@@ -35,7 +35,7 @@ ogs_log_install_domain(&__ogs_gtp_domain, "gtp", ogs_core()->log.level); - ogs_pool_init(&pool, ogs_app()->pool.nf); + ogs_pool_init(&pool, ogs_app()->pool.gtp_node); ogs_pool_init(&ogs_gtpu_resource_pool, num_of_gtpu_resource); context_initialized = 1;
View file
open5gs_2.4.9.tar.xz/lib/gtp/meson.build -> open5gs_2.4.10.tar.xz/lib/gtp/meson.build
Changed
@@ -56,10 +56,10 @@ version : libogslib_version, c_args : '-DOGS_GTP_COMPILATION', include_directories : libgtp_inc, libinc, - dependencies : libcore_dep, libapp_dep, libnas_common_dep, + dependencies : libproto_dep, libipfw_dep, libapp_dep, install : true) libgtp_dep = declare_dependency( link_with : libgtp, include_directories : libgtp_inc, libinc, - dependencies : libcore_dep, libapp_dep, libnas_common_dep) + dependencies : libproto_dep, libipfw_dep, libapp_dep)
View file
open5gs_2.4.9.tar.xz/lib/gtp/ogs-gtp.h -> open5gs_2.4.10.tar.xz/lib/gtp/ogs-gtp.h
Changed
@@ -20,10 +20,9 @@ #ifndef OGS_GTP_H #define OGS_GTP_H -#include "ogs-core.h" #include "ipfw/ogs-ipfw.h" -#include "ogs-app.h" -#include "ogs-nas-common.h" +#include "proto/ogs-proto.h" +#include "app/ogs-app.h" #define OGS_GTPV1_U_UDP_PORT 2152 #define OGS_GTPV2_C_UDP_PORT 2123
View file
open5gs_2.4.9.tar.xz/lib/gtp/v1/message.c -> open5gs_2.4.10.tar.xz/lib/gtp/v1/message.c
Changed
@@ -2520,7 +2520,7 @@ &ogs_gtp1_tlv_desc_mbms_session_update_response, pkbuf, OGS_TLV_MODE_T1_L2); break; default: - ogs_warn("Not implmeneted(type:%d)", gtp1_message->h.type); + ogs_warn("Not implemented(type:%d)", gtp1_message->h.type); break; } @@ -2760,7 +2760,7 @@ >p1_message->mbms_session_update_response, OGS_TLV_MODE_T1_L2); break; default: - ogs_warn("Not implmeneted(type:%d)", gtp1_message->h.type); + ogs_warn("Not implemented(type:%d)", gtp1_message->h.type); break; }
View file
open5gs_2.4.9.tar.xz/lib/gtp/v1/support/gtp1-tlv.py -> open5gs_2.4.10.tar.xz/lib/gtp/v1/support/gtp1-tlv.py
Changed
@@ -633,7 +633,7 @@ f.write(" &ogs_gtp1_tlv_desc_%s, pkbuf, OGS_TLV_MODE_T1_L2);\n" % v_lower(k)) f.write(" break;\n") f.write(""" default: - ogs_warn("Not implmeneted(type:%d)", gtp1_message->h.type); + ogs_warn("Not implemented(type:%d)", gtp1_message->h.type); break; } @@ -658,7 +658,7 @@ f.write(" >p1_message->%s, OGS_TLV_MODE_T1_L2);\n" % v_lower(k)) f.write(" break;\n") f.write(""" default: - ogs_warn("Not implmeneted(type:%d)", gtp1_message->h.type); + ogs_warn("Not implemented(type:%d)", gtp1_message->h.type); break; }
View file
open5gs_2.4.9.tar.xz/lib/gtp/v2/message.c -> open5gs_2.4.10.tar.xz/lib/gtp/v2/message.c
Changed
@@ -2846,7 +2846,7 @@ &ogs_gtp2_tlv_desc_modify_access_bearers_response, pkbuf, OGS_TLV_MODE_T1_L2_I1); break; default: - ogs_warn("Not implmeneted(type:%d)", gtp2_message->h.type); + ogs_warn("Not implemented(type:%d)", gtp2_message->h.type); break; } @@ -2986,7 +2986,7 @@ >p2_message->modify_access_bearers_response, OGS_TLV_MODE_T1_L2_I1); break; default: - ogs_warn("Not implmeneted(type:%d)", gtp2_message->h.type); + ogs_warn("Not implemented(type:%d)", gtp2_message->h.type); break; }
View file
open5gs_2.4.9.tar.xz/lib/gtp/v2/support/gtp-tlv.py -> open5gs_2.4.10.tar.xz/lib/gtp/v2/support/gtp-tlv.py
Changed
@@ -722,7 +722,7 @@ f.write(" &ogs_gtp2_tlv_desc_%s, pkbuf, OGS_TLV_MODE_T1_L2_I1);\n" % v_lower(k)) f.write(" break;\n") f.write(""" default: - ogs_warn("Not implmeneted(type:%d)", gtp2_message->h.type); + ogs_warn("Not implemented(type:%d)", gtp2_message->h.type); break; } @@ -747,7 +747,7 @@ f.write(" >p2_message->%s, OGS_TLV_MODE_T1_L2_I1);\n" % v_lower(k)) f.write(" break;\n") f.write(""" default: - ogs_warn("Not implmeneted(type:%d)", gtp2_message->h.type); + ogs_warn("Not implemented(type:%d)", gtp2_message->h.type); break; }
View file
open5gs_2.4.9.tar.xz/lib/gtp/xact.c -> open5gs_2.4.10.tar.xz/lib/gtp/xact.c
Changed
@@ -191,7 +191,8 @@ xact->gtp_version = gtp_version; xact->org = OGS_GTP_REMOTE_ORIGINATOR; - xact->xid = (gtp_version == 1) ? OGS_GTP1_SQN_TO_XID(sqn) : OGS_GTP2_SQN_TO_XID(sqn); + xact->xid = (gtp_version == 1) ? + OGS_GTP1_SQN_TO_XID(sqn) : OGS_GTP2_SQN_TO_XID(sqn); xact->gnode = gnode; xact->tm_response = ogs_timer_add(
View file
open5gs_2.4.9.tar.xz/lib/gtp/xact.h -> open5gs_2.4.10.tar.xz/lib/gtp/xact.h
Changed
@@ -96,13 +96,15 @@ #define OGS_GTP_MODIFY_QOS_UPDATE ((uint64_t)1<<1) uint64_t update_flags; -#define OGS_GTP_DELETE_SEND_AUTHENTICATION_REQUEST 1 -#define OGS_GTP_DELETE_SEND_DETACH_ACCEPT 2 -#define OGS_GTP_DELETE_SEND_DEACTIVATE_BEARER_CONTEXT_REQUEST 3 -#define OGS_GTP_DELETE_SEND_UE_CONTEXT_RELEASE_COMMAND 4 -#define OGS_GTP_DELETE_HANDLE_PDN_CONNECTIVITY_REQUEST 5 -#define OGS_GTP_DELETE_UE_CONTEXT_REMOVE 6 -#define OGS_GTP_DELETE_IN_PATH_SWITCH_REQUEST 7 +#define OGS_GTP_DELETE_NO_ACTION 1 +#define OGS_GTP_DELETE_SEND_AUTHENTICATION_REQUEST 2 +#define OGS_GTP_DELETE_SEND_DETACH_ACCEPT 3 +#define OGS_GTP_DELETE_SEND_DEACTIVATE_BEARER_CONTEXT_REQUEST 4 +#define OGS_GTP_DELETE_SEND_UE_CONTEXT_RELEASE_COMMAND 5 +#define OGS_GTP_DELETE_SEND_S1_REMOVE_AND_UNLINK 6 +#define OGS_GTP_DELETE_HANDLE_PDN_CONNECTIVITY_REQUEST 7 +#define OGS_GTP_DELETE_UE_CONTEXT_REMOVE 8 +#define OGS_GTP_DELETE_IN_PATH_SWITCH_REQUEST 9 int delete_action; #define OGS_GTP_RELEASE_SEND_UE_CONTEXT_RELEASE_COMMAND 1
View file
open5gs_2.4.9.tar.xz/lib/ipfw/ogs-ipfw.h -> open5gs_2.4.10.tar.xz/lib/ipfw/ogs-ipfw.h
Changed
@@ -24,7 +24,7 @@ extern "C" { #endif -#include "ogs-core.h" +#include "proto/ogs-proto.h" typedef struct ogs_ipfw_rule_s { uint8_t proto;
View file
open5gs_2.4.9.tar.xz/lib/meson.build -> open5gs_2.4.10.tar.xz/lib/meson.build
Changed
@@ -18,8 +18,9 @@ libinc = include_directories('.') subdir('core') -subdir('ipfw') +subdir('proto') subdir('crypt') +subdir('ipfw') subdir('app') subdir('metrics') subdir('sctp')
View file
open5gs_2.4.9.tar.xz/lib/metrics/meson.build -> open5gs_2.4.10.tar.xz/lib/metrics/meson.build
Changed
@@ -20,7 +20,7 @@ context.h context.c ''' -libmetrics_dependencies = libcore_dep, libapp_dep +libmetrics_dependencies = libapp_dep metrics_impl_optval = get_option('metrics_impl')
View file
open5gs_2.4.9.tar.xz/lib/metrics/ogs-metrics.h -> open5gs_2.4.10.tar.xz/lib/metrics/ogs-metrics.h
Changed
@@ -20,8 +20,7 @@ #ifndef OGS_METRICS_H #define OGS_METRICS_H -#include "ogs-core.h" -#include "ogs-app.h" +#include "app/ogs-app.h" #define OGS_METRICS_INSIDE
View file
open5gs_2.4.9.tar.xz/lib/metrics/prometheus/context.c -> open5gs_2.4.10.tar.xz/lib/metrics/prometheus/context.c
Changed
@@ -427,7 +427,7 @@ { unsigned int i; - ogs_list_remove(&inst->spec->inst_list, inst); + ogs_list_remove(&inst->spec->inst_list, &inst->entry); for (i = 0; i < inst->num_labels; i++) ogs_free(inst->label_valuesi);
View file
open5gs_2.4.9.tar.xz/lib/nas/common/meson.build -> open5gs_2.4.10.tar.xz/lib/nas/common/meson.build
Changed
@@ -28,10 +28,10 @@ version : libogslib_version, c_args : '-DOGS_NAS_COMPILATION', include_directories : libnas_common_inc, libcrypt_inc, libinc, - dependencies : libcore_dep, libcrypt_dep, + dependencies : libcrypt_dep, install : true) libnas_common_dep = declare_dependency( link_with : libnas_common, include_directories : libnas_common_inc, libcrypt_inc, libinc, - dependencies : libcore_dep, libcrypt_dep) + dependencies : libcrypt_dep)
View file
open5gs_2.4.9.tar.xz/lib/nas/common/ogs-nas-common.h -> open5gs_2.4.10.tar.xz/lib/nas/common/ogs-nas-common.h
Changed
@@ -20,8 +20,7 @@ #ifndef OGS_NAS_COMMON_H #define OGS_NAS_COMMON_H -#include "ogs-core.h" -#include "ogs-crypt.h" +#include "crypt/ogs-crypt.h" #define OGS_NAS_INSIDE
View file
open5gs_2.4.9.tar.xz/lib/nas/eps/types.h -> open5gs_2.4.10.tar.xz/lib/nas/eps/types.h
Changed
@@ -225,7 +225,7 @@ * O TV 2 */ /* REQUEST_ACCEPTED(16) cause is defined by Open5GS */ -#define EMM_CAUSE_REQUEST_ACCEPTED 16 +#define OGS_NAS_EMM_CAUSE_REQUEST_ACCEPTED 16 /* Annex A (informative) Cause values for EPS mobility management * A.1 Causes related to UE identification */
View file
open5gs_2.4.9.tar.xz/lib/ngap/ogs-ngap.h -> open5gs_2.4.10.tar.xz/lib/ngap/ogs-ngap.h
Changed
@@ -20,7 +20,7 @@ #ifndef OGS_NGAP_H #define OGS_NGAP_H -#include "ogs-core.h" +#include "core/ogs-core.h" #include "NGAP_AdditionalDLUPTNLInformationForHOItem.h" #include "NGAP_AdditionalDLUPTNLInformationForHOList.h"
View file
open5gs_2.4.9.tar.xz/lib/pfcp/handler.c -> open5gs_2.4.10.tar.xz/lib/pfcp/handler.c
Changed
@@ -74,9 +74,11 @@ if (req->up_function_features.presence) { if (req->up_function_features.data && req->up_function_features.len) { - node->up_function_features_len = req->up_function_features.len; + node->up_function_features_len = + ogs_min(req->up_function_features.len, + sizeof(node->up_function_features)); memcpy(&node->up_function_features, req->up_function_features.data, - node->up_function_features_len); + node->up_function_features_len); } } @@ -120,9 +122,11 @@ if (rsp->up_function_features.presence) { if (rsp->up_function_features.data && rsp->up_function_features.len) { - node->up_function_features_len = rsp->up_function_features.len; + node->up_function_features_len = + ogs_min(rsp->up_function_features.len, + sizeof(node->up_function_features)); memcpy(&node->up_function_features, rsp->up_function_features.data, - node->up_function_features_len); + node->up_function_features_len); } } @@ -250,11 +254,13 @@ if (len == OGS_IPV4_LEN) { report->error_indication.remote_f_teid.ipv4 = 1; memcpy(&report->error_indication.remote_f_teid.addr, - far->hash.f_teid.key.addr, len); + far->hash.f_teid.key.addr, + ogs_min(sizeof(report->error_indication.remote_f_teid.addr), len)); } else if (len == OGS_IPV6_LEN) { report->error_indication.remote_f_teid.ipv6 = 1; memcpy(report->error_indication.remote_f_teid.addr6, - far->hash.f_teid.key.addr, len); + far->hash.f_teid.key.addr, + ogs_min(sizeof(report->error_indication.remote_f_teid.addr6), len)); } else { ogs_error("Invalid Length %d", len); return false; @@ -315,7 +321,7 @@ ogs_pfcp_f_teid_t f_teid; memcpy(&f_teid, message->pdi.local_f_teid.data, - message->pdi.local_f_teid.len); + ogs_min(sizeof(f_teid), message->pdi.local_f_teid.len)); if (f_teid.ipv4 == 0 && f_teid.ipv6 == 0) { ogs_error("One of the IPv4 and IPv6 flags should be 1 " "in the local F-TEID"); @@ -365,8 +371,8 @@ if (oppsite_direction_rule) { /* Copy oppsite direction rule and Swap */ - memcpy(&rule->ipfw, - &oppsite_direction_rule->ipfw, sizeof(rule->ipfw)); + memcpy(&rule->ipfw, &oppsite_direction_rule->ipfw, + sizeof(rule->ipfw)); ogs_ipfw_rule_swap(&rule->ipfw); } @@ -449,7 +455,8 @@ pdr->f_teid_len = 0; if (message->pdi.local_f_teid.presence) { - pdr->f_teid_len = message->pdi.local_f_teid.len; + pdr->f_teid_len = + ogs_min(message->pdi.local_f_teid.len, sizeof(pdr->f_teid)); memcpy(&pdr->f_teid, message->pdi.local_f_teid.data, pdr->f_teid_len); ogs_assert(pdr->f_teid.ipv4 || pdr->f_teid.ipv6); pdr->f_teid.teid = be32toh(pdr->f_teid.teid); @@ -465,16 +472,19 @@ pdr->ue_ip_addr_len = 0; if (message->pdi.ue_ip_address.presence) { - pdr->ue_ip_addr_len = message->pdi.ue_ip_address.len; - memcpy(&pdr->ue_ip_addr, - message->pdi.ue_ip_address.data, pdr->ue_ip_addr_len); + pdr->ue_ip_addr_len = + ogs_min(message->pdi.ue_ip_address.len, sizeof(pdr->ue_ip_addr)); + memcpy(&pdr->ue_ip_addr, message->pdi.ue_ip_address.data, + pdr->ue_ip_addr_len); } memset(&pdr->outer_header_removal, 0, sizeof(pdr->outer_header_removal)); pdr->outer_header_removal_len = 0; if (message->outer_header_removal.presence) { - pdr->outer_header_removal_len = message->outer_header_removal.len; + pdr->outer_header_removal_len = + ogs_min(message->outer_header_removal.len, + sizeof(pdr->outer_header_removal)); memcpy(&pdr->outer_header_removal, message->outer_header_removal.data, pdr->outer_header_removal_len); } @@ -539,7 +549,8 @@ if (message->local_f_teid.presence) { ogs_pfcp_f_teid_t f_teid; - memcpy(&f_teid, message->local_f_teid.data, message->local_f_teid.len); + memcpy(&f_teid, message->local_f_teid.data, + ogs_min(sizeof(f_teid), message->local_f_teid.len)); if (f_teid.ipv4 == 0 && f_teid.ipv6 == 0) { ogs_error("One of the IPv4 and IPv6 flags should be 1 " "in the local F-TEID"); @@ -550,7 +561,8 @@ } pdr->f_teid_len = message->local_f_teid.len; - memcpy(&pdr->f_teid, message->local_f_teid.data, pdr->f_teid_len); + memcpy(&pdr->f_teid, message->local_f_teid.data, + ogs_min(sizeof(pdr->f_teid), pdr->f_teid_len)); ogs_assert(pdr->f_teid.ipv4 || pdr->f_teid.ipv6); pdr->f_teid.teid = be32toh(pdr->f_teid.teid); } @@ -599,7 +611,7 @@ ogs_pfcp_f_teid_t f_teid; memcpy(&f_teid, message->pdi.local_f_teid.data, - message->pdi.local_f_teid.len); + ogs_min(sizeof(f_teid), message->pdi.local_f_teid.len)); if (f_teid.ipv4 == 0 && f_teid.ipv6 == 0) { ogs_error("One of the IPv4 and IPv6 flags should be 1 " "in the local F-TEID"); @@ -649,8 +661,8 @@ if (oppsite_direction_rule) { /* Copy oppsite direction rule and Swap */ - memcpy(&rule->ipfw, - &oppsite_direction_rule->ipfw, sizeof(rule->ipfw)); + memcpy(&rule->ipfw, &oppsite_direction_rule->ipfw, + sizeof(rule->ipfw)); ogs_ipfw_rule_swap(&rule->ipfw); } @@ -725,8 +737,8 @@ if (message->pdi.local_f_teid.presence) { pdr->f_teid_len = message->pdi.local_f_teid.len; - memcpy(&pdr->f_teid, - message->pdi.local_f_teid.data, pdr->f_teid_len); + memcpy(&pdr->f_teid, message->pdi.local_f_teid.data, + ogs_min(sizeof(pdr->f_teid), pdr->f_teid_len)); pdr->f_teid.teid = be32toh(pdr->f_teid.teid); } @@ -838,8 +850,9 @@ ogs_assert(outer_header_creation->data); ogs_assert(outer_header_creation->len); - memcpy(&far->outer_header_creation, - outer_header_creation->data, outer_header_creation->len); + memcpy(&far->outer_header_creation, outer_header_creation->data, + ogs_min(sizeof(far->outer_header_creation), + outer_header_creation->len)); far->outer_header_creation.teid = be32toh(far->outer_header_creation.teid); } @@ -945,8 +958,9 @@ ogs_assert(outer_header_creation->data); ogs_assert(outer_header_creation->len); - memcpy(&far->outer_header_creation, - outer_header_creation->data, outer_header_creation->len); + memcpy(&far->outer_header_creation, outer_header_creation->data, + ogs_min(sizeof(far->outer_header_creation), + outer_header_creation->len)); far->outer_header_creation.teid = be32toh(far->outer_header_creation.teid); }
View file
open5gs_2.4.9.tar.xz/lib/pfcp/meson.build -> open5gs_2.4.10.tar.xz/lib/pfcp/meson.build
Changed
@@ -64,11 +64,11 @@ version : libogslib_version, c_args : '-DOGS_PFCP_COMPILATION', include_directories : libpfcp_inc, libinc, - dependencies : libcore_dep, libipfw_dep, libapp_dep, libgtp_dep, + dependencies : libgtp_dep, install_rpath : libdir, install : true) libpfcp_dep = declare_dependency( link_with : libpfcp, include_directories : libpfcp_inc, libinc, - dependencies : libcore_dep, libipfw_dep, libapp_dep, libgtp_dep) + dependencies : libgtp_dep)
View file
open5gs_2.4.9.tar.xz/lib/pfcp/message.c -> open5gs_2.4.10.tar.xz/lib/pfcp/message.c
Changed
@@ -4104,7 +4104,7 @@ &ogs_pfcp_msg_desc_pfcp_session_report_response, pkbuf, OGS_TLV_MODE_T2_L2); break; default: - ogs_warn("Not implmeneted(type:%d)", pfcp_message->h.type); + ogs_warn("Not implemented(type:%d)", pfcp_message->h.type); break; } @@ -4211,7 +4211,7 @@ &pfcp_message->pfcp_session_report_response, OGS_TLV_MODE_T2_L2); break; default: - ogs_warn("Not implmeneted(type:%d)", pfcp_message->h.type); + ogs_warn("Not implemented(type:%d)", pfcp_message->h.type); break; }
View file
open5gs_2.4.9.tar.xz/lib/pfcp/ogs-pfcp.h -> open5gs_2.4.10.tar.xz/lib/pfcp/ogs-pfcp.h
Changed
@@ -20,13 +20,9 @@ #ifndef OGS_PFCP_H #define OGS_PFCP_H -#include "ogs-core.h" - #include "pfcp/pfcp-config.h" -#include "ipfw/ogs-ipfw.h" -#include "ogs-app.h" -#include "ogs-gtp.h" +#include "gtp/ogs-gtp.h" #define OGS_PFCP_UDP_PORT 8805
View file
open5gs_2.4.9.tar.xz/lib/pfcp/support/pfcp-tlv.py -> open5gs_2.4.10.tar.xz/lib/pfcp/support/pfcp-tlv.py
Changed
@@ -803,7 +803,7 @@ f.write(" &ogs_pfcp_msg_desc_%s, pkbuf, OGS_TLV_MODE_T2_L2);\n" % v_lower(k)) f.write(" break;\n") f.write(""" default: - ogs_warn("Not implmeneted(type:%d)", pfcp_message->h.type); + ogs_warn("Not implemented(type:%d)", pfcp_message->h.type); break; } @@ -827,7 +827,7 @@ f.write(" &pfcp_message->%s, OGS_TLV_MODE_T2_L2);\n" % v_lower(k)) f.write(" break;\n") f.write(""" default: - ogs_warn("Not implmeneted(type:%d)", pfcp_message->h.type); + ogs_warn("Not implemented(type:%d)", pfcp_message->h.type); break; }
View file
open5gs_2.4.10.tar.xz/lib/proto
Added
+(directory)
View file
open5gs_2.4.10.tar.xz/lib/proto/conv.c
Added
@@ -0,0 +1,42 @@ +/* + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#include "ogs-proto.h" + +void ogs_extract_digit_from_string(char *digit, char *string) +{ + bool extracting = false; + int i = 0; + + ogs_assert(string); + ogs_assert(digit); + + while (*string && i < OGS_MAX_IMSI_BCD_LEN) { + if (*string >= '0' && *string <= '9') { + *digit++ = *string; + extracting = true; + } else if (extracting == true) { + break; + } + string++; + i++; + } + + *digit = 0; +}
View file
open5gs_2.4.10.tar.xz/lib/proto/conv.h
Added
@@ -0,0 +1,37 @@ +/* + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#if !defined(OGS_PROTO_INSIDE) && !defined(OGS_PROTO_COMPILATION) +#error "This header cannot be included directly." +#endif + +#ifndef OGS_PROTO_CONV_H +#define OGS_PROTO_CONV_H + +#ifdef __cplusplus +extern "C" { +#endif + +void ogs_extract_digit_from_string(char *digit, char *string); + +#ifdef __cplusplus +} +#endif + +#endif /* OGS_PROTO_CONV_H */
View file
open5gs_2.4.10.tar.xz/lib/proto/event.c
Added
@@ -0,0 +1,74 @@ +/* + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#include "ogs-proto.h" + +const char *OGS_EVENT_NAME_SBI_SERVER = "OGS_EVENT_NAME_SBI_SERVER"; +const char *OGS_EVENT_NAME_SBI_CLIENT = "OGS_EVENT_NAME_SBI_CLIENT"; +const char *OGS_EVENT_NAME_SBI_TIMER = "OGS_EVENT_NAME_SBI_TIMER"; + +void *ogs_event_size(int id, size_t size) +{ + ogs_event_t *e = NULL; + + e = ogs_calloc(1, size); + ogs_assert(e); + + e->id = id; + + return e; +} + +ogs_event_t *ogs_event_new(int id) +{ + return ogs_event_size(id, sizeof(ogs_event_t)); +} + +void ogs_event_free(void *e) +{ + ogs_assert(e); + ogs_free(e); +} + +const char *ogs_event_get_name(ogs_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 OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; + + default: + break; + } + + ogs_error("Unknown Event%d", e->id); + return "UNKNOWN_EVENT"; +}
View file
open5gs_2.4.10.tar.xz/lib/proto/event.h
Added
@@ -0,0 +1,74 @@ +/* + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#if !defined(OGS_PROTO_INSIDE) && !defined(OGS_PROTO_COMPILATION) +#error "This header cannot be included directly." +#endif + +#ifndef OGS_PROTO_EVENT_H +#define OGS_PROTO_EVENT_H + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char *OGS_EVENT_NAME_SBI_SERVER; +extern const char *OGS_EVENT_NAME_SBI_CLIENT; +extern const char *OGS_EVENT_NAME_SBI_TIMER; + +typedef enum { + OGS_EVENT_BASE = OGS_FSM_USER_SIG, + + OGS_EVENT_SBI_SERVER, + OGS_EVENT_SBI_CLIENT, + OGS_EVENT_SBI_TIMER, + + OGS_MAX_NUM_OF_PROTO_EVENT, + +} ogs_event_e; + +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_event_s { + int id; + int timer_id; + + struct { + ogs_sbi_request_t *request; + ogs_sbi_response_t *response; + void *data; + int state; + + ogs_sbi_message_t *message; + } sbi; +} ogs_event_t; + +void *ogs_event_size(int id, size_t size); +ogs_event_t *ogs_event_new(int id); +void ogs_event_free(void *e); + +const char *ogs_event_get_name(ogs_event_t *e); + +#ifdef __cplusplus +} +#endif + +#endif /* OGS_PROTO_EVENT_H */
View file
open5gs_2.4.10.tar.xz/lib/proto/meson.build
Added
@@ -0,0 +1,45 @@ +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> + +# 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 <https://www.gnu.org/licenses/>. + +libproto_sources = files(''' + ogs-proto.h + + types.h + conv.h + event.h + timer.h + + types.c + conv.c + event.c + timer.c +'''.split()) + +libproto_inc = include_directories('.') + +libproto = library('ogsproto', + sources : libproto_sources, + version : libogslib_version, + c_args : '-DOGS_PROTO_COMPILATION', + include_directories : libproto_inc, libinc, + dependencies : libcore_dep, + install : true) + +libproto_dep = declare_dependency( + link_with : libproto, + include_directories : libproto_inc, libinc, + dependencies : libcore_dep)
View file
open5gs_2.4.10.tar.xz/lib/proto/ogs-proto.h
Added
@@ -0,0 +1,42 @@ +/* + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#ifndef OGS_PROTO_H +#define OGS_PROTO_H + +#include "core/ogs-core.h" + +#define OGS_PROTO_INSIDE + +#include "proto/types.h" +#include "proto/conv.h" +#include "proto/event.h" +#include "proto/timer.h" + +#undef OGS_PROTO_INSIDE + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* OGS_PROTO_H */
View file
open5gs_2.4.10.tar.xz/lib/proto/timer.c
Added
@@ -0,0 +1,56 @@ +/* + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#include "ogs-proto.h" + +const char *OGS_TIMER_NAME_NF_INSTANCE_REGISTRATION_INTERVAL = + "OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; +const char *OGS_TIMER_NAME_NF_INSTANCE_HEARTBEAT_INTERVAL = + "OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; +const char *OGS_TIMER_NAME_NF_INSTANCE_NO_HEARTBEAT = + "OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT"; +const char *OGS_TIMER_NAME_NF_INSTANCE_VALIDITY = + "OGS_TIMER_NF_INSTANCE_VALIDITY"; +const char *OGS_TIMER_NAME_SUBSCRIPTION_VALIDITY = + "OGS_TIMER_SUBSCRIPTION_VALIDITY"; +const char *OGS_TIMER_NAME_SBI_CLIENT_WAIT = + "OGS_TIMER_SBI_CLIENT_WAIT"; + +const char *ogs_timer_get_name(int timer_id) +{ + switch (timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + return OGS_TIMER_NAME_NF_INSTANCE_REGISTRATION_INTERVAL; + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + return OGS_TIMER_NAME_NF_INSTANCE_HEARTBEAT_INTERVAL; + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + return OGS_TIMER_NAME_NF_INSTANCE_NO_HEARTBEAT; + case OGS_TIMER_NF_INSTANCE_VALIDITY: + return OGS_TIMER_NAME_NF_INSTANCE_VALIDITY; + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + return OGS_TIMER_NAME_SUBSCRIPTION_VALIDITY; + case OGS_TIMER_SBI_CLIENT_WAIT: + return OGS_TIMER_NAME_SBI_CLIENT_WAIT; + default: + break; + } + + ogs_error("Unknown Timer%d", timer_id); + return "UNKNOWN_TIMER"; +}
View file
open5gs_2.4.10.tar.xz/lib/proto/timer.h
Added
@@ -0,0 +1,59 @@ +/* + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#if !defined(OGS_PROTO_INSIDE) && !defined(OGS_PROTO_COMPILATION) +#error "This header cannot be included directly." +#endif + +#ifndef OGS_PROTO_TIMER_H +#define OGS_PROTO_TIMER_H + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char *OGS_TIMER_NAME_NF_INSTANCE_REGISTRATION_INTERVAL; +extern const char *OGS_TIMER_NAME_NF_INSTANCE_HEARTBEAT_INTERVAL; +extern const char *OGS_TIMER_NAME_NF_INSTANCE_NO_HEARTBEAT; +extern const char *OGS_TIMER_NAME_NF_INSTANCE_VALIDITY; +extern const char *OGS_TIMER_NAME_SUBSCRIPTION_VALIDITY; +extern const char *OGS_TIMER_NAME_SBI_CLIENT_WAIT; + +/* forward declaration */ +typedef enum { + OGS_TIMER_BASE = 0, + + OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, + OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, + OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT, + OGS_TIMER_NF_INSTANCE_VALIDITY, + OGS_TIMER_SUBSCRIPTION_VALIDITY, + OGS_TIMER_SBI_CLIENT_WAIT, + + OGS_MAX_NUM_OF_PROTO_TIMER, + +} ogs_timer_e; + +const char *ogs_timer_get_name(int timer_id); + +#ifdef __cplusplus +} +#endif + +#endif /* OGS_PROTO_TIMER_H */
View file
open5gs_2.4.10.tar.xz/lib/proto/types.c
Added
@@ -0,0 +1,1068 @@ +/* + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#include "ogs-proto.h" + +#define PLMN_ID_DIGIT1(x) (((x) / 100) % 10) +#define PLMN_ID_DIGIT2(x) (((x) / 10) % 10) +#define PLMN_ID_DIGIT3(x) ((x) % 10) + +uint32_t ogs_plmn_id_hexdump(void *plmn_id) +{ + uint32_t hex; + ogs_assert(plmn_id); + memcpy(&hex, plmn_id, sizeof(ogs_plmn_id_t)); + hex = be32toh(hex) >> 8; + return hex; +} + +uint16_t ogs_plmn_id_mcc(ogs_plmn_id_t *plmn_id) +{ + return plmn_id->mcc1 * 100 + plmn_id->mcc2 * 10 + plmn_id->mcc3; +} +uint16_t ogs_plmn_id_mnc(ogs_plmn_id_t *plmn_id) +{ + return plmn_id->mnc1 == 0xf ? plmn_id->mnc2 * 10 + plmn_id->mnc3 : + plmn_id->mnc1 * 100 + plmn_id->mnc2 * 10 + plmn_id->mnc3; +} +uint16_t ogs_plmn_id_mnc_len(ogs_plmn_id_t *plmn_id) +{ + return plmn_id->mnc1 == 0xf ? 2 : 3; +} + +void *ogs_plmn_id_build(ogs_plmn_id_t *plmn_id, + uint16_t mcc, uint16_t mnc, uint16_t mnc_len) +{ + plmn_id->mcc1 = PLMN_ID_DIGIT1(mcc); + plmn_id->mcc2 = PLMN_ID_DIGIT2(mcc); + plmn_id->mcc3 = PLMN_ID_DIGIT3(mcc); + + if (mnc_len == 2) + plmn_id->mnc1 = 0xf; + else + plmn_id->mnc1 = PLMN_ID_DIGIT1(mnc); + + plmn_id->mnc2 = PLMN_ID_DIGIT2(mnc); + plmn_id->mnc3 = PLMN_ID_DIGIT3(mnc); + + return plmn_id; +} + +void *ogs_nas_from_plmn_id( + ogs_nas_plmn_id_t *ogs_nas_plmn_id, ogs_plmn_id_t *plmn_id) +{ + memcpy(ogs_nas_plmn_id, plmn_id, OGS_PLMN_ID_LEN); + if (plmn_id->mnc1 != 0xf) { + ogs_nas_plmn_id->mnc1 = plmn_id->mnc1; + ogs_nas_plmn_id->mnc2 = plmn_id->mnc2; + ogs_nas_plmn_id->mnc3 = plmn_id->mnc3; + } + return ogs_nas_plmn_id; +} +void *ogs_nas_to_plmn_id( + ogs_plmn_id_t *plmn_id, ogs_nas_plmn_id_t *ogs_nas_plmn_id) +{ + memcpy(plmn_id, ogs_nas_plmn_id, OGS_PLMN_ID_LEN); + if (plmn_id->mnc1 != 0xf) { + plmn_id->mnc1 = ogs_nas_plmn_id->mnc1; + plmn_id->mnc2 = ogs_nas_plmn_id->mnc2; + plmn_id->mnc3 = ogs_nas_plmn_id->mnc3; + } + return plmn_id; +} + +char *ogs_serving_network_name_from_plmn_id(ogs_plmn_id_t *plmn_id) +{ + ogs_assert(plmn_id); + return ogs_msprintf("5G:mnc%03d.mcc%03d.3gppnetwork.org", + ogs_plmn_id_mnc(plmn_id), ogs_plmn_id_mcc(plmn_id)); +} + +char *ogs_plmn_id_mcc_string(ogs_plmn_id_t *plmn_id) +{ + ogs_assert(plmn_id); + return ogs_msprintf("%03d", ogs_plmn_id_mcc(plmn_id)); +} + +char *ogs_plmn_id_mnc_string(ogs_plmn_id_t *plmn_id) +{ + ogs_assert(plmn_id); + if (ogs_plmn_id_mnc_len(plmn_id) == 2) + return ogs_msprintf("%02d", ogs_plmn_id_mnc(plmn_id)); + else + return ogs_msprintf("%03d", ogs_plmn_id_mnc(plmn_id)); +} + +char *ogs_plmn_id_to_string(ogs_plmn_id_t *plmn_id, char *buf) +{ + ogs_assert(plmn_id); + ogs_assert(buf); + + if (ogs_plmn_id_mnc_len(plmn_id) == 2) + ogs_snprintf(buf, OGS_PLMNIDSTRLEN, "%03d%02d", + ogs_plmn_id_mcc(plmn_id), ogs_plmn_id_mnc(plmn_id)); + else + ogs_snprintf(buf, OGS_PLMNIDSTRLEN, "%03d%03d", + ogs_plmn_id_mcc(plmn_id), ogs_plmn_id_mnc(plmn_id)); + + return buf; +} + +uint32_t ogs_amf_id_hexdump(ogs_amf_id_t *amf_id) +{ + uint32_t hex; + + ogs_assert(amf_id); + + memcpy(&hex, amf_id, sizeof(ogs_amf_id_t)); + hex = be32toh(hex) >> 8; + + return hex; +} + +ogs_amf_id_t *ogs_amf_id_from_string(ogs_amf_id_t *amf_id, const char *hex) +{ + char hexbufsizeof(ogs_amf_id_t); + + ogs_assert(amf_id); + ogs_assert(hex); + + OGS_HEX(hex, strlen(hex), hexbuf); + + amf_id->region = hexbuf0; + amf_id->set1 = hexbuf1; + amf_id->set2 = (hexbuf2 & 0xc0) >> 6; + amf_id->pointer = hexbuf2 & 0x3f; + + return amf_id; +} + +#define OGS_AMFIDSTRLEN (sizeof(ogs_amf_id_t)*2+1) +char *ogs_amf_id_to_string(ogs_amf_id_t *amf_id) +{ + char *str = NULL; + ogs_assert(amf_id); + + str = ogs_calloc(1, OGS_AMFIDSTRLEN); + ogs_expect_or_return_val(str, NULL); + + ogs_hex_to_ascii(amf_id, sizeof(ogs_amf_id_t), str, OGS_AMFIDSTRLEN); + + return str; +} + +uint8_t ogs_amf_region_id(ogs_amf_id_t *amf_id) +{ + ogs_assert(amf_id); + return amf_id->region; +} +uint16_t ogs_amf_set_id(ogs_amf_id_t *amf_id) +{ + ogs_assert(amf_id); + return (amf_id->set1 << 2) + amf_id->set2; +} +uint8_t ogs_amf_pointer(ogs_amf_id_t *amf_id) +{ + ogs_assert(amf_id); + return amf_id->pointer; +} + +ogs_amf_id_t *ogs_amf_id_build(ogs_amf_id_t *amf_id, + uint8_t region, uint16_t set, uint8_t pointer) +{ + amf_id->region = region; + amf_id->set1 = set >> 2; + amf_id->set2 = set & 0x3; + amf_id->pointer = pointer; + + return amf_id; +} + +char *ogs_supi_from_suci(char *suci) +{ +#define MAX_SUCI_TOKEN 16 + char *arrayMAX_SUCI_TOKEN; + char *p, *tmp; + int i; + char *supi = NULL; + + ogs_assert(suci); + tmp = ogs_strdup(suci); + ogs_expect_or_return_val(tmp, NULL); + + p = tmp; + i = 0; + while((arrayi++ = strsep(&p, "-"))) { + /* Empty Body */ + } + + SWITCH(array0) + CASE("suci") + SWITCH(array1) + CASE("0") /* SUPI format : IMSI */ + if (array2 && array3 && array7) + supi = ogs_msprintf("imsi-%s%s%s", + array2, array3, array7); + + break; + DEFAULT + ogs_error("Not implemented %s", array1); + break; + END + break; + DEFAULT + ogs_error("Not implemented %s", array0); + break; + END + + ogs_free(tmp); + return supi; +} + +char *ogs_supi_from_supi_or_suci(char *supi_or_suci) +{ + char *type = NULL; + char *supi = NULL; + + ogs_assert(supi_or_suci); + type = ogs_id_get_type(supi_or_suci); + if (!type) { + ogs_error("ogs_id_get_type%s failed", supi_or_suci); + goto cleanup; + } + SWITCH(type) + CASE("imsi") + supi = ogs_strdup(supi_or_suci); + ogs_expect(supi); + break; + CASE("suci") + supi = ogs_supi_from_suci(supi_or_suci); + ogs_expect(supi); + break; + DEFAULT + ogs_error("Not implemented %s", type); + break; + END + +cleanup: + if (type) + ogs_free(type); + return supi; +} + +char *ogs_id_get_type(char *str) +{ + char *token, *p, *tmp; + char *type = NULL; + + ogs_assert(str); + tmp = ogs_strdup(str); + if (!tmp) { + ogs_error("ogs_strdup%s failed", str); + goto cleanup; + } + + p = tmp; + token = strsep(&p, "-"); + if (!token) { + ogs_error("strsep%s failed", str); + goto cleanup; + } + type = ogs_strdup(token); + if (!type) { + ogs_error("ogs_strdup%s:%s failed", str, token); + goto cleanup; + } + +cleanup: + if (tmp) + ogs_free(tmp); + return type; +} + +char *ogs_id_get_value(char *str) +{ + char *token, *p, *tmp; + char *ueid = NULL; + + ogs_assert(str); + tmp = ogs_strdup(str); + if (!tmp) { + ogs_error("ogs_strdup%s failed", str); + goto cleanup; + } + + p = tmp; + token = strsep(&p, "-"); + if (!token) { + ogs_error("strsep%s failed", str); + goto cleanup; + } + token = strsep(&p, "-"); + if (!token) { + ogs_error("strsep%s failed", str); + goto cleanup; + } + ueid = ogs_strdup(token); + if (!ueid) { + ogs_error("ogs_strdup%s:%s failed", str, token); + goto cleanup; + } + +cleanup: + if (tmp) + ogs_free(tmp); + return ueid; +} + +char *ogs_s_nssai_sd_to_string(ogs_uint24_t sd) +{ + char *string = NULL; + + if (sd.v == OGS_S_NSSAI_NO_SD_VALUE) + return NULL; + + string = ogs_uint24_to_0string(sd); + ogs_expect(string); + + return string; +} + +ogs_uint24_t ogs_s_nssai_sd_from_string(const char *hex) +{ + ogs_uint24_t sd; + + sd.v = OGS_S_NSSAI_NO_SD_VALUE; + if (hex == NULL) + return sd; + + return ogs_uint24_from_string((char *)hex); +} + +int ogs_fqdn_build(char *dst, char *src, int length) +{ + int i = 0, j = 0; + + for (i = 0, j = 0; i < length; i++, j++) { + if (srci == '.') { + dsti-j = j; + j = -1; + } else { + dsti+1 = srci; + } + } + dsti-j = j; + + return length+1; +} + +int ogs_fqdn_parse(char *dst, char *src, int length) +{ + int i = 0, j = 0; + uint8_t len = 0; + + while (i+1 < length) { + len = srci++; + if ((j + len + 1) > length) { + ogs_error("Invalid FQDN encodinglen:%d + 1 > length%d", + len, length); + ogs_log_hexdump(OGS_LOG_ERROR, (unsigned char *)src, length); + return 0; + } + memcpy(&dstj, &srci, len); + + i += len; + j += len; + + if (i+1 < length) + dstj++ = '.'; + else + dstj = 0; + } + + return j; +} + +/* 8.13 Protocol Configuration Options (PCO) + * 10.5.6.3 Protocol configuration options in 3GPP TS 24.008 */ +int ogs_pco_parse(ogs_pco_t *pco, unsigned char *data, int data_len) +{ + ogs_pco_t *source = (ogs_pco_t *)data; + int size = 0; + int i = 0; + + ogs_assert(pco); + ogs_assert(data); + ogs_assert(data_len); + + memset(pco, 0, sizeof(ogs_pco_t)); + + pco->ext = source->ext; + pco->configuration_protocol = source->configuration_protocol; + size++; + + while(size < data_len && i < OGS_MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID) { + ogs_pco_id_t *id = &pco->idsi; + ogs_assert(size + sizeof(id->id) <= data_len); + memcpy(&id->id, data + size, sizeof(id->id)); + id->id = be16toh(id->id); + size += sizeof(id->id); + + ogs_assert(size + sizeof(id->len) <= data_len); + memcpy(&id->len, data + size, sizeof(id->len)); + size += sizeof(id->len); + + id->data = data + size; + size += id->len; + + i++; + } + pco->num_of_id = i; + ogs_assert(size == data_len); + + return size; +} +int ogs_pco_build(unsigned char *data, int data_len, ogs_pco_t *pco) +{ + ogs_pco_t target; + int size = 0; + int i = 0; + + ogs_assert(pco); + ogs_assert(data); + ogs_assert(data_len); + + memcpy(&target, pco, sizeof(ogs_pco_t)); + + ogs_assert(size + 1 <= data_len); + memcpy(data + size, &target, 1); + size += 1; + + ogs_assert(target.num_of_id <= OGS_MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID); + for (i = 0; i < target.num_of_id; i++) { + ogs_pco_id_t *id = &target.idsi; + + ogs_assert(size + sizeof(id->id) <= data_len); + id->id = htobe16(id->id); + memcpy(data + size, &id->id, sizeof(id->id)); + size += sizeof(id->id); + + ogs_assert(size + sizeof(id->len) <= data_len); + memcpy(data + size, &id->len, sizeof(id->len)); + size += sizeof(id->len); + + ogs_assert(size + id->len <= data_len); + memcpy(data + size, id->data, id->len); + size += id->len; + } + + return size; +} + +int ogs_ip_to_sockaddr(ogs_ip_t *ip, uint16_t port, ogs_sockaddr_t **list) +{ + ogs_sockaddr_t *addr = NULL, *addr6 = NULL; + + ogs_assert(ip); + ogs_assert(list); + + addr = ogs_calloc(1, sizeof(ogs_sockaddr_t)); + if (!addr) { + ogs_error("ogs_calloc() failed"); + return OGS_ERROR; + } + addr->ogs_sa_family = AF_INET; + addr->ogs_sin_port = htobe16(port); + + addr6 = ogs_calloc(1, sizeof(ogs_sockaddr_t)); + if (!addr6) { + ogs_error("ogs_calloc() failed"); + ogs_free(addr); + return OGS_ERROR; + } + addr6->ogs_sa_family = AF_INET6; + addr6->ogs_sin_port = htobe16(port); + + if (ip->ipv4 && ip->ipv6) { + addr->next = addr6; + + addr->sin.sin_addr.s_addr = ip->addr; + memcpy(addr6->sin6.sin6_addr.s6_addr, ip->addr6, OGS_IPV6_LEN); + + *list = addr; + } else if (ip->ipv4) { + addr->sin.sin_addr.s_addr = ip->addr; + ogs_free(addr6); + + *list = addr; + } else if (ip->ipv6) { + memcpy(addr6->sin6.sin6_addr.s6_addr, ip->addr6, OGS_IPV6_LEN); + ogs_free(addr); + + *list = addr6; + } else { + ogs_error("No IPv4 and IPv6"); + ogs_free(addr); + ogs_free(addr6); + return OGS_ERROR; + } + + return OGS_OK; +} + +int ogs_sockaddr_to_ip( + ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, ogs_ip_t *ip) +{ + ogs_expect_or_return_val(ip, OGS_ERROR); + ogs_expect_or_return_val(addr || addr6, OGS_ERROR); + + memset(ip, 0, sizeof(ogs_ip_t)); + + if (addr && addr6) { + ip->ipv4 = 1; + ip->ipv6 = 1; + ip->len = OGS_IPV4V6_LEN; + ip->addr = addr->sin.sin_addr.s_addr; + memcpy(ip->addr6, addr6->sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); + } else if (addr) { + ip->ipv4 = 1; + ip->len = OGS_IPV4_LEN; + ip->addr = addr->sin.sin_addr.s_addr; + } else if (addr6) { + ip->ipv6 = 1; + ip->len = OGS_IPV6_LEN; + memcpy(ip->addr6, addr6->sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); + } else + ogs_assert_if_reached(); + + return OGS_OK; +} + +char *ogs_ipv4_to_string(uint32_t addr) +{ + char *buf = NULL; + + buf = ogs_calloc(1, OGS_ADDRSTRLEN); + ogs_expect_or_return_val(buf, NULL); + + return (char*)OGS_INET_NTOP(&addr, buf); +} + +char *ogs_ipv6addr_to_string(uint8_t *addr6) +{ + char *buf = NULL; + ogs_assert(addr6); + + buf = ogs_calloc(1, OGS_ADDRSTRLEN); + ogs_expect_or_return_val(buf, NULL); + + return (char *)OGS_INET6_NTOP(addr6, buf); +} + +char *ogs_ipv6prefix_to_string(uint8_t *addr6, uint8_t prefixlen) +{ + char *buf = NULL; + uint8_t tmpOGS_IPV6_LEN; + ogs_assert(addr6); + + memset(tmp, 0, OGS_IPV6_LEN); + memcpy(tmp, addr6, prefixlen >> 3); + + buf = ogs_calloc(1, OGS_ADDRSTRLEN); + ogs_expect_or_return_val(buf, NULL); + + if (OGS_INET6_NTOP(tmp, buf) == NULL) { + ogs_fatal("Invalid IPv6 address"); + ogs_log_hexdump(OGS_LOG_FATAL, addr6, OGS_IPV6_LEN); + ogs_assert_if_reached(); + } + return ogs_mstrcatf(buf, "/%d", prefixlen); +} + +int ogs_ipv4_from_string(uint32_t *addr, char *string) +{ + int rv; + ogs_sockaddr_t tmp; + + ogs_assert(addr); + ogs_assert(string); + + rv = ogs_inet_pton(AF_INET, string, &tmp); + if (rv != OGS_OK) { + ogs_error("Invalid IPv4 string = %s", string); + return OGS_ERROR; + } + + *addr = tmp.sin.sin_addr.s_addr; + + return OGS_OK; +} + +int ogs_ipv6addr_from_string(uint8_t *addr6, char *string) +{ + int rv; + ogs_sockaddr_t tmp; + + ogs_assert(addr6); + ogs_assert(string); + + rv = ogs_inet_pton(AF_INET6, string, &tmp); + if (rv != OGS_OK) { + ogs_error("Invalid IPv6 string = %s", string); + return OGS_ERROR; + } + + memcpy(addr6, tmp.sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); + + return OGS_OK; +} + +int ogs_ipv6prefix_from_string(uint8_t *addr6, uint8_t *prefixlen, char *string) +{ + int rv; + ogs_sockaddr_t tmp; + char *v = NULL, *pv = NULL, *ipstr = NULL, *mask_or_numbits = NULL; + + ogs_assert(addr6); + ogs_assert(prefixlen); + ogs_assert(string); + pv = v = ogs_strdup(string); + ogs_expect_or_return_val(v, OGS_ERROR); + + ipstr = strsep(&v, "/"); + if (ipstr) + mask_or_numbits = v; + + if (!ipstr || !mask_or_numbits) { + ogs_error("Invalid IPv6 Prefix string = %s", v); + ogs_free(v); + return OGS_ERROR; + } + + rv = ogs_inet_pton(AF_INET6, ipstr, &tmp); + ogs_expect_or_return_val(rv == OGS_OK, rv); + + memcpy(addr6, tmp.sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); + *prefixlen = atoi(mask_or_numbits); + + ogs_free(pv); + return OGS_OK; +} + +int ogs_sockaddr_to_user_plane_ip_resource_info( + ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, + ogs_user_plane_ip_resource_info_t *info) +{ + ogs_assert(addr || addr6); + ogs_assert(info); + + if (addr) { + info->v4 = 1; + info->addr = addr->sin.sin_addr.s_addr; + } + if (addr6) { + info->v6 = 1; + memcpy(info->addr6, addr6->sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); + } + + return OGS_OK; +} + +int ogs_user_plane_ip_resource_info_to_sockaddr( + ogs_user_plane_ip_resource_info_t *info, + ogs_sockaddr_t **addr, ogs_sockaddr_t **addr6) +{ + ogs_assert(addr && addr6); + ogs_assert(info); + + *addr = NULL; + *addr6 = NULL; + + if (info->v4) { + *addr = ogs_calloc(1, sizeof(**addr)); + ogs_assert(*addr); + (*addr)->sin.sin_addr.s_addr = info->addr; + (*addr)->ogs_sa_family = AF_INET; + } + + if (info->v6) { + *addr6 = ogs_calloc(1, sizeof(**addr6)); + ogs_assert(*addr6); + memcpy((*addr6)->sin6.sin6_addr.s6_addr, info->addr6, OGS_IPV6_LEN); + (*addr6)->ogs_sa_family = AF_INET6; + } + + return OGS_OK; +} + +ogs_slice_data_t *ogs_slice_find_by_s_nssai( + ogs_slice_data_t *slice_data, int num_of_slice_data, + ogs_s_nssai_t *s_nssai) +{ + int i; + + ogs_assert(slice_data); + ogs_assert(num_of_slice_data); + ogs_assert(s_nssai); + + /* Compare S-NSSAI */ + for (i = 0; i < num_of_slice_data; i++) { + if (s_nssai->sst == slice_datai.s_nssai.sst && + s_nssai->sd.v == slice_datai.s_nssai.sd.v) { + return slice_data + i; + } + } + + return NULL; +} + +void ogs_subscription_data_free(ogs_subscription_data_t *subscription_data) +{ + int i, j; + + ogs_assert(subscription_data); + + for (i = 0; i < subscription_data->num_of_slice; i++) { + ogs_slice_data_t *slice_data = &subscription_data->slicei; + + for (j = 0; j < slice_data->num_of_session; j++) { + if (slice_data->sessionj.name) + ogs_free(slice_data->sessionj.name); + } + + slice_data->num_of_session = 0; + } + + subscription_data->num_of_slice = 0; + + subscription_data->num_of_msisdn = 0; +} + +void ogs_session_data_free(ogs_session_data_t *session_data) +{ + int i; + + ogs_assert(session_data); + + if (session_data->session.name) + ogs_free(session_data->session.name); + + for (i = 0; i < session_data->num_of_pcc_rule; i++) + OGS_PCC_RULE_FREE(&session_data->pcc_rulei); +} + +void ogs_ims_data_free(ogs_ims_data_t *ims_data) +{ + int i, j, k; + + ogs_assert(ims_data); + + for (i = 0; i < ims_data->num_of_media_component; i++) { + ogs_media_component_t *media_component = &ims_data->media_componenti; + + for (j = 0; j < media_component->num_of_sub; j++) { + ogs_media_sub_component_t *sub = &media_component->subj; + + for (k = 0; k < sub->num_of_flow; k++) { + ogs_flow_t *flow = &sub->flowk; + + if (flow->description) { + ogs_free(flow->description); + } else + ogs_assert_if_reached(); + } + } + } +} + +static int flow_rx_to_gx(ogs_flow_t *rx_flow, ogs_flow_t *gx_flow) +{ + int len; + char *from_str, *to_str; + + ogs_assert(rx_flow); + ogs_assert(gx_flow); + + if (!strncmp(rx_flow->description, + "permit out", strlen("permit out"))) { + gx_flow->direction = OGS_FLOW_DOWNLINK_ONLY; + gx_flow->description = ogs_strdup(rx_flow->description); + ogs_assert(gx_flow->description); + + } else if (!strncmp(rx_flow->description, + "permit in", strlen("permit in"))) { + gx_flow->direction = OGS_FLOW_UPLINK_ONLY; + + /* 'permit in' should be changed + * 'permit out' in Gx Diameter */ + len = strlen(rx_flow->description)+2; + gx_flow->description = ogs_calloc(1, len); + ogs_assert(gx_flow->description); + strcpy(gx_flow->description, "permit out"); + from_str = strstr(&rx_flow->descriptionstrlen("permit in"), "from"); + ogs_assert(from_str); + to_str = strstr(&rx_flow->descriptionstrlen("permit in"), "to"); + ogs_assert(to_str); + strncat(gx_flow->description, + &rx_flow->descriptionstrlen("permit in"), + strlen(rx_flow->description) - + strlen("permit in") - strlen(from_str)); + strcat(gx_flow->description, "from"); + strcat(gx_flow->description, &to_strstrlen("to")); + strcat(gx_flow->description, " to"); + strncat(gx_flow->description, &from_strstrlen("from"), + strlen(from_str) - strlen(to_str) - strlen("from") - 1); + ogs_assert(len == strlen(gx_flow->description)+1); + } else { + ogs_error("Invalid Flow Descripton : %s", rx_flow->description); + return OGS_ERROR; + } + + return OGS_OK; +} + +int ogs_pcc_rule_num_of_flow_equal_to_media( + ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component) +{ + int rv; + int i, j, k; + int matched = 0; + int new = 0; + + ogs_assert(pcc_rule); + ogs_assert(media_component); + + for (i = 0; i < media_component->num_of_sub; i++) { + ogs_media_sub_component_t *sub = &media_component->subi; + + for (j = 0; j < sub->num_of_flow; j++) { + new++; + } + } + + if (new == 0) { + /* No new flow in Media-Component */ + return pcc_rule->num_of_flow; + } + + for (i = 0; i < media_component->num_of_sub; i++) { + ogs_media_sub_component_t *sub = &media_component->subi; + + for (j = 0; j < sub->num_of_flow && + j < OGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT; j++) { + ogs_flow_t gx_flow; + ogs_flow_t *rx_flow = &sub->flowj; + + rv = flow_rx_to_gx(rx_flow, &gx_flow); + if (rv != OGS_OK) { + ogs_error("flow reformatting error"); + return OGS_ERROR; + } + + for (k = 0; k < pcc_rule->num_of_flow; k++) { + if (gx_flow.direction == pcc_rule->flowk.direction && + !strcmp(gx_flow.description, + pcc_rule->flowk.description)) { + matched++; + break; + } + } + + OGS_FLOW_FREE(&gx_flow); + } + } + + return matched; +} + +int ogs_pcc_rule_install_flow_from_media( + ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component) +{ + int rv; + int i, j; + + ogs_assert(pcc_rule); + ogs_assert(media_component); + + /* Remove Flow from PCC Rule */ + for (i = 0; i < pcc_rule->num_of_flow; i++) { + OGS_FLOW_FREE(&pcc_rule->flowi); + } + pcc_rule->num_of_flow = 0; + + for (i = 0; i < media_component->num_of_sub; i++) { + ogs_media_sub_component_t *sub = &media_component->subi; + + /* Copy Flow to PCC Rule */ + for (j = 0; j < sub->num_of_flow && + j < OGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT; j++) { + ogs_flow_t *rx_flow = NULL; + ogs_flow_t *gx_flow = NULL; + + if (pcc_rule->num_of_flow < OGS_MAX_NUM_OF_FLOW_IN_PCC_RULE) { + rx_flow = &sub->flowj; + gx_flow = &pcc_rule->flowpcc_rule->num_of_flow; + + rv = flow_rx_to_gx(rx_flow, gx_flow); + if (rv != OGS_OK) { + ogs_error("flow reformatting error"); + return OGS_ERROR; + } + + pcc_rule->num_of_flow++; + } else { + ogs_error("Overflow: Number of Flow"); + return OGS_ERROR; + } + } + } + + return OGS_OK; +} + +int ogs_pcc_rule_update_qos_from_media( + ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component) +{ + int rv; + int i, j; + + ogs_assert(pcc_rule); + ogs_assert(media_component); + + pcc_rule->qos.mbr.downlink = 0; + pcc_rule->qos.mbr.uplink = 0; + pcc_rule->qos.gbr.downlink = 0; + pcc_rule->qos.gbr.uplink = 0; + + for (i = 0; i < media_component->num_of_sub; i++) { + ogs_media_sub_component_t *sub = &media_component->subi; + + for (j = 0; j < sub->num_of_flow && + j < OGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT; j++) { + ogs_flow_t gx_flow; + ogs_flow_t *rx_flow = &sub->flowj; + + rv = flow_rx_to_gx(rx_flow, &gx_flow); + if (rv != OGS_OK) { + ogs_error("flow reformatting error"); + return OGS_ERROR; + } + + if (gx_flow.direction == OGS_FLOW_DOWNLINK_ONLY) { + if (sub->flow_usage == OGS_FLOW_USAGE_RTCP) { + if (media_component->rr_bandwidth && + media_component->rs_bandwidth) { + pcc_rule->qos.mbr.downlink += + (media_component->rr_bandwidth + + media_component->rs_bandwidth); + } else if (media_component->max_requested_bandwidth_dl) { + if (media_component->rr_bandwidth && + !media_component->rs_bandwidth) { + pcc_rule->qos.mbr.downlink += + ogs_max(0.05 * + media_component->max_requested_bandwidth_dl, + media_component->rr_bandwidth); + } + if (!media_component->rr_bandwidth && + media_component->rs_bandwidth) { + pcc_rule->qos.mbr.downlink += + ogs_max(0.05 * + media_component->max_requested_bandwidth_dl, + media_component->rs_bandwidth); + } + if (!media_component->rr_bandwidth && + !media_component->rs_bandwidth) { + pcc_rule->qos.mbr.downlink += + 0.05 * + media_component->max_requested_bandwidth_dl; + } + } + } else { + if (gx_flow.description) { + pcc_rule->qos.mbr.downlink += + media_component->max_requested_bandwidth_dl; + pcc_rule->qos.gbr.downlink += + media_component->min_requested_bandwidth_dl; + } + } + } else if (gx_flow.direction == OGS_FLOW_UPLINK_ONLY) { + if (sub->flow_usage == OGS_FLOW_USAGE_RTCP) { + if (media_component->rr_bandwidth && + media_component->rs_bandwidth) { + pcc_rule->qos.mbr.uplink += + (media_component->rr_bandwidth + + media_component->rs_bandwidth); + } else if (media_component->max_requested_bandwidth_ul) { + if (media_component->rr_bandwidth && + !media_component->rs_bandwidth) { + pcc_rule->qos.mbr.uplink += + ogs_max(0.05 * + media_component->max_requested_bandwidth_ul, + media_component->rr_bandwidth); + } + if (!media_component->rr_bandwidth && + media_component->rs_bandwidth) { + pcc_rule->qos.mbr.uplink += + ogs_max(0.05 * + media_component->max_requested_bandwidth_ul, + media_component->rs_bandwidth); + } + if (!media_component->rr_bandwidth && + !media_component->rs_bandwidth) { + pcc_rule->qos.mbr.uplink += + 0.05 * + media_component->max_requested_bandwidth_ul; + } + } + } else { + if (gx_flow.description) { + pcc_rule->qos.mbr.uplink += + media_component->max_requested_bandwidth_ul; + pcc_rule->qos.gbr.uplink += + media_component->min_requested_bandwidth_ul; + } + } + } else + ogs_assert_if_reached(); + + OGS_FLOW_FREE(&gx_flow); + } + } + + if (pcc_rule->qos.mbr.downlink == 0) { + pcc_rule->qos.mbr.downlink += + media_component->max_requested_bandwidth_dl; + pcc_rule->qos.mbr.downlink += + (media_component->rr_bandwidth + media_component->rs_bandwidth); + } + + if (pcc_rule->qos.mbr.uplink == 0) { + pcc_rule->qos.mbr.uplink += + media_component->max_requested_bandwidth_ul; + pcc_rule->qos.mbr.uplink += + (media_component->rr_bandwidth + media_component->rs_bandwidth); + } + + if (pcc_rule->qos.gbr.downlink == 0) + pcc_rule->qos.gbr.downlink = pcc_rule->qos.mbr.downlink; + if (pcc_rule->qos.gbr.uplink == 0) + pcc_rule->qos.gbr.uplink = pcc_rule->qos.mbr.uplink; + + return OGS_OK; +}
View file
open5gs_2.4.10.tar.xz/lib/proto/types.h
Added
@@ -0,0 +1,777 @@ +/* + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#if !defined(OGS_PROTO_INSIDE) && !defined(OGS_PROTO_COMPILATION) +#error "This header cannot be included directly." +#endif + +#ifndef OGS_PROTO_TYPES_H +#define OGS_PROTO_TYPES_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define OGS_MAX_NUM_OF_SESS 4 /* Num of APN(Session) per UE */ +#define OGS_MAX_NUM_OF_BEARER 4 /* Num of Bearer per Session */ +#define OGS_BEARER_PER_UE 8 /* Num of Bearer per UE */ +#define OGS_MAX_NUM_OF_PACKET_BUFFER 64 /* Num of PacketBuffer per UE */ + +/* + * The array of TLV messages is limited to 8. + * So, Flow(PDI.SDF_Filter) in PDR is limited to 8. + * + * However, the number of flow in bearer context seems to need more than 16. + * + * Therefore, the maximum number of flows of messages is defined as 8, + * and the maximum number of flows stored by the context is 16. + */ +#define OGS_MAX_NUM_OF_FLOW_IN_PDR 8 +#define OGS_MAX_NUM_OF_FLOW_IN_GTP OGS_MAX_NUM_OF_FLOW_IN_PDR +#define OGS_MAX_NUM_OF_FLOW_IN_NAS OGS_MAX_NUM_OF_FLOW_IN_PDR +#define OGS_MAX_NUM_OF_FLOW_IN_PCC_RULE OGS_MAX_NUM_OF_FLOW_IN_PDR +#define OGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT OGS_MAX_NUM_OF_FLOW_IN_PDR +#define OGS_MAX_NUM_OF_FLOW_IN_BEARER 16 + +#define OGS_MAX_NUM_OF_GTPU_RESOURCE 4 + +#define OGS_MAX_SDU_LEN 8192 +#define OGS_MAX_PKT_LEN 2048 +#define OGS_PLMN_ID_LEN 3 +#define OGS_MAX_PLMN_ID_BCD_LEN 6 + +#define OGS_CHRGCHARS_LEN 2 + +#define OGS_BCD_TO_BUFFER_LEN(x) (((x)+1)/2) +#define OGS_MAX_IMSI_BCD_LEN 15 +#define OGS_MAX_IMSI_LEN \ + OGS_BCD_TO_BUFFER_LEN(OGS_MAX_IMSI_BCD_LEN) + +#define OGS_MAX_IMEISV_BCD_LEN 16 +#define OGS_MAX_IMEISV_LEN \ + OGS_BCD_TO_BUFFER_LEN(OGS_MAX_IMEISV_BCD_LEN) + +#define OGS_MAX_MSISDN_BCD_LEN 15 +#define OGS_MAX_MSISDN_LEN \ + OGS_BCD_TO_BUFFER_LEN(OGS_MAX_MSISDN_BCD_LEN) + +#define OGS_MAX_NUM_OF_CELL_ID 16 +#define OGS_MAX_NUM_OF_ENB_ID 16 +#define OGS_MAX_NUM_OF_DNN 16 +#define OGS_MAX_NUM_OF_APN OGS_MAX_NUM_OF_DNN +#define OGS_MAX_NUM_OF_HOSTNAME 16 +#define OGS_MAX_DNN_LEN 100 +#define OGS_MAX_APN_LEN OGS_MAX_DNN_LEN +#define OGS_MAX_PCO_LEN 251 +#define OGS_MAX_FQDN_LEN 256 + +#define OGS_MAX_NUM_OF_SERVED_TAI 16 +#define OGS_MAX_NUM_OF_ALGORITHM 8 + +#define OGS_MAX_NUM_OF_BPLMN 6 + +#define OGS_NEXT_ID(__id, __min, __max) \ + ((__id) = ((__id) == (__max) ? (__min) : ((__id) + 1))) +#define OGS_COMPARE_ID(__id1, __id2, __max) \ + ((__id2) > (__id1) ? ((__id2) - (__id1) < ((__max)-1) ? -1 : 1) : \ + (__id1) > (__id2) ? ((__id1) - (__id2) < ((__max)-1) ? 1 : -1) : 0) + +#define OGS_TIME_TO_BCD(x) \ + (((((x) % 10) << 4) & 0xf0) | (((x) / 10) & 0x0f)) + +#define OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED 0 +#define OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED 0 + +#define OGS_ACCESS_TYPE_3GPP 1 +#define OGS_ACCESS_TYPE_NON_3GPP 2 +#define OGS_ACCESS_TYPE_BOTH_3GPP_AND_NON_3GPP 3 + +#define OGS_MAX_QOS_FLOW_ID 63 + +/************************************ + * PLMN_ID Structure */ +#define OGS_MAX_NUM_OF_PLMN 6 +typedef struct ogs_plmn_id_s { +ED2(uint8_t mcc2:4;, + uint8_t mcc1:4;) +ED2(uint8_t mnc1:4;, + uint8_t mcc3:4;) +ED2(uint8_t mnc3:4;, + uint8_t mnc2:4;) +} __attribute__ ((packed)) ogs_plmn_id_t; + +uint32_t ogs_plmn_id_hexdump(void *plmn_id); + +uint16_t ogs_plmn_id_mcc(ogs_plmn_id_t *plmn_id); +uint16_t ogs_plmn_id_mnc(ogs_plmn_id_t *plmn_id); +uint16_t ogs_plmn_id_mnc_len(ogs_plmn_id_t *plmn_id); + +void *ogs_plmn_id_build(ogs_plmn_id_t *plmn_id, + uint16_t mcc, uint16_t mnc, uint16_t mnc_len); + +char *ogs_serving_network_name_from_plmn_id(ogs_plmn_id_t *plmn_id); +char *ogs_plmn_id_mcc_string(ogs_plmn_id_t *plmn_id); +char *ogs_plmn_id_mnc_string(ogs_plmn_id_t *plmn_id); + +#define OGS_PLMNIDSTRLEN (sizeof(ogs_plmn_id_t)*2+1) +char *ogs_plmn_id_to_string(ogs_plmn_id_t *plmn_id, char *buf); + +/************************* + * NAS PLMN_ID Structure */ +typedef struct ogs_nas_plmn_id_s { +ED2(uint8_t mcc2:4;, + uint8_t mcc1:4;) +ED2(uint8_t mnc3:4;, + uint8_t mcc3:4;) +ED2(uint8_t mnc2:4;, + uint8_t mnc1:4;) +} __attribute__ ((packed)) ogs_nas_plmn_id_t; + +void *ogs_nas_from_plmn_id( + ogs_nas_plmn_id_t *ogs_nas_plmn_id, ogs_plmn_id_t *plmn_id); +void *ogs_nas_to_plmn_id( + ogs_plmn_id_t *plmn_id, ogs_nas_plmn_id_t *ogs_nas_plmn_id); + +/************************************ + * AMF_ID Structure */ +typedef struct ogs_amf_id_s { + uint8_t region; + uint8_t set1; +ED2(uint8_t set2:2;, + uint8_t pointer:6;) +} __attribute__ ((packed)) ogs_amf_id_t; + +typedef struct ogs_guami_s { + ogs_plmn_id_t plmn_id; + ogs_amf_id_t amf_id; +} ogs_guami_t; + +uint32_t ogs_amf_id_hexdump(ogs_amf_id_t *amf_id); + +ogs_amf_id_t *ogs_amf_id_from_string(ogs_amf_id_t *amf_id, const char *hex); +char *ogs_amf_id_to_string(ogs_amf_id_t *amf_id); + +uint8_t ogs_amf_region_id(ogs_amf_id_t *amf_id); +uint16_t ogs_amf_set_id(ogs_amf_id_t *amf_id); +uint8_t ogs_amf_pointer(ogs_amf_id_t *amf_id); + +ogs_amf_id_t *ogs_amf_id_build(ogs_amf_id_t *amf_id, + uint8_t region, uint16_t set, uint8_t pointer); + +/************************************ + * SUPI/SUCI */ +char *ogs_supi_from_suci(char *suci); +char *ogs_supi_from_supi_or_suci(char *supi_or_suci); + +/************************************ + * SUPI/GPSI */ +#define OGS_ID_SUPI_TYPE_IMSI "imsi" +#define OGS_ID_GPSI_TYPE_MSISDN "msisdn" +char *ogs_id_get_type(char *str); +char *ogs_id_get_value(char *str); + +/************************************ + * TAI Structure */ +#define OGS_MAX_NUM_OF_TAI 16 +typedef struct ogs_eps_tai_s { + ogs_plmn_id_t plmn_id; + uint16_t tac; +} __attribute__ ((packed)) ogs_eps_tai_t; + +typedef struct ogs_5gs_tai_s { + ogs_plmn_id_t plmn_id; + ogs_uint24_t tac; +} __attribute__ ((packed)) ogs_5gs_tai_t; + +typedef struct ogs_e_cgi_s { + ogs_plmn_id_t plmn_id; + uint32_t cell_id; /* 28 bit */ +} __attribute__ ((packed)) ogs_e_cgi_t; + +typedef struct ogs_nr_cgi_s { + ogs_plmn_id_t plmn_id; + uint64_t cell_id; /* 36 bit */ +} __attribute__ ((packed)) ogs_nr_cgi_t; + +/************************************ + * S-NSSAI Structure */ +#define OGS_MAX_NUM_OF_SLICE 8 +#define OGS_S_NSSAI_NO_SD_VALUE 0xffffff +typedef struct ogs_s_nssai_s { + uint8_t sst; + ogs_uint24_t sd; +} __attribute__ ((packed)) ogs_s_nssai_t; + +char *ogs_s_nssai_sd_to_string(ogs_uint24_t sd); +ogs_uint24_t ogs_s_nssai_sd_from_string(const char *hex); + +/************************************************** + * Common Structure + * S1AP : 9.2.2.1 Transport Layer Address, See 36.414 + * GTP : 8.22 Fully Qualified TEID (F-TEID) */ +#define OGS_IPV4_LEN 4 +#define OGS_IPV6_LEN 16 +#define OGS_IPV6_DEFAULT_PREFIX_LEN 64 +#define OGS_IPV6_128_PREFIX_LEN 128 +#define OGS_IPV4V6_LEN 20 +typedef struct ogs_ip_s { + uint32_t addr; + uint8_t addr6OGS_IPV6_LEN; + uint32_t len; +ED3(uint8_t ipv4:1;, + uint8_t ipv6:1;, + uint8_t reserved:6;) +} ogs_ip_t; + +int ogs_ip_to_sockaddr(ogs_ip_t *ip, uint16_t port, ogs_sockaddr_t **list); +int ogs_sockaddr_to_ip( + ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, ogs_ip_t *ip); + +char *ogs_ipv4_to_string(uint32_t addr); +char *ogs_ipv6addr_to_string(uint8_t *addr6); +char *ogs_ipv6prefix_to_string(uint8_t *addr6, uint8_t prefixlen); +int ogs_ipv4_from_string(uint32_t *addr, char *string); +int ogs_ipv6addr_from_string(uint8_t *addr6, char *string); +int ogs_ipv6prefix_from_string( + uint8_t *addr6, uint8_t *prefixlen, char *string); + +/************************************************** + * GTPv1-C: TS 29.060 7.7.27 End User Address (EUA) */ +#define OGS_PDP_EUA_ORG_ETSI 0 +#define OGS_PDP_EUA_ORG_IETF 1 +#define OGS_PDP_EUA_ETSI_PPP 1 +#define OGS_PDP_EUA_IETF_IPV4 0x21 +#define OGS_PDP_EUA_IETF_IPV6 0x57 +#define OGS_PDP_EUA_IETF_IPV4V6 0x8D +typedef struct ogs_eua_s { +ED2(uint8_t spare:4;, + uint8_t organization:4;) + uint8_t type; + union { + /* PDU_SESSION_TYPE_IPV4 */ + uint32_t addr; + + /* PDU_SESSION_TYPE_IPV6 */ + uint8_t addr6OGS_IPV6_LEN; + + /* PDU_SESSION_TYPE_IPV4V6 */ + struct { + uint32_t addr; + uint8_t addr6OGS_IPV6_LEN; + } __attribute__ ((packed)) both; + }; +} __attribute__ ((packed)) ogs_eua_t; + +/************************************************** + * GTPv2-C: TS 29.274 8.14 PDN Address Allocation (PAA) */ +#define OGS_PAA_IPV4_LEN 5 +#define OGS_PAA_IPV6_LEN 18 +#define OGS_PAA_IPV4V6_LEN 22 +typedef struct ogs_paa_s { +ED2(uint8_t spare:5;, +/* 8.34 PDN Type */ +#define OGS_PDU_SESSION_TYPE_IS_VALID(x) \ + ((x) == OGS_PDU_SESSION_TYPE_IPV4 || \ + (x) == OGS_PDU_SESSION_TYPE_IPV6 || \ + (x) == OGS_PDU_SESSION_TYPE_IPV4V6) \ + + uint8_t session_type:3;) + union { + /* PDU_SESSION_TYPE_IPV4 */ + uint32_t addr; + + /* PDU_SESSION_TYPE_IPV6 */ + struct { + /* the IPv6 Prefix Length */ + uint8_t len; + /* IPv6 Prefix and Interface Identifier */ + uint8_t addr6OGS_IPV6_LEN; + }; + + /* PDU_SESSION_TYPE_IPV4V6 */ + struct { + struct { + /* the IPv6 Prefix Length */ + uint8_t len; + /* IPv6 Prefix and Interface Identifier */ + uint8_t addr6OGS_IPV6_LEN; + }; + uint32_t addr; + } __attribute__ ((packed)) both; + }; +} __attribute__ ((packed)) ogs_paa_t; + +#define MAX_BIT_RATE 10000000000UL + +typedef struct ogs_bitrate_s { + uint64_t downlink; /* bits per seconds */ + uint64_t uplink; /* bits per seconds */ +} ogs_bitrate_t; + +/********************************** + * QoS Structure */ +typedef struct ogs_qos_s { +#define OGS_QOS_INDEX_1 1 +#define OGS_QOS_INDEX_2 2 +#define OGS_QOS_INDEX_5 5 + uint8_t index; + + struct { + /* Values 1 to 8 should only be assigned for services that are + * authorized to receive prioritized treatment within an operator domain. + * Values 9 to 15 may be assigned to resources that are authorized + * by the home network and thus applicable when a UE is roaming. */ + uint8_t priority_level; +/* + * Ch 7.3.40 Allocation-Retenion-Proirty in TS 29.272 V15.9.0 + * + * If the Pre-emption-Capability AVP is not present in the + * Allocation-Retention-Priority AVP, the default value shall be + * PRE-EMPTION_CAPABILITY_DISABLED (1). + * + * If the Pre-emption-Vulnerability AVP is not present in the + * Allocation-Retention-Priority AVP, the default value shall be + * PRE-EMPTION_VULNERABILITY_ENABLED (0). + * + * However, to easily set up VoLTE service, + * enable Pre-emption Capability/Vulnerablility + * in Default Bearer + */ +#define OGS_EPC_PRE_EMPTION_DISABLED 1 +#define OGS_EPC_PRE_EMPTION_ENABLED 0 + +#define OGS_5GC_PRE_EMPTION_DISABLED 1 +#define OGS_5GC_PRE_EMPTION_ENABLED 2 + uint8_t pre_emption_capability; + uint8_t pre_emption_vulnerability; + } arp; + + ogs_bitrate_t mbr; /* Maxmimum Bit Rate (MBR) */ + ogs_bitrate_t gbr; /* Guaranteed Bit Rate (GBR) */ +} ogs_qos_t; + +/********************************** + * Flow Structure */ +#define OGS_FLOW_DOWNLINK_ONLY 1 +#define OGS_FLOW_UPLINK_ONLY 2 +typedef struct ogs_flow_s { + uint8_t direction; + char *description; +} ogs_flow_t; + +#define OGS_FLOW_FREE(__fLOW) \ + do { \ + if ((__fLOW)->description) { \ + ogs_free((__fLOW)->description); \ + } \ + else \ + ogs_assert_if_reached(); \ + } while(0) + +/********************************** + * PCC Rule Structure */ +typedef struct ogs_pcc_rule_s { +#define OGS_PCC_RULE_TYPE_INSTALL 1 +#define OGS_PCC_RULE_TYPE_REMOVE 2 + uint8_t type; + + char *id; /* 5GC */ + char *name; /* EPC */ + + ogs_flow_t flowOGS_MAX_NUM_OF_FLOW_IN_PCC_RULE; + int num_of_flow; + + int flow_status; + uint32_t precedence; + + ogs_qos_t qos; +} ogs_pcc_rule_t; + +#define OGS_STORE_PCC_RULE(__dST, __sRC) \ + do { \ + int __iNDEX; \ + ogs_assert((__sRC)); \ + ogs_assert((__dST)); \ + OGS_PCC_RULE_FREE(__dST); \ + (__dST)->type = (__sRC)->type; \ + if ((__sRC)->name) { \ + (__dST)->name = ogs_strdup((__sRC)->name); \ + ogs_assert((__dST)->name); \ + } \ + if ((__sRC)->id) { \ + (__dST)->id = ogs_strdup((__sRC)->id); \ + ogs_assert((__dST)->id); \ + } \ + for (__iNDEX = 0; __iNDEX < (__sRC)->num_of_flow; __iNDEX++) { \ + (__dST)->flow__iNDEX.direction = \ + (__sRC)->flow__iNDEX.direction; \ + (__dST)->flow__iNDEX.description = \ + ogs_strdup((__sRC)->flow__iNDEX.description); \ + ogs_assert((__dST)->flow__iNDEX.description); \ + } \ + (__dST)->num_of_flow = (__sRC)->num_of_flow; \ + (__dST)->flow_status = (__sRC)->flow_status; \ + (__dST)->precedence = (__sRC)->precedence; \ + memcpy(&(__dST)->qos, &(__sRC)->qos, sizeof(ogs_qos_t)); \ + } while(0) + +#define OGS_PCC_RULE_FREE(__pCCrULE) \ + do { \ + int __pCCrULE_iNDEX; \ + ogs_assert((__pCCrULE)); \ + if ((__pCCrULE)->id) \ + ogs_free((__pCCrULE)->id); \ + if ((__pCCrULE)->name) \ + ogs_free((__pCCrULE)->name); \ + for (__pCCrULE_iNDEX = 0; \ + __pCCrULE_iNDEX < (__pCCrULE)->num_of_flow; __pCCrULE_iNDEX++) { \ + OGS_FLOW_FREE(&((__pCCrULE)->flow__pCCrULE_iNDEX)); \ + } \ + (__pCCrULE)->num_of_flow = 0; \ + } while(0) + +/********************************** + * PDN Structure */ +typedef struct ogs_session_s { + char *name; + + uint32_t context_identifier; /* EPC */ + bool default_dnn_indicator; /* 5GC */ + + uint8_t charging_characteristicsOGS_CHRGCHARS_LEN; + bool charging_characteristics_presence; + +#define OGS_PDU_SESSION_TYPE_IPV4 1 +#define OGS_PDU_SESSION_TYPE_IPV6 2 +#define OGS_PDU_SESSION_TYPE_IPV4V6 3 +#define OGS_PDU_SESSION_TYPE_UNSTRUCTURED 4 +#define OGS_PDU_SESSION_TYPE_ETHERNET 5 + +#define OGS_PDU_SESSION_TYPE_TO_DIAMETER(x) ((x)-1) +#define OGS_PDU_SESSION_TYPE_FROM_DIAMETER(x) ((x)+1) + uint8_t session_type; + +#define OGS_SSC_MODE_1 1 +#define OGS_SSC_MODE_2 2 +#define OGS_SSC_MODE_3 3 + uint8_t ssc_mode; + + ogs_qos_t qos; + ogs_bitrate_t ambr; /* APN-AMBR */ + + ogs_paa_t paa; + ogs_ip_t ue_ip; + ogs_ip_t smf_ip; +} ogs_session_t; + +int ogs_fqdn_build(char *dst, char *src, int len); +int ogs_fqdn_parse(char *dst, char *src, int len); + +/************************************************** + * Protocol Configuration Options Structure + * 8.13 Protocol Configuration Options (PCO) + * 10.5.6.3 Protocol configuration options in 3GPP TS 24.008 + * RFC 3232 103 + * RFC 1661 102 */ +#define OGS_PCO_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE 0 + +#define OGS_PCO_ID_INTERNET_PROTOCOL_CONTROL_PROTOCOL 0x8021 +#define OGS_PCO_ID_PASSWORD_AUTHENTICATION_PROTOCOL 0xc023 +#define OGS_PCO_ID_CHALLENGE_HANDSHAKE_AUTHENTICATION_PROTOCOL 0xc223 +#define OGS_PCO_ID_P_CSCF_IPV6_ADDRESS_REQUEST 0x0001 +#define OGS_PCO_ID_DNS_SERVER_IPV6_ADDRESS_REQUEST 0x0003 +#define OGS_PCO_ID_MS_SUPPORTS_BCM 0x0005 +#define OGS_PCO_ID_IP_ADDRESS_ALLOCATION_VIA_NAS_SIGNALLING 0x000a +#define OGS_PCO_ID_P_CSCF_IPV4_ADDRESS_REQUEST 0x000c +#define OGS_PCO_ID_DNS_SERVER_IPV4_ADDRESS_REQUEST 0x000d +#define OGS_PCO_ID_IPV4_LINK_MTU_REQUEST 0x0010 +#define OGS_PCO_ID_MS_SUPPORT_LOCAL_ADDR_TFT_INDICATOR 0x0011 +#define OGS_PCO_ID_P_CSCF_RE_SELECTION_SUPPORT 0x0012 + +enum ogs_pco_ipcp_options { + OGS_IPCP_OPT_IPADDR = 3, + OGS_IPCP_OPT_PRIMARY_DNS = 129, + OGS_IPCP_OPT_SECONDARY_DNS = 131, +}; + +typedef struct ogs_pco_ipcp_options_s { + uint8_t type; + uint8_t len; + uint32_t addr; +} __attribute__ ((packed)) ogs_pco_ipcp_options_t; + +#define OGS_PCO_MAX_NUM_OF_IPCP_OPTIONS 4 +typedef struct ogs_pco_ipcp_s { + uint8_t code; + uint8_t identifier; + uint16_t len; + ogs_pco_ipcp_options_t optionsOGS_PCO_MAX_NUM_OF_IPCP_OPTIONS; +} __attribute__ ((packed)) ogs_pco_ipcp_t; + +typedef struct ogs_pco_pap_s { + uint8_t code; + uint8_t identifier; + uint16_t len; + uint8_t welcome_len; + char welcome255; +} __attribute__ ((packed)) ogs_pco_pap_t; + +typedef struct ogs_pco_chap_s { + uint8_t code; + uint8_t identifier; + uint16_t len; +} __attribute__ ((packed)) ogs_pco_chap_t; + +typedef struct ogs_pco_id_s { + uint16_t id; + uint8_t len; + void *data; +} ogs_pco_id_t; + +#define OGS_MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID 16 +typedef struct ogs_pco_s { +ED3(uint8_t ext:1;, + uint8_t spare:4;, + uint8_t configuration_protocol:3;) + uint8_t num_of_id; + ogs_pco_id_t idsOGS_MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID; +} ogs_pco_t; + +int ogs_pco_parse(ogs_pco_t *pco, unsigned char *data, int data_len); +int ogs_pco_build(unsigned char *data, int data_len, ogs_pco_t *pco); + +/* + * PFCP Specification + * + * TS29.244, Ch 8.2.82 User Plane IP Resource Information + * + * The following flags are coded within Octet 5: + * - Bit 1 – V4: If this bit is set to "1", then the IPv4 address field + * shall be present, otherwise the IPv4 address field shall not be present. + * - Bit 2 – V6: If this bit is set to "1", then the IPv6 address field + * shall be present, otherwise the IPv6 address field shall not be present. + * - Bit 3-5 – TEID Range Indication (TEIDRI): the value of this field + * indicates the number of bits in the most significant octet of a TEID + * that are used to partition the TEID range, + * e.g. if this field is set to "4", then the first 4 bits in the TEID + * are used to partition the TEID range. + * - Bit 6 – Associated Network Instance (ASSONI): if this bit is set to "1", + * then the Network Instance field shall be present, otherwise the Network + * Instance field shall not be present. + * - Bit 7 – Associated Source Interface (ASSOSI): if this bit is set to "1", + * then the Source Interface field shall be present, + * otherwise the Source Interface field shall not be present. + * - Bit 8: Spare, for future use and set to 0. + * + * At least one of the V4 and V6 flags shall be set to "1", + * and both may be set to "1". + * + * If both the ASSONI and ASSOSI flags are set to "0", this shall indicate + * that the User Plane IP Resource Information provided can be used + * by CP function for any Network Instance and any Source Interface + * of GTP-U user plane in the UP function. Octet 6 (TEID Range) shall be + * present if the TEID Range Indication is not set to zero and + * shall contain a value of the bits which are used to partition the TEID range. + * E.g. if the TEID Range Indication is set to "4", then Octet 6 shall be + * one of values between 0 and 15. When TEID Range Indication is set to zero, + * the Octet 6 shall not be present, the TEID is not partitioned, + * i.e. all TEID values are available for use by the CP function. + * + * Octets "m to (m+3)" and/or "p to (p+15)" (IPv4 address / IPv6 address fields) + * , if present, shall contain the respective IP address values. + * + * Octets "k to l", if present, shall contain a Network Instance value + * as encoded in octet "5 to n+4" of the Figure 8.2.4-1 in clause 8.2.4, + * identifying a Network Instance with which the IP address or TEID Range + * is associated. + * + * Octet r, if present, shall contain a Source Interface value as encoded + * in octet 5 of the Figure 8.2.2-1 in clause 8.2.2, + * identifying the Source Interface with which the IP address or TEID Range + * is associated. + */ + +/* Flags(1) + TEID Range(1) + IPV4(4) + IPV6(16) + Source Interface(1) = 23 */ +#define OGS_MAX_USER_PLANE_IP_RESOURCE_INFO_LEN \ + (23 + (OGS_MAX_APN_LEN+1)) +typedef struct ogs_user_plane_ip_resource_info_s { + union { + struct { +ED6(uint8_t spare:1;, + uint8_t assosi:1;, + uint8_t assoni:1;, + uint8_t teidri:3;, + uint8_t v6:1;, + uint8_t v4:1;) + }; + uint8_t flags; + }; + + /* + * OGS_PFCP-GTPU-TEID = INDEX | TEID_RANGE + * INDEX = OGS_PFCP-GTPU-TEID & ~TEID_RANGE + */ +#define OGS_PFCP_GTPU_TEID_TO_INDEX(__tEID, __iND, __rANGE) \ + (__tEID & ~(__rANGE << (32 - __iND))) +#define OGS_PFCP_GTPU_INDEX_TO_TEID(__iNDEX, __iND, __rANGE) \ + (__iNDEX | (__rANGE << (32 - __iND))) + uint8_t teid_range; + uint32_t addr; + uint8_t addr6OGS_IPV6_LEN; + char network_instanceOGS_MAX_APN_LEN+1; + uint8_t source_interface; +} __attribute__ ((packed)) ogs_user_plane_ip_resource_info_t; + +int ogs_sockaddr_to_user_plane_ip_resource_info( + ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, + ogs_user_plane_ip_resource_info_t *info); +int ogs_user_plane_ip_resource_info_to_sockaddr( + ogs_user_plane_ip_resource_info_t *info, + ogs_sockaddr_t **addr, ogs_sockaddr_t **addr6); + +typedef struct ogs_slice_data_s { + ogs_s_nssai_t s_nssai; + bool default_indicator; + + uint32_t context_identifier; /* EPC for checking default APN */ + + int num_of_session; + ogs_session_t sessionOGS_MAX_NUM_OF_SESS; +} ogs_slice_data_t; + +ogs_slice_data_t *ogs_slice_find_by_s_nssai( + ogs_slice_data_t *slice_data, int num_of_slice_data, + ogs_s_nssai_t *s_nssai); + +typedef struct ogs_subscription_data_s { +#define OGS_ACCESS_RESTRICTION_UTRAN_NOT_ALLOWED (1) +#define OGS_ACCESS_RESTRICTION_GERAN_NOT_ALLOWED (1<<1) +#define OGS_ACCESS_RESTRICTION_GAN_NOT_ALLOWED (1<<2) +#define OGS_ACCESS_RESTRICTION_I_HSPA_EVOLUTION_NOT_ALLOWED (1<<3) +#define OGS_ACCESS_RESTRICTION_WB_E_UTRAN_NOT_ALLOWED (1<<4) +#define OGS_ACCESS_RESTRICTION_HO_TO_NON_3GPP_ACCESS_NOT_ALLOWED (1<<5) +#define OGS_ACCESS_RESTRICTION_NB_IOT_NOT_ALLOWED (1<<6) + uint32_t access_restriction_data; +#define OGS_SUBSCRIBER_STATUS_SERVICE_GRANTED 0 +#define OGS_SUBSCRIBER_STATUS_OPERATOR_DETERMINED_BARRING 1 + uint32_t subscriber_status; +#define OGS_NETWORK_ACCESS_MODE_PACKET_AND_CIRCUIT 0 +#define OGS_NETWORK_ACCESS_MODE_RESERVED 1 +#define OGS_NETWORK_ACCESS_MODE_ONLY_PACKET 2 + uint32_t network_access_mode; + + ogs_bitrate_t ambr; /* UE-AMBR */ + +#define OGS_RAU_TAU_DEFAULT_TIME (12*60) /* 12 min */ + uint32_t subscribed_rau_tau_timer; /* unit : seconds */ + + int num_of_slice; + ogs_slice_data_t sliceOGS_MAX_NUM_OF_SLICE; + +#define OGS_MAX_NUM_OF_MSISDN 2 + int num_of_msisdn; + struct { + uint8_t bufOGS_MAX_MSISDN_LEN; + int len; + char bcdOGS_MAX_MSISDN_BCD_LEN+1; + } msisdnOGS_MAX_NUM_OF_MSISDN; +} ogs_subscription_data_t; + +void ogs_subscription_data_free(ogs_subscription_data_t *subscription_data); + +typedef struct ogs_session_data_s { + ogs_session_t session; +#define OGS_MAX_NUM_OF_PCC_RULE 8 /* Num of PCC Rule */ + ogs_pcc_rule_t pcc_ruleOGS_MAX_NUM_OF_PCC_RULE; + int num_of_pcc_rule; +} ogs_session_data_t; + +void ogs_session_data_free(ogs_session_data_t *session_data); + +typedef struct ogs_media_sub_component_s { + uint32_t flow_number; +/* + * TS29.214 + * 5.3.12 Flow-Usage AVP + * NO_INFORMATION(0) + * RTCP(1) + * AF_SIGNALLING(2) + * + * TS29.514 + * 5.6.3.14 Enumeration: FlowUsage + * NO_INFO : 1 + * RTCP : 2 + * AF_SIGNALLING : 3 + * + * EPC and 5GC have different values for FlowUsage + * At this point, we will use the 5GC value. + */ +#define OGS_FLOW_USAGE_NO_INFO 1 +#define OGS_FLOW_USAGE_RTCP 2 +#define OGS_FLOW_USAGE_AF_SIGNALLING 3 + uint32_t flow_usage; + ogs_flow_t flowOGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT; + int num_of_flow; +} ogs_media_sub_component_t; + +typedef struct ogs_media_component_s { + uint32_t media_component_number; + uint32_t media_type; + + uint64_t max_requested_bandwidth_dl; + uint64_t max_requested_bandwidth_ul; + uint64_t min_requested_bandwidth_dl; + uint64_t min_requested_bandwidth_ul; + uint64_t rr_bandwidth; + uint64_t rs_bandwidth; + + int flow_status; + +#define OGS_MAX_NUM_OF_MEDIA_SUB_COMPONENT 8 + ogs_media_sub_component_t subOGS_MAX_NUM_OF_MEDIA_SUB_COMPONENT; + int num_of_sub; +} ogs_media_component_t; + +typedef struct ogs_ims_data_s { + int num_of_msisdn; + struct { + uint8_t bufOGS_MAX_MSISDN_LEN; + int len; + char bcdOGS_MAX_MSISDN_BCD_LEN+1; + } msisdnOGS_MAX_NUM_OF_MSISDN; + +#define OGS_MAX_NUM_OF_MEDIA_COMPONENT 16 + ogs_media_component_t media_componentOGS_MAX_NUM_OF_MEDIA_COMPONENT; + int num_of_media_component; +} ogs_ims_data_t; + +void ogs_ims_data_free(ogs_ims_data_t *ims_data); + +int ogs_pcc_rule_num_of_flow_equal_to_media( + ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component); +int ogs_pcc_rule_install_flow_from_media( + ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component); +int ogs_pcc_rule_update_qos_from_media( + ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component); + +#ifdef __cplusplus +} +#endif + +#endif /* OGS_PROTO_TYPES_H */
View file
open5gs_2.4.9.tar.xz/lib/s1ap/ogs-s1ap.h -> open5gs_2.4.10.tar.xz/lib/s1ap/ogs-s1ap.h
Changed
@@ -20,7 +20,7 @@ #ifndef OGS_S1AP_H #define OGS_S1AP_H -#include "ogs-core.h" +#include "core/ogs-core.h" #include "S1AP_Additional-GUTI.h" #include "S1AP_AdditionalCSFallbackIndicator.h"
View file
open5gs_2.4.9.tar.xz/lib/sbi/client.c -> open5gs_2.4.10.tar.xz/lib/sbi/client.c
Changed
@@ -17,7 +17,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#include "ogs-app.h" #include "ogs-sbi.h" #include "curl/curl.h" @@ -102,15 +101,18 @@ ogs_assert(client); memset(client, 0, sizeof(ogs_sbi_client_t)); - client->reference_count++; - ogs_trace("ogs_sbi_client_add()"); + ogs_debug("ogs_sbi_client_add()"); + OGS_OBJECT_REF(client); ogs_assert(OGS_OK == ogs_copyaddrinfo(&client->node.addr, addr)); - ogs_list_init(&client->connection_list); - client->t_curl = ogs_timer_add( ogs_app()->timer_mgr, multi_timer_expired, client); + if (!client->t_curl) { + ogs_error("ogs_timer_add() failed"); + ogs_pool_free(&client_pool, client); + return NULL; + } multi = client->multi = curl_multi_init(); ogs_assert(multi); @@ -118,6 +120,12 @@ curl_multi_setopt(multi, CURLMOPT_SOCKETDATA, client); curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, multi_timer_cb); curl_multi_setopt(multi, CURLMOPT_TIMERDATA, client); +#ifdef CURLMOPT_MAX_CONCURRENT_STREAMS + curl_multi_setopt(multi, CURLMOPT_MAX_CONCURRENT_STREAMS, + ogs_app()->pool.stream); +#endif + + ogs_list_init(&client->connection_list); ogs_list_add(&ogs_sbi_self()->client_list, client); @@ -126,17 +134,22 @@ void ogs_sbi_client_remove(ogs_sbi_client_t *client) { + ogs_sockaddr_t *addr = NULL; + char bufOGS_ADDRSTRLEN; + ogs_assert(client); - /* ogs_sbi_client_t is always created with reference context */ - ogs_assert(client->reference_count > 0); + addr = client->node.addr; + ogs_assert(addr); + ogs_debug("ogs_sbi_client_remove() %s:%d", + OGS_ADDR(addr, buf), OGS_PORT(addr)); - ogs_trace("client->reference_count = %d", client->reference_count); - client->reference_count--; - if (client->reference_count > 0) + /* ogs_sbi_client_t is always created with reference context */ + if (OGS_OBJECT_IS_REF(client)) { + OGS_OBJECT_UNREF(client); return; + } - ogs_trace("ogs_sbi_client_remove()"); ogs_list_remove(&ogs_sbi_self()->client_list, client); connection_remove_all(client);
View file
open5gs_2.4.9.tar.xz/lib/sbi/client.h -> open5gs_2.4.10.tar.xz/lib/sbi/client.h
Changed
@@ -47,10 +47,8 @@ ogs_sbi_client_remove(client); \ } \ \ - (__pClient)->reference_count++; \ + OGS_OBJECT_REF(__pClient); \ ((__cTX)->client) = (__pClient); \ - ogs_trace("client->reference_count = %d", \ - (__pClient)->reference_count); \ } while(0) typedef int (*ogs_sbi_client_cb_f)(
View file
open5gs_2.4.9.tar.xz/lib/sbi/context.c -> open5gs_2.4.10.tar.xz/lib/sbi/context.c
Changed
@@ -17,7 +17,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#include "app/ogs-app.h" #include "ogs-sbi.h" int __ogs_sbi_domain; @@ -27,7 +26,7 @@ static OGS_POOL(nf_instance_pool, ogs_sbi_nf_instance_t); static OGS_POOL(nf_service_pool, ogs_sbi_nf_service_t); static OGS_POOL(xact_pool, ogs_sbi_xact_t); -static OGS_POOL(subscription_pool, ogs_sbi_subscription_t); +static OGS_POOL(subscription_data_pool, ogs_sbi_subscription_data_t); static OGS_POOL(smf_info_pool, ogs_sbi_smf_info_t); static OGS_POOL(nf_info_pool, ogs_sbi_nf_info_t); @@ -52,8 +51,8 @@ ogs_pool_init(&xact_pool, ogs_app()->pool.xact); - ogs_list_init(&self.subscription_list); - ogs_pool_init(&subscription_pool, ogs_app()->pool.subscription); + ogs_list_init(&self.subscription_data_list); + ogs_pool_init(&subscription_data_pool, ogs_app()->pool.subscription); ogs_pool_init(&smf_info_pool, ogs_app()->pool.nf); @@ -75,8 +74,8 @@ { ogs_assert(context_initialized == 1); - ogs_sbi_subscription_remove_all(); - ogs_pool_final(&subscription_pool); + ogs_sbi_subscription_data_remove_all(); + ogs_pool_final(&subscription_data_pool); ogs_pool_final(&xact_pool); @@ -121,36 +120,35 @@ return OGS_ERROR; } - if (context_initialized == 1) { - switch (self.discovery_config.delegated) { - case OGS_SBI_DISCOVERY_DELEGATED_AUTO: - if (strcmp(local, "nrf") != 0 && /* Skip NRF */ - strcmp(local, "smf") != 0 && /* Skip SMF since SMF can run 4G */ - ogs_sbi_self()->nrf_instance == NULL && - ogs_sbi_self()->scp_instance == NULL) { - ogs_error("DELEGATED_AUTO - Both NRF and %s are unavailable", - strcmp(scp, "next_scp") == 0 ? "Next-hop SCP" : "SCP"); - return OGS_ERROR; - } - break; - case OGS_SBI_DISCOVERY_DELEGATED_YES: - if (ogs_sbi_self()->scp_instance == NULL) { - ogs_error("DELEGATED_YES - no %s available", - strcmp(scp, "next_scp") == 0 ? "Next-hop SCP" : "SCP"); - return OGS_ERROR; - } - break; - case OGS_SBI_DISCOVERY_DELEGATED_NO: - if (ogs_sbi_self()->nrf_instance == NULL) { - ogs_error("DELEGATED_NO - no NRF available"); - return OGS_ERROR; - } - break; - default: - ogs_fatal("Invalid dicovery-config delegated %d", - self.discovery_config.delegated); - ogs_assert_if_reached(); + ogs_assert(context_initialized == 1); + switch (self.discovery_config.delegated) { + case OGS_SBI_DISCOVERY_DELEGATED_AUTO: + if (strcmp(local, "nrf") != 0 && /* Skip NRF */ + strcmp(local, "smf") != 0 && /* Skip SMF since SMF can run 4G */ + ogs_sbi_self()->nrf_instance == NULL && + ogs_sbi_self()->scp_instance == NULL) { + ogs_error("DELEGATED_AUTO - Both NRF and %s are unavailable", + strcmp(scp, "next_scp") == 0 ? "Next-hop SCP" : "SCP"); + return OGS_ERROR; + } + break; + case OGS_SBI_DISCOVERY_DELEGATED_YES: + if (ogs_sbi_self()->scp_instance == NULL) { + ogs_error("DELEGATED_YES - no %s available", + strcmp(scp, "next_scp") == 0 ? "Next-hop SCP" : "SCP"); + return OGS_ERROR; } + break; + case OGS_SBI_DISCOVERY_DELEGATED_NO: + if (ogs_sbi_self()->nrf_instance == NULL) { + ogs_error("DELEGATED_NO - no NRF available"); + return OGS_ERROR; + } + break; + default: + ogs_fatal("Invalid dicovery-config delegated %d", + self.discovery_config.delegated); + ogs_assert_if_reached(); } return OGS_OK; @@ -400,6 +398,74 @@ ogs_socknode_remove_all(&list); ogs_socknode_remove_all(&list6); } + } else if (!strcmp(local_key, "service_name")) { + ogs_yaml_iter_t service_name_iter; + ogs_yaml_iter_recurse(&local_iter, &service_name_iter); + ogs_assert(ogs_yaml_iter_type( + &service_name_iter) != YAML_MAPPING_NODE); + + do { + const char *v = NULL; + + if (ogs_yaml_iter_type(&service_name_iter) == + YAML_SEQUENCE_NODE) { + if (!ogs_yaml_iter_next(&service_name_iter)) + break; + } + + v = ogs_yaml_iter_value(&service_name_iter); + if (v && strlen(v)) + self.service_nameself.num_of_service_name++ = v; + + } while (ogs_yaml_iter_type( + &service_name_iter) == YAML_SEQUENCE_NODE); + + } else if (!strcmp(local_key, "discovery")) { + ogs_yaml_iter_t discovery_iter; + ogs_yaml_iter_recurse(&local_iter, &discovery_iter); + while (ogs_yaml_iter_next(&discovery_iter)) { + const char *discovery_key = + ogs_yaml_iter_key(&discovery_iter); + ogs_assert(discovery_key); + if (!strcmp(discovery_key, "delegated")) { + const char *delegated = + ogs_yaml_iter_value(&discovery_iter); + if (!strcmp(delegated, "auto")) + self.discovery_config.delegated = + OGS_SBI_DISCOVERY_DELEGATED_AUTO; + else if (!strcmp(delegated, "yes")) + self.discovery_config.delegated = + OGS_SBI_DISCOVERY_DELEGATED_YES; + else if (!strcmp(delegated, "no")) + self.discovery_config.delegated = + OGS_SBI_DISCOVERY_DELEGATED_NO; + else + ogs_warn("unknown 'delegated' value `%s`", + delegated); + } else if (!strcmp(discovery_key, "option")) { + ogs_yaml_iter_t option_iter; + ogs_yaml_iter_recurse( + &discovery_iter, &option_iter); + + while (ogs_yaml_iter_next(&option_iter)) { + const char *option_key = + ogs_yaml_iter_key(&option_iter); + ogs_assert(option_key); + + if (!strcmp(option_key, "no_service_names")) { + self.discovery_config.no_service_names = + ogs_yaml_iter_bool(&option_iter); + } else if (!strcmp(option_key, + "prefer_requester_nf_instance_id")) { + self.discovery_config. + prefer_requester_nf_instance_id = + ogs_yaml_iter_bool(&option_iter); + } else + ogs_warn("unknown key `%s`", option_key); + } + } else + ogs_warn("unknown key `%s`", discovery_key); + } } } } else if (nrf && !strcmp(root_key, nrf)) { @@ -660,41 +726,6 @@ } while (ogs_yaml_iter_type(&sbi_array) == YAML_SEQUENCE_NODE); - } else if (!strcmp(scp_key, "discovery")) { - ogs_yaml_iter_t discovery_iter; - yaml_node_t *node = yaml_document_get_node( - document, scp_iter.pair->value); - ogs_assert(node); - ogs_assert(node->type == YAML_MAPPING_NODE); - ogs_yaml_iter_recurse(&scp_iter, &discovery_iter); - while (ogs_yaml_iter_next(&discovery_iter)) { - const char *discovery_key = - ogs_yaml_iter_key(&discovery_iter); - ogs_assert(discovery_key); - if (!strcmp(discovery_key, "delegated")) { - yaml_node_t *discovery_node = - yaml_document_get_node(document, - discovery_iter.pair->value); - ogs_assert(discovery_node->type == - YAML_SCALAR_NODE); - const char* delegated = - ogs_yaml_iter_value(&discovery_iter); - if (!strcmp(delegated, "auto")) - self.discovery_config.delegated = - OGS_SBI_DISCOVERY_DELEGATED_AUTO; - else if (!strcmp(delegated, "yes")) - self.discovery_config.delegated = - OGS_SBI_DISCOVERY_DELEGATED_YES; - else if (!strcmp(delegated, "no")) - self.discovery_config.delegated = - OGS_SBI_DISCOVERY_DELEGATED_NO; - else - ogs_warn("unknown 'delegated' value `%s`", - delegated); - } else - ogs_warn("unknown key `%s`", - discovery_key); - } } } } @@ -706,6 +737,24 @@ return OGS_OK; } +bool ogs_sbi_nf_service_is_available(const char *name) +{ + int i; + + ogs_assert(name); + + if (self.num_of_service_name == 0) + /* If no service name is configured, all services are available */ + return true; + + for (i = 0; i < self.num_of_service_name; i++) + /* Only services in the configuration are available */ + if (strcmp(self.service_namei, name) == 0) + return true; + + return false; +} + ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_add(void) { ogs_sbi_nf_instance_t *nf_instance = NULL; @@ -714,8 +763,9 @@ ogs_assert(nf_instance); memset(nf_instance, 0, sizeof(ogs_sbi_nf_instance_t)); - nf_instance->reference_count++; - ogs_trace("ogs_sbi_nf_instance_add()"); + ogs_debug("ogs_sbi_nf_instance_add()"); + + OGS_OBJECT_REF(nf_instance); nf_instance->time.heartbeat_interval = ogs_app()->time.nf_instance.heartbeat_interval; @@ -763,12 +813,35 @@ ogs_assert(allowed_nf_type); if (nf_instance->num_of_allowed_nf_type < OGS_SBI_MAX_NUM_OF_NF_TYPE) { - nf_instance->allowed_nf_typesnf_instance->num_of_allowed_nf_type = + nf_instance->allowed_nf_typenf_instance->num_of_allowed_nf_type = allowed_nf_type; nf_instance->num_of_allowed_nf_type++; } } +bool ogs_sbi_nf_instance_is_allowed_nf_type( + ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_type_e allowed_nf_type) +{ + int i; + + ogs_assert(nf_instance); + ogs_assert(allowed_nf_type); + + if (!nf_instance->num_of_allowed_nf_type) { + return true; + } + + for (i = 0; i < nf_instance->num_of_allowed_nf_type; i++) { + if (nf_instance->allowed_nf_typei == allowed_nf_type) + return true; + } + + ogs_error("Not allowed nf-type%s in nf-instance%s", + OpenAPI_nf_type_ToString(allowed_nf_type), + OpenAPI_nf_type_ToString(nf_instance->nf_type)); + return false; +} + void ogs_sbi_nf_instance_clear(ogs_sbi_nf_instance_t *nf_instance) { int i; @@ -777,6 +850,7 @@ if (nf_instance->fqdn) ogs_free(nf_instance->fqdn); + nf_instance->fqdn = NULL; for (i = 0; i < nf_instance->num_of_ipv4; i++) { if (nf_instance->ipv4i) @@ -797,13 +871,13 @@ { ogs_assert(nf_instance); - ogs_trace("nf_instance->reference_count = %d", - nf_instance->reference_count); - nf_instance->reference_count--; - if (nf_instance->reference_count > 0) + ogs_debug("ogs_sbi_nf_instance_remove()"); + + if (OGS_OBJECT_IS_REF(nf_instance)) { + OGS_OBJECT_UNREF(nf_instance); return; + } - ogs_trace("ogs_sbi_nf_instance_remove()"); ogs_list_remove(&ogs_sbi_self()->nf_instance_list, nf_instance); ogs_sbi_nf_info_remove_all(&nf_instance->nf_info_list); @@ -813,16 +887,13 @@ ogs_sbi_nf_instance_clear(nf_instance); if (nf_instance->id) { - ogs_sbi_subscription_remove_all_by_nf_instance_id(nf_instance->id); + ogs_sbi_subscription_data_remove_all_by_nf_instance_id(nf_instance->id); ogs_free(nf_instance->id); } if (nf_instance->client) ogs_sbi_client_remove(nf_instance->client); - if (nf_instance->nf_profile) - OpenAPI_nf_profile_free(nf_instance->nf_profile); - ogs_pool_free(&nf_instance_pool, nf_instance); } @@ -849,6 +920,52 @@ return nf_instance; } +ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_find_by_discovery_param( + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + + ogs_assert(target_nf_type); + + ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { + if (ogs_sbi_discovery_param_is_matched( + nf_instance, target_nf_type, discovery_option) == false) + continue; + + return nf_instance; + } + + return NULL; +} + +ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_find_by_service_type( + ogs_sbi_service_type_e service_type) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_discovery_option_t *discovery_option = NULL; + + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; + char *service_name = NULL; + + ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); + ogs_assert(target_nf_type); + service_name = (char *)ogs_sbi_service_type_to_name(service_type); + ogs_assert(service_name); + + discovery_option = ogs_sbi_discovery_option_new(); + ogs_assert(discovery_option); + ogs_sbi_discovery_option_add_service_names(discovery_option, service_name); + + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + + ogs_sbi_discovery_option_free(discovery_option); + + return nf_instance; +} + bool ogs_sbi_nf_instance_maximum_number_is_reached() { return nf_instance_pool.avail <= 0; @@ -856,7 +973,7 @@ ogs_sbi_nf_service_t *ogs_sbi_nf_service_add( ogs_sbi_nf_instance_t *nf_instance, - char *id, char *name, OpenAPI_uri_scheme_e scheme) + char *id, const char *name, OpenAPI_uri_scheme_e scheme) { ogs_sbi_nf_service_t *nf_service = NULL; @@ -888,7 +1005,7 @@ } void ogs_sbi_nf_service_add_version(ogs_sbi_nf_service_t *nf_service, - char *in_uri, char *full, char *expiry) + const char *in_uri, const char *full, const char *expiry) { ogs_assert(nf_service); @@ -896,17 +1013,17 @@ ogs_assert(full); if (nf_service->num_of_version < OGS_SBI_MAX_NUM_OF_SERVICE_VERSION) { - nf_service->versionsnf_service->num_of_version.in_uri = + nf_service->versionnf_service->num_of_version.in_uri = ogs_strdup(in_uri); - ogs_assert(nf_service->versionsnf_service->num_of_version.in_uri); - nf_service->versionsnf_service->num_of_version.full = + ogs_assert(nf_service->versionnf_service->num_of_version.in_uri); + nf_service->versionnf_service->num_of_version.full = ogs_strdup(full); - ogs_assert(nf_service->versionsnf_service->num_of_version.full); + ogs_assert(nf_service->versionnf_service->num_of_version.full); if (expiry) { - nf_service->versionsnf_service->num_of_version.expiry = + nf_service->versionnf_service->num_of_version.expiry = ogs_strdup(expiry); ogs_assert( - nf_service->versionsnf_service->num_of_version.expiry); + nf_service->versionnf_service->num_of_version.expiry); } nf_service->num_of_version++; @@ -920,12 +1037,36 @@ ogs_assert(allowed_nf_type); if (nf_service->num_of_allowed_nf_type < OGS_SBI_MAX_NUM_OF_NF_TYPE) { - nf_service->allowed_nf_typesnf_service->num_of_allowed_nf_type = + nf_service->allowed_nf_typenf_service->num_of_allowed_nf_type = allowed_nf_type; nf_service->num_of_allowed_nf_type++; } } +bool ogs_sbi_nf_service_is_allowed_nf_type( + ogs_sbi_nf_service_t *nf_service, OpenAPI_nf_type_e allowed_nf_type) +{ + int i; + + ogs_assert(nf_service); + ogs_assert(allowed_nf_type); + + if (!nf_service->num_of_allowed_nf_type) { + return true; + } + + for (i = 0; i < nf_service->num_of_allowed_nf_type; i++) { + if (nf_service->allowed_nf_typei == allowed_nf_type) + return true; + } + + ogs_assert(nf_service->name); + ogs_error("Not allowed nf-type%s in nf-service%s", + OpenAPI_nf_type_ToString(allowed_nf_type), + nf_service->name); + return false; +} + void ogs_sbi_nf_service_clear(ogs_sbi_nf_service_t *nf_service) { ogs_sbi_nf_instance_t *nf_instance = NULL; @@ -937,14 +1078,15 @@ if (nf_service->fqdn) ogs_free(nf_service->fqdn); + nf_service->fqdn = NULL; for (i = 0; i < nf_service->num_of_version; i++) { - if (nf_service->versionsi.in_uri) - ogs_free(nf_service->versionsi.in_uri); - if (nf_service->versionsi.full) - ogs_free(nf_service->versionsi.full); - if (nf_service->versionsi.expiry) - ogs_free(nf_service->versionsi.expiry); + if (nf_service->versioni.in_uri) + ogs_free(nf_service->versioni.in_uri); + if (nf_service->versioni.full) + ogs_free(nf_service->versioni.full); + if (nf_service->versioni.expiry) + ogs_free(nf_service->versioni.expiry); } nf_service->num_of_version = 0; @@ -1022,10 +1164,10 @@ ogs_list_for_each(&nf_instance->nf_service_list, nf_service) { ogs_assert(nf_service->name); if (strcmp(nf_service->name, name) == 0) - break; + return nf_service; } - return nf_service; + return NULL; } ogs_sbi_nf_info_t *ogs_sbi_nf_info_add( @@ -1094,6 +1236,22 @@ ogs_sbi_nf_info_remove(list, nf_info); } +ogs_sbi_nf_info_t *ogs_sbi_nf_info_find( + ogs_list_t *list, OpenAPI_nf_type_e nf_type) +{ + ogs_sbi_nf_info_t *nf_info = NULL; + + ogs_assert(list); + ogs_assert(nf_type); + + ogs_list_for_each(list, nf_info) { + if (nf_info->nf_type == nf_type) + return nf_info; + } + + return NULL; +} + void ogs_sbi_nf_instance_build_default( ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_type_e nf_type) { @@ -1148,7 +1306,7 @@ } ogs_sbi_nf_service_t *ogs_sbi_nf_service_build_default( - ogs_sbi_nf_instance_t *nf_instance, char *name) + ogs_sbi_nf_instance_t *nf_instance, const char *name) { ogs_sbi_server_t *server = NULL; ogs_sbi_nf_service_t *nf_service = NULL; @@ -1231,6 +1389,8 @@ ogs_assert(nf_service->fqdn); } + ogs_info("NF Service %s", nf_service->name); + return nf_service; } @@ -1323,65 +1483,87 @@ nf_service_associate_client(nf_service); } -bool ogs_sbi_discovery_param_is_matched( +bool ogs_sbi_discovery_option_is_matched( ogs_sbi_nf_instance_t *nf_instance, - OpenAPI_nf_type_e target_nf_type, + OpenAPI_nf_type_e requester_nf_type, ogs_sbi_discovery_option_t *discovery_option) { ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_state_registered); - ogs_assert(target_nf_type); + ogs_assert(requester_nf_type); + ogs_assert(discovery_option); - if (!OGS_FSM_CHECK(&nf_instance->sm, - ogs_sbi_self()->nf_state_registered)) return false; - - if (nf_instance->nf_type != target_nf_type) return false; - - if (discovery_option) { - if (discovery_option->target_nf_instance_id && - strcmp(nf_instance->id, - discovery_option->target_nf_instance_id) != 0) - return false; + if (discovery_option->target_nf_instance_id && + nf_instance->id && strcmp(nf_instance->id, + discovery_option->target_nf_instance_id) != 0) { + return false; + } + + if (discovery_option->num_of_service_names) { + ogs_sbi_nf_service_t *nf_service = NULL; + + bool exist = false; + int i; + + ogs_list_for_each(&nf_instance->nf_service_list, nf_service) { + for (i = 0; i < discovery_option->num_of_service_names; i++) { + if (nf_service->name && + discovery_option->service_namesi && + strcmp(nf_service->name, + discovery_option->service_namesi) == 0) { + if (ogs_sbi_nf_service_is_allowed_nf_type( + nf_service, requester_nf_type) == true) { + exist = true; + break; + } + } + } + if (exist == true) break; + } + if (exist == false) return false; } return true; } -void ogs_sbi_select_nf( - ogs_sbi_object_t *sbi_object, +bool ogs_sbi_discovery_param_is_matched( + ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_type_e target_nf_type, ogs_sbi_discovery_option_t *discovery_option) { - ogs_sbi_nf_instance_t *nf_instance = NULL; + OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; - ogs_assert(ogs_sbi_self()->nf_state_registered); - ogs_assert(sbi_object); + ogs_assert(nf_instance); ogs_assert(target_nf_type); + ogs_assert(ogs_sbi_self()->nf_instance); + requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; + ogs_assert(requester_nf_type); + + if (!OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_registered)) + return false; + + if (nf_instance->nf_type != target_nf_type) + return false; + + if (discovery_option && + ogs_sbi_discovery_option_is_matched( + nf_instance, requester_nf_type, discovery_option) == false) + return false; - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (ogs_sbi_discovery_param_is_matched( - nf_instance, target_nf_type, discovery_option) == false) - continue; - - OGS_SBI_SETUP_NF(sbi_object, target_nf_type, nf_instance); - break; - } + return true; } -bool ogs_sbi_client_associate(ogs_sbi_nf_instance_t *nf_instance) +void ogs_sbi_client_associate(ogs_sbi_nf_instance_t *nf_instance) { ogs_sbi_client_t *client = NULL; ogs_assert(nf_instance); client = nf_instance_find_client(nf_instance); - if (!client) return false; + ogs_assert(client); OGS_SBI_SETUP_CLIENT(nf_instance, client); nf_service_associate_client_all(nf_instance); - - return true; } OpenAPI_uri_scheme_e ogs_sbi_default_uri_scheme(void) @@ -1403,7 +1585,7 @@ ogs_assert(nf_service->name); if (strcmp(nf_service->name, name) == 0) { for (i = 0; i < nf_service->num_of_version; i++) { - if (strcmp(nf_service->versionsi.in_uri, version) == 0) { + if (strcmp(nf_service->versioni.in_uri, version) == 0) { return nf_service->client; } } @@ -1423,21 +1605,28 @@ if (ogs_list_count(&sbi_object->xact_list)) ogs_error("SBI running %d", ogs_list_count(&sbi_object->xact_list)); - for (i = 0; i < OGS_SBI_MAX_NF_TYPE; i++) { - if (OGS_SBI_NF_INSTANCE(sbi_object, i)) - ogs_sbi_nf_instance_remove(OGS_SBI_NF_INSTANCE(sbi_object, i)); + for (i = 0; i < OGS_SBI_MAX_NUM_OF_SERVICE_TYPE; i++) { + ogs_sbi_nf_instance_t *nf_instance = + sbi_object->service_type_arrayi.nf_instance; + if (nf_instance) + ogs_sbi_nf_instance_remove(nf_instance); + } + for (i = 0; i < OGS_SBI_MAX_NUM_OF_NF_TYPE; i++) { + ogs_sbi_nf_instance_t *nf_instance = + sbi_object->nf_type_arrayi.nf_instance; + if (nf_instance) + ogs_sbi_nf_instance_remove(nf_instance); } } ogs_sbi_xact_t *ogs_sbi_xact_add( ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_build_f build, void *context, void *data) { ogs_sbi_xact_t *xact = NULL; - ogs_assert(ogs_sbi_self()->client_wait_expire); ogs_assert(sbi_object); ogs_pool_alloc(&xact_pool, &xact); @@ -1445,22 +1634,25 @@ memset(xact, 0, sizeof(ogs_sbi_xact_t)); xact->sbi_object = sbi_object; + xact->service_type = service_type; - xact->target_nf_type = target_nf_type; - xact->discovery_option = discovery_option; + /* Always insert one service-name in the discovery option */ + if (!discovery_option) { + discovery_option = ogs_sbi_discovery_option_new(); + ogs_assert(discovery_option); + } - xact->request = (*build)(context, data); - if (!xact->request) { - ogs_error("SBI build failed"); - ogs_pool_free(&xact_pool, xact); - return NULL; + if (!discovery_option->num_of_service_names) { + ogs_sbi_discovery_option_add_service_names( + discovery_option, + (char *)ogs_sbi_service_type_to_name(service_type)); } + xact->discovery_option = discovery_option; xact->t_response = ogs_timer_add( - ogs_app()->timer_mgr, ogs_sbi_self()->client_wait_expire, xact); + ogs_app()->timer_mgr, ogs_timer_sbi_client_wait_expire, xact); if (!xact->t_response) { ogs_error("ogs_timer_add() failed"); - ogs_sbi_request_free(xact->request); ogs_pool_free(&xact_pool, xact); return NULL; } @@ -1468,6 +1660,42 @@ ogs_timer_start(xact->t_response, ogs_app()->time.message.sbi.client_wait_duration); + if (build) { + xact->request = (*build)(context, data); + if (!xact->request) { + ogs_error("SBI build failed"); + ogs_timer_delete(xact->t_response); + ogs_pool_free(&xact_pool, xact); + return NULL; + } + if (!xact->request->h.uri) { + const char *service_name = NULL; + + ogs_assert(xact->service_type); + service_name = ogs_sbi_service_type_to_name(xact->service_type); + ogs_assert(service_name); + ogs_assert(xact->request->h.service.name); + + /* + * Make sure the service matches + * between discover and build functions: + * + * DISCOVER : amf_ue_sbi_discover_and_send( + * OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL, + * BUILD : amf_npcf_am_policy_control_build_create() + * message.h.service.name = + * (char *)OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL; + */ + + if (strcmp(service_name, xact->request->h.service.name) != 0) { + ogs_fatal("%s:%d is not the same with %s", + service_name, xact->service_type, + xact->request->h.service.name); + ogs_assert_if_reached(); + } + } + } + ogs_list_add(&sbi_object->xact_list, xact); return xact; @@ -1488,8 +1716,8 @@ ogs_assert(xact->t_response); ogs_timer_delete(xact->t_response); - ogs_assert(xact->request); - ogs_sbi_request_free(xact->request); + if (xact->request) + ogs_sbi_request_free(xact->request); ogs_list_remove(&sbi_object->xact_list, xact); ogs_pool_free(&xact_pool, xact); @@ -1510,90 +1738,136 @@ return ogs_pool_cycle(&xact_pool, xact); } -ogs_sbi_subscription_t *ogs_sbi_subscription_add(void) +ogs_sbi_subscription_data_t *ogs_sbi_subscription_data_add(void) { - ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; - ogs_pool_alloc(&subscription_pool, &subscription); - ogs_assert(subscription); - memset(subscription, 0, sizeof(ogs_sbi_subscription_t)); + ogs_pool_alloc(&subscription_data_pool, &subscription_data); + ogs_assert(subscription_data); + memset(subscription_data, 0, sizeof(ogs_sbi_subscription_data_t)); - subscription->time.validity_duration = + subscription_data->time.validity_duration = ogs_app()->time.subscription.validity_duration; - ogs_list_add(&ogs_sbi_self()->subscription_list, subscription); + ogs_list_add(&ogs_sbi_self()->subscription_data_list, subscription_data); - return subscription; + return subscription_data; } -void ogs_sbi_subscription_set_id(ogs_sbi_subscription_t *subscription, char *id) +void ogs_sbi_subscription_data_set_id( + ogs_sbi_subscription_data_t *subscription_data, char *id) { - ogs_assert(subscription); + ogs_assert(subscription_data); ogs_assert(id); - subscription->id = ogs_strdup(id); - ogs_assert(subscription->id); + subscription_data->id = ogs_strdup(id); + ogs_assert(subscription_data->id); } -void ogs_sbi_subscription_remove(ogs_sbi_subscription_t *subscription) +void ogs_sbi_subscription_data_remove( + ogs_sbi_subscription_data_t *subscription_data) { - ogs_assert(subscription); + ogs_assert(subscription_data); + + ogs_list_remove(&ogs_sbi_self()->subscription_data_list, subscription_data); - ogs_list_remove(&ogs_sbi_self()->subscription_list, subscription); + if (subscription_data->id) + ogs_free(subscription_data->id); - if (subscription->id) - ogs_free(subscription->id); + if (subscription_data->notification_uri) + ogs_free(subscription_data->notification_uri); - if (subscription->notification_uri) - ogs_free(subscription->notification_uri); + if (subscription_data->req_nf_instance_id) + ogs_free(subscription_data->req_nf_instance_id); - if (subscription->req_nf_instance_id) - ogs_free(subscription->req_nf_instance_id); + if (subscription_data->subscr_cond.service_name) + ogs_free(subscription_data->subscr_cond.service_name); - if (subscription->t_validity) - ogs_timer_delete(subscription->t_validity); + if (subscription_data->t_validity) + ogs_timer_delete(subscription_data->t_validity); - if (subscription->client) - ogs_sbi_client_remove(subscription->client); + if (subscription_data->client) + ogs_sbi_client_remove(subscription_data->client); - ogs_pool_free(&subscription_pool, subscription); + ogs_pool_free(&subscription_data_pool, subscription_data); } -void ogs_sbi_subscription_remove_all_by_nf_instance_id(char *nf_instance_id) +void ogs_sbi_subscription_data_remove_all_by_nf_instance_id( + char *nf_instance_id) { - ogs_sbi_subscription_t *subscription = NULL, *next_subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; + ogs_sbi_subscription_data_t *next_subscription_data = NULL; ogs_assert(nf_instance_id); - ogs_list_for_each_safe(&ogs_sbi_self()->subscription_list, - next_subscription, subscription) { - if (subscription->req_nf_instance_id && - strcmp(subscription->req_nf_instance_id, nf_instance_id) == 0) { - ogs_sbi_subscription_remove(subscription); + ogs_list_for_each_safe(&ogs_sbi_self()->subscription_data_list, + next_subscription_data, subscription_data) { + if (subscription_data->req_nf_instance_id && + strcmp(subscription_data->req_nf_instance_id, + nf_instance_id) == 0) { + ogs_sbi_subscription_data_remove(subscription_data); } } } -void ogs_sbi_subscription_remove_all(void) +void ogs_sbi_subscription_data_remove_all(void) { - ogs_sbi_subscription_t *subscription = NULL, *next_subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; + ogs_sbi_subscription_data_t *next_subscription_data = NULL; - ogs_list_for_each_safe(&ogs_sbi_self()->subscription_list, - next_subscription, subscription) - ogs_sbi_subscription_remove(subscription); + ogs_list_for_each_safe(&ogs_sbi_self()->subscription_data_list, + next_subscription_data, subscription_data) + ogs_sbi_subscription_data_remove(subscription_data); } -ogs_sbi_subscription_t *ogs_sbi_subscription_find(char *id) +ogs_sbi_subscription_data_t *ogs_sbi_subscription_data_find(char *id) { - ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; ogs_assert(id); - ogs_list_for_each(&ogs_sbi_self()->subscription_list, subscription) { - ogs_assert(subscription->id); - if (strcmp(subscription->id, id) == 0) + ogs_list_for_each(&ogs_sbi_self()->subscription_data_list, + subscription_data) { + ogs_assert(subscription_data->id); + if (strcmp(subscription_data->id, id) == 0) break; } - return subscription; + return subscription_data; +} + +void ogs_sbi_subscription_data_build_default( + OpenAPI_nf_type_e nf_type, const char *service_name) +{ + ogs_sbi_subscription_data_t *subscription_data = NULL; + ogs_sbi_nf_instance_t *nf_instance = NULL, *nrf_instance = NULL; + ogs_sbi_client_t *client = NULL; + + ogs_assert(nf_type); + + nrf_instance = ogs_sbi_self()->nrf_instance; + if (!nrf_instance) { + ogs_warn("%s:%s has no NRF", + OpenAPI_nf_type_ToString(nf_type), service_name); + return; + } + + client = nrf_instance->client; + ogs_assert(client); + + nf_instance = ogs_sbi_self()->nf_instance; + ogs_assert(nf_instance); + ogs_assert(nf_instance->id); + ogs_assert(nf_instance->nf_type); + + subscription_data = ogs_sbi_subscription_data_add(); + ogs_assert(subscription_data); + + OGS_SBI_SETUP_CLIENT(subscription_data, client); + subscription_data->req_nf_type = nf_instance->nf_type; + if (nf_instance->id) + subscription_data->req_nf_instance_id = ogs_strdup(nf_instance->id); + subscription_data->subscr_cond.nf_type = nf_type; + if (service_name) + subscription_data->subscr_cond.service_name = ogs_strdup(service_name); }
View file
open5gs_2.4.9.tar.xz/lib/sbi/context.h -> open5gs_2.4.10.tar.xz/lib/sbi/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -28,8 +28,6 @@ extern "C" { #endif -#define OGS_SBI_MAX_NF_TYPE 64 - #define OGS_MAX_NUM_OF_NF_INFO 8 typedef struct ogs_sbi_client_s ogs_sbi_client_t; @@ -44,6 +42,8 @@ typedef struct ogs_sbi_discovery_config_s { ogs_sbi_discovery_delegated_mode delegated; + bool no_service_names; + bool prefer_requester_nf_instance_id; } ogs_sbi_discovery_config_t; typedef struct ogs_sbi_context_s { @@ -57,7 +57,7 @@ ogs_uuid_t uuid; ogs_list_t nf_instance_list; - ogs_list_t subscription_list; + ogs_list_t subscription_data_list; ogs_sbi_nf_instance_t *nf_instance; /* SELF NF Instance */ ogs_sbi_nf_instance_t *nrf_instance; /* NRF Instance */ @@ -65,9 +65,8 @@ const char *content_encoding; - void (*client_wait_expire)(void *data); - ogs_fsm_handler_t nf_state_registered; - + int num_of_service_name; + const char *service_nameOGS_SBI_MAX_NUM_OF_SERVICE_TYPE; } ogs_sbi_context_t; typedef struct ogs_sbi_nf_instance_s { @@ -85,14 +84,14 @@ ogs_timer_t *t_no_heartbeat; /* check heartbeat */ ogs_timer_t *t_validity; /* check validation */ -#define NF_INSTANCE_IS_SELF(_iD) \ +#define NF_INSTANCE_ID_IS_SELF(_iD) \ (_iD) && ogs_sbi_self()->nf_instance && \ strcmp((_iD), ogs_sbi_self()->nf_instance->id) == 0 -#define NF_INSTANCE_IS_OTHERS(_iD) \ +#define NF_INSTANCE_ID_IS_OTHERS(_iD) \ (_iD) && ogs_sbi_self()->nf_instance && \ strcmp((_iD), ogs_sbi_self()->nf_instance->id) != 0 -#define NF_INSTANCE_IS_NRF(__nFInstance) \ +#define NF_INSTANCE_TYPE_IS_NRF(__nFInstance) \ ((__nFInstance->nf_type) == OpenAPI_nf_type_NRF) char *id; /* NFInstanceId */ @@ -108,9 +107,9 @@ int num_of_ipv6; ogs_sockaddr_t *ipv6OGS_SBI_MAX_NUM_OF_IP_ADDRESS; -#define OGS_SBI_MAX_NUM_OF_NF_TYPE 16 int num_of_allowed_nf_type; - OpenAPI_nf_type_e allowed_nf_typesOGS_SBI_MAX_NUM_OF_NF_TYPE; +#define OGS_SBI_MAX_NUM_OF_NF_TYPE 128 + OpenAPI_nf_type_e allowed_nf_typeOGS_SBI_MAX_NUM_OF_NF_TYPE; #define OGS_SBI_DEFAULT_PRIORITY 0 #define OGS_SBI_DEFAULT_CAPACITY 100 @@ -120,19 +119,12 @@ int load; ogs_list_t nf_service_list; + ogs_list_t nf_info_list; void *client; /* only used in CLIENT */ unsigned int reference_count; /* reference count for memory free */ - - ogs_list_t nf_info_list; - - OpenAPI_nf_profile_t *nf_profile; /* stored NF Profile */ } ogs_sbi_nf_instance_t; -typedef struct ogs_sbi_nf_type_array_s { - ogs_sbi_nf_instance_t *nf_instance; -} ogs_sbi_nf_type_array_tOGS_SBI_MAX_NF_TYPE; - typedef enum { OGS_SBI_OBJ_BASE = 0, @@ -147,7 +139,10 @@ ogs_sbi_obj_type_e type; - ogs_sbi_nf_type_array_t nf_type_array; + struct { + ogs_sbi_nf_instance_t *nf_instance; + } nf_type_arrayOGS_SBI_MAX_NUM_OF_NF_TYPE, + service_type_arrayOGS_SBI_MAX_NUM_OF_SERVICE_TYPE; ogs_list_t xact_list; @@ -159,7 +154,7 @@ typedef struct ogs_sbi_xact_s { ogs_lnode_t lnode; - OpenAPI_nf_type_e target_nf_type; + ogs_sbi_service_type_e service_type; ogs_sbi_discovery_option_t *discovery_option; ogs_sbi_request_t *request; @@ -186,7 +181,7 @@ char *in_uri; char *full; char *expiry; - } versionsOGS_SBI_MAX_NUM_OF_SERVICE_VERSION; + } versionOGS_SBI_MAX_NUM_OF_SERVICE_VERSION; char *fqdn; int num_of_addr; @@ -197,7 +192,7 @@ } addrOGS_SBI_MAX_NUM_OF_IP_ADDRESS; int num_of_allowed_nf_type; - OpenAPI_nf_type_e allowed_nf_typesOGS_SBI_MAX_NUM_OF_NF_TYPE; + OpenAPI_nf_type_e allowed_nf_typeOGS_SBI_MAX_NUM_OF_NF_TYPE; int priority; int capacity; @@ -208,7 +203,7 @@ void *client; } ogs_sbi_nf_service_t; -typedef struct ogs_sbi_subscription_s { +typedef struct ogs_sbi_subscription_data_s { ogs_lnode_t lnode; struct { @@ -225,10 +220,14 @@ struct { OpenAPI_nf_type_e nf_type; /* nfType */ + char *service_name; /* ServiceName */ } subscr_cond; + uint64_t requester_features; + uint64_t nrf_supported_features; + void *client; /* only used in SERVER */ -} ogs_sbi_subscription_t; +} ogs_sbi_subscription_data_t; typedef struct ogs_sbi_smf_info_s { int num_of_slice; @@ -271,6 +270,8 @@ int ogs_sbi_context_parse_config( const char *local, const char *nrf, const char *scp); +bool ogs_sbi_nf_service_is_available(const char *name); + ogs_sbi_nf_instance_t *ogs_sbi_scp_instance(void); ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_add(void); @@ -281,18 +282,29 @@ ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_status_e nf_status); void ogs_sbi_nf_instance_add_allowed_nf_type( ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_type_e allowed_nf_type); +bool ogs_sbi_nf_instance_is_allowed_nf_type( + ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_type_e allowed_nf_type); void ogs_sbi_nf_instance_clear(ogs_sbi_nf_instance_t *nf_instance); void ogs_sbi_nf_instance_remove(ogs_sbi_nf_instance_t *nf_instance); void ogs_sbi_nf_instance_remove_all(void); ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_find(char *id); +ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_find_by_discovery_param( + OpenAPI_nf_type_e nf_type, + ogs_sbi_discovery_option_t *discovery_option); +ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_find_by_service_type( + ogs_sbi_service_type_e service_type); bool ogs_sbi_nf_instance_maximum_number_is_reached(void); -ogs_sbi_nf_service_t *ogs_sbi_nf_service_add(ogs_sbi_nf_instance_t *nf_instance, - char *id, char *name, OpenAPI_uri_scheme_e scheme); -void ogs_sbi_nf_service_add_version(ogs_sbi_nf_service_t *nf_service, - char *in_uri, char *full, char *expiry); +ogs_sbi_nf_service_t *ogs_sbi_nf_service_add( + ogs_sbi_nf_instance_t *nf_instance, + char *id, const char *name, OpenAPI_uri_scheme_e scheme); +void ogs_sbi_nf_service_add_version( + ogs_sbi_nf_service_t *nf_service, + const char *in_uri, const char *full, const char *expiry); void ogs_sbi_nf_service_add_allowed_nf_type( ogs_sbi_nf_service_t *nf_service, OpenAPI_nf_type_e allowed_nf_type); +bool ogs_sbi_nf_service_is_allowed_nf_type( + ogs_sbi_nf_service_t *nf_service, OpenAPI_nf_type_e allowed_nf_type); void ogs_sbi_nf_service_clear(ogs_sbi_nf_service_t *nf_service); void ogs_sbi_nf_service_remove(ogs_sbi_nf_service_t *nf_service); void ogs_sbi_nf_service_remove_all(ogs_sbi_nf_instance_t *nf_instance); @@ -305,40 +317,32 @@ ogs_list_t *list, OpenAPI_nf_type_e nf_type); void ogs_sbi_nf_info_remove(ogs_list_t *list, ogs_sbi_nf_info_t *nf_info); void ogs_sbi_nf_info_remove_all(ogs_list_t *list); +ogs_sbi_nf_info_t *ogs_sbi_nf_info_find( + ogs_list_t *list, OpenAPI_nf_type_e nf_type); void ogs_sbi_nf_instance_build_default( ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_type_e nf_type); ogs_sbi_nf_service_t *ogs_sbi_nf_service_build_default( - ogs_sbi_nf_instance_t *nf_instance, char *name); + ogs_sbi_nf_instance_t *nf_instance, const char *name); ogs_sbi_client_t *ogs_sbi_client_find_by_service_name( ogs_sbi_nf_instance_t *nf_instance, char *name, char *version); -bool ogs_sbi_client_associate(ogs_sbi_nf_instance_t *nf_instance); +void ogs_sbi_client_associate(ogs_sbi_nf_instance_t *nf_instance); OpenAPI_uri_scheme_e ogs_sbi_default_uri_scheme(void); -#define OGS_SBI_NF_INSTANCE(__sBIObject, __nFType) \ - (((__sBIObject)->nf_type_array)__nFType.nf_instance) - -#define OGS_SBI_SETUP_NF(__sBIObject, __nFType, __nFInstance) \ +#define OGS_SBI_SETUP_NF_INSTANCE(__cTX, __nFInstance) \ do { \ - ogs_assert((__sBIObject)); \ - ogs_assert((__nFType)); \ - ogs_assert((__nFInstance)); \ + ogs_assert(__nFInstance); \ \ - if (OGS_SBI_NF_INSTANCE((__sBIObject), (__nFType))) { \ - ogs_warn("UE %s-EndPoint updated %s", \ - OpenAPI_nf_type_ToString((__nFType)), \ - (__nFInstance)->id); \ - ogs_sbi_nf_instance_remove( \ - OGS_SBI_NF_INSTANCE((__sBIObject), (__nFType))); \ + if ((__cTX).nf_instance) { \ + ogs_warn("NF Instance updated %s", (__nFInstance)->id); \ + ogs_sbi_nf_instance_remove((__cTX).nf_instance); \ } \ \ - (__nFInstance)->reference_count++; \ - OGS_SBI_NF_INSTANCE((__sBIObject), (__nFType)) = (__nFInstance); \ - ogs_trace("nf_instance->reference_count = %d", \ - (__nFInstance)->reference_count); \ + OGS_OBJECT_REF(__nFInstance); \ + ((__cTX).nf_instance) = (__nFInstance); \ } while(0) bool ogs_sbi_discovery_param_is_matched( @@ -346,29 +350,33 @@ OpenAPI_nf_type_e target_nf_type, ogs_sbi_discovery_option_t *discovery_option); -void ogs_sbi_select_nf( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, +bool ogs_sbi_discovery_option_is_matched( + ogs_sbi_nf_instance_t *nf_instance, + OpenAPI_nf_type_e requester_nf_type, ogs_sbi_discovery_option_t *discovery_option); void ogs_sbi_object_free(ogs_sbi_object_t *sbi_object); ogs_sbi_xact_t *ogs_sbi_xact_add( ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_build_f build, void *context, void *data); void ogs_sbi_xact_remove(ogs_sbi_xact_t *xact); void ogs_sbi_xact_remove_all(ogs_sbi_object_t *sbi_object); ogs_sbi_xact_t *ogs_sbi_xact_cycle(ogs_sbi_xact_t *xact); -ogs_sbi_subscription_t *ogs_sbi_subscription_add(void); -void ogs_sbi_subscription_set_id( - ogs_sbi_subscription_t *subscription, char *id); -void ogs_sbi_subscription_remove(ogs_sbi_subscription_t *subscription); -void ogs_sbi_subscription_remove_all_by_nf_instance_id(char *nf_instance_id); -void ogs_sbi_subscription_remove_all(void); -ogs_sbi_subscription_t *ogs_sbi_subscription_find(char *id); +ogs_sbi_subscription_data_t *ogs_sbi_subscription_data_add(void); +void ogs_sbi_subscription_data_set_id( + ogs_sbi_subscription_data_t *subscription_data, char *id); +void ogs_sbi_subscription_data_remove( + ogs_sbi_subscription_data_t *subscription_data); +void ogs_sbi_subscription_data_remove_all_by_nf_instance_id( + char *nf_instance_id); +void ogs_sbi_subscription_data_remove_all(void); +ogs_sbi_subscription_data_t *ogs_sbi_subscription_data_find(char *id); +void ogs_sbi_subscription_data_build_default( + OpenAPI_nf_type_e nf_type, const char *service_name); #ifdef __cplusplus }
View file
open5gs_2.4.9.tar.xz/lib/sbi/meson.build -> open5gs_2.4.10.tar.xz/lib/sbi/meson.build
Changed
@@ -27,7 +27,9 @@ custom/patch_item.c yuarel.c + types.c conv.c + timer.c message.c mhd-server.c @@ -39,8 +41,9 @@ nnrf-build.c nnrf-handler.c - + path.c + nf-sm.c '''.split()) libsbi_inc = include_directories('.') @@ -57,8 +60,7 @@ version : libogslib_version, c_args : sbi_cc_flags, include_directories : libsbi_inc, libinc, - dependencies : libcore_dep, - libcrypt_dep, + dependencies : libcrypt_dep, libapp_dep, libsbi_openapi_dep, libgnutls_dep, @@ -71,8 +73,7 @@ libsbi_dep = declare_dependency( link_with : libsbi, include_directories : libsbi_inc, libinc, - dependencies : libcore_dep, - libcrypt_dep, + dependencies : libcrypt_dep, libapp_dep, libsbi_openapi_dep, libgnutls_dep,
View file
open5gs_2.4.9.tar.xz/lib/sbi/message.c -> open5gs_2.4.10.tar.xz/lib/sbi/message.c
Changed
@@ -18,7 +18,6 @@ */ #include "ogs-sbi.h" -#include "ogs-crypt.h" #include "yuarel.h" #include "contrib/multipart_parser.h" @@ -304,18 +303,21 @@ OGS_SBI_PARAM_REQUESTER_NF_INSTANCE_ID, discovery_option->requester_nf_instance_id); } - if (discovery_option->num_of_service_names) { - char *v = NULL; - cJSON *item = NULL; + if (ogs_sbi_self()->discovery_config.no_service_names == false && + discovery_option->num_of_service_names) { - item = cJSON_CreateStringArray( - (const char * const*)discovery_option->service_names, - discovery_option->num_of_service_names); - ogs_expect_or_return_val(item, NULL); + /* send array items separated by a comma */ + char *v = NULL; - v = cJSON_Print(item); + v = ogs_strdup(discovery_option->service_names0); ogs_expect_or_return_val(v, NULL); - cJSON_Delete(item); + + if (discovery_option->num_of_service_names > 1) + { + int i; + for (i = 1; i < discovery_option->num_of_service_names; i++) + v = ogs_mstrcatf(v, ",%s", discovery_option->service_namesi); + } ogs_sbi_header_set( request->http.params, OGS_SBI_PARAM_SERVICE_NAMES, v); @@ -523,23 +525,26 @@ } else if (!strcmp(ogs_hash_this_key(hi), OGS_SBI_PARAM_SERVICE_NAMES)) { char *v = NULL; - cJSON *array = NULL, *item = NULL; + char *service_names; + char *token; + char *saveptr; v = ogs_hash_this_val(hi); if (v) { - array = cJSON_Parse(v); - if (cJSON_IsArray(array)) { + service_names = ogs_strdup(v); + ogs_assert(service_names); + token = ogs_strtok_r(service_names, ",", &saveptr); + while (token != NULL) + { discovery_option_presence = true; + ogs_sbi_discovery_option_add_service_names( + discovery_option, token); - cJSON_ArrayForEach(item, array) { - char *names = cJSON_GetStringValue(item); - if (names) - ogs_sbi_discovery_option_add_service_names( - discovery_option, names); - } + token = ogs_strtok_r(NULL, ",", &saveptr); } - cJSON_Delete(array); + + ogs_free(service_names); } /* URL Query Parameter */ @@ -722,7 +727,7 @@ ogs_assert(message); ogs_assert(header); - memset(message, 0, sizeof(*message)); + memset(message, 0, sizeof(ogs_sbi_message_t)); message->h.method = header->method; message->h.uri = header->uri; @@ -2338,7 +2343,7 @@ ogs_assert(service_name); ogs_assert(discovery_option->num_of_service_names < - OGS_MAX_NUM_OF_NF_SERVICE); + OGS_SBI_MAX_NUM_OF_SERVICE_TYPE); discovery_option->service_namesdiscovery_option->num_of_service_names = ogs_strdup(service_name);
View file
open5gs_2.4.9.tar.xz/lib/sbi/message.h -> open5gs_2.4.10.tar.xz/lib/sbi/message.h
Changed
@@ -80,19 +80,15 @@ #define OGS_SBI_API_V2 "v2" #define OGS_SBI_API_V2_0_0 "2.0.0" -#define OGS_SBI_SERVICE_NAME_NNRF_NFM "nnrf-nfm" -#define OGS_SBI_SERVICE_NAME_NNRF_DISC "nnrf-disc" #define OGS_SBI_RESOURCE_NAME_NF_INSTANCES "nf-instances" #define OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS "subscriptions" #define OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY "nf-status-notify" -#define OGS_SBI_SERVICE_NAME_NAUSF_AUTH "nausf-auth" #define OGS_SBI_RESOURCE_NAME_UE_AUTHENTICATIONS "ue-authentications" #define OGS_SBI_RESOURCE_NAME_5G_AKA "5g-aka" #define OGS_SBI_RESOURCE_NAME_5G_AKA_CONFIRMATION "5g-aka-confirmation" #define OGS_SBI_RESOURCE_NAME_EAP_SESSION "eap-session" -#define OGS_SBI_SERVICE_NAME_NUDM_SDM "nudm-sdm" #define OGS_SBI_RESOURCE_NAME_AM_DATA "am-data" #define OGS_SBI_RESOURCE_NAME_SM_DATA "sm-data" #define OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA "smf-select-data" @@ -100,15 +96,12 @@ #define OGS_SBI_RESOURCE_NAME_SMF_SELECTION_SUBSCRIPTION_DATA \ "smf-selection-subscription-data" -#define OGS_SBI_SERVICE_NAME_NUDM_UEAU "nudm-ueau" #define OGS_SBI_RESOURCE_NAME_SECURITY_INFORMATION "security-information" #define OGS_SBI_RESOURCE_NAME_GENERATE_AUTH_DATA "generate-auth-data" #define OGS_SBI_RESOURCE_NAME_AUTH_EVENTS "auth-events" -#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_SERVICE_NAME_NUDR_DR "nudr-dr" #define OGS_SBI_RESOURCE_NAME_SUBSCRIPTION_DATA "subscription-data" #define OGS_SBI_RESOURCE_NAME_AUTHENTICATION_DATA "authentication-data" #define OGS_SBI_RESOURCE_NAME_AUTHENTICATION_SUBSCRIPTION \ @@ -120,52 +113,42 @@ #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" -#define OGS_SBI_SERVICE_NAME_NSMF_EVENT_EXPOSURE "nsmf-event-exposure" #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_RESOURCE_NAME_N1_N2_FAILURE_NOTIFY "n1-n2-failure-notify" -#define OGS_SBI_SERVICE_NAME_NAMF_COMM "namf-comm" #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_RESOURCE_NAME_DELETE "delete" -#define OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION \ - "npcf-policyauthorization" #define OGS_SBI_RESOURCE_NAME_APP_SESSIONS "app-sessions" #define OGS_SBI_RESOURCE_NAME_NOTIFY "notify" -#define OGS_SBI_SERVICE_NAME_NPCF_CALLBACK "npcf-callback" #define OGS_SBI_RESOURCE_NAME_UPDATE "update" #define OGS_SBI_RESOURCE_NAME_TERMINATE "terminate" -#define OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION "nnssf-nsselection" #define OGS_SBI_RESOURCE_NAME_NETWORK_SLICE_INFORMATION \ "network-slice-information" -#define OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT "nbsf-management" #define OGS_SBI_RESOURCE_NAME_PCF_BINDINGS "pcfBindings" -#define OGS_SBI_SERVICE_NAME_NAF_EVENTEXPOSURE "naf-eventexposure" #define OGS_SBI_FEATURES_IS_SET(__fEATURES, __n) \ (__fEATURES & (1 << ((__n)-1))) #define OGS_SBI_FEATURES_SET(__fEATURES, __n) \ __fEATURES |= (1 << ((__n)-1)) +#define OGS_SBI_NNRF_NFM_SERVICE_MAP 1 +#define OGS_SBI_NNRF_NFM_EMPTY_OBJECTS_NRF_INFO 2 + #define OGS_SBI_NPCF_AM_POLICY_CONTROL_SLICE_SUPPORT 1 #define OGS_SBI_NPCF_AM_POLICY_CONTROL_PENDING_TRANSACTION 2 #define OGS_SBI_NPCF_AM_POLICY_CONTROL_UE_AMBR_AUTHORIZATION 3 @@ -369,7 +352,7 @@ char *requester_nf_instance_id; int num_of_service_names; - char *service_namesOGS_MAX_NUM_OF_NF_SERVICE; + char *service_namesOGS_SBI_MAX_NUM_OF_SERVICE_TYPE; } ogs_sbi_discovery_option_t; typedef struct ogs_sbi_message_s {
View file
open5gs_2.4.9.tar.xz/lib/sbi/mhd-server.c -> open5gs_2.4.10.tar.xz/lib/sbi/mhd-server.c
Changed
@@ -17,7 +17,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#include "ogs-app.h" #include "ogs-sbi.h" #include "microhttpd.h" @@ -136,7 +135,11 @@ sbi_sess->timer = ogs_timer_add( ogs_app()->timer_mgr, session_timer_expired, sbi_sess); - ogs_assert(sbi_sess->timer); + if (!sbi_sess->timer) { + ogs_error("ogs_timer_add() failed"); + ogs_pool_free(&session_pool, sbi_sess); + return NULL; + } /* If User does not send HTTP response within deadline, * Open5GS will assert this program. */ @@ -371,7 +374,12 @@ hi; hi = ogs_hash_next(hi)) { const char *key = ogs_hash_this_key(hi); char *val = ogs_hash_this_val(hi); - MHD_add_response_header(mhd_response, key, val); + ret = MHD_add_response_header(mhd_response, key, val); + if (ret != MHD_YES) { + ogs_error("MHD_add_response_header failed %d", ret); + MHD_destroy_response(mhd_response); + return false; + } } status = response->status; @@ -386,7 +394,9 @@ ret = MHD_queue_response(connection, status, mhd_response); if (ret != MHD_YES) { - ogs_error("MHD_queue_response_error %d", ret); + ogs_error("MHD_queue_response failed %d", ret); + MHD_destroy_response(mhd_response); + ogs_pollset_remove(request->poll.write); return false; } MHD_destroy_response(mhd_response); @@ -562,7 +572,7 @@ ogs_assert(server->cb); if (server->cb(request, sbi_sess) != OGS_OK) { - ogs_error("server callback error"); + ogs_warn("server callback error"); ogs_assert(true == ogs_sbi_server_send_error((ogs_sbi_stream_t *)sbi_sess, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL,
View file
open5gs_2.4.10.tar.xz/lib/sbi/nf-sm.c
Added
@@ -0,0 +1,449 @@ +/* + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#include "ogs-sbi.h" + +void ogs_sbi_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) +{ + ogs_event_t e; + + ogs_assert(nf_instance); + + memset(&e, 0, sizeof(e)); + e.sbi.data = nf_instance; + + ogs_fsm_init(&nf_instance->sm, + ogs_sbi_nf_state_initial, ogs_sbi_nf_state_final, &e); +} + +void ogs_sbi_nf_fsm_tran(ogs_sbi_nf_instance_t *nf_instance, void *state) +{ + ogs_event_t e; + + ogs_assert(nf_instance); + + memset(&e, 0, sizeof(e)); + e.sbi.data = nf_instance; + + ogs_fsm_tran(&nf_instance->sm, state, &e); +} + +void ogs_sbi_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) +{ + ogs_event_t e; + + ogs_assert(nf_instance); + + memset(&e, 0, sizeof(e)); + e.sbi.data = nf_instance; + + ogs_fsm_fini(&nf_instance->sm, &e); +} + +void ogs_sbi_nf_state_initial(ogs_fsm_t *s, ogs_event_t *e) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + + ogs_assert(s); + ogs_assert(e); + + ogs_sbi_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + + nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, + ogs_timer_nf_instance_registration_interval, nf_instance); + ogs_assert(nf_instance->t_registration_interval); + nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, + ogs_timer_nf_instance_heartbeat_interval, nf_instance); + ogs_assert(nf_instance->t_heartbeat_interval); + nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, + ogs_timer_nf_instance_no_heartbeat, nf_instance); + ogs_assert(nf_instance->t_no_heartbeat); + nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, + ogs_timer_nf_instance_validity, nf_instance); + ogs_assert(nf_instance->t_validity); + + if (NF_INSTANCE_TYPE_IS_NRF(nf_instance)) { + OGS_FSM_TRAN(s, &ogs_sbi_nf_state_will_register); + } else { + ogs_assert(nf_instance->id); + OGS_FSM_TRAN(s, &ogs_sbi_nf_state_registered); + } +} + +void ogs_sbi_nf_state_final(ogs_fsm_t *s, ogs_event_t *e) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + + ogs_assert(s); + ogs_assert(e); + + ogs_sbi_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + + ogs_timer_delete(nf_instance->t_registration_interval); + ogs_timer_delete(nf_instance->t_heartbeat_interval); + ogs_timer_delete(nf_instance->t_no_heartbeat); + ogs_timer_delete(nf_instance->t_validity); +} + +void ogs_sbi_nf_state_will_register(ogs_fsm_t *s, ogs_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); + + ogs_sbi_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + ogs_assert(ogs_sbi_self()->nf_instance); + ogs_assert(NF_INSTANCE_TYPE_IS_NRF(nf_instance)); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + ogs_timer_start(nf_instance->t_registration_interval, + ogs_app()->time.message.sbi.nf_register_interval); + + ogs_assert(true == ogs_nnrf_nfm_send_nf_register(nf_instance)); + break; + + case OGS_FSM_EXIT_SIG: + ogs_timer_stop(nf_instance->t_registration_interval); + break; + + case OGS_EVENT_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.component0) + CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) + + if (message->res_status == OGS_SBI_HTTP_STATUS_OK || + message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { + ogs_sbi_nnrf_handle_nf_register(nf_instance, message); + OGS_FSM_TRAN(s, &ogs_sbi_nf_state_registered); + } else { + ogs_error("%s HTTP Response Status Code %d", + ogs_sbi_self()->nf_instance->id, + message->res_status); + OGS_FSM_TRAN(s, &ogs_sbi_nf_state_exception); + } + break; + + DEFAULT + ogs_error("%s Invalid resource name %s", + ogs_sbi_self()->nf_instance->id, + message->h.resource.component0); + END + break; + + DEFAULT + ogs_error("%s Invalid API name %s", + ogs_sbi_self()->nf_instance->id, message->h.service.name); + END + break; + + case OGS_EVENT_SBI_TIMER: + switch(e->timer_id) { + case OGS_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", + ogs_sbi_self()->nf_instance->id); + + ogs_timer_start(nf_instance->t_registration_interval, + ogs_app()->time.message.sbi.nf_register_interval); + + ogs_assert(true == ogs_nnrf_nfm_send_nf_register(nf_instance)); + break; + + default: + ogs_error("%s Unknown timer%s:%d", + ogs_sbi_self()->nf_instance->id, + ogs_timer_get_name(e->timer_id), e->timer_id); + } + break; + + default: + ogs_error("Unknown event %s", ogs_event_get_name(e)); + break; + } +} + +void ogs_sbi_nf_state_registered(ogs_fsm_t *s, ogs_event_t *e) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_message_t *message = NULL; + ogs_assert(s); + ogs_assert(e); + + ogs_sbi_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + ogs_assert(ogs_sbi_self()->nf_instance); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + if (NF_INSTANCE_TYPE_IS_NRF(nf_instance)) { + ogs_sbi_subscription_data_t *subscription_data = NULL; + + ogs_info("%s NF registered Heartbeat:%ds", + ogs_sbi_self()->nf_instance->id, + nf_instance->time.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_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_list_for_each( + &ogs_sbi_self()->subscription_data_list, subscription_data) { + ogs_assert(true == + ogs_nnrf_nfm_send_nf_status_subscribe(subscription_data)); + } + } + break; + + case OGS_FSM_EXIT_SIG: + if (NF_INSTANCE_TYPE_IS_NRF(nf_instance)) { + ogs_info("%s NF de-registered", ogs_sbi_self()->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, ogs_sbi_nf_state_exception)) { + ogs_assert(true == + ogs_nnrf_nfm_send_nf_de_register(nf_instance)); + } + } + break; + + case OGS_EVENT_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.component0) + 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", + ogs_sbi_self()->nf_instance->id, + message->res_status); + OGS_FSM_TRAN(s, &ogs_sbi_nf_state_exception); + } + + break; + + DEFAULT + ogs_error("%s Invalid resource name %s", + ogs_sbi_self()->nf_instance->id, + message->h.resource.component0); + END + break; + + DEFAULT + ogs_error("%s Invalid API name %s", + ogs_sbi_self()->nf_instance->id, message->h.service.name); + END + break; + + case OGS_EVENT_SBI_TIMER: + switch(e->timer_id) { + case OGS_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_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); + break; + + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); + OGS_FSM_TRAN(s, &ogs_sbi_nf_state_will_register); + break; + + case OGS_TIMER_NF_INSTANCE_VALIDITY: + ogs_assert(!NF_INSTANCE_TYPE_IS_NRF(nf_instance)); + ogs_assert(nf_instance->id); + + ogs_info("%s NF expired", nf_instance->id); + OGS_FSM_TRAN(s, &ogs_sbi_nf_state_de_registered); + break; + + default: + ogs_error("%s:%s Unknown timer%s:%d", + OpenAPI_nf_type_ToString(nf_instance->nf_type), + nf_instance->id ? nf_instance->id : "Undefined", + ogs_timer_get_name(e->timer_id), e->timer_id); + } + break; + + default: + ogs_error("%s:%s Unknown event %s", + OpenAPI_nf_type_ToString(nf_instance->nf_type), + nf_instance->id ? nf_instance->id : "Undefined", + ogs_event_get_name(e)); + break; + } +} + +void ogs_sbi_nf_state_de_registered(ogs_fsm_t *s, ogs_event_t *e) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_assert(s); + ogs_assert(e); + + ogs_sbi_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + ogs_assert(ogs_sbi_self()->nf_instance); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + if (NF_INSTANCE_TYPE_IS_NRF(nf_instance)) { + ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); + } + break; + + case OGS_FSM_EXIT_SIG: + break; + + default: + ogs_error("%s:%s Unknown event %s", + OpenAPI_nf_type_ToString(nf_instance->nf_type), + nf_instance->id ? nf_instance->id : "Undefined", + ogs_event_get_name(e)); + break; + } +} + +void ogs_sbi_nf_state_exception(ogs_fsm_t *s, ogs_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); + + ogs_sbi_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + ogs_assert(ogs_sbi_self()->nf_instance); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + if (NF_INSTANCE_TYPE_IS_NRF(nf_instance)) { + 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_TYPE_IS_NRF(nf_instance)) { + ogs_timer_stop(nf_instance->t_registration_interval); + } + break; + + case OGS_EVENT_SBI_TIMER: + switch(e->timer_id) { + case OGS_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", + ogs_sbi_self()->nf_instance->id); + + OGS_FSM_TRAN(s, &ogs_sbi_nf_state_will_register); + break; + + default: + ogs_error("%s:%s Unknown timer%s:%d", + OpenAPI_nf_type_ToString(nf_instance->nf_type), + nf_instance->id ? nf_instance->id : "Undefined", + ogs_timer_get_name(e->timer_id), e->timer_id); + } + break; + + case OGS_EVENT_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.component0) + CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) + break; + DEFAULT + ogs_error("Invalid resource name %s", + message->h.resource.component0); + END + break; + DEFAULT + ogs_error("Invalid API name %s", message->h.service.name); + END + break; + + default: + ogs_error("%s:%s Unknown event %s", + OpenAPI_nf_type_ToString(nf_instance->nf_type), + nf_instance->id ? nf_instance->id : "Undefined", + ogs_event_get_name(e)); + break; + } +}
View file
open5gs_2.4.10.tar.xz/lib/sbi/nf-sm.h
Added
@@ -0,0 +1,49 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#if !defined(OGS_SBI_INSIDE) && !defined(OGS_SBI_COMPILATION) +#error "This header cannot be included directly." +#endif + +#ifndef OGS_SBI_NF_SM_H +#define OGS_SBI_NF_SM_H + +#ifdef __cplusplus +extern "C" { +#endif + +void ogs_sbi_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); +void ogs_sbi_nf_fsm_tran(ogs_sbi_nf_instance_t *nf_instance, void *state); +void ogs_sbi_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); + +void ogs_sbi_nf_state_initial(ogs_fsm_t *s, ogs_event_t *e); +void ogs_sbi_nf_state_final(ogs_fsm_t *s, ogs_event_t *e); +void ogs_sbi_nf_state_will_register(ogs_fsm_t *s, ogs_event_t *e); +void ogs_sbi_nf_state_registered(ogs_fsm_t *s, ogs_event_t *e); +void ogs_sbi_nf_state_de_registered(ogs_fsm_t *s, ogs_event_t *e); +void ogs_sbi_nf_state_exception(ogs_fsm_t *s, ogs_event_t *e); + +#define ogs_sbi_sm_debug(__e) \ + ogs_debug("%s(): %s", __func__, ogs_event_get_name(__e)) + +#ifdef __cplusplus +} +#endif + +#endif /* OGS_SBI_NF_SM_H */
View file
open5gs_2.4.9.tar.xz/lib/sbi/nghttp2-server.c -> open5gs_2.4.10.tar.xz/lib/sbi/nghttp2-server.c
Changed
@@ -17,7 +17,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#include "ogs-app.h" #include "ogs-sbi.h" #include "yuarel.h" @@ -1112,7 +1111,7 @@ { int rv; nghttp2_settings_entry iv1 = { - { NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, 100 } + { NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, ogs_app()->pool.stream } }; ogs_assert(sbi_sess);
View file
open5gs_2.4.9.tar.xz/lib/sbi/nnrf-build.c -> open5gs_2.4.10.tar.xz/lib/sbi/nnrf-build.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,37 +18,86 @@ */ #include "ogs-sbi.h" -#include "ogs-app.h" -OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(void) +static OpenAPI_nf_service_t *build_nf_service( + ogs_sbi_nf_service_t *nf_service); +static void free_nf_service(OpenAPI_nf_service_t *NFService); +static OpenAPI_smf_info_t *build_smf_info(ogs_sbi_nf_info_t *nf_info); +static void free_smf_info(OpenAPI_smf_info_t *SmfInfo); + +ogs_sbi_request_t *ogs_nnrf_nfm_build_register(void) { ogs_sbi_nf_instance_t *nf_instance = NULL; + + ogs_sbi_message_t message; + ogs_sbi_request_t *request = NULL; + + OpenAPI_nf_profile_t *NFProfile = NULL; + uint64_t supported_features = 0; + + nf_instance = ogs_sbi_self()->nf_instance; + ogs_assert(nf_instance); + ogs_assert(nf_instance->id); + + memset(&message, 0, sizeof(message)); + message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; + message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; + message.h.api.version = (char *)OGS_SBI_API_V1; + message.h.resource.component0 = + (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; + message.h.resource.component1 = nf_instance->id; + + message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; + + OGS_SBI_FEATURES_SET(supported_features, OGS_SBI_NNRF_NFM_SERVICE_MAP); + NFProfile = ogs_nnrf_nfm_build_nf_profile( + ogs_sbi_self()->nf_instance, + NULL, NULL, supported_features); + ogs_expect_or_return_val(NFProfile, NULL); + + message.NFProfile = NFProfile; + + request = ogs_sbi_build_request(&message); + + ogs_nnrf_nfm_free_nf_profile(NFProfile); + + return request; +} + +OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile( + ogs_sbi_nf_instance_t *nf_instance, + const char *service_name, + ogs_sbi_discovery_option_t *discovery_option, + uint64_t supported_features) +{ ogs_sbi_nf_service_t *nf_service = NULL; + ogs_sbi_nf_info_t *nf_info = NULL; OpenAPI_nf_profile_t *NFProfile = NULL; OpenAPI_list_t *Ipv4AddrList = NULL; OpenAPI_list_t *Ipv6AddrList = NULL; OpenAPI_list_t *AllowedNfTypeList = NULL; OpenAPI_list_t *NFServiceList = NULL; + OpenAPI_map_t *NFServiceMap = NULL; + OpenAPI_list_t *SmfInfoList = NULL; + OpenAPI_map_t *SmfInfoMap = NULL; + OpenAPI_smf_info_t *SmfInfo = NULL; + int SmfInfoMapKey; - int i = 0; -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - int fqdn_len; - char fqdnOGS_MAX_FQDN_LEN; -#endif + OpenAPI_lnode_t *node = NULL; + int i = 0; char *ipstr = NULL; - nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); ogs_assert(nf_instance->id); NFProfile = ogs_calloc(1, sizeof(*NFProfile)); ogs_expect_or_return_val(NFProfile, NULL); - NFProfile->nf_instance_id = nf_instance->id; - NFProfile->nf_type = nf_instance->nf_type; - NFProfile->nf_status = nf_instance->nf_status; + NFProfile->nf_instance_id = nf_instance->id; + NFProfile->nf_type = nf_instance->nf_type; + NFProfile->nf_status = nf_instance->nf_status; ogs_trace("%s ogs_nnrf_nfm_build_nf_profile()", nf_instance->id); @@ -64,22 +113,8 @@ NFProfile->is_nf_profile_changes_support_ind = true; NFProfile->nf_profile_changes_support_ind = true; - if (nf_instance->fqdn) { -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - memset(fqdn, 0, sizeof(fqdn)); - fqdn_len = ogs_fqdn_build(fqdn, - nf_instance->fqdn, strlen(nf_instance->fqdn)); - NFProfile->fqdn = ogs_memdup(fqdn, fqdn_len+1); - ogs_expect_or_return_val(NFProfile->fqdn, NULL); - NFProfile->fqdnfqdn_len = 0; - - ogs_debug("NFInstance-FQDN%s", nf_instance->fqdn); - ogs_log_hexdump(OGS_LOG_DEBUG, - (unsigned char *)NFProfile->fqdn, fqdn_len); -#else + if (nf_instance->fqdn) NFProfile->fqdn = ogs_strdup(nf_instance->fqdn); -#endif - } NFProfile->is_priority = true; NFProfile->priority = nf_instance->priority; @@ -131,7 +166,7 @@ for (i = 0; i < nf_instance->num_of_allowed_nf_type; i++) { OpenAPI_list_add(AllowedNfTypeList, - (void *)(uintptr_t)nf_instance->allowed_nf_typesi); + (void *)(uintptr_t)nf_instance->allowed_nf_typei); } if (AllowedNfTypeList->count) @@ -144,141 +179,111 @@ ogs_list_for_each(&nf_instance->nf_service_list, nf_service) { OpenAPI_nf_service_t *NFService = NULL; - OpenAPI_list_t *VersionList = NULL; - OpenAPI_list_t *IpEndPointList = NULL; - OpenAPI_list_t *AllowedNfTypeList = NULL; - NFService = ogs_calloc(1, sizeof(*NFService)); - ogs_expect_or_return_val(NFService, NULL); - NFService->service_instance_id = ogs_strdup(nf_service->id); - ogs_expect_or_return_val(NFService->service_instance_id, NULL); - NFService->service_name = ogs_strdup(nf_service->name); - ogs_expect_or_return_val(NFService->service_name, NULL); - - VersionList = OpenAPI_list_create(); - ogs_assert(VersionList); - - for (i = 0; i < nf_service->num_of_version; i++) { - OpenAPI_nf_service_version_t *NFServiceVersion = NULL; - - NFServiceVersion = ogs_calloc(1, sizeof(*NFServiceVersion)); - ogs_expect_or_return_val(NFServiceVersion, NULL); - if (nf_service->versionsi.in_uri) { - NFServiceVersion->api_version_in_uri = - ogs_strdup(nf_service->versionsi.in_uri); - ogs_expect_or_return_val( - NFServiceVersion->api_version_in_uri, NULL); - } - if (nf_service->versionsi.full) { - NFServiceVersion->api_full_version = - ogs_strdup(nf_service->versionsi.full); - ogs_expect_or_return_val( - NFServiceVersion->api_full_version, NULL); - } - if (nf_service->versionsi.expiry) { - NFServiceVersion->expiry = - ogs_strdup(nf_service->versionsi.expiry); - ogs_expect_or_return_val( - NFServiceVersion->expiry, NULL); + if (service_name && nf_service->name && + strcmp(service_name, nf_service->name) != 0) + continue; + + if (discovery_option && discovery_option->num_of_service_names) { + for (i = 0; i < discovery_option->num_of_service_names; i++) { + if (nf_service->name && + discovery_option->service_namesi && + strcmp(nf_service->name, + discovery_option->service_namesi) == 0) { + break; + } } - OpenAPI_list_add(VersionList, NFServiceVersion); + if (i == discovery_option->num_of_service_names) + continue; } - ogs_assert(VersionList->count); - NFService->versions = VersionList; + NFService = build_nf_service(nf_service); + ogs_expect_or_return_val(NFService, NULL); - NFService->scheme = nf_service->scheme; - NFService->nf_service_status = nf_service->status; + if (OGS_SBI_FEATURES_IS_SET( + supported_features, OGS_SBI_NNRF_NFM_SERVICE_MAP)) { + NFServiceMap = OpenAPI_map_create(nf_service->id, NFService); + ogs_assert(NFServiceMap); + + OpenAPI_list_add(NFServiceList, NFServiceMap); + } else { + OpenAPI_list_add(NFServiceList, NFService); + } + } - if (nf_service->fqdn) { -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - memset(fqdn, 0, sizeof(fqdn)); - fqdn_len = ogs_fqdn_build(fqdn, - nf_service->fqdn, strlen(nf_service->fqdn)); - NFService->fqdn = ogs_memdup(fqdn, fqdn_len+1); - ogs_expect_or_return_val(NFService->fqdn, NULL); - NFService->fqdnfqdn_len = 0; - - ogs_debug("NFService-FQDN%s", nf_service->fqdn); - ogs_log_hexdump(OGS_LOG_DEBUG, - (unsigned char *)NFService->fqdn, fqdn_len); -#else - NFService->fqdn = ogs_strdup(nf_service->fqdn); -#endif - } - - IpEndPointList = OpenAPI_list_create(); - ogs_assert(IpEndPointList); - - for (i = 0; i < nf_service->num_of_addr; i++) { - ogs_sockaddr_t *ipv4 = NULL; - ogs_sockaddr_t *ipv6 = NULL; - - OpenAPI_ip_end_point_t *IpEndPoint = NULL; - - ipv4 = nf_service->addri.ipv4; - ipv6 = nf_service->addri.ipv6; - - if (ipv4 || ipv6) { - IpEndPoint = ogs_calloc(1, sizeof(*IpEndPoint)); - ogs_expect_or_return_val(IpEndPoint, NULL); - if (ipv4) { - IpEndPoint->ipv4_address = ogs_ipstrdup(ipv4); - ogs_expect_or_return_val(IpEndPoint->ipv4_address, NULL); - } - if (ipv6) { - IpEndPoint->ipv6_address = ogs_ipstrdup(ipv6); - ogs_expect_or_return_val(IpEndPoint->ipv6_address, NULL); - } - IpEndPoint->is_port = true; - IpEndPoint->port = nf_service->addri.port; - OpenAPI_list_add(IpEndPointList, IpEndPoint); - } + if (NFServiceList->count) { + if (OGS_SBI_FEATURES_IS_SET( + supported_features, OGS_SBI_NNRF_NFM_SERVICE_MAP)) { + NFProfile->nf_service_list = NFServiceList; + } else { + NFProfile->nf_services = NFServiceList; } + } else + OpenAPI_list_free(NFServiceList); - if (IpEndPointList->count) - NFService->ip_end_points = IpEndPointList; - else - OpenAPI_list_free(IpEndPointList); + SmfInfoList = OpenAPI_list_create(); + ogs_assert(SmfInfoList); - AllowedNfTypeList = OpenAPI_list_create(); - ogs_assert(AllowedNfTypeList); + SmfInfoMapKey = 0; - for (i = 0; i < nf_service->num_of_allowed_nf_type; i++) { - OpenAPI_list_add(AllowedNfTypeList, - (void *)(uintptr_t)nf_service->allowed_nf_typesi); - } + ogs_list_for_each(&nf_instance->nf_info_list, nf_info) { + if (nf_info->nf_type == OpenAPI_nf_type_SMF) { - if (AllowedNfTypeList->count) - NFService->allowed_nf_types = AllowedNfTypeList; - else - OpenAPI_list_free(AllowedNfTypeList); + if (nf_info->smf.num_of_slice == 0) { + ogs_fatal("CHECK CONFIGURATION: No S-NSSAI"); + ogs_assert_if_reached(); + } - NFService->is_priority = true; - NFService->priority = nf_service->priority; - NFService->is_capacity = true; - NFService->capacity = nf_service->capacity; - NFService->is_load = true; - NFService->load = nf_service->load; + SmfInfo = build_smf_info(nf_info); + ogs_expect_or_return_val(SmfInfo, NULL); - OpenAPI_list_add(NFServiceList, NFService); + SmfInfoMap = OpenAPI_map_create( + ogs_msprintf("%d", ++SmfInfoMapKey), SmfInfo); + ogs_assert(SmfInfoMap); + + OpenAPI_list_add(SmfInfoList, SmfInfoMap); + + } else { + ogs_fatal("Not implemented NF-type%s", + OpenAPI_nf_type_ToString(nf_info->nf_type)); + ogs_assert_if_reached(); + } } - if (NFServiceList->count) - NFProfile->nf_services = NFServiceList; - else - OpenAPI_list_free(NFServiceList); + if (SmfInfoList->count == 1) { + NFProfile->smf_info = SmfInfo; + + OpenAPI_list_for_each(SmfInfoList, node) { + SmfInfoMap = node->data; + if (SmfInfoMap) { + if (SmfInfoMap->key) + ogs_free(SmfInfoMap->key); + ogs_free(SmfInfoMap); + } + } + OpenAPI_list_free(SmfInfoList); + } else if (SmfInfoList->count > 1) { + NFProfile->smf_info_list = SmfInfoList; + } else + OpenAPI_list_free(SmfInfoList); return NFProfile; } -void ogs_sbi_nnrf_free_nf_profile(OpenAPI_nf_profile_t *NFProfile) +void ogs_nnrf_nfm_free_nf_profile(OpenAPI_nf_profile_t *NFProfile) { + OpenAPI_map_t *NFServiceMap = NULL; + OpenAPI_nf_service_t *NFService = NULL; + OpenAPI_map_t *SmfInfoMap = NULL; + OpenAPI_smf_info_t *SmfInfo = NULL; OpenAPI_lnode_t *node = NULL; ogs_assert(NFProfile); + if (NFProfile->fqdn) + ogs_free(NFProfile->fqdn); + OpenAPI_list_for_each(NFProfile->ipv4_addresses, node) ogs_free(node->data); OpenAPI_list_free(NFProfile->ipv4_addresses); @@ -289,48 +294,415 @@ OpenAPI_list_free(NFProfile->allowed_nf_types); OpenAPI_list_for_each(NFProfile->nf_services, node) { - OpenAPI_lnode_t *node2; - OpenAPI_nf_service_t *NFService = node->data; + NFService = node->data; ogs_assert(NFService); + free_nf_service(NFService); + } + OpenAPI_list_free(NFProfile->nf_services); - ogs_free(NFService->service_instance_id); - ogs_free(NFService->service_name); + OpenAPI_list_for_each(NFProfile->nf_service_list, node) { + NFServiceMap = node->data; + if (NFServiceMap) { + NFService = NFServiceMap->value; + ogs_assert(NFService); + free_nf_service(NFService); + ogs_free(NFServiceMap); + } + } + OpenAPI_list_free(NFProfile->nf_service_list); - OpenAPI_list_for_each(NFService->versions, node2) { - OpenAPI_nf_service_version_t *NFServiceVersion = node2->data; - ogs_assert(NFServiceVersion); - ogs_free(NFServiceVersion->api_version_in_uri); - ogs_free(NFServiceVersion->api_full_version); - if (NFServiceVersion->expiry) - ogs_free(NFServiceVersion->expiry); - ogs_free(NFServiceVersion); - } - OpenAPI_list_free(NFService->versions); - - OpenAPI_list_for_each(NFService->ip_end_points, node2) { - OpenAPI_ip_end_point_t *IpEndPoint = node2->data; - ogs_assert(IpEndPoint); - if (IpEndPoint->ipv4_address) - ogs_free(IpEndPoint->ipv4_address); - if (IpEndPoint->ipv6_address) - ogs_free(IpEndPoint->ipv6_address); - ogs_free(IpEndPoint); + OpenAPI_list_for_each(NFProfile->smf_info_list, node) { + SmfInfoMap = node->data; + if (SmfInfoMap) { + SmfInfo = SmfInfoMap->value; + if (SmfInfo) + free_smf_info(SmfInfo); + if (SmfInfoMap->key) + ogs_free(SmfInfoMap->key); + ogs_free(SmfInfoMap); } - OpenAPI_list_free(NFService->ip_end_points); + } + OpenAPI_list_free(NFProfile->smf_info_list); + + if (NFProfile->smf_info) + free_smf_info(NFProfile->smf_info); + + ogs_free(NFProfile); +} - OpenAPI_list_free(NFService->allowed_nf_types); +static OpenAPI_nf_service_t *build_nf_service( + ogs_sbi_nf_service_t *nf_service) +{ + int i; + OpenAPI_nf_service_t *NFService = NULL; + OpenAPI_list_t *VersionList = NULL; + OpenAPI_list_t *IpEndPointList = NULL; + OpenAPI_list_t *AllowedNfTypeList = NULL; - if (NFService->fqdn) - ogs_free(NFService->fqdn); + ogs_assert(nf_service); + ogs_assert(nf_service->id); + ogs_assert(nf_service->name); + + NFService = ogs_calloc(1, sizeof(*NFService)); + ogs_expect_or_return_val(NFService, NULL); + NFService->service_instance_id = ogs_strdup(nf_service->id); + ogs_expect_or_return_val(NFService->service_instance_id, NULL); + NFService->service_name = ogs_strdup(nf_service->name); + ogs_expect_or_return_val(NFService->service_name, NULL); + + VersionList = OpenAPI_list_create(); + ogs_assert(VersionList); + + for (i = 0; i < nf_service->num_of_version; i++) { + OpenAPI_nf_service_version_t *NFServiceVersion = NULL; + + NFServiceVersion = ogs_calloc(1, sizeof(*NFServiceVersion)); + ogs_expect_or_return_val(NFServiceVersion, NULL); + if (nf_service->versioni.in_uri) { + NFServiceVersion->api_version_in_uri = + ogs_strdup(nf_service->versioni.in_uri); + ogs_expect_or_return_val( + NFServiceVersion->api_version_in_uri, NULL); + } + if (nf_service->versioni.full) { + NFServiceVersion->api_full_version = + ogs_strdup(nf_service->versioni.full); + ogs_expect_or_return_val( + NFServiceVersion->api_full_version, NULL); + } + if (nf_service->versioni.expiry) { + NFServiceVersion->expiry = + ogs_strdup(nf_service->versioni.expiry); + ogs_expect_or_return_val( + NFServiceVersion->expiry, NULL); + } - ogs_free(NFService); + OpenAPI_list_add(VersionList, NFServiceVersion); } - OpenAPI_list_free(NFProfile->nf_services); - if (NFProfile->fqdn) - ogs_free(NFProfile->fqdn); + ogs_assert(VersionList->count); + NFService->versions = VersionList; - ogs_free(NFProfile); + NFService->scheme = nf_service->scheme; + NFService->nf_service_status = nf_service->status; + + if (nf_service->fqdn) + NFService->fqdn = ogs_strdup(nf_service->fqdn); + + IpEndPointList = OpenAPI_list_create(); + ogs_assert(IpEndPointList); + + for (i = 0; i < nf_service->num_of_addr; i++) { + ogs_sockaddr_t *ipv4 = NULL; + ogs_sockaddr_t *ipv6 = NULL; + + OpenAPI_ip_end_point_t *IpEndPoint = NULL; + + ipv4 = nf_service->addri.ipv4; + ipv6 = nf_service->addri.ipv6; + + if (ipv4 || ipv6) { + IpEndPoint = ogs_calloc(1, sizeof(*IpEndPoint)); + ogs_expect_or_return_val(IpEndPoint, NULL); + if (ipv4) { + IpEndPoint->ipv4_address = ogs_ipstrdup(ipv4); + ogs_expect_or_return_val(IpEndPoint->ipv4_address, NULL); + } + if (ipv6) { + IpEndPoint->ipv6_address = ogs_ipstrdup(ipv6); + ogs_expect_or_return_val(IpEndPoint->ipv6_address, NULL); + } + IpEndPoint->is_port = true; + IpEndPoint->port = nf_service->addri.port; + OpenAPI_list_add(IpEndPointList, IpEndPoint); + } + } + + if (IpEndPointList->count) + NFService->ip_end_points = IpEndPointList; + else + OpenAPI_list_free(IpEndPointList); + + AllowedNfTypeList = OpenAPI_list_create(); + ogs_assert(AllowedNfTypeList); + + for (i = 0; i < nf_service->num_of_allowed_nf_type; i++) { + OpenAPI_list_add(AllowedNfTypeList, + (void *)(uintptr_t)nf_service->allowed_nf_typei); + } + + if (AllowedNfTypeList->count) + NFService->allowed_nf_types = AllowedNfTypeList; + else + OpenAPI_list_free(AllowedNfTypeList); + + NFService->is_priority = true; + NFService->priority = nf_service->priority; + NFService->is_capacity = true; + NFService->capacity = nf_service->capacity; + NFService->is_load = true; + NFService->load = nf_service->load; + + return NFService; +} + +static void free_nf_service(OpenAPI_nf_service_t *NFService) +{ + OpenAPI_lnode_t *node = NULL; + + ogs_assert(NFService); + + ogs_free(NFService->service_instance_id); + ogs_free(NFService->service_name); + + OpenAPI_list_for_each(NFService->versions, node) { + OpenAPI_nf_service_version_t *NFServiceVersion = node->data; + ogs_assert(NFServiceVersion); + ogs_free(NFServiceVersion->api_version_in_uri); + ogs_free(NFServiceVersion->api_full_version); + if (NFServiceVersion->expiry) + ogs_free(NFServiceVersion->expiry); + ogs_free(NFServiceVersion); + } + OpenAPI_list_free(NFService->versions); + + OpenAPI_list_for_each(NFService->ip_end_points, node) { + OpenAPI_ip_end_point_t *IpEndPoint = node->data; + ogs_assert(IpEndPoint); + if (IpEndPoint->ipv4_address) + ogs_free(IpEndPoint->ipv4_address); + if (IpEndPoint->ipv6_address) + ogs_free(IpEndPoint->ipv6_address); + ogs_free(IpEndPoint); + } + OpenAPI_list_free(NFService->ip_end_points); + + OpenAPI_list_free(NFService->allowed_nf_types); + + if (NFService->fqdn) + ogs_free(NFService->fqdn); + + ogs_free(NFService); +} + +static OpenAPI_smf_info_t *build_smf_info(ogs_sbi_nf_info_t *nf_info) +{ + int i, j; + OpenAPI_smf_info_t *SmfInfo = NULL; + + OpenAPI_list_t *sNssaiSmfInfoList = NULL; + OpenAPI_snssai_smf_info_item_t *sNssaiSmfInfoItem = NULL; + OpenAPI_snssai_t *sNssai = NULL; + OpenAPI_list_t *DnnSmfInfoList = NULL; + OpenAPI_dnn_smf_info_item_t *DnnSmfInfoItem = NULL; + + OpenAPI_list_t *TaiList = NULL; + OpenAPI_tai_t *TaiItem = NULL; + OpenAPI_list_t *TaiRangeList = NULL; + OpenAPI_tai_range_t *TaiRangeItem = NULL; + OpenAPI_list_t *TacRangeList = NULL; + OpenAPI_tac_range_t *TacRangeItem = NULL; + + ogs_assert(nf_info); + + SmfInfo = ogs_calloc(1, sizeof(*SmfInfo)); + ogs_expect_or_return_val(SmfInfo, NULL); + + sNssaiSmfInfoList = OpenAPI_list_create(); + ogs_assert(sNssaiSmfInfoList); + + for (i = 0; i < nf_info->smf.num_of_slice; i++) { + DnnSmfInfoList = OpenAPI_list_create(); + ogs_assert(DnnSmfInfoList); + + for (j = 0; j < nf_info->smf.slicei.num_of_dnn; j++) { + DnnSmfInfoItem = ogs_calloc(1, sizeof(*DnnSmfInfoItem)); + ogs_expect_or_return_val(DnnSmfInfoItem, NULL); + DnnSmfInfoItem->dnn = nf_info->smf.slicei.dnnj; + + OpenAPI_list_add(DnnSmfInfoList, DnnSmfInfoItem); + } + + if (!DnnSmfInfoList->count) { + OpenAPI_list_free(DnnSmfInfoList); + + ogs_error("CHECK CONFIGURATION: No DNN"); + ogs_expect_or_return_val(0, NULL); + } + + sNssaiSmfInfoItem = ogs_calloc(1, sizeof(*sNssaiSmfInfoItem)); + ogs_expect_or_return_val(sNssaiSmfInfoItem, NULL); + + sNssaiSmfInfoItem->dnn_smf_info_list = DnnSmfInfoList; + + sNssaiSmfInfoItem->s_nssai = sNssai = + ogs_calloc(1, sizeof(*sNssai)); + ogs_expect_or_return_val(sNssai, NULL); + sNssai->sst = nf_info->smf.slicei.s_nssai.sst; + sNssai->sd = + ogs_s_nssai_sd_to_string(nf_info->smf.slicei.s_nssai.sd); + + OpenAPI_list_add(sNssaiSmfInfoList, sNssaiSmfInfoItem); + } + + if (sNssaiSmfInfoList->count) + SmfInfo->s_nssai_smf_info_list = sNssaiSmfInfoList; + else + OpenAPI_list_free(sNssaiSmfInfoList); + + TaiList = OpenAPI_list_create(); + ogs_assert(TaiList); + + for (i = 0; i < nf_info->smf.num_of_nr_tai; i++) { + TaiItem = ogs_calloc(1, sizeof(*TaiItem)); + ogs_expect_or_return_val(TaiItem, NULL); + TaiItem->plmn_id = ogs_sbi_build_plmn_id( + &nf_info->smf.nr_taii.plmn_id); + ogs_expect_or_return_val(TaiItem->plmn_id, NULL); + TaiItem->tac = + ogs_uint24_to_0string(nf_info->smf.nr_taii.tac); + ogs_expect_or_return_val(TaiItem->tac, NULL); + + OpenAPI_list_add(TaiList, TaiItem); + } + + if (TaiList->count) + SmfInfo->tai_list = TaiList; + else + OpenAPI_list_free(TaiList); + + TaiRangeList = OpenAPI_list_create(); + ogs_assert(TaiRangeList); + + for (i = 0; i < nf_info->smf.num_of_nr_tai_range; i++) { + TacRangeList = OpenAPI_list_create(); + ogs_assert(TacRangeList); + + for (j = 0; + j < nf_info->smf.nr_tai_rangei.num_of_tac_range; + j++) { + TacRangeItem = ogs_calloc(1, sizeof(*TacRangeItem)); + ogs_expect_or_return_val(TacRangeItem, NULL); + + TacRangeItem->start = ogs_uint24_to_0string( + nf_info->smf.nr_tai_rangei.startj); + ogs_expect_or_return_val(TacRangeItem->start, NULL); + TacRangeItem->end = + ogs_uint24_to_0string( + nf_info->smf.nr_tai_rangei.endj); + ogs_expect_or_return_val(TacRangeItem->end, NULL); + + OpenAPI_list_add(TacRangeList, TacRangeItem); + } + + if (!TacRangeList->count) { + OpenAPI_list_free(TacRangeList); + + ogs_error("CHECK CONFIGURATION: No Start/End in TacRange"); + ogs_expect_or_return_val(0, NULL); + } + + TaiRangeItem = ogs_calloc(1, sizeof(*TaiRangeItem)); + ogs_expect_or_return_val(TaiRangeItem, NULL); + + TaiRangeItem->plmn_id = ogs_sbi_build_plmn_id( + &nf_info->smf.nr_tai_rangei.plmn_id); + ogs_expect_or_return_val(TaiRangeItem->plmn_id, NULL); + + TaiRangeItem->tac_range_list = TacRangeList; + + OpenAPI_list_add(TaiRangeList, TaiRangeItem); + } + + if (TaiRangeList->count) + SmfInfo->tai_range_list = TaiRangeList; + else + OpenAPI_list_free(TaiRangeList); + + return SmfInfo; +} + +static void free_smf_info(OpenAPI_smf_info_t *SmfInfo) +{ + OpenAPI_list_t *sNssaiSmfInfoList = NULL; + OpenAPI_snssai_smf_info_item_t *sNssaiSmfInfoItem = NULL; + OpenAPI_snssai_t *sNssai = NULL; + OpenAPI_list_t *DnnSmfInfoList = NULL; + OpenAPI_dnn_smf_info_item_t *DnnSmfInfoItem = NULL; + + OpenAPI_list_t *TaiList = NULL; + OpenAPI_tai_t *TaiItem = NULL; + OpenAPI_list_t *TaiRangeList = NULL; + OpenAPI_tai_range_t *TaiRangeItem = NULL; + OpenAPI_list_t *TacRangeList = NULL; + OpenAPI_tac_range_t *TacRangeItem = NULL; + + OpenAPI_lnode_t *node = NULL, *node2 = NULL; + + ogs_assert(SmfInfo); + + sNssaiSmfInfoList = SmfInfo->s_nssai_smf_info_list; + OpenAPI_list_for_each(sNssaiSmfInfoList, node) { + sNssaiSmfInfoItem = node->data; + ogs_assert(sNssaiSmfInfoItem); + + DnnSmfInfoList = sNssaiSmfInfoItem->dnn_smf_info_list; + OpenAPI_list_for_each(DnnSmfInfoList, node2) { + DnnSmfInfoItem = node2->data; + ogs_assert(DnnSmfInfoItem); + ogs_free(DnnSmfInfoItem); + } + OpenAPI_list_free(DnnSmfInfoList); + + sNssai = sNssaiSmfInfoItem->s_nssai; + if (sNssai) { + if (sNssai->sd) + ogs_free(sNssai->sd); + ogs_free(sNssai); + } + + ogs_free(sNssaiSmfInfoItem); + } + OpenAPI_list_free(sNssaiSmfInfoList); + + TaiList = SmfInfo->tai_list; + OpenAPI_list_for_each(TaiList, node) { + TaiItem = node->data; + ogs_assert(TaiItem); + if (TaiItem->plmn_id) + ogs_sbi_free_plmn_id(TaiItem->plmn_id); + if (TaiItem->tac) + ogs_free(TaiItem->tac); + ogs_free(TaiItem); + } + OpenAPI_list_free(TaiList); + + TaiRangeList = SmfInfo->tai_range_list; + OpenAPI_list_for_each(TaiRangeList, node) { + TaiRangeItem = node->data; + ogs_assert(TaiRangeItem); + + if (TaiRangeItem->plmn_id) + ogs_sbi_free_plmn_id(TaiRangeItem->plmn_id); + + TacRangeList = TaiRangeItem->tac_range_list; + OpenAPI_list_for_each(TacRangeList, node2) { + TacRangeItem = node2->data; + ogs_assert(TacRangeItem); + if (TacRangeItem->start) + ogs_free(TacRangeItem->start); + if (TacRangeItem->end) + ogs_free(TacRangeItem->end); + + ogs_free(TacRangeItem); + } + OpenAPI_list_free(TacRangeList); + + ogs_free(TaiRangeItem); + } + OpenAPI_list_free(TaiRangeList); + + ogs_free(SmfInfo); } ogs_sbi_request_t *ogs_nnrf_nfm_build_update(void) @@ -404,7 +776,7 @@ } ogs_sbi_request_t *ogs_nnrf_nfm_build_status_subscribe( - ogs_sbi_subscription_t *subscription) + ogs_sbi_subscription_data_t *subscription_data) { ogs_sbi_message_t message; ogs_sbi_header_t header; @@ -414,8 +786,8 @@ OpenAPI_subscription_data_t *SubscriptionData = NULL; OpenAPI_subscription_data_subscr_cond_t SubscrCond; - ogs_assert(subscription); - ogs_assert(subscription->req_nf_type); + ogs_assert(subscription_data); + ogs_assert(subscription_data->req_nf_type); memset(&message, 0, sizeof(message)); message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST; @@ -440,12 +812,23 @@ ogs_expect_or_return_val( SubscriptionData->nf_status_notification_uri, NULL); - SubscriptionData->req_nf_type = subscription->req_nf_type; - SubscriptionData->req_nf_instance_id = subscription->req_nf_instance_id; + SubscriptionData->req_nf_type = subscription_data->req_nf_type; + SubscriptionData->req_nf_instance_id = + subscription_data->req_nf_instance_id; + + OGS_SBI_FEATURES_SET(subscription_data->requester_features, + OGS_SBI_NNRF_NFM_SERVICE_MAP); + SubscriptionData->requester_features = + ogs_uint64_to_string(subscription_data->requester_features); + ogs_expect_or_return_val(SubscriptionData->requester_features, NULL); memset(&SubscrCond, 0, sizeof(SubscrCond)); - if (subscription->subscr_cond.nf_type) { - SubscrCond.nf_type = subscription->subscr_cond.nf_type; + if (subscription_data->subscr_cond.nf_type) { + SubscrCond.nf_type = subscription_data->subscr_cond.nf_type; + SubscriptionData->subscr_cond = &SubscrCond; + } + if (subscription_data->subscr_cond.service_name) { + SubscrCond.service_name = subscription_data->subscr_cond.service_name; SubscriptionData->subscr_cond = &SubscrCond; } @@ -454,18 +837,20 @@ request = ogs_sbi_build_request(&message); ogs_free(SubscriptionData->nf_status_notification_uri); + ogs_free(SubscriptionData->requester_features); ogs_free(SubscriptionData); return request; } ogs_sbi_request_t *ogs_nnrf_nfm_build_status_unsubscribe( - ogs_sbi_subscription_t *subscription) + ogs_sbi_subscription_data_t *subscription_data) { ogs_sbi_message_t message; ogs_sbi_request_t *request = NULL; - ogs_assert(subscription); + ogs_assert(subscription_data); + ogs_assert(subscription_data->id); memset(&message, 0, sizeof(message)); message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE; @@ -473,7 +858,7 @@ message.h.api.version = (char *)OGS_SBI_API_V1; message.h.resource.component0 = (char *)OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS; - message.h.resource.component1 = subscription->id; + message.h.resource.component1 = subscription_data->id; request = ogs_sbi_build_request(&message); @@ -501,13 +886,18 @@ } ogs_sbi_request_t *ogs_nnrf_disc_build_discover( - OpenAPI_nf_type_e target_nf_type, OpenAPI_nf_type_e requester_nf_type, + OpenAPI_nf_type_e target_nf_type, ogs_sbi_discovery_option_t *discovery_option) { ogs_sbi_message_t message; ogs_sbi_request_t *request = NULL; + OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; + ogs_assert(target_nf_type); + + ogs_assert(ogs_sbi_self()->nf_instance); + requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; ogs_assert(requester_nf_type); memset(&message, 0, sizeof(message));
View file
open5gs_2.4.9.tar.xz/lib/sbi/nnrf-build.h -> open5gs_2.4.10.tar.xz/lib/sbi/nnrf-build.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -24,20 +24,25 @@ extern "C" { #endif -OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(void); -void ogs_sbi_nnrf_free_nf_profile(OpenAPI_nf_profile_t *NFProfile); +OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile( + ogs_sbi_nf_instance_t *nf_instance, + const char *service_name, + ogs_sbi_discovery_option_t *discovery_option, + uint64_t supported_features); +void ogs_nnrf_nfm_free_nf_profile(OpenAPI_nf_profile_t *NFProfile); +ogs_sbi_request_t *ogs_nnrf_nfm_build_register(void); ogs_sbi_request_t *ogs_nnrf_nfm_build_update(void); ogs_sbi_request_t *ogs_nnrf_nfm_build_de_register(void); ogs_sbi_request_t *ogs_nnrf_nfm_build_status_subscribe( - ogs_sbi_subscription_t *subscription); + ogs_sbi_subscription_data_t *subscription_data); ogs_sbi_request_t *ogs_nnrf_nfm_build_status_unsubscribe( - ogs_sbi_subscription_t *subscription); + ogs_sbi_subscription_data_t *subscription_data); ogs_sbi_request_t *ogs_nnrf_nfm_build_profile_retrieve(char *nf_instance_id); ogs_sbi_request_t *ogs_nnrf_disc_build_discover( - OpenAPI_nf_type_e target_nf_type, OpenAPI_nf_type_e requester_nf_type, + OpenAPI_nf_type_e target_nf_type, ogs_sbi_discovery_option_t *discovery_option); #ifdef __cplusplus
View file
open5gs_2.4.9.tar.xz/lib/sbi/nnrf-handler.c -> open5gs_2.4.10.tar.xz/lib/sbi/nnrf-handler.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,7 +18,305 @@ */ #include "ogs-sbi.h" -#include "ogs-app.h" + +static void handle_nf_service( + ogs_sbi_nf_service_t *nf_service, OpenAPI_nf_service_t *NFService); +static void handle_smf_info( + ogs_sbi_nf_instance_t *nf_instance, OpenAPI_smf_info_t *SmfInfo); + +void ogs_sbi_nnrf_handle_nf_register( + ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) +{ + OpenAPI_nf_profile_t *NFProfile = NULL; + ogs_sbi_client_t *client = NULL; + + ogs_assert(recvmsg); + ogs_assert(nf_instance); + client = nf_instance->client; + ogs_assert(client); + + NFProfile = recvmsg->NFProfile; + if (!NFProfile) { + ogs_error("No NFProfile"); + return; + } + + /* TIME : Update heartbeat from NRF */ + if (NFProfile->is_heart_beat_timer == true) + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; +} + +void ogs_sbi_nnrf_handle_nf_profile( + ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_profile_t *NFProfile) +{ + int rv; + OpenAPI_lnode_t *node; + + ogs_assert(nf_instance); + ogs_assert(NFProfile); + ogs_assert(NFProfile->nf_instance_id); + ogs_assert(NFProfile->nf_type); + ogs_assert(NFProfile->nf_status); + + ogs_sbi_nf_instance_clear(nf_instance); + + nf_instance->nf_type = NFProfile->nf_type; + nf_instance->nf_status = NFProfile->nf_status; + if (NFProfile->is_heart_beat_timer == true) + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + + if (NFProfile->fqdn) + nf_instance->fqdn = ogs_strdup(NFProfile->fqdn); + + if (NFProfile->is_priority == true) + nf_instance->priority = NFProfile->priority; + if (NFProfile->is_capacity == true) + nf_instance->capacity = NFProfile->capacity; + if (NFProfile->is_load == true) + nf_instance->load = NFProfile->load; + + OpenAPI_list_for_each(NFProfile->ipv4_addresses, node) { + ogs_sockaddr_t *addr = NULL; + + if (!node->data) { + ogs_error("No IPv4 Address"); + continue; + } + + if (nf_instance->num_of_ipv4 < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) { + + rv = ogs_getaddrinfo(&addr, AF_UNSPEC, + node->data, ogs_sbi_self()->sbi_port, 0); + if (rv != OGS_OK) continue; + + nf_instance->ipv4nf_instance->num_of_ipv4 = addr; + nf_instance->num_of_ipv4++; + } + } + OpenAPI_list_for_each(NFProfile->ipv6_addresses, node) { + ogs_sockaddr_t *addr = NULL; + + if (!node->data) { + ogs_error("No IPv6 Address"); + continue; + } + + if (nf_instance->num_of_ipv6 < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) { + + rv = ogs_getaddrinfo(&addr, AF_UNSPEC, + node->data, ogs_sbi_self()->sbi_port, 0); + if (rv != OGS_OK) continue; + + nf_instance->ipv6nf_instance->num_of_ipv6 = addr; + nf_instance->num_of_ipv6++; + } + } + + OpenAPI_list_for_each(NFProfile->allowed_nf_types, node) { + OpenAPI_nf_type_e AllowedNfType = (uintptr_t)node->data; + + if (!AllowedNfType) { + ogs_error("AllowedNfType"); + continue; + } + + if (nf_instance->num_of_allowed_nf_type < + OGS_SBI_MAX_NUM_OF_NF_TYPE) { + nf_instance->allowed_nf_type + nf_instance->num_of_allowed_nf_type = AllowedNfType; + nf_instance->num_of_allowed_nf_type++; + } + } + + OpenAPI_list_for_each(NFProfile->nf_services, node) { + ogs_sbi_nf_service_t *nf_service = NULL; + OpenAPI_nf_service_t *NFService = node->data; + + if (!NFService) { + ogs_error("No NFService"); + continue; + } + + if (!NFService->service_instance_id) { + ogs_error("No NFService.service_instance_id"); + continue; + } + + if (!NFService->service_name) { + ogs_error("No NFService.service_name"); + continue; + } + + nf_service = ogs_sbi_nf_service_find_by_id( + nf_instance, NFService->service_instance_id); + if (!nf_service) { + nf_service = ogs_sbi_nf_service_add( + nf_instance, + NFService->service_instance_id, + NFService->service_name, NFService->scheme); + ogs_assert(nf_service); + } + + ogs_sbi_nf_service_clear(nf_service); + + handle_nf_service(nf_service, NFService); + } + + OpenAPI_list_for_each(NFProfile->nf_service_list, node) { + ogs_sbi_nf_service_t *nf_service = NULL; + OpenAPI_map_t *NFServiceMap = NULL; + OpenAPI_nf_service_t *NFService = node->data; + + NFServiceMap = node->data; + if (NFServiceMap) { + NFService = NFServiceMap->value; + if (!NFService) { + ogs_error("No NFService"); + continue; + } + + if (!NFService->service_instance_id) { + ogs_error("No NFService.service_instance_id"); + continue; + } + + if (!NFService->service_name) { + ogs_error("No NFService.service_name"); + continue; + } + + nf_service = ogs_sbi_nf_service_find_by_id( + nf_instance, NFService->service_instance_id); + if (!nf_service) { + nf_service = ogs_sbi_nf_service_add( + nf_instance, + NFService->service_instance_id, + NFService->service_name, NFService->scheme); + ogs_assert(nf_service); + } + + ogs_sbi_nf_service_clear(nf_service); + + handle_nf_service(nf_service, NFService); + } + } + + ogs_sbi_nf_info_remove_all(&nf_instance->nf_info_list); + + if (NFProfile->smf_info) + handle_smf_info(nf_instance, NFProfile->smf_info); + + OpenAPI_list_for_each(NFProfile->smf_info_list, node) { + OpenAPI_map_t *SmfInfoMap = node->data; + if (SmfInfoMap && SmfInfoMap->value) + handle_smf_info(nf_instance, SmfInfoMap->value); + } +} + +static void handle_nf_service( + ogs_sbi_nf_service_t *nf_service, OpenAPI_nf_service_t *NFService) +{ + int rv; + OpenAPI_lnode_t *node = NULL; + + ogs_assert(nf_service); + ogs_assert(NFService); + + OpenAPI_list_for_each(NFService->versions, node) { + OpenAPI_nf_service_version_t *NFServiceVersion = node->data; + + if (!NFServiceVersion) { + ogs_error("No NFServiceVersion"); + continue; + } + + ogs_sbi_nf_service_add_version(nf_service, + NFServiceVersion->api_version_in_uri, + NFServiceVersion->api_full_version, + NFServiceVersion->expiry); + } + + if (NFService->fqdn) + nf_service->fqdn = ogs_strdup(NFService->fqdn); + + OpenAPI_list_for_each(NFService->ip_end_points, node) { + OpenAPI_ip_end_point_t *IpEndPoint = node->data; + ogs_sockaddr_t *addr = NULL, *addr6 = NULL; + int port = 0; + + if (!IpEndPoint) { + ogs_error("No IpEndPoint"); + continue; + } + + if (nf_service->num_of_addr < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) { + if (!IpEndPoint->is_port) { + if (nf_service->scheme == OpenAPI_uri_scheme_http) + port = OGS_SBI_HTTP_PORT; + else if (nf_service->scheme == OpenAPI_uri_scheme_https) + port = OGS_SBI_HTTPS_PORT; + else { + ogs_error("Invalid scheme %d", nf_service->scheme); + continue; + } + } else { + port = IpEndPoint->port; + } + + if (IpEndPoint->ipv4_address) { + rv = ogs_getaddrinfo(&addr, AF_UNSPEC, + IpEndPoint->ipv4_address, port, 0); + if (rv != OGS_OK) { + ogs_error("ogs_getaddrinfo%s failed", + IpEndPoint->ipv4_address); + continue; + } + } + if (IpEndPoint->ipv6_address) { + rv = ogs_getaddrinfo(&addr6, AF_UNSPEC, + IpEndPoint->ipv6_address, port, 0); + if (rv != OGS_OK) { + ogs_error("ogs_getaddrinfo%s failed", + IpEndPoint->ipv6_address); + continue; + } + } + + if (addr || addr6) { + nf_service->addrnf_service->num_of_addr. + port = port; + nf_service->addrnf_service->num_of_addr. + ipv4 = addr; + nf_service->addrnf_service->num_of_addr. + ipv6 = addr6; + nf_service->num_of_addr++; + } + } + } + + OpenAPI_list_for_each(NFService->allowed_nf_types, node) { + OpenAPI_nf_type_e AllowedNfType = (uintptr_t)node->data; + + if (!AllowedNfType) { + ogs_error("AllowedNfType"); + continue; + } + + if (nf_service->num_of_allowed_nf_type < + OGS_SBI_MAX_NUM_OF_NF_TYPE) { + nf_service->allowed_nf_type + nf_service->num_of_allowed_nf_type = AllowedNfType; + nf_service->num_of_allowed_nf_type++; + } + } + + if (NFService->is_priority == true) + nf_service->priority = NFService->priority; + if (NFService->is_capacity == true) + nf_service->capacity = NFService->capacity; + if (NFService->is_load == true) + nf_service->load = NFService->load; +} static void handle_smf_info( ogs_sbi_nf_instance_t *nf_instance, OpenAPI_smf_info_t *SmfInfo) @@ -153,291 +451,311 @@ } } -bool ogs_sbi_nnrf_handle_nf_profile(ogs_sbi_nf_instance_t *nf_instance, - OpenAPI_nf_profile_t *NFProfile, - ogs_sbi_stream_t *stream, ogs_sbi_message_t *message) +void ogs_nnrf_handle_nf_status_subscribe( + ogs_sbi_subscription_data_t *subscription_data, + ogs_sbi_message_t *recvmsg) { - int rv; + OpenAPI_subscription_data_t *SubscriptionData = NULL; + ogs_sbi_client_t *client = NULL; - OpenAPI_lnode_t *node; - ogs_sbi_nf_service_t *nf_service = NULL, *next_nf_service = NULL; -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - char fqdnOGS_MAX_FQDN_LEN+1; -#endif + ogs_assert(recvmsg); + ogs_assert(subscription_data); + client = subscription_data->client; + ogs_assert(client); + + SubscriptionData = recvmsg->SubscriptionData; + if (!SubscriptionData) { + ogs_error("No SubscriptionData"); + return; + } - ogs_assert(nf_instance); - ogs_assert(NFProfile); + if (!SubscriptionData->subscription_id) { + ogs_error("No SubscriptionId"); + return; + } + ogs_sbi_subscription_data_set_id( + subscription_data, SubscriptionData->subscription_id); - if (!NFProfile) { - ogs_error("No NFProfile"); - if (stream) - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - message, "No NFProfile", NULL)); + /* SBI Features */ + if (SubscriptionData->nrf_supported_features) { + subscription_data->nrf_supported_features = + ogs_uint64_from_string(SubscriptionData->nrf_supported_features); + } else { + subscription_data->nrf_supported_features = 0; + } + + if (SubscriptionData->validity_time) { +#define VALIDITY_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ + ogs_time_t time, duration; + if (ogs_sbi_time_from_string( + &time, SubscriptionData->validity_time) == true) { + duration = time - ogs_time_now(); + if (duration < VALIDITY_MINIMUM) { + duration = VALIDITY_MINIMUM; + ogs_warn("%s Forced to %lld seconds", subscription_data->id, + (long long)ogs_time_sec(VALIDITY_MINIMUM)); + } + subscription_data->t_validity = ogs_timer_add(ogs_app()->timer_mgr, + ogs_timer_subscription_validity, subscription_data); + ogs_assert(subscription_data->t_validity); + ogs_timer_start(subscription_data->t_validity, duration); + } else { + ogs_error("Cannot parse validitiyTime %s", + SubscriptionData->validity_time); + } + } +} + +bool ogs_nnrf_handle_nf_status_notify( + ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) +{ + int rv; + + ogs_sbi_response_t *response = NULL; + OpenAPI_notification_data_t *NotificationData = NULL; + ogs_sbi_nf_instance_t *nf_instance = NULL; + + ogs_sbi_message_t message; + ogs_sbi_header_t header; + + ogs_assert(stream); + ogs_assert(recvmsg); + + NotificationData = recvmsg->NotificationData; + if (!NotificationData) { + ogs_error("No NotificationData"); + ogs_assert(true == + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No NotificationData", NULL)); return false; } - if (!NFProfile->nf_instance_id) { - ogs_error("No NFProfile.NFInstanceId"); - if (stream) - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - message, "NFProfile", "No NFInstanceId")); + if (!NotificationData->nf_instance_uri) { + ogs_error("No nfInstanceUri"); + ogs_assert(true == + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No nfInstanceUri", NULL)); return false; } - if (!NFProfile->nf_type) { - ogs_error("No NFProfile.NFType"); - if (stream) - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - message, "NFProfile", "No NFType")); + memset(&header, 0, sizeof(header)); + header.uri = NotificationData->nf_instance_uri; + + rv = ogs_sbi_parse_header(&message, &header); + if (rv != OGS_OK) { + ogs_error("Cannot parse nfInstanceUri %s", header.uri); + ogs_assert(true == + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "Cannot parse nfInstanceUri", header.uri)); return false; } - if (!NFProfile->nf_status) { - ogs_error("No NFProfile.NFStatus"); - if (stream) - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - message, "NFProfile", "No NFStatus")); + if (!message.h.resource.component1) { + ogs_error("No nfInstanceId %s", header.uri); + ogs_assert(true == + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "Cannot parse nfInstanceUri", header.uri)); + ogs_sbi_header_free(&header); return false; } - ogs_list_for_each_safe(&nf_instance->nf_service_list, - next_nf_service, nf_service) { - bool nf_service_should_not_be_deleted = false; + if (NF_INSTANCE_ID_IS_SELF(message.h.resource.component1)) { + ogs_warn("%s The notification is not allowed", + message.h.resource.component1); + ogs_assert(true == + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, + recvmsg, "The notification is not allowed", + message.h.resource.component1)); + ogs_sbi_header_free(&header); + return false; + } - ogs_assert(nf_service->id); + if (NotificationData->event == + OpenAPI_notification_event_type_NF_REGISTERED) { - OpenAPI_list_for_each(NFProfile->nf_services, node) { - OpenAPI_nf_service_t *NFService = node->data; + OpenAPI_nf_profile_t *NFProfile = NULL; - if (!NFService) continue; - if (!NFService->service_instance_id) continue; - if (!NFService->service_name) continue; + NFProfile = NotificationData->nf_profile; + if (!NFProfile) { + ogs_error("No NFProfile"); + ogs_assert(true == + ogs_sbi_server_send_error( + stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No NFProfile", NULL)); + ogs_sbi_header_free(&header); + return false; + } - if (strcmp(nf_service->id, NFService->service_instance_id) == 0) { - nf_service_should_not_be_deleted = true; - break; - } + if (!NFProfile->nf_instance_id) { + ogs_error("No NFProfile.NFInstanceId"); + ogs_assert(true == + ogs_sbi_server_send_error( + stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No NFProfile.NFInstanceId", NULL)); + ogs_sbi_header_free(&header); + return false; } - if (nf_service_should_not_be_deleted == false) { - ogs_warn("NFService%s:%s removed", - nf_service->id, nf_service->name); - OpenAPI_list_for_each(NFProfile->nf_services, node) { - OpenAPI_nf_service_t *NFService = node->data; + if (!NFProfile->nf_type) { + ogs_error("No NFProfile.NFType"); + ogs_assert(true == + ogs_sbi_server_send_error( + stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No NFProfile.NFType", NULL)); + ogs_sbi_header_free(&header); + return false; + } - if (!NFService) continue; - if (!NFService->service_instance_id) continue; - if (!NFService->service_name) continue; + if (!NFProfile->nf_status) { + ogs_error("No NFProfile.NFStatus"); + ogs_assert(true == + ogs_sbi_server_send_error( + stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No NFProfile.NFStatus", NULL)); + ogs_sbi_header_free(&header); + return false; + } - ogs_warn("NFService%s:%s will be added", - NFService->service_instance_id, NFService->service_name); - } - ogs_sbi_nf_service_remove(nf_service); + nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); + if (!nf_instance) { + nf_instance = ogs_sbi_nf_instance_add(); + ogs_assert(nf_instance); + + ogs_sbi_nf_instance_set_id( + nf_instance, message.h.resource.component1); + ogs_sbi_nf_fsm_init(nf_instance); + + ogs_info("%s (NRF-notify) NF registered", nf_instance->id); + } else { + ogs_sbi_nf_fsm_tran(nf_instance, ogs_sbi_nf_state_registered); + + ogs_warn("%s (NRF-notify) NF has already been added", + message.h.resource.component1); } - } - ogs_sbi_nf_instance_clear(nf_instance); - nf_instance->nf_type = NFProfile->nf_type; - nf_instance->nf_status = NFProfile->nf_status; - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + ogs_sbi_nnrf_handle_nf_profile(nf_instance, NFProfile); - if (NFProfile->fqdn) { -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - if (ogs_fqdn_parse( - fqdn, NFProfile->fqdn, - ogs_min(strlen(NFProfile->fqdn), OGS_MAX_FQDN_LEN)) > 0) { + ogs_info("%s (NRF-notify) NF Profile updated", nf_instance->id); - /* Nothing : succeeded to parse FQDN */ - nf_instance->fqdn = ogs_strdup(fqdn); - ogs_assert(nf_instance); + ogs_sbi_client_associate(nf_instance); + } else if (NotificationData->event == + OpenAPI_notification_event_type_NF_DEREGISTERED) { + nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); + if (nf_instance) { + if (OGS_OBJECT_IS_REF(nf_instance)) { + /* There are references to other contexts. */ + ogs_warn("%s:%d NF was referenced in other contexts", + nf_instance->id, nf_instance->reference_count); + ogs_sbi_nf_fsm_tran( + nf_instance, ogs_sbi_nf_state_de_registered); + } else { + ogs_info("%s NF removed", nf_instance->id); + ogs_sbi_nf_fsm_fini((nf_instance)); + ogs_sbi_nf_instance_remove(nf_instance); + } } else { - ogs_error("ogs_fqdn_parse() failed%s", NFProfile->fqdn); + ogs_warn("%s (NRF-notify) Not found", + message.h.resource.component1); + ogs_assert(true == + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_NOT_FOUND, + recvmsg, "Not found", message.h.resource.component1)); + ogs_sbi_header_free(&header); return false; } -#else - nf_instance->fqdn = ogs_strdup(NFProfile->fqdn); -#endif + } else { + char *eventstr = OpenAPI_notification_event_type_ToString( + NotificationData->event); + ogs_error("Not supported event %d:%s", + NotificationData->event, eventstr ? eventstr : "Unknown"); + ogs_assert(true == + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "Not supported event", + eventstr ? eventstr : "Unknown")); + ogs_sbi_header_free(&header); + return false; } - if (NFProfile->is_priority == true) - nf_instance->priority = NFProfile->priority; - if (NFProfile->is_capacity == true) - nf_instance->capacity = NFProfile->capacity; - if (NFProfile->is_load == true) - nf_instance->load = NFProfile->load; - - /* Only one time handles RegisterNFInstance operation */ - OpenAPI_list_for_each(NFProfile->ipv4_addresses, node) { - ogs_sockaddr_t *addr = NULL; + response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); + ogs_assert(response); + ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - if (!node->data) continue; + ogs_sbi_header_free(&header); + return true; +} - if (nf_instance->num_of_ipv4 < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) { +void ogs_nnrf_handle_nf_discover_search_result( + OpenAPI_search_result_t *SearchResult) +{ + OpenAPI_lnode_t *node = NULL; + ogs_sbi_nf_instance_t *nf_instance = NULL; - rv = ogs_getaddrinfo(&addr, AF_UNSPEC, - node->data, ogs_sbi_self()->sbi_port, 0); - if (rv != OGS_OK) continue; + ogs_assert(SearchResult); - nf_instance->ipv4nf_instance->num_of_ipv4 = addr; - nf_instance->num_of_ipv4++; - } - } - OpenAPI_list_for_each(NFProfile->ipv6_addresses, node) { - ogs_sockaddr_t *addr = NULL; + OpenAPI_list_for_each(SearchResult->nf_instances, node) { + OpenAPI_nf_profile_t *NFProfile = NULL; if (!node->data) continue; - if (nf_instance->num_of_ipv6 < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) { + NFProfile = node->data; - rv = ogs_getaddrinfo(&addr, AF_UNSPEC, - node->data, ogs_sbi_self()->sbi_port, 0); - if (rv != OGS_OK) continue; - - nf_instance->ipv6nf_instance->num_of_ipv6 = addr; - nf_instance->num_of_ipv6++; + if (!NFProfile) { + ogs_error("No NFProfile"); + continue; } - } - OpenAPI_list_for_each(NFProfile->nf_services, node) { - OpenAPI_nf_service_t *NFService = node->data; - OpenAPI_list_t *VersionList = NULL; - OpenAPI_list_t *IpEndPointList = NULL; - OpenAPI_list_t *AllowedNfTypeList = NULL; - OpenAPI_lnode_t *node2 = NULL; - - if (!NFService) continue; - if (!NFService->service_instance_id) continue; - if (!NFService->service_name) continue; - - VersionList = NFService->versions; - IpEndPointList = NFService->ip_end_points; - AllowedNfTypeList = NFService->allowed_nf_types; - - nf_service = ogs_sbi_nf_service_find_by_id(nf_instance, - NFService->service_instance_id); - if (!nf_service) { - nf_service = ogs_sbi_nf_service_add(nf_instance, - NFService->service_instance_id, - NFService->service_name, NFService->scheme); - ogs_assert(nf_service); + if (!NFProfile->nf_instance_id) { + ogs_error("No NFProfile.NFInstanceId"); + continue; } - ogs_sbi_nf_service_clear(nf_service); - - OpenAPI_list_for_each(VersionList, node2) { - OpenAPI_nf_service_version_t *NFServiceVersion = node2->data; - - if (!NFServiceVersion) continue; - - ogs_sbi_nf_service_add_version(nf_service, - NFServiceVersion->api_version_in_uri, - NFServiceVersion->api_full_version, - NFServiceVersion->expiry); + if (!NFProfile->nf_type) { + ogs_error("No NFProfile.NFType"); + continue; } - if (NFService->fqdn) { -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - if (ogs_fqdn_parse( - fqdn, NFService->fqdn, - ogs_min(strlen(NFService->fqdn), OGS_MAX_FQDN_LEN)) > 0) { - - /* Nothing : succeeded to parse FQDN */ - nf_service->fqdn = ogs_strdup(fqdn); - ogs_assert(nf_service); - - } else { - ogs_error("ogs_fqdn_parse() failed%s", NFService->fqdn); - return false; - } -#else - nf_service->fqdn = ogs_strdup(NFService->fqdn); - ogs_assert(nf_service); -#endif + if (!NFProfile->nf_status) { + ogs_error("No NFProfile.NFStatus"); + continue; } - OpenAPI_list_for_each(IpEndPointList, node2) { - OpenAPI_ip_end_point_t *IpEndPoint = node2->data; - ogs_sockaddr_t *addr = NULL, *addr6 = NULL; - int port = 0; - - if (!IpEndPoint) continue; - - if (nf_service->num_of_addr < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) { - if (!IpEndPoint->is_port) { - if (nf_service->scheme == OpenAPI_uri_scheme_http) - port = OGS_SBI_HTTP_PORT; - else if (nf_service->scheme == OpenAPI_uri_scheme_https) - port = OGS_SBI_HTTPS_PORT; - else - continue; - } else { - port = IpEndPoint->port; - } + nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id); + if (!nf_instance) { + nf_instance = ogs_sbi_nf_instance_add(); + ogs_assert(nf_instance); - if (IpEndPoint->ipv4_address) { - rv = ogs_getaddrinfo(&addr, AF_UNSPEC, - IpEndPoint->ipv4_address, port, 0); - if (rv != OGS_OK) continue; - } - if (IpEndPoint->ipv6_address) { - rv = ogs_getaddrinfo(&addr6, AF_UNSPEC, - IpEndPoint->ipv6_address, port, 0); - if (rv != OGS_OK) continue; - } + ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); + ogs_sbi_nf_fsm_init(nf_instance); - if (addr || addr6) { - nf_service->addrnf_service->num_of_addr. - port = port; - nf_service->addrnf_service->num_of_addr. - ipv4 = addr; - nf_service->addrnf_service->num_of_addr. - ipv6 = addr6; - nf_service->num_of_addr++; - } - } + ogs_info("%s (NF-discover) NF registered", nf_instance->id); + } else { + ogs_sbi_nf_fsm_tran(nf_instance, ogs_sbi_nf_state_registered); + + ogs_warn("%s (NF-discover) NF has already been added", + NFProfile->nf_instance_id); } - OpenAPI_list_for_each(AllowedNfTypeList, node2) { - OpenAPI_nf_type_e AllowedNfType = (uintptr_t)node2->data; + if (NF_INSTANCE_ID_IS_OTHERS(nf_instance->id)) { + ogs_sbi_nnrf_handle_nf_profile(nf_instance, NFProfile); - if (!AllowedNfType) continue; + ogs_sbi_client_associate(nf_instance); - if (nf_service->num_of_allowed_nf_type < - OGS_SBI_MAX_NUM_OF_NF_TYPE) { - nf_service->allowed_nf_types - nf_service->num_of_allowed_nf_type = AllowedNfType; - nf_service->num_of_allowed_nf_type++; - } - } - - if (NFService->is_priority == true) - nf_service->priority = NFService->priority; - if (NFService->is_capacity == true) - nf_service->capacity = NFService->capacity; - if (NFService->is_load == true) - nf_service->load = NFService->load; - } + /* TIME : Update validity from NRF */ + if (SearchResult->is_validity_period && + SearchResult->validity_period) { + nf_instance->time.validity_duration = + SearchResult->validity_period; - ogs_sbi_nf_info_remove_all(&nf_instance->nf_info_list); + ogs_assert(nf_instance->t_validity); + ogs_timer_start(nf_instance->t_validity, + ogs_time_from_sec(nf_instance->time.validity_duration)); - if (NFProfile->smf_info) - handle_smf_info(nf_instance, NFProfile->smf_info); + } else + ogs_warn("%s NF Instance validity-time should not 0", + nf_instance->id); - OpenAPI_list_for_each(NFProfile->smf_info_list, node) { - OpenAPI_map_t *SmfInfoMap = node->data; - if (SmfInfoMap && SmfInfoMap->value) - handle_smf_info(nf_instance, SmfInfoMap->value); + ogs_info("%s (NF-discover) NF Profile updated", nf_instance->id); + } } - - return true; }
View file
open5gs_2.4.9.tar.xz/lib/sbi/nnrf-handler.h -> open5gs_2.4.10.tar.xz/lib/sbi/nnrf-handler.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -24,9 +24,19 @@ extern "C" { #endif -bool ogs_sbi_nnrf_handle_nf_profile(ogs_sbi_nf_instance_t *nf_instance, - OpenAPI_nf_profile_t *NFProfile, - ogs_sbi_stream_t *stream, ogs_sbi_message_t *message); +void ogs_sbi_nnrf_handle_nf_register( + ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); +void ogs_sbi_nnrf_handle_nf_profile( + ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_profile_t *NFProfile); + +void ogs_nnrf_handle_nf_status_subscribe( + ogs_sbi_subscription_data_t *subscription_data, + ogs_sbi_message_t *recvmsg); +bool ogs_nnrf_handle_nf_status_notify( + ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); + +void ogs_nnrf_handle_nf_discover_search_result( + OpenAPI_search_result_t *SearchResult); #ifdef __cplusplus }
View file
open5gs_2.4.9.tar.xz/lib/sbi/ogs-sbi.h -> open5gs_2.4.10.tar.xz/lib/sbi/ogs-sbi.h
Changed
@@ -20,7 +20,8 @@ #ifndef OGS_SBI_H #define OGS_SBI_H -#include "ogs-core.h" +#include "crypt/ogs-crypt.h" +#include "app/ogs-app.h" #if defined(__GNUC__) #pragma GCC diagnostic push @@ -85,13 +86,17 @@ #define OGS_SBI_INSIDE +#include "sbi/types.h" #include "sbi/conv.h" +#include "sbi/timer.h" #include "sbi/message.h" #include "sbi/server.h" #include "sbi/client.h" #include "sbi/context.h" +#include "sbi/nf-sm.h" + #include "sbi/nnrf-build.h" #include "sbi/nnrf-handler.h"
View file
open5gs_2.4.9.tar.xz/lib/sbi/openapi/model/subscription_data.c -> open5gs_2.4.10.tar.xz/lib/sbi/openapi/model/subscription_data.c
Changed
@@ -20,7 +20,9 @@ OpenAPI_list_t *req_per_plmn_snssais, OpenAPI_list_t *req_plmn_list, OpenAPI_list_t *req_snpn_list, - OpenAPI_list_t *serving_scope + OpenAPI_list_t *serving_scope, + char *requester_features, + char *nrf_supported_features ) { OpenAPI_subscription_data_t *subscription_data_local_var = ogs_malloc(sizeof(OpenAPI_subscription_data_t)); @@ -42,6 +44,8 @@ subscription_data_local_var->req_plmn_list = req_plmn_list; subscription_data_local_var->req_snpn_list = req_snpn_list; subscription_data_local_var->serving_scope = serving_scope; + subscription_data_local_var->requester_features = requester_features; + subscription_data_local_var->nrf_supported_features = nrf_supported_features; return subscription_data_local_var; } @@ -82,6 +86,8 @@ ogs_free(node->data); } OpenAPI_list_free(subscription_data->serving_scope); + ogs_free(subscription_data->requester_features); + ogs_free(subscription_data->nrf_supported_features); ogs_free(subscription_data); } @@ -292,6 +298,20 @@ } } + if (subscription_data->requester_features) { + if (cJSON_AddStringToObject(item, "requesterFeatures", subscription_data->requester_features) == NULL) { + ogs_error("OpenAPI_subscription_data_convertToJSON() failed requester_features"); + goto end; + } + } + + if (subscription_data->nrf_supported_features) { + if (cJSON_AddStringToObject(item, "nrfSupportedFeatures", subscription_data->nrf_supported_features) == NULL) { + ogs_error("OpenAPI_subscription_data_convertToJSON() failed nrf_supported_features"); + goto end; + } + } + end: return item; } @@ -545,6 +565,24 @@ } } + cJSON *requester_features = cJSON_GetObjectItemCaseSensitive(subscription_dataJSON, "requesterFeatures"); + + if (requester_features) { + if (!cJSON_IsString(requester_features)) { + ogs_error("OpenAPI_subscription_data_parseFromJSON() failed requester_features"); + goto end; + } + } + + cJSON *nrf_supported_features = cJSON_GetObjectItemCaseSensitive(subscription_dataJSON, "nrfSupportedFeatures"); + + if (nrf_supported_features) { + if (!cJSON_IsString(nrf_supported_features)) { + ogs_error("OpenAPI_subscription_data_parseFromJSON() failed nrf_supported_features"); + goto end; + } + } + subscription_data_local_var = OpenAPI_subscription_data_create ( ogs_strdup(nf_status_notification_uri->valuestring), req_nf_instance_id ? ogs_strdup(req_nf_instance_id->valuestring) : NULL, @@ -561,7 +599,9 @@ req_per_plmn_snssais ? req_per_plmn_snssaisList : NULL, req_plmn_list ? req_plmn_listList : NULL, req_snpn_list ? req_snpn_listList : NULL, - serving_scope ? serving_scopeList : NULL + serving_scope ? serving_scopeList : NULL, + requester_features ? ogs_strdup(requester_features->valuestring) : NULL, + nrf_supported_features ? ogs_strdup(nrf_supported_features->valuestring) : NULL ); return subscription_data_local_var;
View file
open5gs_2.4.9.tar.xz/lib/sbi/openapi/model/subscription_data.h -> open5gs_2.4.10.tar.xz/lib/sbi/openapi/model/subscription_data.h
Changed
@@ -43,6 +43,8 @@ OpenAPI_list_t *req_plmn_list; OpenAPI_list_t *req_snpn_list; OpenAPI_list_t *serving_scope; + char *requester_features; + char *nrf_supported_features; } OpenAPI_subscription_data_t; OpenAPI_subscription_data_t *OpenAPI_subscription_data_create( @@ -61,7 +63,9 @@ OpenAPI_list_t *req_per_plmn_snssais, OpenAPI_list_t *req_plmn_list, OpenAPI_list_t *req_snpn_list, - OpenAPI_list_t *serving_scope + OpenAPI_list_t *serving_scope, + char *requester_features, + char *nrf_supported_features ); void OpenAPI_subscription_data_free(OpenAPI_subscription_data_t *subscription_data); OpenAPI_subscription_data_t *OpenAPI_subscription_data_parseFromJSON(cJSON *subscription_dataJSON);
View file
open5gs_2.4.9.tar.xz/lib/sbi/path.c -> open5gs_2.4.10.tar.xz/lib/sbi/path.c
Changed
@@ -18,7 +18,6 @@ */ #include "ogs-sbi.h" -#include "ogs-app.h" bool ogs_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_client_cb_f client_cb, ogs_sbi_xact_t *xact) @@ -77,55 +76,99 @@ return true; } -bool ogs_sbi_discover_and_send( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - OpenAPI_nf_type_e requester_nf_type, - ogs_sbi_discovery_option_t *discovery_option, - ogs_sbi_client_cb_f client_cb, void *data) +bool ogs_sbi_discover_only( + ogs_sbi_xact_t *xact, ogs_sbi_client_cb_f client_cb) { ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_object_t *sbi_object = NULL; + ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; + ogs_sbi_discovery_option_t *discovery_option = NULL; + + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; + + sbi_object = xact->sbi_object; ogs_assert(sbi_object); + service_type = xact->service_type; + ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); ogs_assert(target_nf_type); - ogs_assert(requester_nf_type); ogs_assert(client_cb); - /* Target NF-Instance */ - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); + discovery_option = xact->discovery_option; + + /* NRF NF-Instance */ + nf_instance = sbi_object->nf_type_arrayOpenAPI_nf_type_NRF.nf_instance; if (!nf_instance) { - ogs_assert(target_nf_type != OpenAPI_nf_type_NRF); - ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + OpenAPI_nf_type_NRF, NULL); + if (nf_instance) + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->nf_type_arrayOpenAPI_nf_type_NRF, nf_instance); } if (nf_instance) { - return ogs_sbi_send_request(nf_instance, client_cb, data); + ogs_sbi_client_t *client = NULL; + ogs_sbi_request_t *request = NULL; + + ogs_warn("Try to discover %s", + ogs_sbi_service_type_to_name(service_type)); + + request = ogs_nnrf_disc_build_discover( + target_nf_type, discovery_option); + ogs_expect_or_return_val(request, false); + + client = nf_instance->client; + ogs_assert(client); + + return ogs_sbi_client_send_request(client, client_cb, request, xact); } - /* NRF NF-Instance */ - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, OpenAPI_nf_type_NRF); + ogs_error("Cannot discover %s", + ogs_sbi_service_type_to_name(service_type)); + + return false; +} + +bool ogs_sbi_discover_and_send( + ogs_sbi_xact_t *xact, ogs_sbi_client_cb_f client_cb) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + + ogs_sbi_object_t *sbi_object = NULL; + ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; + ogs_sbi_discovery_option_t *discovery_option = NULL; + + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; + + sbi_object = xact->sbi_object; + ogs_assert(sbi_object); + service_type = xact->service_type; + ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); + ogs_assert(target_nf_type); + ogs_assert(client_cb); + + discovery_option = xact->discovery_option; + + /* Target NF-Instance */ + nf_instance = sbi_object->service_type_arrayservice_type.nf_instance; if (!nf_instance) { - ogs_sbi_select_nf(sbi_object, OpenAPI_nf_type_NRF, NULL); - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, OpenAPI_nf_type_NRF); + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (nf_instance) + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_arrayservice_type, nf_instance); } if (nf_instance) { - ogs_warn("Try to discover %s", - OpenAPI_nf_type_ToString(target_nf_type)); - return ogs_nnrf_disc_send_nf_discover( - nf_instance, - target_nf_type, requester_nf_type, discovery_option, - data); + return ogs_sbi_send_request(nf_instance, client_cb, xact); } - ogs_error("Cannot discover %s", OpenAPI_nf_type_ToString(target_nf_type)); - - return false; + return ogs_sbi_discover_only(xact, client_cb); } -bool ogs_nnrf_nfm_send_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_request_t *(*build)(void)) +bool ogs_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance) { ogs_sbi_request_t *request = NULL; ogs_sbi_client_t *client = NULL; @@ -133,9 +176,8 @@ ogs_assert(nf_instance); client = nf_instance->client; ogs_assert(client); - ogs_assert(build); - request = (*build)(); + request = ogs_nnrf_nfm_build_register(); ogs_expect_or_return_val(request, false); return ogs_sbi_scp_send_request(client, client->cb, request, nf_instance); @@ -189,55 +231,45 @@ client, client->cb, request, data); } -bool ogs_nnrf_nfm_send_nf_status_subscribe(ogs_sbi_client_t *client, - OpenAPI_nf_type_e req_nf_type, char *req_nf_instance_id, - OpenAPI_nf_type_e subscr_cond_nf_type) +bool ogs_nnrf_nfm_send_nf_status_subscribe( + ogs_sbi_subscription_data_t *subscription_data) { ogs_sbi_request_t *request = NULL; - ogs_sbi_subscription_t *subscription = NULL; - - ogs_assert(client); - - subscription = ogs_sbi_subscription_add(); - ogs_assert(subscription); + ogs_sbi_client_t *client = NULL; - OGS_SBI_SETUP_CLIENT(subscription, client); - subscription->req_nf_type = req_nf_type; - if (req_nf_instance_id) { - subscription->req_nf_instance_id = ogs_strdup(req_nf_instance_id); - ogs_expect_or_return_val(req_nf_instance_id, false); - } - subscription->subscr_cond.nf_type = subscr_cond_nf_type; + ogs_assert(subscription_data); - request = ogs_nnrf_nfm_build_status_subscribe(subscription); + request = ogs_nnrf_nfm_build_status_subscribe(subscription_data); ogs_expect_or_return_val(request, false); + client = subscription_data->client; + ogs_assert(client); + return ogs_sbi_scp_send_request( - client, client->cb, request, subscription); + client, client->cb, request, subscription_data); } bool ogs_nnrf_nfm_send_nf_status_unsubscribe( - ogs_sbi_subscription_t *subscription) + ogs_sbi_subscription_data_t *subscription_data) { ogs_sbi_request_t *request = NULL; ogs_sbi_client_t *client = NULL; - ogs_assert(subscription); + ogs_assert(subscription_data); - request = ogs_nnrf_nfm_build_status_unsubscribe(subscription); + request = ogs_nnrf_nfm_build_status_unsubscribe(subscription_data); ogs_expect_or_return_val(request, false); - client = subscription->client; + client = subscription_data->client; ogs_assert(client); return ogs_sbi_scp_send_request( - client, client->cb, request, subscription); + client, client->cb, request, subscription_data); } bool ogs_nnrf_disc_send_nf_discover( ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_type_e target_nf_type, - OpenAPI_nf_type_e requester_nf_type, ogs_sbi_discovery_option_t *discovery_option, void *data) { @@ -246,10 +278,8 @@ ogs_assert(nf_instance); ogs_assert(target_nf_type); - ogs_assert(requester_nf_type); - request = ogs_nnrf_disc_build_discover( - target_nf_type, requester_nf_type, discovery_option); + request = ogs_nnrf_disc_build_discover(target_nf_type, discovery_option); ogs_expect_or_return_val(request, false); client = nf_instance->client;
View file
open5gs_2.4.9.tar.xz/lib/sbi/path.h -> open5gs_2.4.10.tar.xz/lib/sbi/path.h
Changed
@@ -28,33 +28,29 @@ bool ogs_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_client_cb_f client_cb, ogs_sbi_xact_t *xact); +bool ogs_sbi_discover_only( + ogs_sbi_xact_t *xact, ogs_sbi_client_cb_f client_cb); bool ogs_sbi_discover_and_send( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - OpenAPI_nf_type_e requester_nf_type, - ogs_sbi_discovery_option_t *discovery_option, - ogs_sbi_client_cb_f client_cb, void *data); + ogs_sbi_xact_t *xact, ogs_sbi_client_cb_f client_cb); -bool ogs_nnrf_nfm_send_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_request_t *(*build)(void)); +bool ogs_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance); bool ogs_nnrf_nfm_send_nf_update(ogs_sbi_nf_instance_t *nf_instance); bool ogs_nnrf_nfm_send_nf_de_register(ogs_sbi_nf_instance_t *nf_instance); bool ogs_nnrf_nfm_send_nf_profile_retrieve(ogs_sbi_nf_instance_t *nf_instance, char *nf_instance_id, void *data); -bool ogs_nnrf_nfm_send_nf_status_subscribe(ogs_sbi_client_t *client, - OpenAPI_nf_type_e req_nf_type, char *req_nf_instance_id, - OpenAPI_nf_type_e subscr_cond_nf_type); +bool ogs_nnrf_nfm_send_nf_status_subscribe( + ogs_sbi_subscription_data_t *subscription_data); bool ogs_nnrf_nfm_send_nf_status_unsubscribe( - ogs_sbi_subscription_t *subscription); + ogs_sbi_subscription_data_t *subscription_data); bool ogs_nnrf_disc_send_nf_discover( ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_type_e target_nf_type, - OpenAPI_nf_type_e requester_nf_type, ogs_sbi_discovery_option_t *discovery_option, void *data); + #define ogs_sbi_send_http_status_no_content(__sTREAM) \ ogs_sbi_send_response(__sTREAM, OGS_SBI_HTTP_STATUS_NO_CONTENT) bool ogs_sbi_send_response(ogs_sbi_stream_t *stream, int status);
View file
open5gs_2.4.9.tar.xz/lib/sbi/server.c -> open5gs_2.4.10.tar.xz/lib/sbi/server.c
Changed
@@ -17,7 +17,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#include "ogs-app.h" #include "ogs-sbi.h" extern const ogs_sbi_server_actions_t ogs_mhd_server_actions;
View file
open5gs_2.4.9.tar.xz/lib/sbi/support/20210629/modified/TS29510_Nnrf_NFManagement.yaml -> open5gs_2.4.10.tar.xz/lib/sbi/support/20210629/modified/TS29510_Nnrf_NFManagement.yaml
Changed
@@ -1442,11 +1442,13 @@ items: type: string minItems: 1 -# requesterFeatures: + requesterFeatures: + $ref: 'TS29571_CommonData.yaml#/components/schemas/SupportedFeatures' # writeOnly: true # allOf: # - $ref: 'TS29571_CommonData.yaml#/components/schemas/SupportedFeatures' -# nrfSupportedFeatures: + nrfSupportedFeatures: + $ref: 'TS29571_CommonData.yaml#/components/schemas/SupportedFeatures' # readOnly: true # allOf: # - $ref: 'TS29571_CommonData.yaml#/components/schemas/SupportedFeatures'
View file
open5gs_2.4.9.tar.xz/lib/sbi/support/20210629/openapi-generator/templates/cJSON.c.mustache -> open5gs_2.4.10.tar.xz/lib/sbi/support/20210629/openapi-generator/templates/cJSON.c.mustache
Changed
@@ -43,6 +43,7 @@ #include <stdlib.h> #include <limits.h> #include <ctype.h> +#include <float.h> #ifdef ENABLE_LOCALES #include <locale.h> @@ -58,9 +59,32 @@ #include "cJSON.h" /* define our own boolean type */ +#ifdef true +#undef true +#endif #define true ((cJSON_bool)1) + +#ifdef false +#undef false +#endif #define false ((cJSON_bool)0) +/* define isnan and isinf for ANSI C, if in C99 or above, isnan and isinf has been defined in math.h */ +#ifndef isinf +#define isinf(d) (isnan((d - d)) && !isnan(d)) +#endif +#ifndef isnan +#define isnan(d) (d != d) +#endif + +#ifndef NAN +#ifdef _WIN32 +#define NAN sqrt(-1.0) +#else +#define NAN 0.0/0.0 +#endif +#endif + typedef struct { const unsigned char *json; size_t position; @@ -72,16 +96,28 @@ return (const char*) (global_error.json + global_error.position); } -CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item) { - if (!cJSON_IsString(item)) { +CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item) +{ + if (!cJSON_IsString(item)) + { return NULL; } return item->valuestring; } +CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item) +{ + if (!cJSON_IsNumber(item)) + { + return (double) NAN; + } + + return item->valuedouble; +} + /* This is a safeguard to prevent copy-pasters from using incompatible C and header files */ -#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 7) +#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 15) #error cJSON.h and cJSON.c have different versions. Make sure that both have the same. #endif @@ -119,31 +155,30 @@ typedef struct internal_hooks { - void *(*allocate)(size_t size); - void (*deallocate)(void *pointer); - void *(*reallocate)(void *pointer, size_t size); + void *(CJSON_CDECL *allocate)(size_t size); + void (CJSON_CDECL *deallocate)(void *pointer); + void *(CJSON_CDECL *reallocate)(void *pointer, size_t size); } internal_hooks; -#if 0 /* modified by acetcom */ #if defined(_MSC_VER) -/* work around MSVC error C2322: '...' address of dillimport '...' is not static */ -static void *internal_malloc(size_t size) +/* work around MSVC error C2322: '...' address of dllimport '...' is not static */ +static void * CJSON_CDECL internal_malloc(size_t size) { return malloc(size); } -static void internal_free(void *pointer) +static void CJSON_CDECL internal_free(void *pointer) { free(pointer); } -static void *internal_realloc(void *pointer, size_t size) +static void * CJSON_CDECL internal_realloc(void *pointer, size_t size) { return realloc(pointer, size); } #else +#if 0 /* modified by acetcom */ #define internal_malloc malloc #define internal_free free #define internal_realloc realloc -#endif #else #include "ogs-core.h" static void *internal_malloc(size_t size) @@ -163,6 +198,10 @@ return ptr; } #endif +#endif + +/* strlen of character literals resolved at compile time */ +#define static_strlen(string_literal) (sizeof(string_literal) - sizeof("")) static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc }; @@ -344,7 +383,7 @@ { item->valueint = INT_MAX; } - else if (number <= INT_MIN) + else if (number <= (double)INT_MIN) { item->valueint = INT_MIN; } @@ -366,7 +405,7 @@ { object->valueint = INT_MAX; } - else if (number <= INT_MIN) + else if (number <= (double)INT_MIN) { object->valueint = INT_MIN; } @@ -378,6 +417,33 @@ return object->valuedouble = number; } +CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring) +{ + char *copy = NULL; + /* if object's type is not cJSON_String or is cJSON_IsReference, it should not set valuestring */ + if (!(object->type & cJSON_String) || (object->type & cJSON_IsReference)) + { + return NULL; + } + if (strlen(valuestring) <= strlen(object->valuestring)) + { + strcpy(object->valuestring, valuestring); + return object->valuestring; + } + copy = (char*) cJSON_strdup((const unsigned char*)valuestring, &global_hooks); + if (copy == NULL) + { + return NULL; + } + if (object->valuestring != NULL) + { + cJSON_free(object->valuestring); + } + object->valuestring = copy; + + return copy; +} + typedef struct { unsigned char *buffer; @@ -465,10 +531,8 @@ return NULL; } - if (newbuffer) - { - memcpy(newbuffer, p->buffer, p->offset + 1); - } + + memcpy(newbuffer, p->buffer, p->offset + 1); p->hooks.deallocate(p->buffer); } p->length = newsize; @@ -490,6 +554,13 @@ buffer->offset += strlen((const char*)buffer_pointer); } +/* securely comparison of floating-point variables */ +static cJSON_bool compare_double(double a, double b) +{ + double maxVal = fabs(a) > fabs(b) ? fabs(a) : fabs(b); + return (fabs(a - b) <= maxVal * DBL_EPSILON); +} + /* Render the number nicely from the given item into a string. */ static cJSON_bool print_number(const cJSON * const item, printbuffer * const output_buffer) { @@ -497,9 +568,9 @@ double d = item->valuedouble; int length = 0; size_t i = 0; - unsigned char number_buffer26; /* temporary buffer to print the number into */ + unsigned char number_buffer26 = {0}; /* temporary buffer to print the number into */ unsigned char decimal_point = get_decimal_point(); - double test; + double test = 0.0; if (output_buffer == NULL) { @@ -507,24 +578,28 @@ } /* This checks for NaN and Infinity */ - if ((d * 0) != 0) + if (isnan(d) || isinf(d)) { length = sprintf((char*)number_buffer, "null"); } + else if(d == (double)item->valueint) + { + length = sprintf((char*)number_buffer, "%d", item->valueint); + } else { /* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */ length = sprintf((char*)number_buffer, "%1.15g", d); /* Check whether the original double can be recovered */ - if ((sscanf((char*)number_buffer, "%lg", &test) != 1) || ((double)test != d)) + if ((sscanf((char*)number_buffer, "%lg", &test) != 1) || !compare_double((double)test, d)) { /* If not, print with 17 decimal places of precision */ length = sprintf((char*)number_buffer, "%1.17g", d); } } - /* sprintf failed or buffer overrun occured */ + /* sprintf failed or buffer overrun occurred */ if ((length < 0) || (length > (int)(sizeof(number_buffer) - 1))) { return false; @@ -987,6 +1062,11 @@ return NULL; } + if (cannot_access_at_index(buffer, 0)) + { + return buffer; + } + while (can_access_at_index(buffer, 0) && (buffer_at_offset(buffer)0 <= 32)) { buffer->offset++; @@ -1016,9 +1096,24 @@ return buffer; } -/* Parse an object - create a new root, and populate. */ CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated) { + size_t buffer_length; + + if (NULL == value) + { + return NULL; + } + + /* Adding null character size due to require_null_terminated. */ + buffer_length = strlen(value) + sizeof(""); + + return cJSON_ParseWithLengthOpts(value, buffer_length, return_parse_end, require_null_terminated); +} + +/* Parse an object - create a new root, and populate. */ +CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated) +{ parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } }; cJSON *item = NULL; @@ -1026,13 +1121,13 @@ global_error.json = NULL; global_error.position = 0; - if (value == NULL) + if (value == NULL || 0 == buffer_length) { goto fail; } buffer.content = (const unsigned char*)value; - buffer.length = strlen((const char*)value) + sizeof(""); + buffer.length = buffer_length; buffer.offset = 0; buffer.hooks = global_hooks; @@ -1102,7 +1197,12 @@ return cJSON_ParseWithOpts(value, 0, 0); } -#define cjson_min(a, b) ((a < b) ? a : b) +CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length) +{ + return cJSON_ParseWithLengthOpts(value, buffer_length, 0, 0); +} + +#define cjson_min(a, b) (((a) < (b)) ? (a) : (b)) static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks) { @@ -1209,20 +1309,20 @@ return (char*)p.buffer; } -CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buf, const int len, const cJSON_bool fmt) +CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format) { printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }; - if ((len < 0) || (buf == NULL)) + if ((length < 0) || (buffer == NULL)) { return false; } - p.buffer = (unsigned char*)buf; - p.length = (size_t)len; + p.buffer = (unsigned char*)buffer; + p.length = (size_t)length; p.offset = 0; p.noalloc = true; - p.format = fmt; + p.format = format; p.hooks = global_hooks; return print_value(item, &p); @@ -1435,6 +1535,10 @@ success: input_buffer->depth--; + if (head != NULL) { + head->prev = current_item; + } + item->type = cJSON_Array; item->child = head; @@ -1575,7 +1679,7 @@ buffer_skip_whitespace(input_buffer); if (!parse_string(current_item, input_buffer)) { - goto fail; /* faile to parse name */ + goto fail; /* failed to parse name */ } buffer_skip_whitespace(input_buffer); @@ -1607,6 +1711,10 @@ success: input_buffer->depth--; + if (head != NULL) { + head->prev = current_item; + } + item->type = cJSON_Object; item->child = head; @@ -1695,7 +1803,7 @@ update_offset(output_buffer); /* print comma if not last */ - length = (size_t) ((output_buffer->format ? 1 : 0) + (current_item->next ? 1 : 0)); + length = ((size_t)(output_buffer->format ? 1 : 0) + (size_t)(current_item->next ? 1 : 0)); output_pointer = ensure(output_buffer, length + 1); if (output_pointer == NULL) { @@ -1801,7 +1909,7 @@ current_element = object->child; if (case_sensitive) { - while ((current_element != NULL) && (strcmp(name, current_element->string) != 0)) + while ((current_element != NULL) && (current_element->string != NULL) && (strcmp(name, current_element->string) != 0)) { current_element = current_element->next; } @@ -1814,6 +1922,10 @@ } } + if ((current_element == NULL) || (current_element->string == NULL)) { + return NULL; + } + return current_element; } @@ -1865,35 +1977,39 @@ { cJSON *child = NULL; - if ((item == NULL) || (array == NULL)) + if ((item == NULL) || (array == NULL) || (array == item)) { return false; } child = array->child; - + /* + * To find the last item in array quickly, we use prev in array + */ if (child == NULL) { /* list is empty, start new one */ array->child = item; + item->prev = item; + item->next = NULL; } else { /* append to the end */ - while (child->next) + if (child->prev) { - child = child->next; + suffix_object(child->prev, item); + array->child->prev = item; } - suffix_object(child, item); } return true; } /* Add item to array/object. */ -CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item) +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item) { - add_item_to_array(array, item); + return add_item_to_array(array, item); } #if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)))) @@ -1917,7 +2033,7 @@ char *new_key = NULL; int new_type = cJSON_Invalid; - if ((object == NULL) || (string == NULL) || (item == NULL)) + if ((object == NULL) || (string == NULL) || (item == NULL) || (object == item)) { return false; } @@ -1949,35 +2065,35 @@ return add_item_to_array(object, item); } -CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item) +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item) { - add_item_to_object(object, string, item, &global_hooks, false); + return add_item_to_object(object, string, item, &global_hooks, false); } /* Add an item to an object with constant string as key */ -CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item) +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item) { - add_item_to_object(object, string, item, &global_hooks, true); + return add_item_to_object(object, string, item, &global_hooks, true); } -CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) { if (array == NULL) { - return; + return false; } - add_item_to_array(array, create_reference(item, &global_hooks)); + return add_item_to_array(array, create_reference(item, &global_hooks)); } -CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item) +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item) { if ((object == NULL) || (string == NULL)) { - return; + return false; } - add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false); + return add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false); } CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name) @@ -2095,7 +2211,7 @@ return NULL; } - if (item->prev != NULL) + if (item != parent->child) { /* not the first element */ item->prev->next = item->next; @@ -2111,6 +2227,12 @@ /* first element */ parent->child = item->next; } + else if (item->next == NULL) + { + /* last element */ + parent->child->prev = item->prev; + } + /* make sure the detached item doesn't point anywhere anymore */ item->prev = NULL; item->next = NULL; @@ -2158,20 +2280,19 @@ } /* Replace array/object items with new ones. */ -CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem) +CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem) { cJSON *after_inserted = NULL; if (which < 0) { - return; + return false; } after_inserted = get_array_item(array, (size_t)which); if (after_inserted == NULL) { - add_item_to_array(array, newitem); - return; + return add_item_to_array(array, newitem); } newitem->next = after_inserted; @@ -2185,6 +2306,7 @@ { newitem->prev->next = newitem; } + return true; } CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement) @@ -2206,14 +2328,28 @@ { replacement->next->prev = replacement; } - if (replacement->prev != NULL) - { - replacement->prev->next = replacement; - } if (parent->child == item) { + if (parent->child->prev == parent->child) + { + replacement->prev = replacement; + } parent->child = replacement; } + else + { /* + * To find the last item in array quickly, we use prev in array. + * We can't modify the last item's next pointer where this item was the parent's child + */ + if (replacement->prev != NULL) + { + replacement->prev->next = replacement; + } + if (replacement->next == NULL) + { + parent->child->prev = replacement; + } + } item->next = NULL; item->prev = NULL; @@ -2222,14 +2358,14 @@ return true; } -CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem) +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem) { if (which < 0) { - return; + return false; } - cJSON_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which), newitem); + return cJSON_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which), newitem); } static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive) @@ -2245,21 +2381,24 @@ cJSON_free(replacement->string); } replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); - replacement->type &= ~cJSON_StringIsConst; + if (replacement->string == NULL) + { + return false; + } - cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement); + replacement->type &= ~cJSON_StringIsConst; - return true; + return cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement); } -CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem) +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem) { - replace_item_in_object(object, string, newitem, false); + return replace_item_in_object(object, string, newitem, false); } -CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem) +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem) { - replace_item_in_object(object, string, newitem, true); + return replace_item_in_object(object, string, newitem, true); } /* Create basic types: */ @@ -2296,12 +2435,12 @@ return item; } -CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool b) +CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean) { cJSON *item = cJSON_New_Item(&global_hooks); if(item) { - item->type = b ? cJSON_True : cJSON_False; + item->type = boolean ? cJSON_True : cJSON_False; } return item; @@ -2320,7 +2459,7 @@ { item->valueint = INT_MAX; } - else if (num <= INT_MIN) + else if (num <= (double)INT_MIN) { item->valueint = INT_MIN; } @@ -2436,6 +2575,7 @@ } a = cJSON_CreateArray(); + for(i = 0; a && (i < (size_t)count); i++) { n = cJSON_CreateNumber(numbersi); @@ -2455,6 +2595,10 @@ p = n; } + if (a && a->child) { + a->child->prev = n; + } + return a; } @@ -2491,6 +2635,10 @@ p = n; } + if (a && a->child) { + a->child->prev = n; + } + return a; } @@ -2508,7 +2656,7 @@ a = cJSON_CreateArray(); - for(i = 0;a && (i < (size_t)count); i++) + for(i = 0; a && (i < (size_t)count); i++) { n = cJSON_CreateNumber(numbersi); if(!n) @@ -2527,10 +2675,14 @@ p = n; } + if (a && a->child) { + a->child->prev = n; + } + return a; } -CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count) +CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count) { size_t i = 0; cJSON *n = NULL; @@ -2563,6 +2715,10 @@ p = n; } + if (a && a->child) { + a->child->prev = n; + } + return a; } @@ -2634,6 +2790,10 @@ } child = child->next; } + if (newitem && newitem->child) + { + newitem->child->prev = newchild; + } return newitem; @@ -2646,69 +2806,96 @@ return NULL; } -CJSON_PUBLIC(void) cJSON_Minify(char *json) +static void skip_oneline_comment(char **input) { - unsigned char *into = (unsigned char*)json; + *input += static_strlen("//"); - if (json == NULL) + for (; (*input)0 != '\0'; ++(*input)) { - return; + if ((*input)0 == '\n') { + *input += static_strlen("\n"); + return; + } } +} - while (*json) +static void skip_multiline_comment(char **input) +{ + *input += static_strlen("/*"); + + for (; (*input)0 != '\0'; ++(*input)) { - if (*json == ' ') - { - json++; - } - else if (*json == '\t') - { - /* Whitespace characters. */ - json++; - } - else if (*json == '\r') - { - json++; - } - else if (*json=='\n') + if (((*input)0 == '*') && ((*input)1 == '/')) { - json++; + *input += static_strlen("*/"); + return; } - else if ((*json == '/') && (json1 == '/')) - { - /* double-slash comments, to end of line. */ - while (*json && (*json != '\n')) - { - json++; - } + } +} + +static void minify_string(char **input, char **output) { + (*output)0 = (*input)0; + *input += static_strlen("\""); + *output += static_strlen("\""); + + + for (; (*input)0 != '\0'; (void)++(*input), ++(*output)) { + (*output)0 = (*input)0; + + if ((*input)0 == '\"') { + (*output)0 = '\"'; + *input += static_strlen("\""); + *output += static_strlen("\""); + return; + } else if (((*input)0 == '\\') && ((*input)1 == '\"')) { + (*output)1 = (*input)1; + *input += static_strlen("\""); + *output += static_strlen("\""); } - else if ((*json == '/') && (json1 == '*')) + } +} + +CJSON_PUBLIC(void) cJSON_Minify(char *json) +{ + char *into = json; + + if (json == NULL) + { + return; + } + + while (json0 != '\0') + { + switch (json0) { - /* multiline comments. */ - while (*json && !((*json == '*') && (json1 == '/'))) - { + case ' ': + case '\t': + case '\r': + case '\n': json++; - } - json += 2; - } - else if (*json == '\"') - { - /* string literals, which are \" sensitive. */ - *into++ = (unsigned char)*json++; - while (*json && (*json != '\"')) - { - if (*json == '\\') + break; + + case '/': + if (json1 == '/') { - *into++ = (unsigned char)*json++; + skip_oneline_comment(&json); } - *into++ = (unsigned char)*json++; - } - *into++ = (unsigned char)*json++; - } - else - { - /* All other characters. */ - *into++ = (unsigned char)*json++; + else if (json1 == '*') + { + skip_multiline_comment(&json); + } else { + json++; + } + break; + + case '\"': + minify_string(&json, (char**)&into); + break; + + default: + into0 = json0; + json++; + into++; } } @@ -2818,7 +3005,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive) { - if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF)) || cJSON_IsInvalid(a)) + if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF))) { return false; } @@ -2855,7 +3042,7 @@ return true; case cJSON_Number: - if (a->valuedouble == b->valuedouble) + if (compare_double(a->valuedouble, b->valuedouble)) { return true; }
View file
open5gs_2.4.9.tar.xz/lib/sbi/support/20210629/openapi-generator/templates/cJSON.h.mustache -> open5gs_2.4.10.tar.xz/lib/sbi/support/20210629/openapi-generator/templates/cJSON.h.mustache
Changed
@@ -28,10 +28,60 @@ { #endif +#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32)) +#define __WINDOWS__ +#endif + +#ifdef __WINDOWS__ + +/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options: + +CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols +CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default) +CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol + +For *nix builds that support visibility attribute, you can define similar behavior by + +setting default visibility to hidden by adding +-fvisibility=hidden (for gcc) +or +-xldscope=hidden (for sun cc) +to CFLAGS + +then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does + +*/ + +#define CJSON_CDECL __cdecl +#define CJSON_STDCALL __stdcall + +/* export symbols by default, this is necessary for copy pasting the C and header file */ +#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS) +#define CJSON_EXPORT_SYMBOLS +#endif + +#if defined(CJSON_HIDE_SYMBOLS) +#define CJSON_PUBLIC(type) type CJSON_STDCALL +#elif defined(CJSON_EXPORT_SYMBOLS) +#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL +#elif defined(CJSON_IMPORT_SYMBOLS) +#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL +#endif +#else /* !__WINDOWS__ */ +#define CJSON_CDECL +#define CJSON_STDCALL + +#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY) +#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type +#else +#define CJSON_PUBLIC(type) type +#endif +#endif + /* project version */ #define CJSON_VERSION_MAJOR 1 #define CJSON_VERSION_MINOR 7 -#define CJSON_VERSION_PATCH 7 +#define CJSON_VERSION_PATCH 15 #include <stddef.h> @@ -74,55 +124,13 @@ typedef struct cJSON_Hooks { - void *(*malloc_fn)(size_t sz); - void (*free_fn)(void *ptr); + /* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */ + void *(CJSON_CDECL *malloc_fn)(size_t sz); + void (CJSON_CDECL *free_fn)(void *ptr); } cJSON_Hooks; typedef int cJSON_bool; -#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32)) -#define __WINDOWS__ -#endif -#ifdef __WINDOWS__ - -/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 2 define options: - -CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols -CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default) -CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol - -For *nix builds that support visibility attribute, you can define similar behavior by - -setting default visibility to hidden by adding --fvisibility=hidden (for gcc) -or --xldscope=hidden (for sun cc) -to CFLAGS - -then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does - -*/ - -/* export symbols by default, this is necessary for copy pasting the C and header file */ -#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS) -#define CJSON_EXPORT_SYMBOLS -#endif - -#if defined(CJSON_HIDE_SYMBOLS) -#define CJSON_PUBLIC(type) type __stdcall -#elif defined(CJSON_EXPORT_SYMBOLS) -#define CJSON_PUBLIC(type) __declspec(dllexport) type __stdcall -#elif defined(CJSON_IMPORT_SYMBOLS) -#define CJSON_PUBLIC(type) __declspec(dllimport) type __stdcall -#endif -#else /* !WIN32 */ -#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY) -#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type -#else -#define CJSON_PUBLIC(type) type -#endif -#endif - /* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them. * This is to prevent stack overflows. */ #ifndef CJSON_NESTING_LIMIT @@ -138,9 +146,11 @@ /* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */ /* Supply a block of JSON, and this returns a cJSON object you can interrogate. */ CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value); +CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length); /* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */ /* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */ CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated); +CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated); /* Render a cJSON entity to text for transfer/storage. */ CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item); @@ -152,7 +162,7 @@ /* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */ CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format); /* Delete a cJSON entity and all subentities. */ -CJSON_PUBLIC(void) cJSON_Delete(cJSON *c); +CJSON_PUBLIC(void) cJSON_Delete(cJSON *item); /* Returns the number of items in an array (or object). */ CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array); @@ -165,8 +175,9 @@ /* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */ CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void); -/* Check if the item is a string and return its valuestring */ -CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item); +/* Check item type and return its value */ +CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item); +CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item); /* These functions check the type of an item */ CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item); @@ -195,29 +206,30 @@ /* Create a string where valuestring references a string so * it will not be freed by cJSON_Delete */ CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string); -/* Create an object/arrray that only references it's elements so +/* Create an object/array that only references it's elements so * they will not be freed by cJSON_Delete */ CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child); CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child); -/* These utilities create an Array of count items. */ +/* These utilities create an Array of count items. + * The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.*/ CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count); CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count); CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count); -CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count); +CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count); /* Append item to the specified array/object. */ -CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item); -CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item); +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item); +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item); /* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object. * WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before * writing to `item->string` */ -CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item); +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item); /* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */ -CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); -CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item); +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item); -/* Remove/Detatch items from Arrays/Objects. */ +/* Remove/Detach items from Arrays/Objects. */ CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item); CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which); CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which); @@ -227,22 +239,24 @@ CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string); /* Update array items. */ -CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */ +CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */ CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement); -CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem); -CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem); -CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem); +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem); +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem); +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem); /* Duplicate a cJSON item */ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse); /* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will -need to be released. With recurse!=0, it will duplicate any children connected to the item. -The item->next and ->prev pointers are always zero on return from Duplicate. */ + * need to be released. With recurse!=0, it will duplicate any children connected to the item. + * The item->next and ->prev pointers are always zero on return from Duplicate. */ /* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal. * case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive); - +/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings. + * The input pointer json cannot point to a read-only address area, such as a string constant, + * but should point to a readable and writable address area. */ CJSON_PUBLIC(void) cJSON_Minify(char *json); /* Helper functions for creating and adding items to an object at the same time. @@ -262,6 +276,15 @@ /* helper for the cJSON_SetNumberValue macro */ CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number); #define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number)) +/* Change the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String */ +CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring); + +/* If the object is not a boolean type this does nothing and returns cJSON_Invalid else it returns the new type*/ +#define cJSON_SetBoolValue(object, boolValue) ( \ + (object != NULL && ((object)->type & (cJSON_False|cJSON_True))) ? \ + (object)->type=((object)->type &(~(cJSON_False|cJSON_True)))|((boolValue)?cJSON_True:cJSON_False) : \ + cJSON_Invalid\ +) /* Macro for iterating over an array or object */ #define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
View file
open5gs_2.4.10.tar.xz/lib/sbi/timer.c
Added
@@ -0,0 +1,82 @@ +/* + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#include "ogs-sbi.h" + +static void timer_send_event(int timer_id, void *data) +{ + int rv; + ogs_event_t *e = NULL; + ogs_assert(data); + + switch (timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + case OGS_TIMER_SBI_CLIENT_WAIT: + e = ogs_event_new(OGS_EVENT_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_error("ogs_queue_push() failed %d in %s", + (int)rv, ogs_timer_get_name(e->timer_id)); + ogs_event_free(e); + } +} + +void ogs_timer_nf_instance_registration_interval(void *data) +{ + timer_send_event(OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); +} + +void ogs_timer_nf_instance_heartbeat_interval(void *data) +{ + timer_send_event(OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); +} + +void ogs_timer_nf_instance_no_heartbeat(void *data) +{ + timer_send_event(OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); +} + +void ogs_timer_nf_instance_validity(void *data) +{ + timer_send_event(OGS_TIMER_NF_INSTANCE_VALIDITY, data); +} + +void ogs_timer_subscription_validity(void *data) +{ + timer_send_event(OGS_TIMER_SUBSCRIPTION_VALIDITY, data); +} + +void ogs_timer_sbi_client_wait_expire(void *data) +{ + timer_send_event(OGS_TIMER_SBI_CLIENT_WAIT, data); +}
View file
open5gs_2.4.10.tar.xz/lib/sbi/timer.h
Added
@@ -0,0 +1,42 @@ +/* + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#if !defined(OGS_SBI_INSIDE) && !defined(OGS_SBI_COMPILATION) +#error "This header cannot be included directly." +#endif + +#ifndef OGS_SBI_TIMER_H +#define OGS_SBI_TIMER_H + +#ifdef __cplusplus +extern "C" { +#endif + +void ogs_timer_nf_instance_registration_interval(void *data); +void ogs_timer_nf_instance_heartbeat_interval(void *data); +void ogs_timer_nf_instance_no_heartbeat(void *data); +void ogs_timer_nf_instance_validity(void *data); +void ogs_timer_subscription_validity(void *data); +void ogs_timer_sbi_client_wait_expire(void *data); + +#ifdef __cplusplus +} +#endif + +#endif /* OGS_SBI_TIMER_H */
View file
open5gs_2.4.10.tar.xz/lib/sbi/types.c
Added
@@ -0,0 +1,118 @@ +/* + * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#include "ogs-sbi.h" + +struct service_desc_s { + OpenAPI_nf_type_e nf_type; + const char *service_name; +}; + +static struct service_desc_s service_desc = { + { OpenAPI_nf_type_NULL, NULL }, + { OpenAPI_nf_type_NRF, OGS_SBI_SERVICE_NAME_NNRF_NFM }, + { OpenAPI_nf_type_NRF, OGS_SBI_SERVICE_NAME_NNRF_DISC }, + { OpenAPI_nf_type_NRF, OGS_SBI_SERVICE_NAME_NNRF_OAUTH2 }, + { OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_SDM }, + { OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_UECM }, + { OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_UEAU }, + { OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_EE }, + { OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_PP }, + { OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_NIDDAU }, + { OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_MT }, + { OpenAPI_nf_type_AMF, OGS_SBI_SERVICE_NAME_NAMF_COMM }, + { OpenAPI_nf_type_AMF, OGS_SBI_SERVICE_NAME_NAMF_EVTS }, + { OpenAPI_nf_type_AMF, OGS_SBI_SERVICE_NAME_NAMF_MT }, + { OpenAPI_nf_type_AMF, OGS_SBI_SERVICE_NAME_NAMF_LOC }, + { OpenAPI_nf_type_SMF, OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION }, + { OpenAPI_nf_type_SMF, OGS_SBI_SERVICE_NAME_NSMF_EVENT_EXPOSURE }, + { OpenAPI_nf_type_SMF, OGS_SBI_SERVICE_NAME_NSMF_NIDD }, + { OpenAPI_nf_type_AUSF, OGS_SBI_SERVICE_NAME_NAUSF_AUTH }, + { OpenAPI_nf_type_AUSF, OGS_SBI_SERVICE_NAME_NAUSF_SORPROTECTION }, + { OpenAPI_nf_type_AUSF, OGS_SBI_SERVICE_NAME_NAUSF_UPUPROTECTION }, + { OpenAPI_nf_type_NEF, OGS_SBI_SERVICE_NAME_NNEF_PFDMANAGEMENT }, + { OpenAPI_nf_type_NEF, OGS_SBI_SERVICE_NAME_NNEF_SMCONTEXT }, + { OpenAPI_nf_type_NEF, OGS_SBI_SERVICE_NAME_NNEF_EVENTEXPOSURE }, + { OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL }, + { OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL }, + { OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION }, + { OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_BDTPOLICYCONTROL }, + { OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_EVENTEXPOSURE }, + { OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_UE_POLICY_CONTROL }, + { OpenAPI_nf_type_SMSF, OGS_SBI_SERVICE_NAME_NSMSF_SMS }, + { OpenAPI_nf_type_NSSF, OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION }, + { OpenAPI_nf_type_NSSF, OGS_SBI_SERVICE_NAME_NNSSF_NSSAIAVAILABILITY }, + { OpenAPI_nf_type_UDR, OGS_SBI_SERVICE_NAME_NUDR_DR }, + { OpenAPI_nf_type_UDR, OGS_SBI_SERVICE_NAME_NUDR_GROUP_ID_MAP }, + { OpenAPI_nf_type_LMF, OGS_SBI_SERVICE_NAME_NLMF_LOC }, + { OpenAPI_nf_type_5G_EIR, OGS_SBI_SERVICE_NAME_N5G_EIR_EIC }, + { OpenAPI_nf_type_BSF, OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT }, + { OpenAPI_nf_type_CHF, OGS_SBI_SERVICE_NAME_NCHF_SPENDINGLIMITCONTROL }, + { OpenAPI_nf_type_CHF, OGS_SBI_SERVICE_NAME_NCHF_CONVERGEDCHARGING }, + { OpenAPI_nf_type_CHF, OGS_SBI_SERVICE_NAME_NCHF_OFFLINEONLYCHARGING }, + { OpenAPI_nf_type_NWDAF, OGS_SBI_SERVICE_NAME_NNWDAF_EVENTSSUBSCRIPTION }, + { OpenAPI_nf_type_NWDAF, OGS_SBI_SERVICE_NAME_NNWDAF_ANALYTICSINFO }, + { OpenAPI_nf_type_GMLC, OGS_SBI_SERVICE_NAME_NGMLC_LOC }, + { OpenAPI_nf_type_UCMF, OGS_SBI_SERVICE_NAME_NUCMF_PROVISIONING }, + { OpenAPI_nf_type_UCMF, OGS_SBI_SERVICE_NAME_NUCMF_UECAPABILITYMANAGEMENT }, + { OpenAPI_nf_type_HSS, OGS_SBI_SERVICE_NAME_NHSS_SDM }, + { OpenAPI_nf_type_HSS, OGS_SBI_SERVICE_NAME_NHSS_UECM }, + { OpenAPI_nf_type_HSS, OGS_SBI_SERVICE_NAME_NHSS_UEAU }, + { OpenAPI_nf_type_HSS, OGS_SBI_SERVICE_NAME_NHSS_EE }, + { OpenAPI_nf_type_HSS, OGS_SBI_SERVICE_NAME_NHSS_IMS_SDM }, + { OpenAPI_nf_type_HSS, OGS_SBI_SERVICE_NAME_NHSS_IMS_UECM }, + { OpenAPI_nf_type_HSS, OGS_SBI_SERVICE_NAME_NHSS_IMS_UEAU }, + { OpenAPI_nf_type_SEPP, OGS_SBI_SERVICE_NAME_NSEPP_TELESCOPIC }, + { OpenAPI_nf_type_SOR_AF, OGS_SBI_SERVICE_NAME_NSORAF_SOR }, + { OpenAPI_nf_type_SPAF, OGS_SBI_SERVICE_NAME_NSPAF_SECURED_PACKET }, + { OpenAPI_nf_type_UDSF, OGS_SBI_SERVICE_NAME_NUDSF_DR }, + { OpenAPI_nf_type_NSSAAF, OGS_SBI_SERVICE_NAME_NNSSAAF_NSSAA }, +}; + + + +OpenAPI_nf_type_e ogs_sbi_service_type_to_nf_type(ogs_sbi_service_type_e type) +{ + ogs_assert(type > OGS_SBI_SERVICE_TYPE_NULL && + type < OGS_SBI_MAX_NUM_OF_SERVICE_TYPE); + return service_desctype.nf_type; +} + +const char *ogs_sbi_service_type_to_name(ogs_sbi_service_type_e type) +{ + ogs_assert(type > OGS_SBI_SERVICE_TYPE_NULL && + type < OGS_SBI_MAX_NUM_OF_SERVICE_TYPE); + ogs_assert(service_desctype.service_name); + return service_desctype.service_name; +} + +ogs_sbi_service_type_e ogs_sbi_service_type_from_name(const char *name) +{ + int i; + + ogs_assert(name); + + for (i = 0; i < OGS_SBI_MAX_NUM_OF_SERVICE_TYPE; i++) { + if (service_desci.service_name && + strcmp(name, service_desci.service_name) == 0) + return (ogs_sbi_service_type_e)i; + } + + return OGS_SBI_SERVICE_TYPE_NULL; +}
View file
open5gs_2.4.10.tar.xz/lib/sbi/types.h
Added
@@ -0,0 +1,168 @@ +/* + * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#if !defined(OGS_SBI_INSIDE) && !defined(OGS_SBI_COMPILATION) +#error "This header cannot be included directly." +#endif + +#ifndef OGS_SBI_TYPES_H +#define OGS_SBI_TYPES_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + OGS_SBI_SERVICE_TYPE_NULL = 0, + + OGS_SBI_SERVICE_TYPE_NNRF_NFM, + OGS_SBI_SERVICE_TYPE_NNRF_DISC, + OGS_SBI_SERVICE_TYPE_NNRF_OAUTH2, + OGS_SBI_SERVICE_TYPE_NUDM_SDM, + OGS_SBI_SERVICE_TYPE_NUDM_UECM, + OGS_SBI_SERVICE_TYPE_NUDM_UEAU, + OGS_SBI_SERVICE_TYPE_NUDM_EE, + OGS_SBI_SERVICE_TYPE_NUDM_PP, + OGS_SBI_SERVICE_TYPE_NUDM_NIDDAU, + OGS_SBI_SERVICE_TYPE_NUDM_MT, + OGS_SBI_SERVICE_TYPE_NAMF_COMM, + OGS_SBI_SERVICE_TYPE_NAMF_EVTS, + OGS_SBI_SERVICE_TYPE_NAMF_MT, + OGS_SBI_SERVICE_TYPE_NAMF_LOC, + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, + OGS_SBI_SERVICE_TYPE_NSMF_EVENT_EXPOSURE, + OGS_SBI_SERVICE_TYPE_NSMF_NIDD, + OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, + OGS_SBI_SERVICE_TYPE_NAUSF_SORPROTECTION, + OGS_SBI_SERVICE_TYPE_NAUSF_UPUPROTECTION, + OGS_SBI_SERVICE_TYPE_NNEF_PFDMANAGEMENT, + OGS_SBI_SERVICE_TYPE_NNEF_SMCONTEXT, + OGS_SBI_SERVICE_TYPE_NNEF_EVENTEXPOSURE, + OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL, + OGS_SBI_SERVICE_TYPE_NPCF_SMPOLICYCONTROL, + OGS_SBI_SERVICE_TYPE_NPCF_POLICYAUTHORIZATION, + OGS_SBI_SERVICE_TYPE_NPCF_BDTPOLICYCONTROL, + OGS_SBI_SERVICE_TYPE_NPCF_EVENTEXPOSURE, + OGS_SBI_SERVICE_TYPE_NPCF_UE_POLICY_CONTROL, + OGS_SBI_SERVICE_TYPE_NSMSF_SMS, + OGS_SBI_SERVICE_TYPE_NNSSF_NSSELECTION, + OGS_SBI_SERVICE_TYPE_NNSSF_NSSAIAVAILABILITY, + OGS_SBI_SERVICE_TYPE_NUDR_DR, + OGS_SBI_SERVICE_TYPE_NUDR_GROUP_ID_MAP, + OGS_SBI_SERVICE_TYPE_NLMF_LOC, + OGS_SBI_SERVICE_TYPE_N5G_EIR_EIC, + OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, + OGS_SBI_SERVICE_TYPE_NCHF_SPENDINGLIMITCONTROL, + OGS_SBI_SERVICE_TYPE_NCHF_CONVERGEDCHARGING, + OGS_SBI_SERVICE_TYPE_NCHF_OFFLINEONLYCHARGING, + OGS_SBI_SERVICE_TYPE_NNWDAF_EVENTSSUBSCRIPTION, + OGS_SBI_SERVICE_TYPE_NNWDAF_ANALYTICSINFO, + OGS_SBI_SERVICE_TYPE_NGMLC_LOC, + OGS_SBI_SERVICE_TYPE_NUCMF_PROVISIONING, + OGS_SBI_SERVICE_TYPE_NUCMF_UECAPABILITYMANAGEMENT, + OGS_SBI_SERVICE_TYPE_NHSS_SDM, + OGS_SBI_SERVICE_TYPE_NHSS_UECM, + OGS_SBI_SERVICE_TYPE_NHSS_UEAU, + OGS_SBI_SERVICE_TYPE_NHSS_EE, + OGS_SBI_SERVICE_TYPE_NHSS_IMS_SDM, + OGS_SBI_SERVICE_TYPE_NHSS_IMS_UECM, + OGS_SBI_SERVICE_TYPE_NHSS_IMS_UEAU, + OGS_SBI_SERVICE_TYPE_NSEPP_TELESCOPIC, + OGS_SBI_SERVICE_TYPE_NSORAF_SOR, + OGS_SBI_SERVICE_TYPE_NSPAF_SECURED_PACKET, + OGS_SBI_SERVICE_TYPE_NUDSF_DR, + OGS_SBI_SERVICE_TYPE_NNSSAAF_NSSAA, + + OGS_SBI_MAX_NUM_OF_SERVICE_TYPE, +} ogs_sbi_service_type_e; + +#define OGS_SBI_SERVICE_NAME_NNRF_NFM "nnrf-nfm" +#define OGS_SBI_SERVICE_NAME_NNRF_DISC "nnrf-disc" +#define OGS_SBI_SERVICE_NAME_NNRF_OAUTH2 "nnrf-oauth2" +#define OGS_SBI_SERVICE_NAME_NUDM_SDM "nudm-sdm" +#define OGS_SBI_SERVICE_NAME_NUDM_UECM "nudm-uecm" +#define OGS_SBI_SERVICE_NAME_NUDM_UEAU "nudm-ueau" +#define OGS_SBI_SERVICE_NAME_NUDM_EE "nudm-ee" +#define OGS_SBI_SERVICE_NAME_NUDM_PP "nudm-pp" +#define OGS_SBI_SERVICE_NAME_NUDM_NIDDAU "nudm-niddau" +#define OGS_SBI_SERVICE_NAME_NUDM_MT "nudm-mt" +#define OGS_SBI_SERVICE_NAME_NAMF_COMM "namf-comm" +#define OGS_SBI_SERVICE_NAME_NAMF_EVTS "namf-evts" +#define OGS_SBI_SERVICE_NAME_NAMF_MT "namf-mt" +#define OGS_SBI_SERVICE_NAME_NAMF_LOC "namf-loc" +#define OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION "nsmf-pdusession" +#define OGS_SBI_SERVICE_NAME_NSMF_EVENT_EXPOSURE "nsmf-event-exposure" +#define OGS_SBI_SERVICE_NAME_NSMF_NIDD "nsmf-nidd" +#define OGS_SBI_SERVICE_NAME_NAUSF_AUTH "nausf-auth" +#define OGS_SBI_SERVICE_NAME_NAUSF_SORPROTECTION "nausf-sorprotection" +#define OGS_SBI_SERVICE_NAME_NAUSF_UPUPROTECTION "nausf-upuprotection" +#define OGS_SBI_SERVICE_NAME_NNEF_PFDMANAGEMENT "nnef-pfdmanagement" +#define OGS_SBI_SERVICE_NAME_NNEF_SMCONTEXT "nnef-smcontext" +#define OGS_SBI_SERVICE_NAME_NNEF_EVENTEXPOSURE "nnef-eventexposure" +#define OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL "npcf-am-policy-control" +#define OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL "npcf-smpolicycontrol" +#define OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION "npcf-policyauthorization" +#define OGS_SBI_SERVICE_NAME_NPCF_BDTPOLICYCONTROL "npcf-bdtpolicycontrol" +#define OGS_SBI_SERVICE_NAME_NPCF_EVENTEXPOSURE "npcf-eventexposure" +#define OGS_SBI_SERVICE_NAME_NPCF_UE_POLICY_CONTROL "npcf-ue-policy-control" +#define OGS_SBI_SERVICE_NAME_NSMSF_SMS "nsmsf-sms" +#define OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION "nnssf-nsselection" +#define OGS_SBI_SERVICE_NAME_NNSSF_NSSAIAVAILABILITY "nnssf-nssaiavailability" +#define OGS_SBI_SERVICE_NAME_NUDR_DR "nudr-dr" +#define OGS_SBI_SERVICE_NAME_NUDR_GROUP_ID_MAP "nudr-group-id-map" +#define OGS_SBI_SERVICE_NAME_NLMF_LOC "nlmf-loc" +#define OGS_SBI_SERVICE_NAME_N5G_EIR_EIC "n5g-eir-eic" +#define OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT "nbsf-management" +#define OGS_SBI_SERVICE_NAME_NCHF_SPENDINGLIMITCONTROL \ + "nchf-spendinglimitcontrol" +#define OGS_SBI_SERVICE_NAME_NCHF_CONVERGEDCHARGING "nchf-convergedcharging" +#define OGS_SBI_SERVICE_NAME_NCHF_OFFLINEONLYCHARGING "nchf-offlineonlycharging" +#define OGS_SBI_SERVICE_NAME_NNWDAF_EVENTSSUBSCRIPTION \ + "nnwdaf-eventssubscription" +#define OGS_SBI_SERVICE_NAME_NNWDAF_ANALYTICSINFO "nnwdaf-analyticsinfo" +#define OGS_SBI_SERVICE_NAME_NGMLC_LOC "ngmlc-loc" +#define OGS_SBI_SERVICE_NAME_NUCMF_PROVISIONING "nucmf-provisioning" +#define OGS_SBI_SERVICE_NAME_NUCMF_UECAPABILITYMANAGEMENT \ + "nucmf-uecapabilitymanagement" +#define OGS_SBI_SERVICE_NAME_NHSS_SDM "nhss-sdm" +#define OGS_SBI_SERVICE_NAME_NHSS_UECM "nhss-uecm" +#define OGS_SBI_SERVICE_NAME_NHSS_UEAU "nhss-ueau" +#define OGS_SBI_SERVICE_NAME_NHSS_EE "nhss-ee" +#define OGS_SBI_SERVICE_NAME_NHSS_IMS_SDM "nhss-ims-sdm" +#define OGS_SBI_SERVICE_NAME_NHSS_IMS_UECM "nhss-ims-uecm" +#define OGS_SBI_SERVICE_NAME_NHSS_IMS_UEAU "nhss-ims-ueau" +#define OGS_SBI_SERVICE_NAME_NSEPP_TELESCOPIC "nsepp-telescopic" +#define OGS_SBI_SERVICE_NAME_NSORAF_SOR "nsoraf-sor" +#define OGS_SBI_SERVICE_NAME_NSPAF_SECURED_PACKET "nspaf-secured-packet" +#define OGS_SBI_SERVICE_NAME_NUDSF_DR "nudsf-dr" +#define OGS_SBI_SERVICE_NAME_NNSSAAF_NSSAA "nnssaaf-nssaa" + +#define OGS_SBI_SERVICE_NAME_NAMF_CALLBACK "namf-callback" +#define OGS_SBI_SERVICE_NAME_NSMF_CALLBACK "nsmf-callback" + +OpenAPI_nf_type_e ogs_sbi_service_type_to_nf_type( + ogs_sbi_service_type_e service_type); +const char *ogs_sbi_service_type_to_name(ogs_sbi_service_type_e service_type); +ogs_sbi_service_type_e ogs_sbi_service_type_from_name(const char *service_name); + +#ifdef __cplusplus +} +#endif + +#endif /* OGS_SBI_TYPES_H */
View file
open5gs_2.4.9.tar.xz/lib/sctp/ogs-sctp.h -> open5gs_2.4.10.tar.xz/lib/sctp/ogs-sctp.h
Changed
@@ -20,7 +20,7 @@ #ifndef OGS_SCTP_H #define OGS_SCTP_H -#include "ogs-app.h" +#include "app/ogs-app.h" #include "sctp/sctp-config.h"
View file
open5gs_2.4.9.tar.xz/lib/sctp/ogs-usrsctp.c -> open5gs_2.4.10.tar.xz/lib/sctp/ogs-usrsctp.c
Changed
@@ -321,14 +321,14 @@ int ogs_sctp_recvmsg(ogs_sock_t *sock, void *msg, size_t len, ogs_sockaddr_t *from, ogs_sctp_info_t *sinfo, int *msg_flags) { - struct socket *socket = (struct socket *)sock; + struct socket *socket = (struct socket *)sock; ogs_sockaddr_t addr; - ssize_t n = 0; - int flags = 0; + ssize_t n = 0; + int flags = 0; socklen_t addrlen = sizeof(struct sockaddr_storage); - socklen_t infolen; - struct sctp_rcvinfo rcv_info; - unsigned int infotype = 0; + socklen_t infolen; + struct sctp_rcvinfo rcv_info; + unsigned int infotype = 0; ogs_assert(socket);
View file
open5gs_2.4.9.tar.xz/lib/tun/mac-setup.c -> open5gs_2.4.10.tar.xz/lib/tun/mac-setup.c
Changed
@@ -39,42 +39,42 @@ static int utun_open(int unit, char *ifname, socklen_t maxlen) { - struct sockaddr_ctl addr; - struct ctl_info info; - int fd = -1; - int err = 0; + struct sockaddr_ctl addr; + struct ctl_info info; + int fd = -1; + int err = 0; ogs_assert(ifname); ogs_assert(maxlen); - fd = socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL); - if (fd < 0) return fd; + fd = socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL); + if (fd < 0) return fd; - bzero(&info, sizeof (info)); - strncpy(info.ctl_name, UTUN_CONTROL_NAME, MAX_KCTL_NAME); + bzero(&info, sizeof (info)); + strncpy(info.ctl_name, UTUN_CONTROL_NAME, MAX_KCTL_NAME); - err = ioctl(fd, CTLIOCGINFO, &info); - if (err != 0) goto on_error; + err = ioctl(fd, CTLIOCGINFO, &info); + if (err != 0) goto on_error; - addr.sc_len = sizeof(addr); - addr.sc_family = AF_SYSTEM; - addr.ss_sysaddr = AF_SYS_CONTROL; - addr.sc_id = info.ctl_id; - addr.sc_unit = unit + 1; + addr.sc_len = sizeof(addr); + addr.sc_family = AF_SYSTEM; + addr.ss_sysaddr = AF_SYS_CONTROL; + addr.sc_id = info.ctl_id; + addr.sc_unit = unit + 1; - err = connect(fd, (struct sockaddr *)&addr, sizeof (addr)); - if (err != 0) goto on_error; + err = connect(fd, (struct sockaddr *)&addr, sizeof (addr)); + if (err != 0) goto on_error; - err = getsockopt(fd, SYSPROTO_CONTROL, UTUN_OPT_IFNAME, ifname, &maxlen); - if (err != 0) goto on_error; + err = getsockopt(fd, SYSPROTO_CONTROL, UTUN_OPT_IFNAME, ifname, &maxlen); + if (err != 0) goto on_error; on_error: - if (err != 0) { - close(fd); - return err; - } + if (err != 0) { + close(fd); + return err; + } - return fd; + return fd; } #endif @@ -118,51 +118,51 @@ { int fd; - struct ifaliasreq ifa; - struct ifreq ifr; - struct sockaddr_in addr; - struct sockaddr_in mask; + struct ifaliasreq ifa; + struct ifreq ifr; + struct sockaddr_in addr; + struct sockaddr_in mask; char buf512; int len; struct rt_msghdr *rtm; struct sockaddr_in dst, gw; - struct sockaddr_in *paddr; + struct sockaddr_in *paddr; ogs_assert(ipaddr); ogs_assert(ipsub); fd = socket(ipaddr->family, SOCK_DGRAM, 0); - (void)memset(&ifa, '\0', sizeof ifa); - (void)strlcpy(ifa.ifra_name, ifname, sizeof ifa.ifra_name); + (void)memset(&ifa, '\0', sizeof ifa); + (void)strlcpy(ifa.ifra_name, ifname, sizeof ifa.ifra_name); - (void)memset(&ifr, '\0', sizeof ifr); - (void)strlcpy(ifr.ifr_name, ifname, sizeof ifr.ifr_name); + (void)memset(&ifr, '\0', sizeof ifr); + (void)strlcpy(ifr.ifr_name, ifname, sizeof ifr.ifr_name); #if 0 - /* Delete previously assigned address */ - (void)ioctl(fd, SIOCDIFADDR, &ifr); + /* Delete previously assigned address */ + (void)ioctl(fd, SIOCDIFADDR, &ifr); #endif - (void)memset(&addr, '\0', sizeof(addr)); - addr.sin_family = ipaddr->family; - addr.sin_addr.s_addr = ipaddr->sub0; - addr.sin_len = sizeof(addr); - (void)memcpy(&ifa.ifra_addr, &addr, sizeof(addr)); - (void)memcpy(&ifa.ifra_broadaddr, &addr, sizeof(addr)); - - (void)memset(&mask, '\0', sizeof(mask)); - mask.sin_family = ipaddr->family; - mask.sin_addr.s_addr = ipaddr->mask0; - mask.sin_len = sizeof(mask); - (void)memcpy(&ifa.ifra_mask, &mask, sizeof(ifa.ifra_mask)); + (void)memset(&addr, '\0', sizeof(addr)); + addr.sin_family = ipaddr->family; + addr.sin_addr.s_addr = ipaddr->sub0; + addr.sin_len = sizeof(addr); + (void)memcpy(&ifa.ifra_addr, &addr, sizeof(addr)); + (void)memcpy(&ifa.ifra_broadaddr, &addr, sizeof(addr)); + + (void)memset(&mask, '\0', sizeof(mask)); + mask.sin_family = ipaddr->family; + mask.sin_addr.s_addr = ipaddr->mask0; + mask.sin_len = sizeof(mask); + (void)memcpy(&ifa.ifra_mask, &mask, sizeof(ifa.ifra_mask)); - if (ioctl(fd, SIOCAIFADDR, &ifa) == -1) { + if (ioctl(fd, SIOCAIFADDR, &ifa) == -1) { ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno, "Can't IP address : dev%s", ifname); - return OGS_ERROR; - } + return OGS_ERROR; + } close(fd); /* SOCK_DGRAM */ @@ -183,27 +183,27 @@ rtm->rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK; paddr = (struct sockaddr_in *)(rtm + 1); - (void)memset(&dst, '\0', sizeof(dst)); - dst.sin_family = ipaddr->family; - dst.sin_addr.s_addr = ipsub->sub0; - dst.sin_len = sizeof(dst); - (void)memcpy(paddr, &dst, sizeof(dst)); + (void)memset(&dst, '\0', sizeof(dst)); + dst.sin_family = ipaddr->family; + dst.sin_addr.s_addr = ipsub->sub0; + dst.sin_len = sizeof(dst); + (void)memcpy(paddr, &dst, sizeof(dst)); paddr = (struct sockaddr_in *)((char *)paddr + TUN_ALIGN(sizeof(*paddr), sizeof(uintptr_t))); - (void)memset(&gw, '\0', sizeof(gw)); - gw.sin_family = ipaddr->family; - gw.sin_addr.s_addr = ipaddr->sub0; - gw.sin_len = sizeof(gw); - (void)memcpy(paddr, &gw, sizeof(gw)); + (void)memset(&gw, '\0', sizeof(gw)); + gw.sin_family = ipaddr->family; + gw.sin_addr.s_addr = ipaddr->sub0; + gw.sin_len = sizeof(gw); + (void)memcpy(paddr, &gw, sizeof(gw)); paddr = (struct sockaddr_in *)((char *)paddr + TUN_ALIGN(sizeof(*paddr), sizeof(uintptr_t))); - (void)memset(&mask, '\0', sizeof(mask)); - mask.sin_family = ipaddr->family; - mask.sin_addr.s_addr = ipsub->mask0; - mask.sin_len = sizeof(mask); - (void)memcpy(paddr, &mask, sizeof(mask)); + (void)memset(&mask, '\0', sizeof(mask)); + mask.sin_family = ipaddr->family; + mask.sin_addr.s_addr = ipsub->mask0; + mask.sin_len = sizeof(mask); + (void)memcpy(paddr, &mask, sizeof(mask)); paddr = (struct sockaddr_in *)((char *)paddr + TUN_ALIGN(sizeof(*paddr), sizeof(uintptr_t))); @@ -217,7 +217,7 @@ close(fd); /* PF_ROUTE, SOCK_RAW */ - return OGS_OK; + return OGS_OK; } static int tun_set_ipv6(char *ifname, @@ -263,54 +263,54 @@ #else /* IPv6 Setting API is not working in UTUN */ int fd; - struct in6_aliasreq ifa; - struct in6_ifreq ifr; - struct sockaddr_in6 addr; - struct sockaddr_in6 mask; + struct in6_aliasreq ifa; + struct in6_ifreq ifr; + struct sockaddr_in6 addr; + struct sockaddr_in6 mask; char buf512; int len; struct rt_msghdr *rtm; struct sockaddr_in6 dst, gw; - struct sockaddr_in6 *paddr; + struct sockaddr_in6 *paddr; ogs_assert(ipaddr); ogs_assert(ipsub); fd = socket(ipaddr->family, SOCK_DGRAM, 0); - (void)memset(&ifa, '\0', sizeof ifa); - (void)strlcpy(ifa.ifra_name, ifname, sizeof ifa.ifra_name); + (void)memset(&ifa, '\0', sizeof ifa); + (void)strlcpy(ifa.ifra_name, ifname, sizeof ifa.ifra_name); - (void)memset(&ifr, '\0', sizeof ifr); - (void)strlcpy(ifr.ifr_name, ifname, sizeof ifr.ifr_name); + (void)memset(&ifr, '\0', sizeof ifr); + (void)strlcpy(ifr.ifr_name, ifname, sizeof ifr.ifr_name); #if 0 - /* Delete previously assigned address */ - (void)ioctl(fd, SIOCDIFADDR, &ifr); + /* Delete previously assigned address */ + (void)ioctl(fd, SIOCDIFADDR, &ifr); #endif - (void)memset(&addr, '\0', sizeof(addr)); - addr.sin6_family = ipaddr->family; + (void)memset(&addr, '\0', sizeof(addr)); + addr.sin6_family = ipaddr->family; memcpy(addr.sin6_addr.s6_addr, ipaddr->sub, sizeof ipaddr->sub); - addr.sin6_len = sizeof(addr); - (void)memcpy(&ifa.ifra_addr, &addr, sizeof(addr)); - (void)memcpy(&ifa.ifra_dstaddr, &addr, sizeof(addr)); + addr.sin6_len = sizeof(addr); + (void)memcpy(&ifa.ifra_addr, &addr, sizeof(addr)); + (void)memcpy(&ifa.ifra_dstaddr, &addr, sizeof(addr)); - (void)memset(&mask, '\0', sizeof(mask)); - mask.sin6_family = ipaddr->family; + (void)memset(&mask, '\0', sizeof(mask)); + mask.sin6_family = ipaddr->family; memcpy(mask.sin6_addr.s6_addr, ipaddr->mask, sizeof ipaddr->mask); - mask.sin6_len = sizeof(mask); - (void)memcpy(&ifa.ifra_prefixmask, &mask, sizeof(ifa.ifra_prefixmask)); + mask.sin6_len = sizeof(mask); + (void)memcpy(&ifa.ifra_prefixmask, &mask, sizeof(ifa.ifra_prefixmask)); ifa.ifra_lifetime.ia6t_vltime = ND6_INFINITE_LIFETIME; ifa.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME; - if (ioctl(fd, SIOCAIFADDR_IN6, &ifa) == -1) { + if (ioctl(fd, SIOCAIFADDR_IN6, &ifa) == -1) { ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno, "Can't IP address : dev%s", ifname); - return OGS_ERROR; - } + return OGS_ERROR; + } close(fd); /* SOCK_DGRAM */ @@ -331,11 +331,11 @@ rtm->rtm_addrs = RTA_DST; paddr = (struct sockaddr_in6 *)(rtm + 1); - (void)memset(&dst, '\0', sizeof(dst)); - dst.sin6_family = ipaddr->family; + (void)memset(&dst, '\0', sizeof(dst)); + dst.sin6_family = ipaddr->family; memcpy(dst.sin6_addr.s6_addr, ipaddr->sub, sizeof ipsub->sub); - dst.sin6_len = sizeof(dst); - (void)memcpy(paddr, &dst, sizeof(dst)); + dst.sin6_len = sizeof(dst); + (void)memcpy(paddr, &dst, sizeof(dst)); paddr = (struct sockaddr_in6 *)((char *)paddr + TUN_ALIGN(sizeof(*paddr), sizeof(uintptr_t))); @@ -359,27 +359,27 @@ rtm->rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK; paddr = (struct sockaddr_in6 *)(rtm + 1); - (void)memset(&dst, '\0', sizeof(dst)); - dst.sin6_family = ipaddr->family; + (void)memset(&dst, '\0', sizeof(dst)); + dst.sin6_family = ipaddr->family; memcpy(dst.sin6_addr.s6_addr, ipsub->sub, sizeof ipsub->sub); - dst.sin6_len = sizeof(dst); - (void)memcpy(paddr, &dst, sizeof(dst)); + dst.sin6_len = sizeof(dst); + (void)memcpy(paddr, &dst, sizeof(dst)); paddr = (struct sockaddr_in6 *)((char *)paddr + TUN_ALIGN(sizeof(*paddr), sizeof(uintptr_t))); - (void)memset(&gw, '\0', sizeof(gw)); - gw.sin6_family = ipaddr->family; + (void)memset(&gw, '\0', sizeof(gw)); + gw.sin6_family = ipaddr->family; memcpy(gw.sin6_addr.s6_addr, ipaddr->sub, sizeof ipaddr->sub); - gw.sin6_len = sizeof(gw); - (void)memcpy(paddr, &gw, sizeof(gw)); + gw.sin6_len = sizeof(gw); + (void)memcpy(paddr, &gw, sizeof(gw)); paddr = (struct sockaddr_in6 *)((char *)paddr + TUN_ALIGN(sizeof(*paddr), sizeof(uintptr_t))); - (void)memset(&mask, '\0', sizeof(mask)); - mask.sin6_family = ipaddr->family; + (void)memset(&mask, '\0', sizeof(mask)); + mask.sin6_family = ipaddr->family; memcpy(mask.sin6_addr.s6_addr, ipsub->mask, sizeof ipsub->mask); - mask.sin6_len = sizeof(mask); - (void)memcpy(paddr, &mask, sizeof(mask)); + mask.sin6_len = sizeof(mask); + (void)memcpy(paddr, &mask, sizeof(mask)); paddr = (struct sockaddr_in6 *)((char *)paddr + TUN_ALIGN(sizeof(*paddr), sizeof(uintptr_t))); @@ -395,7 +395,7 @@ #endif - return OGS_OK; + return OGS_OK; } int ogs_tun_set_ip(char *ifname, ogs_ipsubnet_t *gw, ogs_ipsubnet_t *sub)
View file
open5gs_2.4.9.tar.xz/lib/tun/meson.build -> open5gs_2.4.10.tar.xz/lib/tun/meson.build
Changed
@@ -36,10 +36,10 @@ version : libogslib_version, c_args : '-DOGS_TUN_COMPILATION', include_directories : libtun_inc, libinc, - dependencies : libcore_dep, libipfw_dep, + dependencies : libipfw_dep, install : true) libtun_dep = declare_dependency( link_with : libtun, include_directories : libtun_inc, libinc, - dependencies : libcore_dep, libipfw_dep) + dependencies : libipfw_dep)
View file
open5gs_2.4.9.tar.xz/lib/tun/ogs-tun.h -> open5gs_2.4.10.tar.xz/lib/tun/ogs-tun.h
Changed
@@ -20,7 +20,7 @@ #ifndef OGS_TUN_H #define OGS_TUN_H -#include "ogs-core.h" +#include "proto/ogs-proto.h" #ifdef __cplusplus extern "C" {
View file
open5gs_2.4.9.tar.xz/meson.build -> open5gs_2.4.10.tar.xz/meson.build
Changed
@@ -16,7 +16,7 @@ # along with this program. If not, see <https://www.gnu.org/licenses/>. project('open5gs', 'c', 'cpp', - version : '2.4.9', + version : '2.4.10', license : 'AGPL-3.0-or-later', meson_version : '>= 0.43.0', default_options : @@ -24,7 +24,7 @@ , ) -libogslib_version = '2.4.9' +libogslib_version = '2.4.10' prefix = get_option('prefix') bindir = join_paths(prefix, get_option('bindir'))
View file
open5gs_2.4.9.tar.xz/misc/db/open5gs-dbctl -> open5gs_2.4.10.tar.xz/misc/db/open5gs-dbctl
Changed
@@ -689,8 +689,5 @@ mongo --eval "db.subscribers.find({},{'_id':0,'imsi':1,'security.k':1, 'security.opc':1,'slice.session.name':1,'slice.session.ue.addr':1})" $DB_URI exit $? fi - echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl add imsi key opc\"" - exit 1 -fi display_help
View file
open5gs_2.4.9.tar.xz/misc/netconf.sh -> open5gs_2.4.10.tar.xz/misc/netconf.sh
Changed
@@ -6,10 +6,10 @@ if ! grep "ogstun" /proc/net/dev > /dev/null; then ip tuntap add name ogstun mode tun fi - if test "x`sysctl -n net.ipv6.conf.ogstun.disable_ipv6`" = x1; then - echo "net.ipv6.conf.ogstun.disable_ipv6=0" > /etc/sysctl.d/30-open5gs.conf - sysctl -p /etc/sysctl.d/30-open5gs.conf - fi + if test "x`sysctl -n net.ipv6.conf.ogstun.disable_ipv6`" = x1; then + echo "net.ipv6.conf.ogstun.disable_ipv6=0" > /etc/sysctl.d/30-open5gs.conf + sysctl -p /etc/sysctl.d/30-open5gs.conf + fi ip addr del 10.45.0.1/16 dev ogstun 2> /dev/null ip addr add 10.45.0.1/16 dev ogstun ip addr del 2001:db8:cafe::1/48 dev ogstun 2> /dev/null
View file
open5gs_2.4.9.tar.xz/src/amf/amf-sm.c -> open5gs_2.4.10.tar.xz/src/amf/amf-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -68,10 +68,10 @@ int state = AMF_CREATE_SM_CONTEXT_NO_STATE; ogs_sbi_stream_t *stream = NULL; ogs_sbi_request_t *sbi_request = NULL; - OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; + ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; ogs_sbi_response_t *sbi_response = NULL; ogs_sbi_message_t sbi_message; @@ -79,17 +79,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case AMF_EVT_SBI_SERVER: - sbi_request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + sbi_request = e->h.sbi.request; ogs_assert(sbi_request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&sbi_message, sbi_request); @@ -129,7 +129,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(sbi_message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - amf_nnrf_handle_nf_status_notify(stream, &sbi_message); + ogs_nnrf_handle_nf_status_notify(stream, &sbi_message); break; DEFAULT @@ -240,10 +240,10 @@ ogs_sbi_message_free(&sbi_message); break; - case AMF_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - sbi_response = e->sbi.response; + sbi_response = e->h.sbi.response; ogs_assert(sbi_response); rv = ogs_sbi_parse_response(&sbi_message, sbi_response); if (rv != OGS_OK) { @@ -275,37 +275,37 @@ SWITCH(sbi_message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &sbi_message; + e->h.sbi.message = &sbi_message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; - ogs_assert(subscription); + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); SWITCH(sbi_message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) if (sbi_message.res_status == OGS_SBI_HTTP_STATUS_CREATED || sbi_message.res_status == OGS_SBI_HTTP_STATUS_OK) { - amf_nnrf_handle_nf_status_subscribe( - subscription, &sbi_message); + ogs_nnrf_handle_nf_status_subscribe( + subscription_data, &sbi_message); } else { ogs_error("%s HTTP response error %d", - subscription->id, sbi_message.res_status); + subscription_data->id, sbi_message.res_status); } break; CASE(OGS_SBI_HTTP_METHOD_DELETE) if (sbi_message.res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT) { - ogs_sbi_subscription_remove(subscription); + ogs_sbi_subscription_data_remove(subscription_data); } else { ogs_error("%s HTTP response error %d", - subscription->id, sbi_message.res_status); + subscription_data->id, sbi_message.res_status); } break; @@ -325,7 +325,7 @@ CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) SWITCH(sbi_message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); SWITCH(sbi_message.h.method) @@ -354,7 +354,7 @@ 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; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -376,7 +376,7 @@ ogs_assert(OGS_FSM_STATE(&amf_ue->sm)); e->amf_ue = amf_ue; - e->sbi.message = &sbi_message;; + e->h.sbi.message = &sbi_message;; ogs_fsm_dispatch(&amf_ue->sm, e); } else { @@ -385,7 +385,7 @@ break; CASE(OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -398,10 +398,11 @@ state = sbi_xact->state; - ogs_sbi_xact_remove(sbi_xact); - sess = (amf_sess_t *)sbi_xact->sbi_object; ogs_assert(sess); + + ogs_sbi_xact_remove(sbi_xact); + sess = amf_sess_cycle(sess); if (!sess) { /* @@ -449,7 +450,7 @@ e->amf_ue = amf_ue; e->sess = sess; - e->sbi.message = &sbi_message;; + e->h.sbi.message = &sbi_message;; SWITCH(sbi_message.h.resource.component2) CASE(OGS_SBI_RESOURCE_NAME_MODIFY) @@ -502,7 +503,7 @@ break; CASE(OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -535,7 +536,7 @@ e->amf_ue = amf_ue; e->sess = sess; - e->sbi.message = &sbi_message;; + e->h.sbi.message = &sbi_message;; amf_nnssf_nsselection_handle_get(sess, &sbi_message); break; @@ -549,48 +550,45 @@ ogs_sbi_response_free(sbi_response); break; - case AMF_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case AMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case AMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case AMF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case AMF_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.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, amf_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s:%s State machine exception %d", OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case AMF_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; - ogs_assert(subscription); + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); - ogs_assert(ogs_sbi_self()->nf_instance); ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client, - ogs_sbi_self()->nf_instance->nf_type, - subscription->req_nf_instance_id, - subscription->subscr_cond.nf_type)); + ogs_nnrf_nfm_send_nf_status_subscribe(subscription_data)); - ogs_info("%s Subscription validity expired", subscription->id); - ogs_sbi_subscription_remove(subscription); + ogs_info("Subscription validity expired %s", + subscription_data->id); + ogs_sbi_subscription_data_remove(subscription_data); break; - case AMF_TIMER_SBI_CLIENT_WAIT: - sbi_xact = e->sbi.data; + case OGS_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_object = sbi_xact->sbi_object; ogs_assert(sbi_object); - target_nf_type = sbi_xact->target_nf_type; + service_type = sbi_xact->service_type; ogs_sbi_xact_remove(sbi_xact); @@ -640,18 +638,19 @@ default: ogs_fatal("Not implemented %s:%d", - OpenAPI_nf_type_ToString(target_nf_type), sbi_object->type); + ogs_sbi_service_type_to_name(service_type), + sbi_object->type); ogs_assert_if_reached(); } break; default: ogs_error("Unknown timer%s:%d", - amf_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break; - case AMF_EVT_NGAP_LO_ACCEPT: + case AMF_EVENT_NGAP_LO_ACCEPT: sock = e->ngap.sock; ogs_assert(sock); addr = e->ngap.addr; @@ -674,7 +673,7 @@ break; - case AMF_EVT_NGAP_LO_SCTP_COMM_UP: + case AMF_EVENT_NGAP_LO_SCTP_COMM_UP: sock = e->ngap.sock; ogs_assert(sock); addr = e->ngap.addr; @@ -701,7 +700,7 @@ break; - case AMF_EVT_NGAP_LO_CONNREFUSED: + case AMF_EVENT_NGAP_LO_CONNREFUSED: sock = e->ngap.sock; ogs_assert(sock); addr = e->ngap.addr; @@ -720,7 +719,7 @@ ogs_free(addr); break; - case AMF_EVT_NGAP_MESSAGE: + case AMF_EVENT_NGAP_MESSAGE: sock = e->ngap.sock; ogs_assert(sock); addr = e->ngap.addr; @@ -751,11 +750,11 @@ ogs_pkbuf_free(pkbuf); break; - case AMF_EVT_NGAP_TIMER: + case AMF_EVENT_NGAP_TIMER: ran_ue = e->ran_ue; ogs_assert(ran_ue); - switch (e->timer_id) { + switch (e->h.timer_id) { case AMF_TIMER_NG_DELAYED_SEND: gnb = e->gnb; ogs_assert(gnb); @@ -774,12 +773,12 @@ break; default: ogs_error("Unknown timer%s:%d", - amf_timer_get_name(e->timer_id), e->timer_id); + amf_timer_get_name(e->h.timer_id), e->h.timer_id); break; } break; - case AMF_EVT_5GMM_MESSAGE: + case AMF_EVENT_5GMM_MESSAGE: ran_ue = e->ran_ue; ogs_assert(ran_ue); pkbuf = e->pkbuf; @@ -867,7 +866,7 @@ ogs_pkbuf_free(pkbuf); break; - case AMF_EVT_5GMM_TIMER: + case AMF_EVENT_5GMM_TIMER: amf_ue = e->amf_ue; ogs_assert(amf_ue); ogs_assert(OGS_FSM_STATE(&amf_ue->sm));
View file
open5gs_2.4.9.tar.xz/src/amf/amf-sm.h -> open5gs_2.4.10.tar.xz/src/amf/amf-sm.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,16 +30,6 @@ void amf_state_final(ogs_fsm_t *s, amf_event_t *e); void amf_state_operational(ogs_fsm_t *s, amf_event_t *e); -void amf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void amf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void amf_nf_state_initial(ogs_fsm_t *s, amf_event_t *e); -void amf_nf_state_final(ogs_fsm_t *s, amf_event_t *e); -void amf_nf_state_will_register(ogs_fsm_t *s, amf_event_t *e); -void amf_nf_state_registered(ogs_fsm_t *s, amf_event_t *e); -void amf_nf_state_de_registered(ogs_fsm_t *s, amf_event_t *e); -void amf_nf_state_exception(ogs_fsm_t *s, amf_event_t *e); - void ngap_state_initial(ogs_fsm_t *s, amf_event_t *e); void ngap_state_final(ogs_fsm_t *s, amf_event_t *e); void ngap_state_operational(ogs_fsm_t *s, amf_event_t *e);
View file
open5gs_2.4.9.tar.xz/src/amf/context.c -> open5gs_2.4.10.tar.xz/src/amf/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -56,7 +56,7 @@ ogs_list_init(&self.ngap_list6); /* Allocate TWICE the pool to check if maximum number of gNBs is reached */ - ogs_pool_init(&amf_gnb_pool, ogs_app()->max.gnb*2); + ogs_pool_init(&amf_gnb_pool, ogs_app()->max.peer*2); ogs_pool_init(&amf_ue_pool, ogs_app()->max.ue); ogs_pool_init(&ran_ue_pool, ogs_app()->max.ue); ogs_pool_init(&amf_sess_pool, ogs_app()->pool.sess); @@ -821,6 +821,10 @@ self.amf_name = ogs_yaml_iter_value(&amf_iter); } else if (!strcmp(amf_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(amf_key, "service_name")) { + /* handle config in sbi library */ + } else if (!strcmp(amf_key, "discovery")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", amf_key); } @@ -868,8 +872,7 @@ memset(&e, 0, sizeof(e)); e.gnb = gnb; - ogs_fsm_create(&gnb->sm, ngap_state_initial, ngap_state_final); - ogs_fsm_init(&gnb->sm, &e); + ogs_fsm_init(&gnb->sm, ngap_state_initial, ngap_state_final, &e); ogs_list_add(&self.gnb_list, gnb); amf_metrics_inst_global_inc(AMF_METR_GLOB_GAUGE_GNB); @@ -892,7 +895,6 @@ memset(&e, 0, sizeof(e)); e.gnb = gnb; ogs_fsm_fini(&gnb->sm, &e); - ogs_fsm_delete(&gnb->sm); ogs_hash_set(self.gnb_addr_hash, gnb->sctp.addr, sizeof(ogs_sockaddr_t), NULL); @@ -971,6 +973,14 @@ ogs_assert(ran_ue); memset(ran_ue, 0, sizeof *ran_ue); + ran_ue->t_ng_holding = ogs_timer_add( + ogs_app()->timer_mgr, amf_timer_ng_holding_timer_expire, ran_ue); + if (!ran_ue->t_ng_holding) { + ogs_error("ogs_timer_add() failed"); + ogs_pool_free(&ran_ue_pool, ran_ue); + return NULL; + } + ran_ue->index = ogs_pool_index(&ran_ue_pool, ran_ue); ogs_assert(ran_ue->index > 0 && ran_ue->index <= ogs_app()->max.ue); @@ -987,10 +997,6 @@ ran_ue->gnb_ostream_id = OGS_NEXT_ID(gnb->ostream_id, 1, gnb->max_num_of_ostreams-1); - ran_ue->t_ng_holding = ogs_timer_add( - ogs_app()->timer_mgr, amf_timer_ng_holding_timer_expire, ran_ue); - ogs_assert(ran_ue->t_ng_holding); - ran_ue->gnb = gnb; ogs_list_add(&gnb->ran_ue_list, ran_ue); @@ -1161,41 +1167,71 @@ ogs_assert(amf_ue); memset(amf_ue, 0, sizeof *amf_ue); - /* SBI Type */ - amf_ue->sbi.type = OGS_SBI_OBJ_UE_TYPE; - - /* SBI Features */ - OGS_SBI_FEATURES_SET(amf_ue->am_policy_control_features, - OGS_SBI_NPCF_AM_POLICY_CONTROL_UE_AMBR_AUTHORIZATION); - - ogs_list_init(&amf_ue->sess_list); - - /* Initialization */ - amf_ue->guami = &amf_self()->served_guami0; - amf_ue->nas.access_type = OGS_ACCESS_TYPE_3GPP; - amf_ue->nas.amf.ksi = OGS_NAS_KSI_NO_KEY_IS_AVAILABLE; - amf_ue->abba_len = 2; - /* Add All Timers */ amf_ue->t3513.timer = ogs_timer_add( ogs_app()->timer_mgr, amf_timer_t3513_expire, amf_ue); + if (!amf_ue->t3513.timer) { + ogs_error("ogs_timer_add() failed"); + ogs_pool_free(&amf_ue_pool, amf_ue); + return NULL; + } amf_ue->t3513.pkbuf = NULL; amf_ue->t3522.timer = ogs_timer_add( ogs_app()->timer_mgr, amf_timer_t3522_expire, amf_ue); + if (!amf_ue->t3522.timer) { + ogs_error("ogs_timer_add() failed"); + ogs_pool_free(&amf_ue_pool, amf_ue); + return NULL; + } amf_ue->t3522.pkbuf = NULL; amf_ue->t3550.timer = ogs_timer_add( ogs_app()->timer_mgr, amf_timer_t3550_expire, amf_ue); + if (!amf_ue->t3550.timer) { + ogs_error("ogs_timer_add() failed"); + ogs_pool_free(&amf_ue_pool, amf_ue); + return NULL; + } amf_ue->t3550.pkbuf = NULL; amf_ue->t3555.timer = ogs_timer_add( ogs_app()->timer_mgr, amf_timer_t3555_expire, amf_ue); + if (!amf_ue->t3555.timer) { + ogs_error("ogs_timer_add() failed"); + ogs_pool_free(&amf_ue_pool, amf_ue); + return NULL; + } amf_ue->t3555.pkbuf = NULL; amf_ue->t3560.timer = ogs_timer_add( ogs_app()->timer_mgr, amf_timer_t3560_expire, amf_ue); + if (!amf_ue->t3560.timer) { + ogs_error("ogs_timer_add() failed"); + ogs_pool_free(&amf_ue_pool, amf_ue); + return NULL; + } amf_ue->t3560.pkbuf = NULL; amf_ue->t3570.timer = ogs_timer_add( ogs_app()->timer_mgr, amf_timer_t3570_expire, amf_ue); + if (!amf_ue->t3570.timer) { + ogs_error("ogs_timer_add() failed"); + ogs_pool_free(&amf_ue_pool, amf_ue); + return NULL; + } amf_ue->t3570.pkbuf = NULL; + /* SBI Type */ + amf_ue->sbi.type = OGS_SBI_OBJ_UE_TYPE; + + /* SBI Features */ + OGS_SBI_FEATURES_SET(amf_ue->am_policy_control_features, + OGS_SBI_NPCF_AM_POLICY_CONTROL_UE_AMBR_AUTHORIZATION); + + ogs_list_init(&amf_ue->sess_list); + + /* Initialization */ + amf_ue->guami = &amf_self()->served_guami0; + amf_ue->nas.access_type = OGS_ACCESS_TYPE_3GPP; + amf_ue->nas.amf.ksi = OGS_NAS_KSI_NO_KEY_IS_AVAILABLE; + amf_ue->abba_len = 2; + amf_ue_fsm_init(amf_ue); ogs_list_add(&self.amf_ue_list, amf_ue); @@ -1309,8 +1345,7 @@ memset(&e, 0, sizeof(e)); e.amf_ue = amf_ue; - ogs_fsm_create(&amf_ue->sm, gmm_state_initial, gmm_state_final); - ogs_fsm_init(&amf_ue->sm, &e); + ogs_fsm_init(&amf_ue->sm, gmm_state_initial, gmm_state_final, &e); } void amf_ue_fsm_fini(amf_ue_t *amf_ue) @@ -1322,7 +1357,6 @@ memset(&e, 0, sizeof(e)); e.amf_ue = amf_ue; ogs_fsm_fini(&amf_ue->sm, &e); - ogs_fsm_delete(&amf_ue->sm); } amf_ue_t *amf_ue_find_by_guti(ogs_nas_5gs_guti_t *guti) @@ -1780,23 +1814,30 @@ return ogs_pool_cycle(&amf_sess_pool, sess); } -static bool check_smf_info(amf_sess_t *sess, ogs_list_t *nf_info_list); +static bool check_smf_info(ogs_sbi_nf_info_t *nf_info, void *context); void amf_sbi_select_nf( ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option) { + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_nf_info_t *nf_info = NULL; amf_sess_t *sess = NULL; - ogs_assert(ogs_sbi_self()->nf_state_registered); ogs_assert(sbi_object); + ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); ogs_assert(target_nf_type); switch(sbi_object->type) { case OGS_SBI_OBJ_UE_TYPE: - ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (nf_instance) + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_arrayservice_type, nf_instance); break; case OGS_SBI_OBJ_SESS_TYPE: sess = (amf_sess_t *)sbi_object; @@ -1807,12 +1848,16 @@ nf_instance, target_nf_type, discovery_option) == false) continue; - if (target_nf_type == OpenAPI_nf_type_SMF) { - if (check_smf_info(sess, &nf_instance->nf_info_list) == false) + nf_info = ogs_sbi_nf_info_find( + &nf_instance->nf_info_list, nf_instance->nf_type); + if (nf_info) { + if (nf_instance->nf_type == OpenAPI_nf_type_SMF && + check_smf_info(nf_info, sess) == false) continue; } - OGS_SBI_SETUP_NF(sbi_object, target_nf_type, nf_instance); + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_arrayservice_type, nf_instance); break; } break; @@ -2109,35 +2154,29 @@ } static bool check_smf_info_s_nssai( - amf_sess_t *sess, ogs_sbi_smf_info_t *smf_info); + ogs_sbi_smf_info_t *smf_info, amf_sess_t *sess); static bool check_smf_info_nr_tai( - amf_sess_t *sess, ogs_sbi_smf_info_t *smf_info); + ogs_sbi_smf_info_t *smf_info, amf_sess_t *sess); -static bool check_smf_info(amf_sess_t *sess, ogs_list_t *nf_info_list) +static bool check_smf_info(ogs_sbi_nf_info_t *nf_info, void *context) { - ogs_sbi_nf_info_t *nf_info = NULL; + amf_sess_t *sess = NULL; + ogs_assert(nf_info); + ogs_assert(nf_info->nf_type == OpenAPI_nf_type_SMF); + sess = context; ogs_assert(sess); - ogs_assert(nf_info_list); - if (ogs_list_count(nf_info_list) == 0) { - return true; - } - - ogs_list_for_each(nf_info_list, nf_info) { - ogs_sbi_smf_info_t *smf_info = &nf_info->smf; - ogs_assert(smf_info); - - if (check_smf_info_s_nssai(sess, smf_info) == true && - check_smf_info_nr_tai(sess, smf_info) == true) - return true; - } + if (check_smf_info_s_nssai(&nf_info->smf, sess) == false) + return false; + if (check_smf_info_nr_tai(&nf_info->smf, sess) == false) + return false; - return false; + return true; } static bool check_smf_info_s_nssai( - amf_sess_t *sess, ogs_sbi_smf_info_t *smf_info) + ogs_sbi_smf_info_t *smf_info, amf_sess_t *sess) { int i, j; @@ -2150,7 +2189,7 @@ sess->s_nssai.sd.v == smf_info->slicei.s_nssai.sd.v) { for (j = 0; j < smf_info->slicei.num_of_dnn; j++) { - if (strcmp(sess->dnn, smf_info->slicei.dnnj) == 0) + if (ogs_strcasecmp(sess->dnn, smf_info->slicei.dnnj) == 0) return true; } } @@ -2160,7 +2199,7 @@ } static bool check_smf_info_nr_tai( - amf_sess_t *sess, ogs_sbi_smf_info_t *smf_info) + ogs_sbi_smf_info_t *smf_info, amf_sess_t *sess) { amf_ue_t *amf_ue = NULL; int i, j;
View file
open5gs_2.4.9.tar.xz/src/amf/context.h -> open5gs_2.4.10.tar.xz/src/amf/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -197,22 +197,6 @@ amf_ue_t *amf_ue; }; -#define AMF_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - amf_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, amf_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } while(0) - struct amf_ue_s { ogs_sbi_object_t sbi; ogs_fsm_t sm; @@ -754,7 +738,7 @@ void amf_sbi_select_nf( ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option); #define AMF_SESSION_SYNC_DONE(__aMF, __sTATE) \
View file
open5gs_2.4.9.tar.xz/src/amf/event.c -> open5gs_2.4.10.tar.xz/src/amf/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,90 +20,66 @@ #include "event.h" #include "context.h" -static OGS_POOL(pool, amf_event_t); -static ogs_thread_mutex_t amf_event_alloc_mutex; - -void amf_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); - ogs_thread_mutex_init(&amf_event_alloc_mutex); -} - -void amf_event_final(void) -{ - ogs_pool_final(&pool); - ogs_thread_mutex_destroy(&amf_event_alloc_mutex); -} - -amf_event_t *amf_event_new(amf_event_e id) +amf_event_t *amf_event_new(int id) { amf_event_t *e = NULL; - ogs_thread_mutex_lock(&amf_event_alloc_mutex); - ogs_pool_alloc(&pool, &e); - ogs_thread_mutex_unlock(&amf_event_alloc_mutex); + e = ogs_event_size(id, sizeof(amf_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void amf_event_free(amf_event_t *e) -{ - ogs_assert(e); - ogs_thread_mutex_lock(&amf_event_alloc_mutex); - ogs_pool_free(&pool, e); - ogs_thread_mutex_unlock(&amf_event_alloc_mutex); -} - const char *amf_event_get_name(amf_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { - case OGS_FSM_ENTRY_SIG: + switch (e->h.id) { + case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; - case OGS_FSM_EXIT_SIG: + case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case AMF_EVT_SBI_SERVER: - return "AMF_EVT_SBI_SERVER"; - case AMF_EVT_SBI_CLIENT: - return "AMF_EVT_SBI_CLIENT"; - case AMF_EVT_SBI_TIMER: - return "AMF_EVT_SBI_TIMER"; - - case AMF_EVT_NGAP_MESSAGE: - return "AMF_EVT_NGAP_MESSAGE"; - case AMF_EVT_NGAP_TIMER: - return "AMF_EVT_NGAP_TIMER"; - case AMF_EVT_NGAP_LO_ACCEPT: - return "AMF_EVT_NGAP_LO_ACCEPT"; - case AMF_EVT_NGAP_LO_SCTP_COMM_UP: - return "AMF_EVT_NGAP_LO_SCTP_COMM_UP"; - case AMF_EVT_NGAP_LO_CONNREFUSED: - return "AMF_EVT_NGAP_LO_CONNREFUSED"; - - case AMF_EVT_5GMM_MESSAGE: - return "AMF_EVT_5GMM_MESSAGE"; - case AMF_EVT_5GMM_TIMER: - return "AMF_EVT_5GMM_TIMER"; - case AMF_EVT_5GSM_MESSAGE: - return "AMF_EVT_5GSM_MESSAGE"; - case AMF_EVT_5GSM_TIMER: - return "AMF_EVT_5GSM_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; + + case AMF_EVENT_NGAP_MESSAGE: + return "AMF_EVENT_NGAP_MESSAGE"; + case AMF_EVENT_NGAP_TIMER: + return "AMF_EVENT_NGAP_TIMER"; + case AMF_EVENT_NGAP_LO_ACCEPT: + return "AMF_EVENT_NGAP_LO_ACCEPT"; + case AMF_EVENT_NGAP_LO_SCTP_COMM_UP: + return "AMF_EVENT_NGAP_LO_SCTP_COMM_UP"; + case AMF_EVENT_NGAP_LO_CONNREFUSED: + return "AMF_EVENT_NGAP_LO_CONNREFUSED"; + + case AMF_EVENT_5GMM_MESSAGE: + return "AMF_EVENT_5GMM_MESSAGE"; + case AMF_EVENT_5GMM_TIMER: + return "AMF_EVENT_5GMM_TIMER"; + case AMF_EVENT_5GSM_MESSAGE: + return "AMF_EVENT_5GSM_MESSAGE"; + case AMF_EVENT_5GSM_TIMER: + return "AMF_EVENT_5GSM_TIMER"; - default: - break; + default: + break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; } -void amf_sctp_event_push(amf_event_e id, +void amf_sctp_event_push(int id, void *sock, ogs_sockaddr_t *addr, ogs_pkbuf_t *pkbuf, uint16_t max_num_of_istreams, uint16_t max_num_of_ostreams) { @@ -130,7 +106,7 @@ ogs_free(e->ngap.addr); if (e->pkbuf) ogs_pkbuf_free(e->pkbuf); - amf_event_free(e); + ogs_event_free(e); } #if HAVE_USRSCTP else {
View file
open5gs_2.4.9.tar.xz/src/amf/event.h -> open5gs_2.4.10.tar.xz/src/amf/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,18 +20,12 @@ #ifndef AMF_EVENT_H #define AMF_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.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 ogs_nas_5gs_message_s ogs_nas_5gs_message_t; typedef struct NGAP_NGAP_PDU ogs_ngap_message_t; typedef long NGAP_ProcedureCode_t; @@ -43,39 +37,27 @@ typedef struct amf_bearer_s amf_bearer_t; typedef enum { - AMF_EVT_BASE = OGS_FSM_USER_SIG, + AMF_EVENT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, - AMF_EVT_SBI_SERVER, - AMF_EVT_SBI_CLIENT, - AMF_EVT_SBI_TIMER, - - AMF_EVT_NGAP_MESSAGE, - AMF_EVT_NGAP_TIMER, - AMF_EVT_NGAP_LO_ACCEPT, - AMF_EVT_NGAP_LO_SCTP_COMM_UP, - AMF_EVT_NGAP_LO_CONNREFUSED, - - AMF_EVT_5GMM_MESSAGE, - AMF_EVT_5GMM_TIMER, - AMF_EVT_5GSM_MESSAGE, - AMF_EVT_5GSM_TIMER, + AMF_EVENT_NGAP_MESSAGE, + AMF_EVENT_NGAP_TIMER, + AMF_EVENT_NGAP_LO_ACCEPT, + AMF_EVENT_NGAP_LO_SCTP_COMM_UP, + AMF_EVENT_NGAP_LO_CONNREFUSED, + + AMF_EVENT_5GMM_MESSAGE, + AMF_EVENT_5GMM_TIMER, + AMF_EVENT_5GSM_MESSAGE, + AMF_EVENT_5GSM_TIMER, - AMF_EVT_TOP, + MAX_NUM_OF_AMF_EVENT, } amf_event_e; typedef struct amf_event_s { - int id; - ogs_pkbuf_t *pkbuf; - int timer_id; - - struct { - ogs_sbi_request_t *request; - ogs_sbi_response_t *response; - void *data; + ogs_event_t h; - ogs_sbi_message_t *message; - } sbi; + ogs_pkbuf_t *pkbuf; struct { ogs_sock_t *sock; @@ -101,15 +83,11 @@ ogs_timer_t *timer; } amf_event_t; -void amf_event_init(void); -void amf_event_final(void); - -amf_event_t *amf_event_new(amf_event_e id); -void amf_event_free(amf_event_t *e); +amf_event_t *amf_event_new(int id); const char *amf_event_get_name(amf_event_t *e); -void amf_sctp_event_push(amf_event_e id, +void amf_sctp_event_push(int id, void *sock, ogs_sockaddr_t *addr, ogs_pkbuf_t *pkbuf, uint16_t max_num_of_istreams, uint16_t max_num_of_ostreams);
View file
open5gs_2.4.9.tar.xz/src/amf/gmm-handler.c -> open5gs_2.4.10.tar.xz/src/amf/gmm-handler.c
Changed
@@ -720,8 +720,9 @@ authentication_response_parameter->length); ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, - amf_nausf_auth_build_authenticate_confirmation, amf_ue, NULL)); + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL, + amf_nausf_auth_build_authenticate_confirmation, amf_ue, NULL)); return OGS_OK; } @@ -1013,7 +1014,7 @@ OGS_MAX_NUM_OF_SESS); break; } - if (!strcmp(dnn->value, + if (!ogs_strcasecmp(dnn->value, amf_ue->slicei.sessionk.name)) { selected_slice = amf_ue->slice + i; @@ -1063,25 +1064,30 @@ if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_service_type_e service_type = + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION; - nf_instance = OGS_SBI_NF_INSTANCE( - &sess->sbi, OpenAPI_nf_type_SMF); + nf_instance = sess->sbi. + service_type_arrayservice_type.nf_instance; if (!nf_instance) { - amf_sbi_select_nf(&sess->sbi, OpenAPI_nf_type_SMF, NULL); - nf_instance = OGS_SBI_NF_INSTANCE( - &sess->sbi, OpenAPI_nf_type_SMF); + nf_instance = + ogs_sbi_nf_instance_find_by_service_type(service_type); + if (nf_instance) + OGS_SBI_SETUP_NF_INSTANCE( + sess->sbi.service_type_arrayservice_type, + nf_instance); } if (nf_instance) { ogs_assert(true == amf_sess_sbi_discover_and_send( - OpenAPI_nf_type_SMF, NULL, + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_create_sm_context, sess, AMF_CREATE_SM_CONTEXT_NO_STATE, NULL)); } else { ogs_assert(true == amf_sess_sbi_discover_and_send( - OpenAPI_nf_type_NSSF, NULL, + OGS_SBI_SERVICE_TYPE_NNSSF_NSSELECTION, NULL, amf_nnssf_nsselection_build_get, sess, 0, NULL)); } @@ -1092,7 +1098,8 @@ param.cause = OpenAPI_cause_REL_DUE_TO_DUPLICATE_SESSION_ID; ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_update_sm_context, sess, AMF_UPDATE_SM_CONTEXT_DUPLICATED_PDU_SESSION_ID, ¶m)); @@ -1118,13 +1125,15 @@ param.ue_timezone = true; ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_update_sm_context, sess, AMF_UPDATE_SM_CONTEXT_N1_RELEASED, ¶m)); } else { ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_update_sm_context, sess, AMF_UPDATE_SM_CONTEXT_MODIFIED, ¶m)); }
View file
open5gs_2.4.9.tar.xz/src/amf/gmm-sm.c -> open5gs_2.4.10.tar.xz/src/amf/gmm-sm.c
Changed
@@ -62,7 +62,7 @@ amf_ue = e->amf_ue; ogs_assert(amf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: AMF_UE_CLEAR_PAGING_INFO(amf_ue); AMF_UE_CLEAR_N2_TRANSFER(amf_ue, pdu_session_resource_setup_request); @@ -113,13 +113,13 @@ ogs_assert(amf_ue); } - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case AMF_EVT_5GMM_MESSAGE: + case AMF_EVENT_5GMM_MESSAGE: nas_message = e->nas.message; ogs_assert(nas_message); @@ -177,7 +177,8 @@ if (!PCF_AM_POLICY_ASSOCIATED(amf_ue)) { ogs_assert(true == amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_PCF, NULL, + OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL, + NULL, amf_npcf_am_policy_control_build_create, amf_ue, NULL)); OGS_FSM_TRAN(s, &gmm_state_initial_context_setup); @@ -200,7 +201,8 @@ amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE); if (amf_sess_xact_count(amf_ue) == xact_count) { ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL, amf_nausf_auth_build_authenticate, amf_ue, NULL)); } @@ -277,7 +279,8 @@ amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE); if (amf_sess_xact_count(amf_ue) == xact_count) { ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL, amf_nausf_auth_build_authenticate, amf_ue, NULL)); } @@ -367,8 +370,8 @@ } break; - case AMF_EVT_5GMM_TIMER: - switch (e->timer_id) { + case AMF_EVENT_5GMM_TIMER: + switch (e->h.timer_id) { case AMF_TIMER_T3513: if (amf_ue->t3513.retry_count >= amf_timer_cfg(AMF_TIMER_T3513)->max_count) { @@ -457,14 +460,14 @@ default: ogs_error("Unknown timer%s:%d", - amf_timer_get_name(e->timer_id), e->timer_id); + amf_timer_get_name(e->h.timer_id), e->h.timer_id); } break; - case AMF_EVT_SBI_CLIENT: - sbi_response = e->sbi.response; + case OGS_EVENT_SBI_CLIENT: + sbi_response = e->h.sbi.response; ogs_assert(sbi_response); - sbi_message = e->sbi.message; + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); SWITCH(sbi_message->h.service.name) @@ -536,12 +539,12 @@ ogs_assert(amf_ue); } - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case AMF_EVT_5GMM_MESSAGE: + case AMF_EVENT_5GMM_MESSAGE: nas_message = e->nas.message; ogs_assert(nas_message); @@ -584,7 +587,8 @@ case OGS_5GMM_CAUSE_NGKSI_ALREADY_IN_USE: ogs_warn("Authentication failure(ngKSI already in use)"); ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL, amf_nausf_auth_build_authenticate, amf_ue, NULL)); return; @@ -596,7 +600,8 @@ break; } ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL, amf_nausf_auth_build_authenticate, amf_ue, authentication_failure_parameter->auts)); return; @@ -628,7 +633,8 @@ } ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL, amf_nausf_auth_build_authenticate, amf_ue, NULL)); break; @@ -651,8 +657,8 @@ break; } break; - case AMF_EVT_5GMM_TIMER: - switch (e->timer_id) { + case AMF_EVENT_5GMM_TIMER: + switch (e->h.timer_id) { case AMF_TIMER_T3560: if (amf_ue->t3560.retry_count >= amf_timer_cfg(AMF_TIMER_T3560)->max_count) { @@ -673,14 +679,14 @@ break; default: ogs_error("%s Unknown timer%s:%d", amf_ue->suci, - amf_timer_get_name(e->timer_id), e->timer_id); + amf_timer_get_name(e->h.timer_id), e->h.timer_id); break; } break; - case AMF_EVT_SBI_CLIENT: - sbi_response = e->sbi.response; + case OGS_EVENT_SBI_CLIENT: + sbi_response = e->h.sbi.response; ogs_assert(sbi_response); - sbi_message = e->sbi.message; + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); SWITCH(sbi_message->h.service.name) @@ -772,7 +778,7 @@ amf_ue = e->amf_ue; ogs_assert(amf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: CLEAR_AMF_UE_TIMER(amf_ue->t3560); ogs_assert(OGS_OK == @@ -780,7 +786,7 @@ break; case OGS_FSM_EXIT_SIG: break; - case AMF_EVT_5GMM_MESSAGE: + case AMF_EVENT_5GMM_MESSAGE: nas_message = e->nas.message; ogs_assert(nas_message); @@ -832,7 +838,8 @@ amf_ue->nhcc = 1; ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL, + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NUDM_UECM, NULL, amf_nudm_uecm_build_registration, amf_ue, NULL)); if (amf_ue->nas.message_type == OGS_NAS_5GS_REGISTRATION_REQUEST) { @@ -867,7 +874,8 @@ } ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL, amf_nausf_auth_build_authenticate, amf_ue, NULL)); OGS_FSM_TRAN(s, &gmm_state_authentication); @@ -901,8 +909,8 @@ break; } break; - case AMF_EVT_5GMM_TIMER: - switch (e->timer_id) { + case AMF_EVENT_5GMM_TIMER: + switch (e->h.timer_id) { case AMF_TIMER_T3560: if (amf_ue->t3560.retry_count >= amf_timer_cfg(AMF_TIMER_T3560)->max_count) { @@ -923,7 +931,7 @@ break; default: ogs_error("Unknown timer%s:%d", - amf_timer_get_name(e->timer_id), e->timer_id); + amf_timer_get_name(e->h.timer_id), e->h.timer_id); break; } break; @@ -962,16 +970,16 @@ ogs_assert(amf_ue); } - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case AMF_EVT_SBI_CLIENT: - sbi_response = e->sbi.response; + case OGS_EVENT_SBI_CLIENT: + sbi_response = e->h.sbi.response; ogs_assert(sbi_response); - sbi_message = e->sbi.message; + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); SWITCH(sbi_message->h.service.name) @@ -994,7 +1002,7 @@ CASE(OGS_SBI_HTTP_METHOD_PUT) ogs_assert(true == amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_UDM, NULL, + OGS_SBI_SERVICE_TYPE_NUDM_SDM, NULL, amf_nudm_sdm_build_get, amf_ue, (char *)OGS_SBI_RESOURCE_NAME_AM_DATA)); break; @@ -1105,7 +1113,7 @@ END break; - case AMF_EVT_5GMM_MESSAGE: + case AMF_EVENT_5GMM_MESSAGE: nas_message = e->nas.message; ogs_assert(nas_message); @@ -1194,7 +1202,8 @@ amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE); if (amf_sess_xact_count(amf_ue) == xact_count) { ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL, amf_nausf_auth_build_authenticate, amf_ue, NULL)); } OGS_FSM_TRAN(s, &gmm_state_authentication); @@ -1228,8 +1237,8 @@ break; } break; - case AMF_EVT_5GMM_TIMER: - switch (e->timer_id) { + case AMF_EVENT_5GMM_TIMER: + switch (e->h.timer_id) { case AMF_TIMER_T3550: if (amf_ue->t3550.retry_count >= amf_timer_cfg(AMF_TIMER_T3550)->max_count) { @@ -1248,7 +1257,7 @@ break; default: ogs_error("%s Unknown timer%s:%d", amf_ue->suci, - amf_timer_get_name(e->timer_id), e->timer_id); + amf_timer_get_name(e->h.timer_id), e->h.timer_id); break; } break; @@ -1281,7 +1290,7 @@ ogs_assert(amf_ue); } - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: AMF_UE_CLEAR_PAGING_INFO(amf_ue); AMF_UE_CLEAR_N2_TRANSFER(amf_ue, pdu_session_resource_setup_request); @@ -1300,7 +1309,7 @@ case OGS_FSM_EXIT_SIG: break; - case AMF_EVT_5GMM_MESSAGE: + case AMF_EVENT_5GMM_MESSAGE: nas_message = e->nas.message; ogs_assert(nas_message); @@ -1358,7 +1367,8 @@ if (!PCF_AM_POLICY_ASSOCIATED(amf_ue)) { ogs_assert(true == amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_PCF, NULL, + OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL, + NULL, amf_npcf_am_policy_control_build_create, amf_ue, NULL)); OGS_FSM_TRAN(s, &gmm_state_initial_context_setup); @@ -1381,7 +1391,8 @@ amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE); if (amf_sess_xact_count(amf_ue) == xact_count) { ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL, amf_nausf_auth_build_authenticate, amf_ue, NULL)); }
View file
open5gs_2.4.9.tar.xz/src/amf/init.c -> open5gs_2.4.10.tar.xz/src/amf/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -33,7 +33,6 @@ ogs_sbi_context_init(); amf_context_init(); - amf_event_init(); rv = ogs_sbi_context_parse_config("amf", "nrf", "scp"); if (rv != OGS_OK) return rv; @@ -76,7 +75,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - amf_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -105,8 +104,6 @@ amf_context_final(); ogs_sbi_context_final(); ogs_metrics_context_final(); - - amf_event_final(); /* Destroy event */ } static void amf_main(void *data) @@ -114,8 +111,7 @@ ogs_fsm_t amf_sm; int rv; - ogs_fsm_create(&amf_sm, amf_state_initial, amf_state_final); - ogs_fsm_init(&amf_sm, 0); + ogs_fsm_init(&amf_sm, amf_state_initial, amf_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -148,11 +144,10 @@ ogs_assert(e); ogs_fsm_dispatch(&amf_sm, e); - amf_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&amf_sm, 0); - ogs_fsm_delete(&amf_sm); }
View file
open5gs_2.4.9.tar.xz/src/amf/meson.build -> open5gs_2.4.10.tar.xz/src/amf/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -43,8 +43,6 @@ namf-handler.c sbi-path.c - nf-sm.c - ngap-sctp.c ngap-build.c ngap-handler.c @@ -66,8 +64,7 @@ libamf = static_library('amf', sources : libamf_sources, - dependencies : libapp_dep, - libmetrics_dep, + dependencies : libmetrics_dep, libsctp_dep, libngap_dep, libnas_5gs_dep, @@ -76,8 +73,7 @@ libamf_dep = declare_dependency( link_with : libamf, - dependencies : libapp_dep, - libmetrics_dep, + dependencies : libmetrics_dep, libsctp_dep, libngap_dep, libnas_5gs_dep,
View file
open5gs_2.4.9.tar.xz/src/amf/namf-handler.c -> open5gs_2.4.10.tar.xz/src/amf/namf-handler.c
Changed
@@ -565,7 +565,8 @@ */ - if (CM_CONNECTED(amf_ue)) + if ((CM_CONNECTED(amf_ue)) && + (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_registered))) { amf_ue->network_initiated_de_reg = true; @@ -575,10 +576,14 @@ amf_sbi_send_release_all_sessions( amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE); - if (ogs_list_count(&amf_ue->sess_list) == 0) + if ((ogs_list_count(&amf_ue->sess_list) == 0) && + (PCF_AM_POLICY_ASSOCIATED(amf_ue))) + { ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL, NULL, amf_npcf_am_policy_control_build_delete, amf_ue, NULL)); + } OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_de_registered); } @@ -586,6 +591,11 @@ /* TODO: need to page UE */ /*ngap_send_paging(amf_ue);*/ } + else { + status = OGS_SBI_HTTP_STATUS_BAD_REQUEST; + ogs_error("%s Deregistration notification for UE in wrong state", amf_ue->supi); + goto cleanup; + } cleanup: memset(&sendmsg, 0, sizeof(sendmsg));
View file
open5gs_2.4.9.tar.xz/src/amf/ngap-handler.c -> open5gs_2.4.10.tar.xz/src/amf/ngap-handler.c
Changed
@@ -94,7 +94,7 @@ } } - return number_of_gnbs_online >= ogs_app()->max.gnb; + return number_of_gnbs_online >= ogs_app()->max.peer; } void ngap_handle_ng_setup_request(amf_gnb_t *gnb, ogs_ngap_message_t *message) @@ -904,7 +904,8 @@ ogs_pkbuf_put_data(param.n2smbuf, transfer->buf, transfer->size); ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_update_sm_context, sess, AMF_UPDATE_SM_CONTEXT_ACTIVATED, ¶m)); @@ -1643,7 +1644,8 @@ ogs_pkbuf_put_data(param.n2smbuf, transfer->buf, transfer->size); ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_update_sm_context, sess, AMF_UPDATE_SM_CONTEXT_ACTIVATED, ¶m)); @@ -1762,7 +1764,8 @@ amf_ue->deactivation.cause = NGAP_CauseNas_normal_release; ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_update_sm_context, sess, AMF_UPDATE_SM_CONTEXT_SETUP_FAIL, ¶m)); @@ -1942,7 +1945,8 @@ ogs_pkbuf_put_data(param.n2smbuf, transfer->buf, transfer->size); ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_update_sm_context, sess, AMF_UPDATE_SM_CONTEXT_MODIFIED, ¶m)); @@ -2117,7 +2121,8 @@ ogs_pkbuf_put_data(param.n2smbuf, transfer->buf, transfer->size); ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_update_sm_context, sess, AMF_UPDATE_SM_CONTEXT_N2_RELEASED, ¶m)); @@ -2539,7 +2544,8 @@ ogs_pkbuf_put_data(param.n2smbuf, transfer->buf, transfer->size); ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_update_sm_context, sess, AMF_UPDATE_SM_CONTEXT_PATH_SWITCH_REQUEST, ¶m)); @@ -2855,7 +2861,8 @@ param.TargetID = TargetID; ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_update_sm_context, sess, AMF_UPDATE_SM_CONTEXT_HANDOVER_REQUIRED, ¶m)); @@ -3079,7 +3086,8 @@ param.hoState = OpenAPI_ho_state_PREPARED; ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_update_sm_context, sess, AMF_UPDATE_SM_CONTEXT_HANDOVER_REQ_ACK, ¶m)); @@ -3324,7 +3332,8 @@ param.ngApCause.value = (int)Cause->choice.radioNetwork; ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_update_sm_context, sess, AMF_UPDATE_SM_CONTEXT_HANDOVER_CANCEL, ¶m)); } @@ -3604,7 +3613,8 @@ param.hoState = OpenAPI_ho_state_COMPLETED; ogs_assert(true == - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_update_sm_context, sess, AMF_UPDATE_SM_CONTEXT_HANDOVER_NOTIFY, ¶m)); }
View file
open5gs_2.4.9.tar.xz/src/amf/ngap-path.c -> open5gs_2.4.10.tar.xz/src/amf/ngap-path.c
Changed
@@ -104,7 +104,7 @@ if (duration) { amf_event_t *e = NULL; - e = amf_event_new(AMF_EVT_NGAP_TIMER); + e = amf_event_new(AMF_EVENT_NGAP_TIMER); ogs_assert(e); e->timer = ogs_timer_add( ogs_app()->timer_mgr, amf_timer_ng_delayed_send, e); @@ -132,7 +132,7 @@ ogs_assert(amf_ue); ogs_assert(esmbuf); - e = amf_event_new(AMF_EVT_5GSM_MESSAGE); + e = amf_event_new(AMF_EVENT_5GSM_MESSAGE); ogs_assert(e); e->amf_ue = amf_ue; e->pkbuf = esmbuf; @@ -140,7 +140,7 @@ if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_pkbuf_free(e->pkbuf); - amf_event_free(e); + ogs_event_free(e); } return rv; @@ -203,7 +203,7 @@ if (nas_5gs_security_decode(ran_ue->amf_ue, security_header_type, nasbuf) != OGS_OK) { ogs_error("nas_eps_security_decode failed()"); - return OGS_ERROR; + return OGS_ERROR; } } @@ -212,7 +212,7 @@ if (h->extended_protocol_discriminator == OGS_NAS_EXTENDED_PROTOCOL_DISCRIMINATOR_5GMM) { int rv; - e = amf_event_new(AMF_EVT_5GMM_MESSAGE); + e = amf_event_new(AMF_EVENT_5GMM_MESSAGE); if (!e) { ogs_error("ngap_send_to_nas() failed"); ogs_pkbuf_free(nasbuf); @@ -226,7 +226,7 @@ if (rv != OGS_OK) { ogs_error("ngap_send_to_nas() failed:%d", (int)rv); ogs_pkbuf_free(e->pkbuf); - amf_event_free(e); + ogs_event_free(e); } return rv; } else if (h->extended_protocol_discriminator ==
View file
open5gs_2.4.9.tar.xz/src/amf/ngap-sctp.c -> open5gs_2.4.10.tar.xz/src/amf/ngap-sctp.c
Changed
@@ -78,12 +78,12 @@ #if HAVE_USRSCTP static void usrsctp_recv_handler(struct socket *socket, void *data, int flags) { - int events; + int events; - while ((events = usrsctp_get_events(socket)) && + while ((events = usrsctp_get_events(socket)) && (events & SCTP_EVENT_READ)) { ngap_recv_handler((ogs_sock_t *)socket); - } + } } #else static void lksctp_accept_handler(short when, ogs_socket_t fd, void *data) @@ -113,7 +113,7 @@ ogs_info("gNB-N2 accepted%s:%d in ng-path module", OGS_ADDR(addr, buf), OGS_PORT(addr)); - ngap_event_push(AMF_EVT_NGAP_LO_ACCEPT, + ngap_event_push(AMF_EVENT_NGAP_LO_ACCEPT, new, addr, NULL, 0, 0); } else { ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno, "accept() failed"); @@ -164,7 +164,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - ngap_event_push(AMF_EVT_NGAP_LO_SCTP_COMM_UP, + ngap_event_push(AMF_EVENT_NGAP_LO_SCTP_COMM_UP, sock, addr, NULL, not->sn_assoc_change.sac_inbound_streams, not->sn_assoc_change.sac_outbound_streams); @@ -180,7 +180,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - ngap_event_push(AMF_EVT_NGAP_LO_CONNREFUSED, + ngap_event_push(AMF_EVENT_NGAP_LO_CONNREFUSED, sock, addr, NULL, 0, 0); } break; @@ -193,7 +193,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - ngap_event_push(AMF_EVT_NGAP_LO_CONNREFUSED, + ngap_event_push(AMF_EVENT_NGAP_LO_CONNREFUSED, sock, addr, NULL, 0, 0); break; @@ -235,7 +235,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - ngap_event_push(AMF_EVT_NGAP_MESSAGE, sock, addr, pkbuf, 0, 0); + ngap_event_push(AMF_EVENT_NGAP_MESSAGE, sock, addr, pkbuf, 0, 0); return; } else { if (ogs_socket_errno != OGS_EAGAIN) {
View file
open5gs_2.4.9.tar.xz/src/amf/ngap-sm.c -> open5gs_2.4.10.tar.xz/src/amf/ngap-sm.c
Changed
@@ -55,12 +55,12 @@ gnb = e->gnb; ogs_assert(gnb); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case AMF_EVT_NGAP_MESSAGE: + case AMF_EVENT_NGAP_MESSAGE: pdu = e->ngap.message; ogs_assert(pdu); @@ -190,8 +190,8 @@ } break; - case AMF_EVT_NGAP_TIMER: - switch (e->timer_id) { + case AMF_EVENT_NGAP_TIMER: + switch (e->h.timer_id) { case AMF_TIMER_NG_DELAYED_SEND: ogs_assert(e->ran_ue); ogs_assert(e->pkbuf); @@ -201,7 +201,7 @@ break; default: ogs_error("Unknown timer%s:%d", - amf_timer_get_name(e->timer_id), e->timer_id); + amf_timer_get_name(e->h.timer_id), e->h.timer_id); break; } break; @@ -218,7 +218,7 @@ amf_sm_debug(e); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG:
View file
open5gs_2.4.9.tar.xz/src/amf/nnrf-build.c -> open5gs_2.4.10.tar.xz/src/amf/nnrf-build.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -19,50 +19,25 @@ #include "nnrf-build.h" -ogs_sbi_request_t *amf_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -} - ogs_sbi_request_t *amf_nnrf_disc_build_discover( char *nrf_id, - OpenAPI_nf_type_e target_nf_type, OpenAPI_nf_type_e requester_nf_type) + ogs_sbi_service_type_e service_type, + ogs_sbi_discovery_option_t *discovery_option) { ogs_sbi_message_t message; ogs_sbi_request_t *request = NULL; + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; + OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; + ogs_assert(nrf_id); + + ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); ogs_assert(target_nf_type); + + ogs_assert(ogs_sbi_self()->nf_instance); + requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; ogs_assert(requester_nf_type); memset(&message, 0, sizeof(message)); @@ -72,6 +47,8 @@ message.param.target_nf_type = target_nf_type; message.param.requester_nf_type = requester_nf_type; + message.param.discovery_option = discovery_option; + request = ogs_sbi_build_request(&message); return request;
View file
open5gs_2.4.9.tar.xz/src/amf/nnrf-build.h -> open5gs_2.4.10.tar.xz/src/amf/nnrf-build.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -26,11 +26,10 @@ extern "C" { #endif -ogs_sbi_request_t *amf_nnrf_nfm_build_register(void); - ogs_sbi_request_t *amf_nnrf_disc_build_discover( char *nrf_id, - OpenAPI_nf_type_e target_nf_type, OpenAPI_nf_type_e requester_nf_type); + ogs_sbi_service_type_e service_type, + ogs_sbi_discovery_option_t *discovery_option); #ifdef __cplusplus }
View file
open5gs_2.4.9.tar.xz/src/amf/nnrf-handler.c -> open5gs_2.4.10.tar.xz/src/amf/nnrf-handler.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -22,240 +22,12 @@ #include "ngap-path.h" #include "nnrf-handler.h" -void amf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void amf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->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_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - 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, - amf_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 amf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - amf_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - nf_instance->reference_count++; - - OGS_FSM_TRAN(&nf_instance->sm, amf_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - AMF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - AMF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - AMF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -} - void amf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; - OpenAPI_nf_type_e target_nf_type = 0; + ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; OpenAPI_search_result_t *SearchResult = NULL; @@ -264,8 +36,8 @@ ogs_assert(xact); sbi_object = xact->sbi_object; ogs_assert(sbi_object); - target_nf_type = xact->target_nf_type; - ogs_assert(target_nf_type); + service_type = xact->service_type; + ogs_assert(service_type); discovery_option = xact->discovery_option; @@ -275,86 +47,52 @@ return; } - amf_nnrf_handle_nf_discover_search_result( - sbi_object, target_nf_type, discovery_option, SearchResult); - - amf_sbi_select_nf(sbi_object, target_nf_type, discovery_option); - - ogs_expect(true == amf_sbi_send_request(sbi_object, target_nf_type, xact)); -} - -void amf_nnrf_handle_nf_discover_search_result( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - ogs_sbi_discovery_option_t *discovery_option, - OpenAPI_search_result_t *SearchResult) -{ - bool handled; - - OpenAPI_lnode_t *node = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(sbi_object); - ogs_assert(SearchResult); - - 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(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); + ogs_nnrf_handle_nf_discover_search_result(SearchResult); - amf_nf_fsm_init(nf_instance); + amf_sbi_select_nf(sbi_object, service_type, discovery_option); - ogs_info("%s (NF-discover) NF registered", nf_instance->id); - } else { - nf_instance->reference_count++; - - OGS_FSM_TRAN(&nf_instance->sm, amf_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("ogs_sbi_nnrf_handle_nf_profile() failed %s", - nf_instance->id); - AMF_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); - AMF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; + nf_instance = sbi_object->service_type_arrayservice_type.nf_instance; + if (!nf_instance) { + amf_ue_t *amf_ue = NULL; + amf_sess_t *sess = NULL; + + 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, + ogs_sbi_service_type_to_name(service_type)); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi(amf_ue, + OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); + break; + 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, + ogs_sbi_service_type_to_name(service_type)); + if (sess->payload_container_type) { + ogs_assert(OGS_OK == + nas_5gs_send_back_gsm_message(sess, + OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, + AMF_NAS_BACKOFF_TIME)); + } else { + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_transport, + NGAP_CauseTransport_transport_resource_unavailable)); } - - /* TIME : Update validity from NRF */ - if (SearchResult->is_validity_period && - 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); + break; + default: + ogs_fatal("(NF discover) Not implemented %s:%d", + ogs_sbi_service_type_to_name(service_type), sbi_object->type); + ogs_assert_if_reached(); } + + return; } + + ogs_expect(true == amf_sbi_send_request(nf_instance, xact)); }
View file
open5gs_2.4.9.tar.xz/src/amf/nnrf-handler.h -> open5gs_2.4.10.tar.xz/src/amf/nnrf-handler.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -26,21 +26,8 @@ extern "C" { #endif -void amf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void amf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool amf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - void amf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg); -void amf_nnrf_handle_nf_discover_search_result( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - ogs_sbi_discovery_option_t *discovery_option, - OpenAPI_search_result_t *SearchResult); #ifdef __cplusplus }
View file
open5gs_2.4.9.tar.xz/src/amf/nnssf-handler.c -> open5gs_2.4.10.tar.xz/src/amf/nnssf-handler.c
Changed
@@ -98,7 +98,8 @@ ogs_freeaddrinfo(addr); - ogs_assert(true == amf_sess_sbi_discover_by_nsi(OpenAPI_nf_type_SMF, sess)); + ogs_assert(true == amf_sess_sbi_discover_by_nsi( + sess, OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL)); return OGS_OK; }
View file
open5gs_2.4.9.tar.xz/src/amf/nsmf-build.c -> open5gs_2.4.10.tar.xz/src/amf/nsmf-build.c
Changed
@@ -120,7 +120,8 @@ SmContextCreateData.ue_time_zone = ogs_sbi_timezone_string(ogs_timezone()); ogs_expect_or_return_val(SmContextCreateData.ue_time_zone, NULL); - pcf_nf_instance = OGS_SBI_NF_INSTANCE(&amf_ue->sbi, OpenAPI_nf_type_PCF); + pcf_nf_instance = amf_ue->sbi.service_type_array + OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL.nf_instance; ogs_expect_or_return_val(pcf_nf_instance, NULL); SmContextCreateData.pcf_id = pcf_nf_instance->id;
View file
open5gs_2.4.9.tar.xz/src/amf/nsmf-handler.c -> open5gs_2.4.10.tar.xz/src/amf/nsmf-handler.c
Changed
@@ -174,6 +174,8 @@ amf_sess_t *sess, int state, ogs_sbi_message_t *recvmsg) { amf_ue_t *amf_ue = NULL; + ran_ue_t *ran_ue = NULL; + ogs_assert(sess); amf_ue = sess->amf_ue; ogs_assert(amf_ue); @@ -231,7 +233,8 @@ if (!PCF_AM_POLICY_ASSOCIATED(amf_ue)) { ogs_assert(true == amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_PCF, NULL, + OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL, + NULL, amf_npcf_am_policy_control_build_create, amf_ue, NULL)); } else { @@ -356,7 +359,7 @@ if (!n2smbuf) { ogs_error("%s:%d No N2 SM Content", amf_ue->supi, sess->psi); - ogs_assert(OGS_OK == + ogs_expect(OGS_OK == ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); @@ -380,7 +383,7 @@ if (!n2smbuf) { ogs_error("%s:%d No N2 SM Content", amf_ue->supi, sess->psi); - ogs_assert(OGS_OK == + ogs_expect(OGS_OK == ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); @@ -402,13 +405,14 @@ default: ogs_error("Not implemented %d", SmContextUpdatedData->n2_sm_info_type); - ogs_assert(OGS_OK == + ogs_expect(OGS_OK == ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); } } else { + SmContextUpdatedData = recvmsg->SmContextUpdatedData; if (state == AMF_UPDATE_SM_CONTEXT_ACTIVATED) { /* @@ -563,7 +567,8 @@ ogs_warn("%s:%d Receive Update SM context" "(DUPLICATED_PDU_SESSION_ID)", amf_ue->supi, sess->psi); - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_create_sm_context, sess, AMF_CREATE_SM_CONTEXT_NO_STATE, NULL); @@ -605,7 +610,7 @@ } else if (state == AMF_REMOVE_S1_CONTEXT_BY_LO_CONNREFUSED) { if (AMF_SESSION_SYNC_DONE(amf_ue, state)) { - ran_ue_t *ran_ue = ran_ue_cycle(amf_ue->ran_ue); + ran_ue = ran_ue_cycle(amf_ue->ran_ue); amf_ue_deassociate(amf_ue); @@ -644,7 +649,7 @@ } else if (state == AMF_REMOVE_S1_CONTEXT_BY_RESET_PARTIAL) { if (AMF_SESSION_SYNC_DONE(amf_ue, state)) { ran_ue_t *iter = NULL; - ran_ue_t *ran_ue = ran_ue_cycle(amf_ue->ran_ue); + ran_ue = ran_ue_cycle(amf_ue->ran_ue); amf_ue_deassociate(amf_ue); @@ -701,8 +706,6 @@ } } } else { - amf_ue_t *amf_ue = NULL; - OpenAPI_sm_context_update_error_t *SmContextUpdateError = NULL; OpenAPI_ref_to_binary_data_t *n1SmMsg = NULL; ogs_pkbuf_t *n1smbuf = NULL; @@ -719,7 +722,7 @@ if (!SmContextUpdateError) { ogs_error("%d:%d No SmContextUpdateError %d", sess->psi, sess->pti, recvmsg->res_status); - ogs_assert(OGS_OK == + ogs_expect(OGS_OK == ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); @@ -728,7 +731,7 @@ if (!SmContextUpdateError->error) { ogs_error("%d:%d No Error %d", sess->psi, sess->pti, recvmsg->res_status); - ogs_assert(OGS_OK == + ogs_expect(OGS_OK == ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); @@ -761,7 +764,7 @@ n2SmInfo = SmContextUpdateError->n2_sm_info; if (!n2SmInfo || !n2SmInfo->content_id) { ogs_error("%d:%d No N2 SM Message", sess->psi, sess->pti); - ogs_assert(OGS_OK == + ogs_expect(OGS_OK == ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); @@ -773,7 +776,7 @@ if (!n2smbuf) { ogs_error("%d:%d No N2 SM Content %s", sess->psi, sess->pti, n2SmInfo->content_id); - ogs_assert(OGS_OK == + ogs_expect(OGS_OK == ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); @@ -783,7 +786,7 @@ ogs_error("%d:%d Error Indication", sess->psi, sess->pti); - ogs_assert(OGS_OK == + ogs_expect(OGS_OK == ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); @@ -816,7 +819,8 @@ if (!PCF_AM_POLICY_ASSOCIATED(amf_ue)) { ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL, NULL, amf_npcf_am_policy_control_build_create, amf_ue, NULL)); } else { CLEAR_AMF_UE_TIMER(amf_ue->t3550); @@ -868,7 +872,8 @@ if (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_authentication)) { ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, NULL, + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, NULL, amf_nausf_auth_build_authenticate, amf_ue, NULL)); } else if (OGS_FSM_CHECK(&amf_ue->sm, @@ -885,7 +890,8 @@ */ ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL, NULL, amf_npcf_am_policy_control_build_delete, amf_ue, NULL));
View file
open5gs_2.4.9.tar.xz/src/amf/nudm-handler.c -> open5gs_2.4.10.tar.xz/src/amf/nudm-handler.c
Changed
@@ -140,7 +140,8 @@ } ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL, + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NUDM_SDM, NULL, amf_nudm_sdm_build_get, amf_ue, (char *)OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA)); break; @@ -212,14 +213,16 @@ } } ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL, + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NUDM_SDM, NULL, amf_nudm_sdm_build_get, amf_ue, (char *)OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA)); break; CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA) ogs_assert(true == - amf_ue_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + amf_ue_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL, NULL, amf_npcf_am_policy_control_build_create, amf_ue, NULL)); break;
View file
open5gs_2.4.9.tar.xz/src/amf/sbi-path.c -> open5gs_2.4.10.tar.xz/src/amf/sbi-path.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,17 +30,17 @@ ogs_assert(request); ogs_assert(data); - e = amf_event_new(AMF_EVT_SBI_SERVER); + e = amf_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - amf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -61,16 +61,16 @@ ogs_assert(response); - e = amf_event_new(AMF_EVT_SBI_CLIENT); + e = amf_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - amf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -85,28 +85,21 @@ /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_AMF); ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_SMF); + ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_SCP); /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NAMF_COMM); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF); - - /* Initialize SCP NF Instance */ - nf_instance = ogs_sbi_self()->scp_instance; - if (nf_instance) { - ogs_sbi_client_t *client = NULL; - - /* Client callback is only used when NF sends to SCP */ - client = nf_instance->client; - ogs_assert(client); - client->cb = client_cb; + if (ogs_sbi_nf_service_is_available(OGS_SBI_SERVICE_NAME_NAMF_COMM)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NAMF_COMM); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF); } /* Initialize NRF NF Instance */ @@ -121,15 +114,22 @@ /* NFRegister is sent and the response is received * by the above client callback. */ - amf_nf_fsm_init(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); } - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = amf_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)amf_nf_state_registered; + /* Build Subscription-Data */ + ogs_sbi_subscription_data_build_default( + OpenAPI_nf_type_AUSF, OGS_SBI_SERVICE_NAME_NAUSF_AUTH); + ogs_sbi_subscription_data_build_default( + OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_UECM); + ogs_sbi_subscription_data_build_default( + OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_SDM); + ogs_sbi_subscription_data_build_default( + OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL); + ogs_sbi_subscription_data_build_default( + OpenAPI_nf_type_SMF, OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION); + ogs_sbi_subscription_data_build_default( + OpenAPI_nf_type_NSSF, OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION); if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR; @@ -143,83 +143,28 @@ ogs_sbi_server_stop_all(); } -bool amf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - void *data) +bool amf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data) { - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(sbi_object); - ogs_assert(target_nf_type); + ogs_assert(nf_instance); ogs_assert(data); - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); - if (!nf_instance) { - amf_ue_t *amf_ue = NULL; - amf_sess_t *sess = NULL; - - 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, - OpenAPI_nf_type_ToString(target_nf_type)); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi(amf_ue, - OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); - break; - 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, - OpenAPI_nf_type_ToString(target_nf_type)); - if (sess->payload_container_type) { - ogs_assert(OGS_OK == - nas_5gs_send_back_gsm_message(sess, - OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, - AMF_NAS_BACKOFF_TIME)); - } else { - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_transport, - NGAP_CauseTransport_transport_resource_unavailable)); - } - break; - default: - ogs_fatal("(NF discover) Not implemented %s:%d", - OpenAPI_nf_type_ToString(target_nf_type), - sbi_object->type); - ogs_assert_if_reached(); - } - - return false; - } - return ogs_sbi_send_request(nf_instance, client_cb, data); } bool amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(amf_ue_t *amf_ue, void *data), amf_ue_t *amf_ue, void *data) { ogs_sbi_xact_t *xact = NULL; - OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; - - ogs_assert(ogs_sbi_self()->nf_instance); - requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; - ogs_assert(requester_nf_type); - ogs_assert(target_nf_type); + ogs_assert(service_type); ogs_assert(amf_ue); ogs_assert(build); xact = ogs_sbi_xact_add( - &amf_ue->sbi, target_nf_type, discovery_option, + &amf_ue->sbi, service_type, discovery_option, (ogs_sbi_build_f)build, amf_ue, data); if (!xact) { ogs_error("amf_ue_sbi_discover_and_send() failed"); @@ -229,10 +174,7 @@ return false; } - if (ogs_sbi_discover_and_send( - &amf_ue->sbi, - target_nf_type, requester_nf_type, discovery_option, - client_cb, xact) != true) { + if (ogs_sbi_discover_and_send(xact, client_cb) != true) { ogs_error("amf_ue_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); ogs_assert(OGS_OK == @@ -245,24 +187,19 @@ } bool amf_sess_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(amf_sess_t *sess, void *data), amf_sess_t *sess, int state, void *data) { ogs_sbi_xact_t *xact = NULL; - OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; - - ogs_assert(ogs_sbi_self()->nf_instance); - requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; - ogs_assert(requester_nf_type); - ogs_assert(target_nf_type); + ogs_assert(service_type); ogs_assert(sess); ogs_assert(build); xact = ogs_sbi_xact_add( - &sess->sbi, target_nf_type, discovery_option, + &sess->sbi, service_type, discovery_option, (ogs_sbi_build_f)build, sess, data); if (!xact) { ogs_error("amf_sess_sbi_discover_and_send() failed"); @@ -273,10 +210,7 @@ xact->state = state; - if (ogs_sbi_discover_and_send( - &sess->sbi, - target_nf_type, requester_nf_type, discovery_option, - client_cb, xact) != true) { + if (ogs_sbi_discover_and_send(xact, client_cb) != true) { ogs_error("amf_sess_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); ogs_assert(OGS_OK == nas_5gs_send_back_gsm_message(sess, @@ -290,21 +224,50 @@ int status, ogs_sbi_response_t *response, void *data) { int rv; - ogs_sbi_message_t message; - amf_sess_t *sess = data; + + ogs_sbi_xact_t *xact = NULL; + ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; + ogs_sbi_discovery_option_t *discovery_option = NULL; + amf_ue_t *amf_ue = NULL; + amf_sess_t *sess = NULL; + + ogs_assert(response); + + xact = data; + ogs_assert(xact); + + xact = ogs_sbi_xact_cycle(xact); + if (!xact) { + ogs_error("SBI transaction has already been removed"); + return OGS_ERROR; + } + + sess = (amf_sess_t *)xact->sbi_object; + ogs_assert(sess); + + service_type = xact->service_type; + discovery_option = xact->discovery_option; + + sess = amf_sess_cycle(sess); + if (!sess) { + ogs_error("Session has already been removed"); + ogs_sbi_xact_remove(xact); + return OGS_ERROR; + } + + ogs_assert(sess->sbi.type == OGS_SBI_OBJ_SESS_TYPE); + amf_ue = sess->amf_ue; + ogs_assert(amf_ue); if (status != OGS_OK) { ogs_log_message( status == OGS_DONE ? OGS_LOG_DEBUG : OGS_LOG_WARN, 0, "client_discover_cb() failed %d", status); + ogs_sbi_xact_remove(xact); return OGS_ERROR; } - ogs_assert(response); - ogs_assert(sess); - ogs_assert(sess->sbi.type == OGS_SBI_OBJ_SESS_TYPE); - rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { ogs_error("cannot parse HTTP response"); @@ -330,14 +293,14 @@ goto cleanup; } - amf_nnrf_handle_nf_discover_search_result( - &sess->sbi, OpenAPI_nf_type_SMF, NULL, message.SearchResult); + ogs_nnrf_handle_nf_discover_search_result(message.SearchResult); - amf_sbi_select_nf(&sess->sbi, OpenAPI_nf_type_SMF, NULL); + amf_sbi_select_nf(&sess->sbi, service_type, discovery_option); - if (!OGS_SBI_NF_INSTANCE(&sess->sbi, OpenAPI_nf_type_SMF)) { - ogs_error("Cannot discover %s", - OpenAPI_nf_type_ToString(OpenAPI_nf_type_SMF)); + if (!sess->sbi.service_type_arrayservice_type.nf_instance) { + ogs_error("%s:%d (NF discover) No %s", + amf_ue->supi, sess->psi, + ogs_sbi_service_type_to_name(service_type)); ogs_assert(OGS_OK == nas_5gs_send_back_gsm_message(sess, OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, @@ -346,11 +309,14 @@ goto cleanup; } - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + service_type, NULL, amf_nsmf_pdusession_build_create_sm_context, sess, AMF_CREATE_SM_CONTEXT_NO_STATE, NULL); cleanup: + ogs_sbi_xact_remove(xact); + ogs_sbi_message_free(&message); ogs_sbi_response_free(response); @@ -358,24 +324,31 @@ } bool amf_sess_sbi_discover_by_nsi( - OpenAPI_nf_type_e target_nf_type, amf_sess_t *sess) + amf_sess_t *sess, + ogs_sbi_service_type_e service_type, + ogs_sbi_discovery_option_t *discovery_option) { - ogs_sbi_request_t *request = NULL; + ogs_sbi_xact_t *xact = NULL; ogs_sbi_client_t *client = NULL; - ogs_assert(target_nf_type); ogs_assert(sess); client = sess->nssf.nrf.client; ogs_assert(client); + ogs_assert(service_type); + + ogs_warn("Try to discover %s", + ogs_sbi_service_type_to_name(service_type)); + + xact = ogs_sbi_xact_add( + &sess->sbi, service_type, discovery_option, NULL, NULL, NULL); + ogs_expect_or_return_val(xact, false); - ogs_assert(ogs_sbi_self()->nf_instance); - request = amf_nnrf_disc_build_discover( - sess->nssf.nrf.id, target_nf_type, - ogs_sbi_self()->nf_instance->nf_type); - ogs_expect_or_return_val(request, false); + xact->request = amf_nnrf_disc_build_discover( + sess->nssf.nrf.id, xact->service_type, xact->discovery_option); + ogs_expect_or_return_val(xact->request, false); - return ogs_sbi_client_send_request( - client, client_discover_cb, request, sess); + return ogs_sbi_client_send_reqmem_persistent( + client, client_discover_cb, xact->request, xact); } void amf_sbi_send_activating_session(amf_sess_t *sess, int state) @@ -387,7 +360,8 @@ memset(¶m, 0, sizeof(param)); param.upCnxState = OpenAPI_up_cnx_state_ACTIVATING; - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_update_sm_context, sess, state, ¶m); } @@ -405,7 +379,8 @@ param.ue_location = true; param.ue_timezone = true; - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_update_sm_context, sess, state, ¶m); } @@ -467,7 +442,8 @@ { ogs_assert(sess); - amf_sess_sbi_discover_and_send(OpenAPI_nf_type_SMF, NULL, + amf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, NULL, amf_nsmf_pdusession_build_release_sm_context, sess, state, NULL); /* Prevent to invoke SMF for this session */
View file
open5gs_2.4.9.tar.xz/src/amf/sbi-path.h -> open5gs_2.4.10.tar.xz/src/amf/sbi-path.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -34,12 +34,9 @@ int amf_sbi_open(void); void amf_sbi_close(void); -bool amf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - void *data); +bool amf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data); bool amf_ue_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(amf_ue_t *amf_ue, void *data), amf_ue_t *amf_ue, void *data); @@ -67,13 +64,15 @@ #define AMF_REMOVE_S1_CONTEXT_BY_RESET_ALL 52 #define AMF_REMOVE_S1_CONTEXT_BY_RESET_PARTIAL 53 bool amf_sess_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(amf_sess_t *sess, void *data), amf_sess_t *sess, int state, void *data); bool amf_sess_sbi_discover_by_nsi( - OpenAPI_nf_type_e target_nf_type, amf_sess_t *sess); + amf_sess_t *sess, + ogs_sbi_service_type_e service_type, + ogs_sbi_discovery_option_t *discovery_option); void amf_sbi_send_activating_session(amf_sess_t *sess, int state);
View file
open5gs_2.4.9.tar.xz/src/amf/timer.c -> open5gs_2.4.10.tar.xz/src/amf/timer.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,36 +20,33 @@ #include "context.h" static amf_timer_cfg_t g_amf_timer_cfgMAX_NUM_OF_AMF_TIMER = { - AMF_TIMER_SBI_CLIENT_WAIT = - { .duration = ogs_time_from_msec(500) }, - /* Paging procedure for EPS services initiated */ AMF_TIMER_T3513 = - { .max_count = 2, .duration = ogs_time_from_sec(2) }, + { .have = true, .max_count = 2, .duration = ogs_time_from_sec(2) }, /* DEREGISTRATION REQUEST sent */ AMF_TIMER_T3522 = - { .max_count = 4, .duration = ogs_time_from_sec(3) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(3) }, /* REGISTRATION ACCEPT sent */ AMF_TIMER_T3550 = - { .max_count = 4, .duration = ogs_time_from_sec(6) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(6) }, /* CONFIGURATION UPDATE COMMAND sent */ AMF_TIMER_T3555 = - { .max_count = 4, .duration = ogs_time_from_sec(6) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(6) }, /* AUTHENTICATION REQUEST sent * SECURITY MODE COMMAND sent */ AMF_TIMER_T3560 = - { .max_count = 4, .duration = ogs_time_from_sec(6) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(6) }, /* IDENTITY REQUEST sent */ AMF_TIMER_T3570 = - { .max_count = 4, .duration = ogs_time_from_sec(3) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(3) }, AMF_TIMER_NG_HOLDING = - { .duration = ogs_time_from_sec(30) }, + { .have = true, .duration = ogs_time_from_sec(30) }, }; static void gmm_timer_event_send( @@ -58,24 +55,28 @@ amf_timer_cfg_t *amf_timer_cfg(amf_timer_e id) { ogs_assert(id < MAX_NUM_OF_AMF_TIMER); + if (g_amf_timer_cfgid.have != true) { + ogs_fatal("No timer%d configuration", id); + ogs_assert_if_reached(); + } return &g_amf_timer_cfgid; } -const char *amf_timer_get_name(amf_timer_e id) +const char *amf_timer_get_name(int timer_id) { - switch (id) { - case AMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "AMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case AMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "AMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case AMF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "AMF_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case AMF_TIMER_NF_INSTANCE_VALIDITY: - return "AMF_TIMER_NF_INSTANCE_VALIDITY"; - case AMF_TIMER_SUBSCRIPTION_VALIDITY: - return "AMF_TIMER_SUBSCRIPTION_VALIDITY"; - case AMF_TIMER_SBI_CLIENT_WAIT: - return "AMF_TIMER_SBI_CLIENT_WAIT"; + switch (timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + return OGS_TIMER_NAME_NF_INSTANCE_REGISTRATION_INTERVAL; + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + return OGS_TIMER_NAME_NF_INSTANCE_HEARTBEAT_INTERVAL; + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + return OGS_TIMER_NAME_NF_INSTANCE_NO_HEARTBEAT; + case OGS_TIMER_NF_INSTANCE_VALIDITY: + return OGS_TIMER_NAME_NF_INSTANCE_VALIDITY; + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + return OGS_TIMER_NAME_SUBSCRIPTION_VALIDITY; + case OGS_TIMER_SBI_CLIENT_WAIT: + return OGS_TIMER_NAME_SBI_CLIENT_WAIT; case AMF_TIMER_NG_DELAYED_SEND: return "AMF_TIMER_NG_DELAYED_SEND"; case AMF_TIMER_T3513: @@ -93,9 +94,10 @@ case AMF_TIMER_NG_HOLDING: return "AMF_TIMER_NG_HOLDING"; default: - break; + break; } + ogs_error("Unknown Timer%d", timer_id); return "UNKNOWN_TIMER"; } @@ -105,90 +107,16 @@ amf_event_t *e = data; ogs_assert(e); - e->timer_id = AMF_TIMER_NG_DELAYED_SEND; + e->h.timer_id = AMF_TIMER_NG_DELAYED_SEND; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_timer_delete(e->timer); - amf_event_free(e); + ogs_event_free(e); } } -static void sbi_timer_send_event(int timer_id, void *data) -{ - int rv; - amf_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case AMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case AMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case AMF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case AMF_TIMER_NF_INSTANCE_VALIDITY: - case AMF_TIMER_SUBSCRIPTION_VALIDITY: - e = amf_event_new(AMF_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - case AMF_TIMER_SBI_CLIENT_WAIT: - e = amf_event_new(AMF_EVT_SBI_TIMER); - if (!e) { - ogs_sbi_xact_t *sbi_xact = data; - ogs_assert(sbi_xact); - - ogs_error("sbi_timer_send_event() failed"); - ogs_sbi_xact_remove(sbi_xact); - return; - } - 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_error("ogs_queue_push() failed %d in %s", - (int)rv, amf_timer_get_name(e->timer_id)); - amf_event_free(e); - } -} - -void amf_timer_nf_instance_registration_interval(void *data) -{ - sbi_timer_send_event(AMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void amf_timer_nf_instance_heartbeat_interval(void *data) -{ - sbi_timer_send_event(AMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void amf_timer_nf_instance_no_heartbeat(void *data) -{ - sbi_timer_send_event(AMF_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void amf_timer_nf_instance_validity(void *data) -{ - sbi_timer_send_event(AMF_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void amf_timer_subscription_validity(void *data) -{ - sbi_timer_send_event(AMF_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void amf_timer_sbi_client_wait_expire(void *data) -{ - sbi_timer_send_event(AMF_TIMER_SBI_CLIENT_WAIT, data); -} - static void gmm_timer_event_send( amf_timer_e timer_id, amf_ue_t *amf_ue) { @@ -196,15 +124,16 @@ amf_event_t *e = NULL; ogs_assert(amf_ue); - e = amf_event_new(AMF_EVT_5GMM_TIMER); + e = amf_event_new(AMF_EVENT_5GMM_TIMER); ogs_assert(e); - e->timer_id = timer_id; + e->h.timer_id = timer_id; e->amf_ue = amf_ue; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { - ogs_error("ogs_queue_push() failed:%d", (int)rv); - amf_event_free(e); + ogs_error("ogs_queue_push() failed:%d in %s", + (int)rv, amf_timer_get_name(timer_id)); + ogs_event_free(e); } } @@ -242,15 +171,15 @@ ogs_assert(data); ran_ue = data; - e = amf_event_new(AMF_EVT_NGAP_TIMER); + e = amf_event_new(AMF_EVENT_NGAP_TIMER); ogs_assert(e); - e->timer_id = AMF_TIMER_NG_HOLDING; + e->h.timer_id = AMF_TIMER_NG_HOLDING; e->ran_ue = ran_ue; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); - amf_event_free(e); + ogs_event_free(e); } }
View file
open5gs_2.4.9.tar.xz/src/amf/timer.h -> open5gs_2.4.10.tar.xz/src/amf/timer.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,7 @@ #ifndef AMF_TIMER_H #define AMF_TIMER_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { @@ -28,14 +28,7 @@ /* forward declaration */ typedef enum { - AMF_TIMER_BASE = 0, - - AMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - AMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - AMF_TIMER_NF_INSTANCE_NO_HEARTBEAT, - AMF_TIMER_NF_INSTANCE_VALIDITY, - AMF_TIMER_SUBSCRIPTION_VALIDITY, - AMF_TIMER_SBI_CLIENT_WAIT, + AMF_TIMER_BASE = OGS_MAX_NUM_OF_PROTO_TIMER, AMF_TIMER_NG_DELAYED_SEND, AMF_TIMER_NG_HOLDING, @@ -52,20 +45,14 @@ } amf_timer_e; typedef struct amf_timer_cfg_s { + bool have; int max_count; ogs_time_t duration; } amf_timer_cfg_t; amf_timer_cfg_t *amf_timer_cfg(amf_timer_e id); -const char *amf_timer_get_name(amf_timer_e id); - -void amf_timer_nf_instance_registration_interval(void *data); -void amf_timer_nf_instance_heartbeat_interval(void *data); -void amf_timer_nf_instance_no_heartbeat(void *data); -void amf_timer_nf_instance_validity(void *data); -void amf_timer_subscription_validity(void *data); -void amf_timer_sbi_client_wait_expire(void *data); +const char *amf_timer_get_name(int timer_id); void amf_timer_ng_delayed_send(void *data);
View file
open5gs_2.4.9.tar.xz/src/ausf/ausf-sm.c -> open5gs_2.4.10.tar.xz/src/ausf/ausf-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -42,7 +42,7 @@ ogs_sbi_request_t *request = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; ogs_sbi_response_t *response = NULL; ogs_sbi_message_t message; ogs_sbi_xact_t *sbi_xact = NULL; @@ -53,17 +53,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case AUSF_EVT_SBI_SERVER: - request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + request = e->h.sbi.request; ogs_assert(request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&message, request); @@ -94,7 +94,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - ausf_nnrf_handle_nf_status_notify(stream, &message); + ogs_nnrf_handle_nf_status_notify(stream, &message); break; DEFAULT @@ -154,7 +154,7 @@ ogs_assert(OGS_FSM_STATE(&ausf_ue->sm)); e->ausf_ue = ausf_ue; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&ausf_ue->sm, e); if (OGS_FSM_CHECK(&ausf_ue->sm, ausf_ue_state_exception)) { ogs_error("%s State machine exception", ausf_ue->suci); @@ -174,10 +174,10 @@ ogs_sbi_message_free(&message); break; - case AUSF_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - response = e->sbi.response; + response = e->h.sbi.response; ogs_assert(response); rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { @@ -199,43 +199,43 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; - ogs_assert(subscription); + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); 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) { - ausf_nnrf_handle_nf_status_subscribe( - subscription, &message); + ogs_nnrf_handle_nf_status_subscribe( + subscription_data, &message); } else { ogs_error("%s HTTP response error %d", - subscription->id, message.res_status); + subscription_data->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); + ogs_sbi_subscription_data_remove(subscription_data); } else { ogs_error("%s HTTP response error %d", - subscription->id, message.res_status); + subscription_data->id, message.res_status); } break; DEFAULT ogs_error("%s Invalid HTTP method %s", - subscription->id, message.h.method); + subscription_data->id, message.h.method); ogs_assert_if_reached(); END break; @@ -250,7 +250,7 @@ CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); SWITCH(message.h.method) @@ -276,7 +276,7 @@ break; CASE(OGS_SBI_SERVICE_NAME_NUDM_UEAU) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -290,7 +290,7 @@ ausf_ue = (ausf_ue_t *)sbi_xact->sbi_object; ogs_assert(ausf_ue); - e->sbi.data = sbi_xact->assoc_stream; + e->h.sbi.data = sbi_xact->assoc_stream; ogs_sbi_xact_remove(sbi_xact); @@ -301,7 +301,7 @@ } e->ausf_ue = ausf_ue; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&ausf_ue->sm, e); if (OGS_FSM_CHECK(&ausf_ue->sm, ausf_ue_state_exception)) { @@ -319,42 +319,39 @@ ogs_sbi_response_free(response); break; - case AUSF_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case AUSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case AUSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case AUSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case AUSF_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.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, ausf_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s:%s State machine exception %d", OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case AUSF_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; - ogs_assert(subscription); + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); - ogs_assert(ogs_sbi_self()->nf_instance); ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client, - ogs_sbi_self()->nf_instance->nf_type, - subscription->req_nf_instance_id, - subscription->subscr_cond.nf_type)); + ogs_nnrf_nfm_send_nf_status_subscribe(subscription_data)); - ogs_info("%s Subscription validity expired", subscription->id); - ogs_sbi_subscription_remove(subscription); + ogs_info("Subscription validity expired %s", + subscription_data->id); + ogs_sbi_subscription_data_remove(subscription_data); break; - case AUSF_TIMER_SBI_CLIENT_WAIT: - sbi_xact = e->sbi.data; + case OGS_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); stream = sbi_xact->assoc_stream; @@ -370,7 +367,7 @@ break; default: ogs_error("Unknown timer%s:%d", - ausf_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break;
View file
open5gs_2.4.9.tar.xz/src/ausf/ausf-sm.h -> open5gs_2.4.10.tar.xz/src/ausf/ausf-sm.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,16 +30,6 @@ void ausf_state_final(ogs_fsm_t *s, ausf_event_t *e); void ausf_state_operational(ogs_fsm_t *s, ausf_event_t *e); -void ausf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void ausf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void ausf_nf_state_initial(ogs_fsm_t *s, ausf_event_t *e); -void ausf_nf_state_final(ogs_fsm_t *s, ausf_event_t *e); -void ausf_nf_state_will_register(ogs_fsm_t *s, ausf_event_t *e); -void ausf_nf_state_registered(ogs_fsm_t *s, ausf_event_t *e); -void ausf_nf_state_de_registered(ogs_fsm_t *s, ausf_event_t *e); -void ausf_nf_state_exception(ogs_fsm_t *s, ausf_event_t *e); - void ausf_ue_state_initial(ogs_fsm_t *s, ausf_event_t *e); void ausf_ue_state_final(ogs_fsm_t *s, ausf_event_t *e); void ausf_ue_state_operational(ogs_fsm_t *s, ausf_event_t *e);
View file
open5gs_2.4.9.tar.xz/src/ausf/context.c -> open5gs_2.4.10.tar.xz/src/ausf/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -102,6 +102,10 @@ ogs_assert(ausf_key); if (!strcmp(ausf_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(ausf_key, "service_name")) { + /* handle config in sbi library */ + } else if (!strcmp(ausf_key, "discovery")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", ausf_key); } @@ -133,14 +137,13 @@ ogs_assert(ausf_ue->suci); ogs_hash_set(self.suci_hash, ausf_ue->suci, strlen(ausf_ue->suci), ausf_ue); - ausf_ue->supi = ogs_supi_from_suci(ausf_ue->suci); + ausf_ue->supi = ogs_supi_from_supi_or_suci(ausf_ue->suci); ogs_assert(ausf_ue->supi); ogs_hash_set(self.supi_hash, ausf_ue->supi, strlen(ausf_ue->supi), ausf_ue); memset(&e, 0, sizeof(e)); e.ausf_ue = ausf_ue; - ogs_fsm_create(&ausf_ue->sm, ausf_ue_state_initial, ausf_ue_state_final); - ogs_fsm_init(&ausf_ue->sm, &e); + ogs_fsm_init(&ausf_ue->sm, ausf_ue_state_initial, ausf_ue_state_final, &e); ogs_list_add(&self.ausf_ue_list, ausf_ue); @@ -158,7 +161,6 @@ memset(&e, 0, sizeof(e)); e.ausf_ue = ausf_ue; ogs_fsm_fini(&ausf_ue->sm, &e); - ogs_fsm_delete(&ausf_ue->sm); /* Free SBI object memory */ ogs_sbi_object_free(&ausf_ue->sbi);
View file
open5gs_2.4.9.tar.xz/src/ausf/context.h -> open5gs_2.4.10.tar.xz/src/ausf/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -25,7 +25,6 @@ #include "ogs-sbi.h" #include "ausf-sm.h" -#include "timer.h" #ifdef __cplusplus extern "C" { @@ -63,22 +62,6 @@ uint8_t hxres_starOGS_MAX_RES_LEN; uint8_t kausfOGS_SHA256_DIGEST_SIZE; uint8_t kseafOGS_SHA256_DIGEST_SIZE; - -#define AUSF_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - ausf_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, ausf_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } while(0) }; void ausf_context_init(void);
View file
open5gs_2.4.9.tar.xz/src/ausf/event.c -> open5gs_2.4.10.tar.xz/src/ausf/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,60 +18,42 @@ */ #include "event.h" -#include "context.h" -static OGS_POOL(pool, ausf_event_t); - -void ausf_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); -} - -void ausf_event_final(void) -{ - ogs_pool_final(&pool); -} - -ausf_event_t *ausf_event_new(ausf_event_e id) +ausf_event_t *ausf_event_new(int id) { ausf_event_t *e = NULL; - ogs_pool_alloc(&pool, &e); + e = ogs_event_size(id, sizeof(ausf_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void ausf_event_free(ausf_event_t *e) -{ - ogs_assert(e); - ogs_pool_free(&pool, e); -} - const char *ausf_event_get_name(ausf_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { - case OGS_FSM_ENTRY_SIG: + switch (e->h.id) { + case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; - case OGS_FSM_EXIT_SIG: + case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case AUSF_EVT_SBI_SERVER: - return "AUSF_EVT_SBI_SERVER"; - case AUSF_EVT_SBI_CLIENT: - return "AUSF_EVT_SBI_CLIENT"; - case AUSF_EVT_SBI_TIMER: - return "AUSF_EVT_SBI_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; - default: - break; + default: + break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.tar.xz/src/ausf/event.h -> open5gs_2.4.10.tar.xz/src/ausf/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,53 +20,21 @@ #ifndef AUSF_EVENT_H #define AUSF_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.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 ausf_ue_s ausf_ue_t; -typedef enum { - AUSF_EVT_BASE = OGS_FSM_USER_SIG, - - AUSF_EVT_SBI_SERVER, - AUSF_EVT_SBI_CLIENT, - AUSF_EVT_SBI_TIMER, - - AUSF_EVT_TOP, - -} ausf_event_e; - typedef struct ausf_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; + ogs_event_t h; ausf_ue_t *ausf_ue; - - ogs_timer_t *timer; } ausf_event_t; -void ausf_event_init(void); -void ausf_event_final(void); - -ausf_event_t *ausf_event_new(ausf_event_e id); -void ausf_event_free(ausf_event_t *e); +ausf_event_t *ausf_event_new(int id); const char *ausf_event_get_name(ausf_event_t *e);
View file
open5gs_2.4.9.tar.xz/src/ausf/init.c -> open5gs_2.4.10.tar.xz/src/ausf/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,7 +30,6 @@ ogs_sbi_context_init(); ausf_context_init(); - ausf_event_init(); rv = ogs_sbi_context_parse_config("ausf", "nrf", "scp"); if (rv != OGS_OK) return rv; @@ -61,7 +60,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - ausf_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -87,8 +86,6 @@ ausf_context_final(); ogs_sbi_context_final(); - - ausf_event_final(); /* Destroy event */ } static void ausf_main(void *data) @@ -96,8 +93,7 @@ ogs_fsm_t ausf_sm; int rv; - ogs_fsm_create(&ausf_sm, ausf_state_initial, ausf_state_final); - ogs_fsm_init(&ausf_sm, 0); + ogs_fsm_init(&ausf_sm, ausf_state_initial, ausf_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -130,11 +126,10 @@ ogs_assert(e); ogs_fsm_dispatch(&ausf_sm, e); - ausf_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&ausf_sm, 0); - ogs_fsm_delete(&ausf_sm); }
View file
open5gs_2.4.9.tar.xz/src/ausf/meson.build -> open5gs_2.4.10.tar.xz/src/ausf/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -18,12 +18,8 @@ libausf_sources = files(''' context.c event.c - timer.c - nnrf-build.c nnrf-handler.c - nf-sm.c - nausf-handler.c nudm-build.c @@ -38,15 +34,13 @@ libausf = static_library('ausf', sources : libausf_sources, - dependencies : libapp_dep, - libcrypt_dep, + dependencies : libcrypt_dep, libsbi_dep, install : false) libausf_dep = declare_dependency( link_with : libausf, - dependencies : libapp_dep, - libcrypt_dep, + dependencies : libcrypt_dep, libsbi_dep) ausf_sources = files('''
View file
open5gs_2.4.9.tar.xz/src/ausf/nausf-handler.c -> open5gs_2.4.10.tar.xz/src/ausf/nausf-handler.c
Changed
@@ -55,7 +55,8 @@ ogs_assert(ausf_ue->serving_network_name); ogs_assert(true == - ausf_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL, + ausf_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NUDM_UEAU, NULL, ausf_nudm_ueau_build_get, ausf_ue, stream, AuthenticationInfo->resynchronization_info)); @@ -104,7 +105,8 @@ } ogs_assert(true == - ausf_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL, + ausf_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NUDM_UEAU, NULL, ausf_nudm_ueau_build_result_confirmation_inform, ausf_ue, stream, NULL));
View file
open5gs_2.4.9.tar.xz/src/ausf/nnrf-handler.c -> open5gs_2.4.10.tar.xz/src/ausf/nnrf-handler.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,251 +20,24 @@ #include "sbi-path.h" #include "nnrf-handler.h" -void ausf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void ausf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->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_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - 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, - ausf_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 ausf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - ausf_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - nf_instance->reference_count++; - - OGS_FSM_TRAN(&nf_instance->sm, ausf_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - AUSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - AUSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - AUSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -} - void ausf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; - OpenAPI_nf_type_e target_nf_type = 0; + ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; OpenAPI_search_result_t *SearchResult = NULL; - OpenAPI_lnode_t *node = NULL; - bool handled; ogs_assert(recvmsg); ogs_assert(xact); sbi_object = xact->sbi_object; ogs_assert(sbi_object); - target_nf_type = xact->target_nf_type; + service_type = xact->service_type; + ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); ogs_assert(target_nf_type); discovery_option = xact->discovery_option; @@ -275,68 +48,18 @@ 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(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); - - ausf_nf_fsm_init(nf_instance); + ogs_nnrf_handle_nf_discover_search_result(SearchResult); - ogs_info("%s (NF-discover) NF registered", nf_instance->id); - } else { - nf_instance->reference_count++; - - OGS_FSM_TRAN(&nf_instance->sm, ausf_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); - AUSF_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); - AUSF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - /* TIME : Update validity from NRF */ - if (SearchResult->is_validity_period && - 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); - } + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (!nf_instance) { + ogs_error("(NF discover) No %s", + ogs_sbi_service_type_to_name(service_type)); + return; } - ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_arrayservice_type, nf_instance); - ogs_expect(true == ausf_sbi_send_request(sbi_object, target_nf_type, xact)); + ogs_expect(true == ausf_sbi_send_request(nf_instance, xact)); }
View file
open5gs_2.4.9.tar.xz/src/ausf/nnrf-handler.h -> open5gs_2.4.10.tar.xz/src/ausf/nnrf-handler.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -26,14 +26,6 @@ extern "C" { #endif -void ausf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void ausf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool ausf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - void ausf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg);
View file
open5gs_2.4.9.tar.xz/src/ausf/sbi-path.c -> open5gs_2.4.10.tar.xz/src/ausf/sbi-path.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -27,17 +27,17 @@ ogs_assert(request); ogs_assert(data); - e = ausf_event_new(AUSF_EVT_SBI_SERVER); + e = ausf_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - ausf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -58,16 +58,16 @@ ogs_assert(response); - e = ausf_event_new(AUSF_EVT_SBI_CLIENT); + e = ausf_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - ausf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -82,41 +82,41 @@ /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_AUSF); ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AMF); + ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_SCP); /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NAUSF_AUTH); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + if (ogs_sbi_nf_service_is_available(OGS_SBI_SERVICE_NAME_NAUSF_AUTH)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NAUSF_AUTH); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + } /* Initialize NRF NF Instance */ - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_sbi_client_t *client = 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. */ - ausf_nf_fsm_init(nf_instance); - } - } - - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = ausf_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)ausf_nf_state_registered; + nf_instance = ogs_sbi_self()->nrf_instance; + if (nf_instance) { + ogs_sbi_client_t *client = 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. */ + ogs_sbi_nf_fsm_init(nf_instance); + } + + /* Build Subscription-Data */ + ogs_sbi_subscription_data_build_default( + OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_UEAU); if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR; @@ -130,43 +130,28 @@ ogs_sbi_server_stop_all(); } -bool ausf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - void *data) +bool ausf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data) { - ogs_sbi_nf_instance_t *nf_instance = NULL; - - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); - if (!nf_instance) { - ogs_error("(NF discover) No %s", - OpenAPI_nf_type_ToString(target_nf_type)); - return false; - } + ogs_assert(nf_instance); return ogs_sbi_send_request(nf_instance, client_cb, data); } bool ausf_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(ausf_ue_t *ausf_ue, void *data), ausf_ue_t *ausf_ue, ogs_sbi_stream_t *stream, void *data) { ogs_sbi_xact_t *xact = NULL; - OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; - - ogs_assert(ogs_sbi_self()->nf_instance); - requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; - ogs_assert(requester_nf_type); - ogs_assert(target_nf_type); + ogs_assert(service_type); ogs_assert(ausf_ue); ogs_assert(stream); ogs_assert(build); xact = ogs_sbi_xact_add( - &ausf_ue->sbi, target_nf_type, discovery_option, + &ausf_ue->sbi, service_type, discovery_option, (ogs_sbi_build_f)build, ausf_ue, data); if (!xact) { ogs_error("ausf_sbi_discover_and_send() failed"); @@ -179,10 +164,7 @@ xact->assoc_stream = stream; - if (ogs_sbi_discover_and_send( - &ausf_ue->sbi, - target_nf_type, requester_nf_type, discovery_option, - client_cb, xact) != true) { + if (ogs_sbi_discover_and_send(xact, client_cb) != true) { ogs_error("ausf_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); ogs_assert(true ==
View file
open5gs_2.4.9.tar.xz/src/ausf/sbi-path.h -> open5gs_2.4.10.tar.xz/src/ausf/sbi-path.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,6 @@ #ifndef AUSF_SBI_PATH_H #define AUSF_SBI_PATH_H -#include "nnrf-build.h" #include "nudm-build.h" #ifdef __cplusplus @@ -30,12 +29,9 @@ int ausf_sbi_open(void); void ausf_sbi_close(void); -bool ausf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - void *data); +bool ausf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data); bool ausf_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(ausf_ue_t *ausf_ue, void *data), ausf_ue_t *ausf_ue, ogs_sbi_stream_t *stream, void *data);
View file
open5gs_2.4.9.tar.xz/src/ausf/ue-sm.c -> open5gs_2.4.10.tar.xz/src/ausf/ue-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -66,17 +66,17 @@ ausf_ue = e->ausf_ue; ogs_assert(ausf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case AUSF_EVT_SBI_SERVER: - message = e->sbi.message; + case OGS_EVENT_SBI_SERVER: + message = e->h.sbi.message; ogs_assert(message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(message->h.method) @@ -109,13 +109,13 @@ break; - case AUSF_EVT_SBI_CLIENT: - message = e->sbi.message; + case OGS_EVENT_SBI_CLIENT: + message = e->h.sbi.message; ogs_assert(message); ausf_ue = e->ausf_ue; ogs_assert(ausf_ue); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(message->h.service.name) @@ -178,7 +178,7 @@ ausf_ue = e->ausf_ue; ogs_assert(ausf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break;
View file
open5gs_2.4.9.tar.xz/src/bsf/bsf-sm.c -> open5gs_2.4.10.tar.xz/src/bsf/bsf-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -47,7 +47,7 @@ ogs_sbi_request_t *request = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; ogs_sbi_response_t *response = NULL; ogs_sbi_message_t message; ogs_sbi_xact_t *sbi_xact = NULL; @@ -56,17 +56,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case BSF_EVT_SBI_SERVER: - request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + request = e->h.sbi.request; ogs_assert(request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&message, request); @@ -97,7 +97,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - bsf_nnrf_handle_nf_status_notify(stream, &message); + ogs_nnrf_handle_nf_status_notify(stream, &message); break; DEFAULT @@ -195,10 +195,10 @@ ogs_sbi_message_free(&message); break; - case BSF_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - response = e->sbi.response; + response = e->h.sbi.response; ogs_assert(response); rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { @@ -220,24 +220,24 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; - ogs_assert(subscription); + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); 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) { - bsf_nnrf_handle_nf_status_subscribe( - subscription, &message); + ogs_nnrf_handle_nf_status_subscribe( + subscription_data, &message); } else { ogs_error("HTTP response error : %d", message.res_status); @@ -246,7 +246,7 @@ CASE(OGS_SBI_HTTP_METHOD_DELETE) if (message.res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT) { - ogs_sbi_subscription_remove(subscription); + ogs_sbi_subscription_data_remove(subscription_data); } else { ogs_error("HTTP response error : %d", message.res_status); @@ -269,7 +269,7 @@ CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); SWITCH(message.h.method) @@ -303,42 +303,39 @@ ogs_sbi_response_free(response); break; - case BSF_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case BSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case BSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case BSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case BSF_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.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, bsf_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s:%s State machine exception %d", OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case BSF_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; - ogs_assert(subscription); + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); - ogs_assert(ogs_sbi_self()->nf_instance); ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client, - ogs_sbi_self()->nf_instance->nf_type, - subscription->req_nf_instance_id, - subscription->subscr_cond.nf_type)); + ogs_nnrf_nfm_send_nf_status_subscribe(subscription_data)); - ogs_info("Subscription validity expired %s", subscription->id); - ogs_sbi_subscription_remove(subscription); + ogs_info("Subscription validity expired %s", + subscription_data->id); + ogs_sbi_subscription_data_remove(subscription_data); break; - case BSF_TIMER_SBI_CLIENT_WAIT: - sbi_xact = e->sbi.data; + case OGS_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); stream = sbi_xact->assoc_stream; @@ -358,7 +355,7 @@ default: ogs_error("Unknown timer%s:%d", - bsf_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break;
View file
open5gs_2.4.9.tar.xz/src/bsf/bsf-sm.h -> open5gs_2.4.10.tar.xz/src/bsf/bsf-sm.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -31,16 +31,6 @@ void bsf_state_operational(ogs_fsm_t *s, bsf_event_t *e); void bsf_state_exception(ogs_fsm_t *s, bsf_event_t *e); -void bsf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void bsf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void bsf_nf_state_initial(ogs_fsm_t *s, bsf_event_t *e); -void bsf_nf_state_final(ogs_fsm_t *s, bsf_event_t *e); -void bsf_nf_state_will_register(ogs_fsm_t *s, bsf_event_t *e); -void bsf_nf_state_registered(ogs_fsm_t *s, bsf_event_t *e); -void bsf_nf_state_de_registered(ogs_fsm_t *s, bsf_event_t *e); -void bsf_nf_state_exception(ogs_fsm_t *s, bsf_event_t *e); - #define bsf_sm_debug(__pe) \ ogs_debug("%s(): %s", __func__, bsf_event_get_name(__pe))
View file
open5gs_2.4.9.tar.xz/src/bsf/context.c -> open5gs_2.4.10.tar.xz/src/bsf/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -104,6 +104,10 @@ ogs_assert(bsf_key); if (!strcmp(bsf_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(bsf_key, "service_name")) { + /* handle config in sbi library */ + } else if (!strcmp(bsf_key, "discovery")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", bsf_key); } @@ -279,7 +283,7 @@ ogs_list_for_each(&self.sess_list, sess) if (sess->s_nssai.sst == s_nssai->sst && - sess->dnn && strcmp(sess->dnn, dnn) == 0) + sess->dnn && ogs_strcasecmp(sess->dnn, dnn) == 0) return sess; return NULL;
View file
open5gs_2.4.9.tar.xz/src/bsf/context.h -> open5gs_2.4.10.tar.xz/src/bsf/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -23,7 +23,6 @@ #include "ogs-sbi.h" #include "ogs-app.h" -#include "timer.h" #include "bsf-sm.h" #ifdef __cplusplus @@ -42,22 +41,6 @@ ogs_list_t sess_list; } bsf_context_t; -#define BSF_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - bsf_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, bsf_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } while(0) - typedef struct bsf_sess_s bsf_sess_t; typedef struct bsf_sess_s {
View file
open5gs_2.4.9.tar.xz/src/bsf/event.c -> open5gs_2.4.10.tar.xz/src/bsf/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,60 +18,42 @@ */ #include "event.h" -#include "context.h" -static OGS_POOL(pool, bsf_event_t); - -void bsf_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); -} - -void bsf_event_final(void) -{ - ogs_pool_final(&pool); -} - -bsf_event_t *bsf_event_new(bsf_event_e id) +bsf_event_t *bsf_event_new(int id) { bsf_event_t *e = NULL; - ogs_pool_alloc(&pool, &e); + e = ogs_event_size(id, sizeof(bsf_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void bsf_event_free(bsf_event_t *e) -{ - ogs_assert(e); - ogs_pool_free(&pool, e); -} - const char *bsf_event_get_name(bsf_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { - case OGS_FSM_ENTRY_SIG: + switch (e->h.id) { + case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; - case OGS_FSM_EXIT_SIG: + case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case BSF_EVT_SBI_SERVER: - return "BSF_EVT_SBI_SERVER"; - case BSF_EVT_SBI_CLIENT: - return "BSF_EVT_SBI_CLIENT"; - case BSF_EVT_SBI_TIMER: - return "BSF_EVT_SBI_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; - default: - break; + default: + break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.tar.xz/src/bsf/event.h -> open5gs_2.4.10.tar.xz/src/bsf/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,51 +20,20 @@ #ifndef BSF_EVENT_H #define BSF_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { #endif typedef struct bsf_sess_s bsf_sess_t; -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_subscription_s ogs_sbi_subscription_t; - -typedef enum { - BSF_EVT_BASE = OGS_FSM_USER_SIG, - - BSF_EVT_SBI_SERVER, - BSF_EVT_SBI_CLIENT, - BSF_EVT_SBI_TIMER, - - BSF_EVT_TOP, - -} bsf_event_e; typedef struct bsf_event_s { - int id; - ogs_pkbuf_t *pkbuf; - int timer_id; - - struct { - ogs_sbi_request_t *request; - ogs_sbi_response_t *response; - void *data; - int state; - - ogs_sbi_message_t *message; - } sbi; - + ogs_event_t h; bsf_sess_t *sess; } bsf_event_t; -void bsf_event_init(void); -void bsf_event_final(void); - -bsf_event_t *bsf_event_new(bsf_event_e id); -void bsf_event_free(bsf_event_t *e); +bsf_event_t *bsf_event_new(int id); const char *bsf_event_get_name(bsf_event_t *e);
View file
open5gs_2.4.9.tar.xz/src/bsf/init.c -> open5gs_2.4.10.tar.xz/src/bsf/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -32,7 +32,6 @@ ogs_sbi_context_init(); bsf_context_init(); - bsf_event_init(); rv = ogs_sbi_context_parse_config("bsf", "nrf", "scp"); if (rv != OGS_OK) return rv; @@ -63,7 +62,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - bsf_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -90,8 +89,6 @@ bsf_context_final(); ogs_sbi_context_final(); - - bsf_event_final(); /* Destroy event */ } static void bsf_main(void *data) @@ -99,8 +96,7 @@ ogs_fsm_t bsf_sm; int rv; - ogs_fsm_create(&bsf_sm, bsf_state_initial, bsf_state_final); - ogs_fsm_init(&bsf_sm, 0); + ogs_fsm_init(&bsf_sm, bsf_state_initial, bsf_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -133,11 +129,10 @@ ogs_assert(e); ogs_fsm_dispatch(&bsf_sm, e); - bsf_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&bsf_sm, 0); - ogs_fsm_delete(&bsf_sm); }
View file
open5gs_2.4.9.tar.xz/src/bsf/meson.build -> open5gs_2.4.10.tar.xz/src/bsf/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -18,12 +18,8 @@ libbsf_sources = files(''' context.c event.c - timer.c - nnrf-build.c nnrf-handler.c - nf-sm.c - nbsf-handler.c sbi-path.c @@ -34,15 +30,13 @@ libbsf = static_library('bsf', sources : libbsf_sources, - dependencies : libapp_dep, - libcrypt_dep, + dependencies : libcrypt_dep, libsbi_dep, install : false) libbsf_dep = declare_dependency( link_with : libbsf, - dependencies : libapp_dep, - libcrypt_dep, + dependencies : libcrypt_dep, libsbi_dep) bsf_sources = files('''
View file
open5gs_2.4.9.tar.xz/src/bsf/nbsf-handler.c -> open5gs_2.4.10.tar.xz/src/bsf/nbsf-handler.c
Changed
@@ -34,10 +34,6 @@ OpenAPI_pcf_binding_t *RecvPcfBinding = NULL; OpenAPI_pcf_binding_t SendPcfBinding; OpenAPI_snssai_t Snssai; -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - char fqdnOGS_MAX_FQDN_LEN+1; - int fqdn_len; -#endif ogs_assert(stream); ogs_assert(recvmsg); @@ -103,22 +99,10 @@ bsf_sess_set_ipv6prefix(sess, RecvPcfBinding->ipv6_prefix); if (RecvPcfBinding->pcf_fqdn) { -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - ogs_assert(0 < ogs_fqdn_parse( - fqdn, RecvPcfBinding->pcf_fqdn, - ogs_min(strlen(RecvPcfBinding->pcf_fqdn), - OGS_MAX_FQDN_LEN))); - - if (sess->pcf_fqdn) - ogs_free(sess->pcf_fqdn); - sess->pcf_fqdn = ogs_strdup(fqdn); - ogs_assert(sess->pcf_fqdn); -#else if (sess->pcf_fqdn) ogs_free(sess->pcf_fqdn); sess->pcf_fqdn = ogs_strdup(RecvPcfBinding->pcf_fqdn); ogs_assert(sess->pcf_fqdn); -#endif } PcfIpEndPointList = RecvPcfBinding->pcf_ip_end_points; @@ -232,18 +216,8 @@ PcfIpEndPointList = OpenAPI_list_create(); ogs_assert(PcfIpEndPointList); - if (sess->pcf_fqdn && strlen(sess->pcf_fqdn)) { -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - memset(fqdn, 0, sizeof(fqdn)); - fqdn_len = ogs_fqdn_build(fqdn, - sess->pcf_fqdn, strlen(sess->pcf_fqdn)); - SendPcfBinding.pcf_fqdn = ogs_memdup(fqdn, fqdn_len+1); - ogs_assert(SendPcfBinding.pcf_fqdn); - SendPcfBinding.pcf_fqdnfqdn_len = 0; -#else + if (sess->pcf_fqdn && strlen(sess->pcf_fqdn)) SendPcfBinding.pcf_fqdn = ogs_strdup(sess->pcf_fqdn); -#endif - } for (i = 0; i < sess->num_of_pcf_ip; i++) { OpenAPI_ip_end_point_t *PcfIpEndPoint = NULL;
View file
open5gs_2.4.9.tar.xz/src/bsf/nnrf-handler.c -> open5gs_2.4.10.tar.xz/src/bsf/nnrf-handler.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,252 +20,24 @@ #include "sbi-path.h" #include "nnrf-handler.h" -void bsf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void bsf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->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_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - 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, - bsf_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 bsf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - bsf_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - nf_instance->reference_count++; - - OGS_FSM_TRAN(&nf_instance->sm, bsf_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - BSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - BSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - BSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -} - void bsf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; - OpenAPI_nf_type_e target_nf_type = 0; + ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; OpenAPI_search_result_t *SearchResult = NULL; - OpenAPI_lnode_t *node = NULL; - bool handled; ogs_assert(recvmsg); ogs_assert(xact); sbi_object = xact->sbi_object; ogs_assert(sbi_object); - target_nf_type = xact->target_nf_type; + service_type = xact->service_type; + ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); ogs_assert(target_nf_type); discovery_option = xact->discovery_option; @@ -276,68 +48,18 @@ 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(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); - - bsf_nf_fsm_init(nf_instance); + ogs_nnrf_handle_nf_discover_search_result(SearchResult); - ogs_info("%s (NF-discover) NF registered", nf_instance->id); - } else { - nf_instance->reference_count++; - - OGS_FSM_TRAN(&nf_instance->sm, bsf_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("ogs_sbi_nnrf_handle_nf_profile() failed %s", - nf_instance->id); - BSF_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); - BSF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - /* TIME : Update validity from NRF */ - if (SearchResult->is_validity_period && - 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); - } + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (!nf_instance) { + ogs_error("(NF discover) No %s", + ogs_sbi_service_type_to_name(service_type)); + return; } - ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_arrayservice_type, nf_instance); - ogs_expect(true == bsf_sbi_send_request(sbi_object, target_nf_type, xact)); + ogs_expect(true == bsf_sbi_send_request(nf_instance, xact)); }
View file
open5gs_2.4.9.tar.xz/src/bsf/nnrf-handler.h -> open5gs_2.4.10.tar.xz/src/bsf/nnrf-handler.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -26,14 +26,6 @@ extern "C" { #endif -void bsf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void bsf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool bsf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - void bsf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg);
View file
open5gs_2.4.9.tar.xz/src/bsf/sbi-path.c -> open5gs_2.4.10.tar.xz/src/bsf/sbi-path.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -27,17 +27,17 @@ ogs_assert(request); ogs_assert(data); - e = bsf_event_new(BSF_EVT_SBI_SERVER); + e = bsf_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - bsf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -58,16 +58,16 @@ ogs_assert(response); - e = bsf_event_new(BSF_EVT_SBI_CLIENT); + e = bsf_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - bsf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -82,41 +82,39 @@ /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_BSF); ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_PCF); + ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AF); + ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_SCP); /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_PCF); + if (ogs_sbi_nf_service_is_available(OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_PCF); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AF); + } /* Initialize NRF NF Instance */ - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_sbi_client_t *client = 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. */ - bsf_nf_fsm_init(nf_instance); - } - } - - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = bsf_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)bsf_nf_state_registered; + nf_instance = ogs_sbi_self()->nrf_instance; + if (nf_instance) { + ogs_sbi_client_t *client = 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. */ + ogs_sbi_nf_fsm_init(nf_instance); + } if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR; @@ -130,42 +128,28 @@ ogs_sbi_server_stop_all(); } -bool bsf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - void *data) +bool bsf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data) { - ogs_sbi_nf_instance_t *nf_instance = NULL; - - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); - if (!nf_instance) { - ogs_error("(NF discover) No %s", - OpenAPI_nf_type_ToString(target_nf_type)); - return false; - } + ogs_assert(nf_instance); return ogs_sbi_send_request(nf_instance, client_cb, data); } bool bsf_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(bsf_sess_t *sess, void *data), bsf_sess_t *sess, ogs_sbi_stream_t *stream, void *data) { ogs_sbi_xact_t *xact = NULL; - OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; - - ogs_assert(ogs_sbi_self()->nf_instance); - requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; - ogs_assert(requester_nf_type); + ogs_assert(service_type); ogs_assert(sess); ogs_assert(stream); ogs_assert(build); xact = ogs_sbi_xact_add( - &sess->sbi, target_nf_type, discovery_option, + &sess->sbi, service_type, discovery_option, (ogs_sbi_build_f)build, sess, data); if (!xact) { ogs_error("bsf_sbi_discover_and_send() failed"); @@ -178,10 +162,7 @@ xact->assoc_stream = stream; - if (ogs_sbi_discover_and_send( - &sess->sbi, - target_nf_type, requester_nf_type, discovery_option, - client_cb, xact) != true) { + if (ogs_sbi_discover_and_send(xact, client_cb) != true) { ogs_error("bsf_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); ogs_assert(true ==
View file
open5gs_2.4.9.tar.xz/src/bsf/sbi-path.h -> open5gs_2.4.10.tar.xz/src/bsf/sbi-path.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,7 @@ #ifndef BSF_SBI_PATH_H #define BSF_SBI_PATH_H -#include "nnrf-build.h" +#include "context.h" #ifdef __cplusplus extern "C" { @@ -29,12 +29,9 @@ int bsf_sbi_open(void); void bsf_sbi_close(void); -bool bsf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - void *data); +bool bsf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data); bool bsf_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(bsf_sess_t *sess, void *data), bsf_sess_t *sess, ogs_sbi_stream_t *stream, void *data);
View file
open5gs_2.4.9.tar.xz/src/hss/hss-cx-path.c -> open5gs_2.4.10.tar.xz/src/hss/hss-cx-path.c
Changed
@@ -37,10 +37,10 @@ static int hss_ogs_diam_cx_fb_cb(struct msg **msg, struct avp *avp, struct session *session, void *opaque, enum disp_action *act) { - /* This CB should never be called */ - ogs_warn("Unexpected message received!"); - - return ENOTSUP; + /* This CB should never be called */ + ogs_warn("Unexpected message received!"); + + return ENOTSUP; } /* Callback for incoming User-Authorization-Request messages */ @@ -50,7 +50,7 @@ int rv, ret; uint32_t result_code = 0; - struct msg *ans, *qry; + struct msg *ans, *qry; struct avp_hdr *hdr; union avp_value val; @@ -63,14 +63,14 @@ char imsi_or_msisdn_bcdOGS_MAX_IMSI_BCD_LEN+1; ogs_msisdn_data_t msisdn_data; - + ogs_assert(msg); ogs_debug("User-Authorization-Request"); - - /* Create answer header */ - qry = *msg; - ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + + /* Create answer header */ + qry = *msg; + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); ogs_assert(ret == 0); ans = *msg; @@ -134,7 +134,7 @@ else result_code = OGS_DIAM_CX_SUBSEQUENT_REGISTRATION; - /* Set the Experimental-Result, Origin-Host and Origin-Realm AVPs */ + /* Set the Experimental-Result, Origin-Host and Origin-Realm AVPs */ ret = ogs_diam_message_experimental_rescode_set(ans, result_code); ogs_assert(ret == 0); @@ -159,22 +159,22 @@ ogs_assert(ret == 0); } - /* Send the answer */ - ret = fd_msg_send(msg, NULL, NULL); + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_debug("User-Authorization-Answer"); - - /* Add this value to the stats */ - ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); - ogs_diam_logger_self()->stats.nb_echoed++; - ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); + + /* Add this value to the stats */ + ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); ogs_free(user_name); ogs_free(public_identity); ogs_free(visited_network_identifier); - return 0; + return 0; out: /* Set Vendor-Specific-Application-Id AVP */ @@ -182,7 +182,7 @@ ans, OGS_DIAM_CX_APPLICATION_ID); ogs_assert(ret == 0); - /* Set the Experimental-Result, Origin-Host and Origin-Realm AVPs */ + /* Set the Experimental-Result, Origin-Host and Origin-Realm AVPs */ ret = ogs_diam_message_experimental_rescode_set(ans, result_code); ogs_assert(ret == 0); @@ -195,7 +195,7 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - ret = fd_msg_send(msg, NULL, NULL); + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_free(user_name); @@ -212,7 +212,7 @@ int rv, ret; uint32_t result_code = 0; - struct msg *ans, *qry; + struct msg *ans, *qry; struct avp *sip_auth_data_item_avp = NULL; struct avp *authentication_scheme_avp = NULL; @@ -252,9 +252,9 @@ ogs_debug("Multimedia-Auth-Request"); - /* Create answer header */ - qry = *msg; - ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + /* Create answer header */ + qry = *msg; + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); ogs_assert(ret == 0); ans = *msg; @@ -449,8 +449,8 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - /* Set the Origin-Host, Origin-Realm, and Result-Code AVPs */ - ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); + /* Set the Origin-Host, Origin-Realm, and Result-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); ogs_assert(ret == 0); /* Set the User-Name AVP */ @@ -548,16 +548,16 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - /* Send the answer */ - ret = fd_msg_send(msg, NULL, NULL); + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_debug("Multimedia-Auth-Answer"); - /* Add this value to the stats */ - ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); - ogs_diam_logger_self()->stats.nb_echoed++; - ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); + /* Add this value to the stats */ + ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); if (authentication_scheme) ogs_free(authentication_scheme); @@ -566,7 +566,7 @@ ogs_free(public_identity); ogs_free(server_name); - return 0; + return 0; out: /* Set Vendor-Specific-Application-Id AVP */ @@ -574,7 +574,7 @@ ans, OGS_DIAM_CX_APPLICATION_ID); ogs_assert(ret == 0); - /* Set the Experimental-Result, Origin-Host and Origin-Realm AVPs */ + /* Set the Experimental-Result, Origin-Host and Origin-Realm AVPs */ ret = ogs_diam_message_experimental_rescode_set(ans, result_code); ogs_assert(ret == 0); @@ -587,7 +587,7 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - ret = fd_msg_send(msg, NULL, NULL); + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); if (authentication_scheme) @@ -607,7 +607,7 @@ int rv, ret; uint32_t result_code = 0; - struct msg *ans, *qry; + struct msg *ans, *qry; bool matched = false; struct avp *user_name_avp = NULL; @@ -629,9 +629,9 @@ ogs_debug("Server-Assignment-Request"); - /* Create answer header */ - qry = *msg; - ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + /* Create answer header */ + qry = *msg; + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); ogs_assert(ret == 0); ans = *msg; @@ -733,8 +733,8 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - /* Set the Origin-Host, Origin-Realm, and Result-Code AVPs */ - ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); + /* Set the Origin-Host, Origin-Realm, and Result-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); ogs_assert(ret == 0); if (user_name_avp) { @@ -808,16 +808,16 @@ } } - /* Send the answer */ - ret = fd_msg_send(msg, NULL, NULL); + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_debug("Server-Assignment-Answer"); - /* Add this value to the stats */ - ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); - ogs_diam_logger_self()->stats.nb_echoed++; - ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); + /* Add this value to the stats */ + ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); if (user_data) ogs_free(user_data); @@ -825,7 +825,7 @@ ogs_free(public_identity); ogs_free(server_name); - return 0; + return 0; out: /* Set Vendor-Specific-Application-Id AVP */ @@ -833,7 +833,7 @@ ans, OGS_DIAM_CX_APPLICATION_ID); ogs_assert(ret == 0); - /* Set the Experimental-Result, Origin-Host and Origin-Realm AVPs */ + /* Set the Experimental-Result, Origin-Host and Origin-Realm AVPs */ ret = ogs_diam_message_experimental_rescode_set(ans, result_code); ogs_assert(ret == 0); @@ -846,7 +846,7 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - ret = fd_msg_send(msg, NULL, NULL); + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); if (user_data) @@ -865,7 +865,7 @@ int ret; uint32_t result_code = 0; - struct msg *ans, *qry; + struct msg *ans, *qry; struct avp_hdr *hdr; union avp_value val; @@ -877,9 +877,9 @@ ogs_debug("Location-Info-Request"); - /* Create answer header */ - qry = *msg; - ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + /* Create answer header */ + qry = *msg; + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); ogs_assert(ret == 0); ans = *msg; @@ -915,8 +915,8 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - /* Set the Origin-Host, Origin-Realm, and Result-Code AVPs */ - ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); + /* Set the Origin-Host, Origin-Realm, and Result-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); ogs_assert(ret == 0); /* Set Server-Name AVPs */ @@ -929,20 +929,20 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - /* Send the answer */ - ret = fd_msg_send(msg, NULL, NULL); + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_debug("Location-Info-Answer"); - /* Add this value to the stats */ - ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); - ogs_diam_logger_self()->stats.nb_echoed++; - ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); + /* Add this value to the stats */ + ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); ogs_free(public_identity); - return 0; + return 0; out: /* Set Vendor-Specific-Application-Id AVP */ @@ -950,7 +950,7 @@ ans, OGS_DIAM_CX_APPLICATION_ID); ogs_assert(ret == 0); - /* Set the Experimental-Result, Origin-Host and Origin-Realm AVPs */ + /* Set the Experimental-Result, Origin-Host and Origin-Realm AVPs */ ret = ogs_diam_message_experimental_rescode_set(ans, result_code); ogs_assert(ret == 0); @@ -963,7 +963,7 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - ret = fd_msg_send(msg, NULL, NULL); + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_free(public_identity); @@ -974,61 +974,61 @@ int hss_cx_init(void) { int ret; - struct disp_when data; + struct disp_when data; - /* Install objects definitions for this application */ - ret = ogs_diam_cx_init(); + /* Install objects definitions for this application */ + ret = ogs_diam_cx_init(); ogs_assert(ret == 0); - memset(&data, 0, sizeof(data)); - data.app = ogs_diam_cx_application; - - /* Fallback CB if command != unexpected message received */ - ret = fd_disp_register(hss_ogs_diam_cx_fb_cb, DISP_HOW_APPID, + memset(&data, 0, sizeof(data)); + data.app = ogs_diam_cx_application; + + /* Fallback CB if command != unexpected message received */ + ret = fd_disp_register(hss_ogs_diam_cx_fb_cb, DISP_HOW_APPID, &data, NULL, &hdl_cx_fb); ogs_assert(ret == 0); - - /* Specific handler for User-Authorization-Request */ - data.command = ogs_diam_cx_cmd_uar; - ret = fd_disp_register(hss_ogs_diam_cx_uar_cb, DISP_HOW_CC, &data, NULL, + + /* Specific handler for User-Authorization-Request */ + data.command = ogs_diam_cx_cmd_uar; + ret = fd_disp_register(hss_ogs_diam_cx_uar_cb, DISP_HOW_CC, &data, NULL, &hdl_cx_uar); ogs_assert(ret == 0); - /* Specific handler for Multimedia-Auth-Request */ - data.command = ogs_diam_cx_cmd_mar; - ret = fd_disp_register(hss_ogs_diam_cx_mar_cb, DISP_HOW_CC, &data, NULL, + /* Specific handler for Multimedia-Auth-Request */ + data.command = ogs_diam_cx_cmd_mar; + ret = fd_disp_register(hss_ogs_diam_cx_mar_cb, DISP_HOW_CC, &data, NULL, &hdl_cx_mar); ogs_assert(ret == 0); - /* Specific handler for Server-Assignment-Request */ - data.command = ogs_diam_cx_cmd_sar; - ret = fd_disp_register(hss_ogs_diam_cx_sar_cb, DISP_HOW_CC, &data, NULL, + /* Specific handler for Server-Assignment-Request */ + data.command = ogs_diam_cx_cmd_sar; + ret = fd_disp_register(hss_ogs_diam_cx_sar_cb, DISP_HOW_CC, &data, NULL, &hdl_cx_sar); ogs_assert(ret == 0); - /* Specific handler for Location-Info-Request */ - data.command = ogs_diam_cx_cmd_lir; - ret = fd_disp_register(hss_ogs_diam_cx_lir_cb, DISP_HOW_CC, &data, NULL, + /* Specific handler for Location-Info-Request */ + data.command = ogs_diam_cx_cmd_lir; + ret = fd_disp_register(hss_ogs_diam_cx_lir_cb, DISP_HOW_CC, &data, NULL, &hdl_cx_lir); ogs_assert(ret == 0); - /* Advertise the support for the application in the peer */ - ret = fd_disp_app_support(ogs_diam_cx_application, ogs_diam_vendor, 1, 0); + /* Advertise the support for the application in the peer */ + ret = fd_disp_app_support(ogs_diam_cx_application, ogs_diam_vendor, 1, 0); ogs_assert(ret == 0); - return OGS_OK; + return OGS_OK; } void hss_cx_final(void) { - if (hdl_cx_fb) - (void) fd_disp_unregister(&hdl_cx_fb, NULL); - if (hdl_cx_uar) - (void) fd_disp_unregister(&hdl_cx_uar, NULL); - if (hdl_cx_mar) - (void) fd_disp_unregister(&hdl_cx_mar, NULL); - if (hdl_cx_sar) - (void) fd_disp_unregister(&hdl_cx_sar, NULL); - if (hdl_cx_lir) - (void) fd_disp_unregister(&hdl_cx_lir, NULL); + if (hdl_cx_fb) + (void) fd_disp_unregister(&hdl_cx_fb, NULL); + if (hdl_cx_uar) + (void) fd_disp_unregister(&hdl_cx_uar, NULL); + if (hdl_cx_mar) + (void) fd_disp_unregister(&hdl_cx_mar, NULL); + if (hdl_cx_sar) + (void) fd_disp_unregister(&hdl_cx_sar, NULL); + if (hdl_cx_lir) + (void) fd_disp_unregister(&hdl_cx_lir, NULL); }
View file
open5gs_2.4.9.tar.xz/src/hss/hss-fd-path.c -> open5gs_2.4.10.tar.xz/src/hss/hss-fd-path.c
Changed
@@ -40,7 +40,7 @@ rv = ogs_diam_start(); ogs_assert(rv == 0); - return OGS_OK; + return OGS_OK; } void hss_fd_final(void)
View file
open5gs_2.4.9.tar.xz/src/hss/hss-init.c -> open5gs_2.4.10.tar.xz/src/hss/hss-init.c
Changed
@@ -43,7 +43,7 @@ initialized = 1; - return OGS_OK; + return OGS_OK; } void hss_terminate(void) @@ -54,6 +54,6 @@ ogs_dbi_final(); hss_context_final(); - - return; + + return; }
View file
open5gs_2.4.9.tar.xz/src/hss/hss-s6a-path.c -> open5gs_2.4.10.tar.xz/src/hss/hss-s6a-path.c
Changed
@@ -33,10 +33,10 @@ static int hss_ogs_diam_s6a_fb_cb(struct msg **msg, struct avp *avp, struct session *session, void *opaque, enum disp_action *act) { - /* This CB should never be called */ - ogs_warn("Unexpected message received!"); - - return ENOTSUP; + /* This CB should never be called */ + ogs_warn("Unexpected message received!"); + + return ENOTSUP; } /* Callback for incoming Authentication-Information-Request messages */ @@ -75,9 +75,9 @@ ogs_debug("Authentication-Information-Request"); - /* Create answer header */ - qry = *msg; - ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + /* Create answer header */ + qry = *msg; + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); ogs_assert(ret == 0); ans = *msg; @@ -211,8 +211,8 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ - ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); + /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); ogs_assert(ret == 0); /* Set the Auth-Session-State AVP */ @@ -229,18 +229,18 @@ ans, OGS_DIAM_S6A_APPLICATION_ID); ogs_assert(ret == 0); - /* Send the answer */ - ret = fd_msg_send(msg, NULL, NULL); + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_debug("Authentication-Information-Answer"); - /* Add this value to the stats */ - ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); - ogs_diam_logger_self()->stats.nb_echoed++; - ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); + /* Add this value to the stats */ + ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); - return 0; + return 0; out: ret = ogs_diam_message_experimental_rescode_set(ans, result_code); @@ -260,7 +260,7 @@ ans, OGS_DIAM_S6A_APPLICATION_ID); ogs_assert(ret == 0); - ret = fd_msg_send(msg, NULL, NULL); + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); return 0; @@ -370,28 +370,6 @@ ogs_assert(ret == 0); memcpy(&visited_plmn_id, hdr->avp_value->os.data, hdr->avp_value->os.len); - /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ - ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); - ogs_assert(ret == 0); - - /* Set the Auth-Session-State AVP */ - ret = fd_msg_avp_new(ogs_diam_auth_session_state, 0, &avp); - ogs_assert(ret == 0); - val.i32 = OGS_DIAM_AUTH_SESSION_NO_STATE_MAINTAINED; - ret = fd_msg_avp_setvalue(avp, &val); - ogs_assert(ret == 0); - ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); - ogs_assert(ret == 0); - - /* Set the ULA Flags */ - ret = fd_msg_avp_new(ogs_diam_s6a_ula_flags, 0, &avp); - ogs_assert(ret == 0); - val.i32 = OGS_DIAM_S6A_ULA_FLAGS_MME_REGISTERED_FOR_SMS; - ret = fd_msg_avp_setvalue(avp, &val); - ogs_assert(ret == 0); - ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); - ogs_assert(ret == 0); - ret = fd_msg_search_avp(qry, ogs_diam_s6a_ulr_flags, &avp); ogs_assert(ret == 0); ret = fd_msg_avp_hdr(avp, &hdr); @@ -817,6 +795,28 @@ ogs_assert(ret == 0); } + /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); + ogs_assert(ret == 0); + + /* Set the Auth-Session-State AVP */ + ret = fd_msg_avp_new(ogs_diam_auth_session_state, 0, &avp); + ogs_assert(ret == 0); + val.i32 = OGS_DIAM_AUTH_SESSION_NO_STATE_MAINTAINED; + ret = fd_msg_avp_setvalue(avp, &val); + ogs_assert(ret == 0); + ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); + ogs_assert(ret == 0); + + /* Set the ULA Flags */ + ret = fd_msg_avp_new(ogs_diam_s6a_ula_flags, 0, &avp); + ogs_assert(ret == 0); + val.i32 = OGS_DIAM_S6A_ULA_FLAGS_MME_REGISTERED_FOR_SMS; + ret = fd_msg_avp_setvalue(avp, &val); + ogs_assert(ret == 0); + ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); + ogs_assert(ret == 0); + /* Set Vendor-Specific-Application-Id AVP */ ret = ogs_diam_message_vendor_specific_appid_set( ans, OGS_DIAM_S6A_APPLICATION_ID); @@ -866,45 +866,45 @@ int hss_s6a_init(void) { int ret; - struct disp_when data; + struct disp_when data; - /* Install objects definitions for this application */ - ret = ogs_diam_s6a_init(); + /* Install objects definitions for this application */ + ret = ogs_diam_s6a_init(); ogs_assert(ret == 0); - memset(&data, 0, sizeof(data)); - data.app = ogs_diam_s6a_application; - - /* Fallback CB if command != unexpected message received */ - ret = fd_disp_register(hss_ogs_diam_s6a_fb_cb, DISP_HOW_APPID, &data, NULL, + memset(&data, 0, sizeof(data)); + data.app = ogs_diam_s6a_application; + + /* Fallback CB if command != unexpected message received */ + ret = fd_disp_register(hss_ogs_diam_s6a_fb_cb, DISP_HOW_APPID, &data, NULL, &hdl_s6a_fb); ogs_assert(ret == 0); - - /* Specific handler for Authentication-Information-Request */ - data.command = ogs_diam_s6a_cmd_air; - ret = fd_disp_register(hss_ogs_diam_s6a_air_cb, DISP_HOW_CC, &data, NULL, + + /* Specific handler for Authentication-Information-Request */ + data.command = ogs_diam_s6a_cmd_air; + ret = fd_disp_register(hss_ogs_diam_s6a_air_cb, DISP_HOW_CC, &data, NULL, &hdl_s6a_air); ogs_assert(ret == 0); - /* Specific handler for Location-Update-Request */ - data.command = ogs_diam_s6a_cmd_ulr; - ret = fd_disp_register(hss_ogs_diam_s6a_ulr_cb, DISP_HOW_CC, &data, NULL, + /* Specific handler for Location-Update-Request */ + data.command = ogs_diam_s6a_cmd_ulr; + ret = fd_disp_register(hss_ogs_diam_s6a_ulr_cb, DISP_HOW_CC, &data, NULL, &hdl_s6a_ulr); ogs_assert(ret == 0); - /* Advertise the support for the application in the peer */ - ret = fd_disp_app_support(ogs_diam_s6a_application, ogs_diam_vendor, 1, 0); + /* Advertise the support for the application in the peer */ + ret = fd_disp_app_support(ogs_diam_s6a_application, ogs_diam_vendor, 1, 0); ogs_assert(ret == 0); - return OGS_OK; + return OGS_OK; } void hss_s6a_final(void) { - if (hdl_s6a_fb) - (void) fd_disp_unregister(&hdl_s6a_fb, NULL); - if (hdl_s6a_air) - (void) fd_disp_unregister(&hdl_s6a_air, NULL); - if (hdl_s6a_ulr) - (void) fd_disp_unregister(&hdl_s6a_ulr, NULL); + if (hdl_s6a_fb) + (void) fd_disp_unregister(&hdl_s6a_fb, NULL); + if (hdl_s6a_air) + (void) fd_disp_unregister(&hdl_s6a_air, NULL); + if (hdl_s6a_ulr) + (void) fd_disp_unregister(&hdl_s6a_ulr, NULL); }
View file
open5gs_2.4.9.tar.xz/src/hss/hss-swx-path.c -> open5gs_2.4.10.tar.xz/src/hss/hss-swx-path.c
Changed
@@ -33,10 +33,10 @@ static int hss_ogs_diam_swx_fb_cb(struct msg **msg, struct avp *avp, struct session *session, void *opaque, enum disp_action *act) { - /* This CB should never be called */ - ogs_warn("Unexpected message received!"); - - return ENOTSUP; + /* This CB should never be called */ + ogs_warn("Unexpected message received!"); + + return ENOTSUP; } /* Callback for incoming Multimedia-Auth-Request messages */ @@ -46,7 +46,7 @@ int rv, ret; uint32_t result_code = 0; - struct msg *ans, *qry; + struct msg *ans, *qry; struct avp *sip_auth_data_item_avp = NULL; struct avp *authentication_scheme_avp = NULL; @@ -82,9 +82,9 @@ ogs_debug("Multimedia-Auth-Request"); - /* Create answer header */ - qry = *msg; - ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + /* Create answer header */ + qry = *msg; + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); ogs_assert(ret == 0); ans = *msg; @@ -238,8 +238,8 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - /* Set the Origin-Host, Origin-Realm, and Result-Code AVPs */ - ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); + /* Set the Origin-Host, Origin-Realm, and Result-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); ogs_assert(ret == 0); /* Set the User-Name AVP */ @@ -327,23 +327,23 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - /* Send the answer */ - ret = fd_msg_send(msg, NULL, NULL); + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_debug("Multimedia-Auth-Answer"); - /* Add this value to the stats */ - ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); - ogs_diam_logger_self()->stats.nb_echoed++; - ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); + /* Add this value to the stats */ + ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); if (authentication_scheme) ogs_free(authentication_scheme); ogs_free(user_name); - return 0; + return 0; out: /* Set Vendor-Specific-Application-Id AVP */ @@ -351,7 +351,7 @@ ans, OGS_DIAM_SWX_APPLICATION_ID); ogs_assert(ret == 0); - /* Set the Experimental-Result, Origin-Host and Origin-Realm AVPs */ + /* Set the Experimental-Result, Origin-Host and Origin-Realm AVPs */ ret = ogs_diam_message_experimental_rescode_set(ans, result_code); ogs_assert(ret == 0); @@ -364,7 +364,7 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - ret = fd_msg_send(msg, NULL, NULL); + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); if (authentication_scheme) @@ -382,7 +382,7 @@ int rv, ret; uint32_t result_code = 0; - struct msg *ans, *qry; + struct msg *ans, *qry; struct avp_hdr *hdr; union avp_value val; @@ -402,9 +402,9 @@ memset(&subscription_data, 0, sizeof(ogs_subscription_data_t)); - /* Create answer header */ - qry = *msg; - ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + /* Create answer header */ + qry = *msg; + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); ogs_assert(ret == 0); ans = *msg; @@ -428,34 +428,6 @@ goto out; } - /* Set Vendor-Specific-Application-Id AVP */ - ret = ogs_diam_message_vendor_specific_appid_set( - ans, OGS_DIAM_SWX_APPLICATION_ID); - ogs_assert(ret == 0); - - /* Set the Auth-Session-State AVP */ - ret = fd_msg_avp_new(ogs_diam_auth_session_state, 0, &avp); - ogs_assert(ret == 0); - val.i32 = OGS_DIAM_AUTH_SESSION_NO_STATE_MAINTAINED; - ret = fd_msg_avp_setvalue(avp, &val); - ogs_assert(ret == 0); - ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); - ogs_assert(ret == 0); - - /* Set the Origin-Host, Origin-Realm, and Result-Code AVPs */ - ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); - ogs_assert(ret == 0); - - /* Set the User-Name AVP */ - ret = fd_msg_avp_new(ogs_diam_user_name, 0, &avp); - ogs_assert(ret == 0); - val.os.data = (uint8_t *)user_name; - val.os.len = strlen(user_name); - ret = fd_msg_avp_setvalue(avp, &val); - ogs_assert(ret == 0); - ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); - ogs_assert(ret == 0); - /* Get Server-Assignment-Type AVP (Mandatory) */ ret = fd_msg_search_avp(qry, ogs_diam_cx_server_assignment_type, &avp); @@ -840,21 +812,49 @@ ogs_assert(ret == 0); } - /* Send the answer */ - ret = fd_msg_send(msg, NULL, NULL); + /* Set Vendor-Specific-Application-Id AVP */ + ret = ogs_diam_message_vendor_specific_appid_set( + ans, OGS_DIAM_SWX_APPLICATION_ID); + ogs_assert(ret == 0); + + /* Set the Auth-Session-State AVP */ + ret = fd_msg_avp_new(ogs_diam_auth_session_state, 0, &avp); + ogs_assert(ret == 0); + val.i32 = OGS_DIAM_AUTH_SESSION_NO_STATE_MAINTAINED; + ret = fd_msg_avp_setvalue(avp, &val); + ogs_assert(ret == 0); + ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); + ogs_assert(ret == 0); + + /* Set the Origin-Host, Origin-Realm, and Result-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); + ogs_assert(ret == 0); + + /* Set the User-Name AVP */ + ret = fd_msg_avp_new(ogs_diam_user_name, 0, &avp); + ogs_assert(ret == 0); + val.os.data = (uint8_t *)user_name; + val.os.len = strlen(user_name); + ret = fd_msg_avp_setvalue(avp, &val); + ogs_assert(ret == 0); + ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); + ogs_assert(ret == 0); + + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_debug("Server-Assignment-Answer"); - /* Add this value to the stats */ - ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); - ogs_diam_logger_self()->stats.nb_echoed++; - ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); + /* Add this value to the stats */ + ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); ogs_subscription_data_free(&subscription_data); ogs_free(user_name); - return 0; + return 0; out: /* Set Vendor-Specific-Application-Id AVP */ @@ -862,7 +862,7 @@ ans, OGS_DIAM_SWX_APPLICATION_ID); ogs_assert(ret == 0); - /* Set the Experimental-Result, Origin-Host and Origin-Realm AVPs */ + /* Set the Experimental-Result, Origin-Host and Origin-Realm AVPs */ ret = ogs_diam_message_experimental_rescode_set(ans, result_code); ogs_assert(ret == 0); @@ -875,7 +875,7 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - ret = fd_msg_send(msg, NULL, NULL); + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_subscription_data_free(&subscription_data); @@ -887,45 +887,45 @@ int hss_swx_init(void) { int ret; - struct disp_when data; + struct disp_when data; - /* Install objects definitions for this application */ - ret = ogs_diam_swx_init(); + /* Install objects definitions for this application */ + ret = ogs_diam_swx_init(); ogs_assert(ret == 0); - memset(&data, 0, sizeof(data)); - data.app = ogs_diam_swx_application; - - /* Fallback CB if command != unexpected message received */ - ret = fd_disp_register(hss_ogs_diam_swx_fb_cb, DISP_HOW_APPID, + memset(&data, 0, sizeof(data)); + data.app = ogs_diam_swx_application; + + /* Fallback CB if command != unexpected message received */ + ret = fd_disp_register(hss_ogs_diam_swx_fb_cb, DISP_HOW_APPID, &data, NULL, &hdl_swx_fb); ogs_assert(ret == 0); - - /* Specific handler for Multimedia-Auth-Request */ - data.command = ogs_diam_cx_cmd_mar; - ret = fd_disp_register(hss_ogs_diam_swx_mar_cb, DISP_HOW_CC, &data, NULL, + + /* Specific handler for Multimedia-Auth-Request */ + data.command = ogs_diam_cx_cmd_mar; + ret = fd_disp_register(hss_ogs_diam_swx_mar_cb, DISP_HOW_CC, &data, NULL, &hdl_swx_mar); ogs_assert(ret == 0); - /* Specific handler for Server-Assignment-Request */ - data.command = ogs_diam_cx_cmd_sar; - ret = fd_disp_register(hss_ogs_diam_swx_sar_cb, DISP_HOW_CC, &data, NULL, + /* Specific handler for Server-Assignment-Request */ + data.command = ogs_diam_cx_cmd_sar; + ret = fd_disp_register(hss_ogs_diam_swx_sar_cb, DISP_HOW_CC, &data, NULL, &hdl_swx_sar); ogs_assert(ret == 0); - /* Advertise the support for the application in the peer */ - ret = fd_disp_app_support(ogs_diam_swx_application, ogs_diam_vendor, 1, 0); + /* Advertise the support for the application in the peer */ + ret = fd_disp_app_support(ogs_diam_swx_application, ogs_diam_vendor, 1, 0); ogs_assert(ret == 0); - return OGS_OK; + return OGS_OK; } void hss_swx_final(void) { - if (hdl_swx_fb) - (void) fd_disp_unregister(&hdl_swx_fb, NULL); - if (hdl_swx_mar) - (void) fd_disp_unregister(&hdl_swx_mar, NULL); - if (hdl_swx_sar) - (void) fd_disp_unregister(&hdl_swx_sar, NULL); + if (hdl_swx_fb) + (void) fd_disp_unregister(&hdl_swx_fb, NULL); + if (hdl_swx_mar) + (void) fd_disp_unregister(&hdl_swx_mar, NULL); + if (hdl_swx_sar) + (void) fd_disp_unregister(&hdl_swx_sar, NULL); }
View file
open5gs_2.4.9.tar.xz/src/hss/meson.build -> open5gs_2.4.10.tar.xz/src/hss/meson.build
Changed
@@ -32,7 +32,6 @@ libhss = static_library('hss', sources : libhss_sources, dependencies : libapp_dep, - libcrypt_dep, libdbi_dep, libdiameter_s6a_dep, libdiameter_cx_dep, @@ -42,7 +41,6 @@ libhss_dep = declare_dependency( link_with : libhss, dependencies : libapp_dep, - libcrypt_dep, libdbi_dep, libdiameter_s6a_dep, libdiameter_cx_dep,
View file
open5gs_2.4.9.tar.xz/src/mme/emm-build.c -> open5gs_2.4.10.tar.xz/src/mme/emm-build.c
Changed
@@ -437,6 +437,26 @@ return nas_eps_security_encode(mme_ue, &message); } +ogs_pkbuf_t *emm_build_detach_request(mme_ue_t *mme_ue) +{ + ogs_nas_eps_message_t message; + + ogs_assert(mme_ue); + + memset(&message, 0, sizeof(message)); + message.h.security_header_type = + OGS_NAS_SECURITY_HEADER_INTEGRITY_PROTECTED_AND_CIPHERED; + message.h.protocol_discriminator = OGS_NAS_PROTOCOL_DISCRIMINATOR_EMM; + + message.emm.h.protocol_discriminator = OGS_NAS_PROTOCOL_DISCRIMINATOR_EMM; + message.emm.h.message_type = OGS_NAS_EPS_DETACH_REQUEST; + + message.emm.detach_request_to_ue.detach_type.value = + mme_ue->nas_eps.detach.value; + + return nas_eps_security_encode(mme_ue, &message); +} + ogs_pkbuf_t *emm_build_detach_accept(mme_ue_t *mme_ue) { ogs_nas_eps_message_t message;
View file
open5gs_2.4.9.tar.xz/src/mme/emm-build.h -> open5gs_2.4.10.tar.xz/src/mme/emm-build.h
Changed
@@ -37,6 +37,7 @@ ogs_pkbuf_t *emm_build_authentication_request(mme_ue_t *mme_ue); ogs_pkbuf_t *emm_build_authentication_reject(void); +ogs_pkbuf_t *emm_build_detach_request(mme_ue_t *mme_ue); ogs_pkbuf_t *emm_build_detach_accept(mme_ue_t *mme_ue); ogs_pkbuf_t *emm_build_tau_accept(mme_ue_t *mme_ue);
View file
open5gs_2.4.9.tar.xz/src/mme/emm-handler.c -> open5gs_2.4.10.tar.xz/src/mme/emm-handler.c
Changed
@@ -64,13 +64,17 @@ /* HashMME */ ogs_kdf_hash_mme(pkbuf->data, pkbuf->len, mme_ue->hash_mme); - /* Set EPS Attach Request Type */ + /* Set EPS Attach */ memcpy(&mme_ue->nas_eps.attach, eps_attach_type, sizeof(ogs_nas_eps_attach_type_t)); mme_ue->nas_eps.type = MME_EPS_TYPE_ATTACH_REQUEST; mme_ue->nas_eps.ksi = eps_attach_type->nas_key_set_identifier; - ogs_debug(" OGS_NAS_EPS TYPE%d KSI%d ATTACH0x%x", - mme_ue->nas_eps.type, mme_ue->nas_eps.ksi, mme_ue->nas_eps.data); + ogs_debug(" OGS_NAS_EPS TYPE%d KSI%d", + mme_ue->nas_eps.type, mme_ue->nas_eps.ksi); + ogs_debug(" ATTACH TSC%d KSI%d VALUE%d", + mme_ue->nas_eps.attach.tsc, + mme_ue->nas_eps.attach.nas_key_set_identifier, + mme_ue->nas_eps.attach.value); switch(mme_ue->nas_eps.attach.value){ case OGS_NAS_ATTACH_TYPE_EPS_ATTACH: ogs_debug(" Requested EPS_ATTACH_TYPE1, EPS_ATTACH"); @@ -117,6 +121,7 @@ mme_ue->enb_ostream_id = enb_ue->enb_ostream_id; memcpy(&mme_ue->tai, &enb_ue->saved.tai, sizeof(ogs_eps_tai_t)); memcpy(&mme_ue->e_cgi, &enb_ue->saved.e_cgi, sizeof(ogs_e_cgi_t)); + mme_ue->ue_location_timestamp = ogs_time_now(); /* Check TAI */ served_tai_index = mme_find_served_tai(&mme_ue->tai); @@ -373,12 +378,30 @@ detach_type = &detach_request->detach_type; - /* Set EPS Attach Type */ + /* Set EPS Detach */ memcpy(&mme_ue->nas_eps.detach, detach_type, sizeof(ogs_nas_detach_type_t)); - mme_ue->nas_eps.type = MME_EPS_TYPE_DETACH_REQUEST_FROM_UE; + + /* 1. MME initiated detach request to the UE. + * (nas_eps.type = MME_EPS_TYPE_DETACH_REQUEST_TO_UE) + * 2. If UE is IDLE, Paging sent to the UE + * 3. If UE is wake-up, UE will send Server Request. + * (nas_eps.type = MME_EPS_TYPE_SERVICE_REQUEST) + * + * So, we will lose the MME_EPS_TYPE_DETACH_REQUEST_TO_UE. + * + * We need more variable(nas_eps.detach_type) + * to keep Detach-Type whether UE-initiated or MME-initiaed. */ + mme_ue->nas_eps.type = mme_ue->nas_eps.detach_type = + MME_EPS_TYPE_DETACH_REQUEST_FROM_UE; + mme_ue->nas_eps.ksi = detach_type->nas_key_set_identifier; - ogs_debug(" OGS_NAS_EPS TYPE%d KSI%d DETACH0x%x", - mme_ue->nas_eps.type, mme_ue->nas_eps.ksi, mme_ue->nas_eps.data); + ogs_debug(" OGS_NAS_EPS TYPE%d KSI%d", + mme_ue->nas_eps.type, mme_ue->nas_eps.ksi); + ogs_debug(" DETACH TSC%d KSI%d SWITCH_OFF%d VALUE%d", + mme_ue->nas_eps.attach.tsc, + mme_ue->nas_eps.detach.nas_key_set_identifier, + mme_ue->nas_eps.detach.switch_off, + mme_ue->nas_eps.attach.value); switch (detach_request->detach_type.value) { /* 0 0 1 : EPS detach */ @@ -403,8 +426,6 @@ if (detach_request->detach_type.switch_off) ogs_debug(" Switch-Off"); - ogs_info(" IMSI%s", mme_ue->imsi_bcd); - return OGS_OK; } @@ -416,11 +437,15 @@ ogs_assert(mme_ue); - /* Set EPS Update Type */ + /* Set EPS Service */ mme_ue->nas_eps.type = MME_EPS_TYPE_SERVICE_REQUEST; mme_ue->nas_eps.ksi = ksi_and_sequence_number->ksi; ogs_debug(" OGS_NAS_EPS TYPE%d KSI%d", mme_ue->nas_eps.type, mme_ue->nas_eps.ksi); + ogs_debug(" SERVICE TSC%d KSI%d VALUE%d", + mme_ue->nas_eps.service.tsc, + mme_ue->nas_eps.service.nas_key_set_identifier, + mme_ue->nas_eps.service.value); /* * ATTACH_REQUEST @@ -471,15 +496,19 @@ /* HashMME */ ogs_kdf_hash_mme(pkbuf->data, pkbuf->len, mme_ue->hash_mme); - /* Set EPS Update Type */ + /* Set EPS Update */ memcpy(&mme_ue->nas_eps.update, eps_update_type, sizeof(ogs_nas_eps_update_type_t)); mme_ue->nas_eps.type = MME_EPS_TYPE_TAU_REQUEST; mme_ue->nas_eps.ksi = eps_update_type->nas_key_set_identifier; - ogs_debug(" OGS_NAS_EPS TYPE%d KSI%d UPDATE0x%x", - mme_ue->nas_eps.type, mme_ue->nas_eps.ksi, - mme_ue->nas_eps.data); - + ogs_debug(" OGS_NAS_EPS TYPE%d KSI%d", + mme_ue->nas_eps.type, mme_ue->nas_eps.ksi); + ogs_debug(" UPDATE TSC%d KSI%d Active-flag%d VALUE%d", + mme_ue->nas_eps.update.tsc, + mme_ue->nas_eps.update.nas_key_set_identifier, + mme_ue->nas_eps.update.active_flag, + mme_ue->nas_eps.update.value); + /* * ATTACH_REQUEST * TAU_REQUEST @@ -510,6 +539,7 @@ mme_ue->enb_ostream_id = enb_ue->enb_ostream_id; memcpy(&mme_ue->tai, &enb_ue->saved.tai, sizeof(ogs_eps_tai_t)); memcpy(&mme_ue->e_cgi, &enb_ue->saved.e_cgi, sizeof(ogs_e_cgi_t)); + mme_ue->ue_location_timestamp = ogs_time_now(); /* Check TAI */ served_tai_index = mme_find_served_tai(&mme_ue->tai); @@ -600,9 +630,8 @@ sizeof(ogs_nas_service_type_t)); mme_ue->nas_eps.type = MME_EPS_TYPE_EXTENDED_SERVICE_REQUEST; mme_ue->nas_eps.ksi = service_type->nas_key_set_identifier; - ogs_debug(" OGS_NAS_EPS TYPE%d KSI%d SERVICE0x%x", - mme_ue->nas_eps.type, mme_ue->nas_eps.ksi, - mme_ue->nas_eps.data); + ogs_debug(" OGS_NAS_EPS TYPE%d KSI%d", + mme_ue->nas_eps.type, mme_ue->nas_eps.ksi); /* * ATTACH_REQUEST @@ -628,6 +657,7 @@ mme_ue->enb_ostream_id = enb_ue->enb_ostream_id; memcpy(&mme_ue->tai, &enb_ue->saved.tai, sizeof(ogs_eps_tai_t)); memcpy(&mme_ue->e_cgi, &enb_ue->saved.e_cgi, sizeof(ogs_e_cgi_t)); + mme_ue->ue_location_timestamp = ogs_time_now(); /* Check TAI */ served_tai_index = mme_find_served_tai(&mme_ue->tai);
View file
open5gs_2.4.9.tar.xz/src/mme/emm-sm.c -> open5gs_2.4.10.tar.xz/src/mme/emm-sm.c
Changed
@@ -109,7 +109,7 @@ case OGS_FSM_EXIT_SIG: break; - case MME_EVT_EMM_MESSAGE: + case MME_EVENT_EMM_MESSAGE: message = e->nas_message; ogs_assert(message); @@ -530,8 +530,7 @@ } if (MME_P_TMSI_IS_AVAILABLE(mme_ue)) { - ogs_assert(OGS_OK == - sgsap_send_detach_indication(mme_ue)); + ogs_assert(OGS_OK == sgsap_send_detach_indication(mme_ue)); } else { mme_send_delete_session_or_detach(mme_ue); } @@ -539,6 +538,19 @@ OGS_FSM_TRAN(s, &emm_state_de_registered); break; + case OGS_NAS_EPS_DETACH_ACCEPT: + ogs_info("%s Detach accept", mme_ue->imsi_bcd); + + CLEAR_MME_UE_TIMER(mme_ue->t3422); + + rv = s1ap_send_ue_context_release_command(enb_ue, + S1AP_Cause_PR_nas, S1AP_CauseNas_detach, + S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0); + ogs_expect(rv == OGS_OK); + + OGS_FSM_TRAN(s, &emm_state_de_registered); + break; + case OGS_NAS_EPS_UPLINK_NAS_TRANSPORT: ogs_debug("Uplink NAS Transport"); ogs_debug(" IMSI%s", mme_ue->imsi_bcd); @@ -577,7 +589,7 @@ } break; - case MME_EVT_EMM_TIMER: + case MME_EVENT_EMM_TIMER: switch (e->timer_id) { case MME_TIMER_T3413: if (mme_ue->t3413.retry_count >= @@ -587,18 +599,8 @@ mme_ue->imsi_bcd); CLEAR_MME_UE_TIMER(mme_ue->t3413); - mme_send_after_paging(mme_ue, OGS_GTP2_CAUSE_UNABLE_TO_PAGE_UE); - - if (CS_CALL_SERVICE_INDICATOR(mme_ue) || - SMS_SERVICE_INDICATOR(mme_ue)) { - ogs_assert(OGS_OK == - sgsap_send_ue_unreachable(mme_ue, - SGSAP_SGS_CAUSE_UE_UNREACHABLE)); - - } - - CLEAR_SERVICE_INDICATOR(mme_ue); - + ogs_assert(MME_PAGING_ONGOING(mme_ue)); + mme_send_after_paging(mme_ue, true); } else { mme_ue->t3413.retry_count++; /* @@ -617,6 +619,7 @@ "Stop retransmission"); OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); } else { + ogs_assert(mme_ue->t3470.pkbuf); rv = nas_eps_send_identity_request(mme_ue); if (rv == OGS_OK) { mme_ue->t3470.retry_count++; @@ -627,6 +630,24 @@ } break; + case MME_TIMER_T3422: + if (mme_ue->t3422.retry_count >= + mme_timer_cfg(MME_TIMER_T3422)->max_count) { + ogs_warn("Retransmission of Detach Request failed. " + "Stop retransmission"); + OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); + } else { + ogs_assert(mme_ue->t3422.pkbuf); + rv = nas_eps_send_detach_request(mme_ue); + if (rv == OGS_OK) { + mme_ue->t3422.retry_count++; + } else { + ogs_error("nas_eps_send_detach_request() failed"); + OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); + } + } + break; + default: ogs_error("Unknown timer%s:%d", mme_timer_get_name(e->timer_id), e->timer_id); @@ -657,7 +678,7 @@ break; case OGS_FSM_EXIT_SIG: break; - case MME_EVT_EMM_MESSAGE: + case MME_EVENT_EMM_MESSAGE: message = e->nas_message; ogs_assert(message); @@ -772,7 +793,7 @@ break; } break; - case MME_EVT_EMM_TIMER: + case MME_EVENT_EMM_TIMER: switch (e->timer_id) { case MME_TIMER_T3460: if (mme_ue->t3460.retry_count >= @@ -828,7 +849,7 @@ break; case OGS_FSM_EXIT_SIG: break; - case MME_EVT_EMM_MESSAGE: + case MME_EVENT_EMM_MESSAGE: message = e->nas_message; ogs_assert(message); @@ -944,7 +965,7 @@ break; } break; - case MME_EVT_EMM_TIMER: + case MME_EVENT_EMM_TIMER: switch (e->timer_id) { case MME_TIMER_T3460: if (mme_ue->t3460.retry_count >= @@ -999,7 +1020,7 @@ break; case OGS_FSM_EXIT_SIG: break; - case MME_EVT_EMM_MESSAGE: + case MME_EVENT_EMM_MESSAGE: message = e->nas_message; ogs_assert(message); @@ -1137,7 +1158,7 @@ break; } break; - case MME_EVT_EMM_TIMER: + case MME_EVENT_EMM_TIMER: switch (e->timer_id) { case MME_TIMER_T3450: if (mme_ue->t3450.retry_count >= @@ -1202,7 +1223,7 @@ case OGS_FSM_EXIT_SIG: break; - case MME_EVT_EMM_MESSAGE: + case MME_EVENT_EMM_MESSAGE: message = e->nas_message; ogs_assert(message);
View file
open5gs_2.4.9.tar.xz/src/mme/esm-sm.c -> open5gs_2.4.10.tar.xz/src/mme/esm-sm.c
Changed
@@ -96,7 +96,7 @@ break; case OGS_FSM_EXIT_SIG: break; - case MME_EVT_ESM_MESSAGE: + case MME_EVENT_ESM_MESSAGE: message = e->nas_message; ogs_assert(message); @@ -221,7 +221,7 @@ break; } break; - case MME_EVT_ESM_TIMER: + case MME_EVENT_ESM_TIMER: switch (e->timer_id) { case MME_TIMER_T3489: if (bearer->t3489.retry_count >= @@ -281,7 +281,7 @@ break; case OGS_FSM_EXIT_SIG: break; - case MME_EVT_ESM_MESSAGE: + case MME_EVENT_ESM_MESSAGE: message = e->nas_message; ogs_assert(message); @@ -382,7 +382,7 @@ break; case OGS_FSM_EXIT_SIG: break; - case MME_EVT_ESM_MESSAGE: + case MME_EVENT_ESM_MESSAGE: message = e->nas_message; ogs_assert(message);
View file
open5gs_2.4.9.tar.xz/src/mme/meson.build -> open5gs_2.4.10.tar.xz/src/mme/meson.build
Changed
@@ -79,8 +79,7 @@ libmme = static_library('mme', sources : libmme_sources, - dependencies : libapp_dep, - libmetrics_dep, + dependencies : libmetrics_dep, libsctp_dep, libs1ap_dep, libnas_eps_dep, @@ -90,8 +89,7 @@ libmme_dep = declare_dependency( link_with : libmme, - dependencies : libapp_dep, - libmetrics_dep, + dependencies : libmetrics_dep, libsctp_dep, libs1ap_dep, libnas_eps_dep,
View file
open5gs_2.4.9.tar.xz/src/mme/mme-context.c -> open5gs_2.4.10.tar.xz/src/mme/mme-context.c
Changed
@@ -97,7 +97,7 @@ ogs_pool_init(&mme_csmap_pool, ogs_app()->pool.csmap); /* Allocate TWICE the pool to check if maximum number of eNBs is reached */ - ogs_pool_init(&mme_enb_pool, ogs_app()->max.gnb*2); + ogs_pool_init(&mme_enb_pool, ogs_app()->max.peer*2); ogs_pool_init(&mme_ue_pool, ogs_app()->max.ue); ogs_pool_init(&enb_ue_pool, ogs_app()->max.ue); @@ -1831,8 +1831,7 @@ memset(&e, 0, sizeof(e)); e.enb = enb; - ogs_fsm_create(&enb->sm, s1ap_state_initial, s1ap_state_final); - ogs_fsm_init(&enb->sm, &e); + ogs_fsm_init(&enb->sm, s1ap_state_initial, s1ap_state_final, &e); ogs_list_add(&self.enb_list, enb); mme_metrics_inst_global_inc(MME_METR_GLOB_GAUGE_ENB); @@ -1855,7 +1854,6 @@ memset(&e, 0, sizeof(e)); e.enb = enb; ogs_fsm_fini(&enb->sm, &e); - ogs_fsm_delete(&enb->sm); ogs_hash_set(self.enb_addr_hash, enb->sctp.addr, sizeof(ogs_sockaddr_t), NULL); @@ -1929,6 +1927,11 @@ return SOCK_STREAM; } +mme_enb_t *mme_enb_cycle(mme_enb_t *enb) +{ + return ogs_pool_cycle(&mme_enb_pool, enb); +} + /** enb_ue_context handling function */ enb_ue_t *enb_ue_add(mme_enb_t *enb, uint32_t enb_ue_s1ap_id) { @@ -1940,6 +1943,14 @@ ogs_assert(enb_ue); memset(enb_ue, 0, sizeof *enb_ue); + enb_ue->t_s1_holding = ogs_timer_add( + ogs_app()->timer_mgr, mme_timer_s1_holding_timer_expire, enb_ue); + if (!enb_ue->t_s1_holding) { + ogs_error("ogs_timer_add() failed"); + ogs_pool_free(&enb_ue_pool, enb_ue); + return NULL; + } + enb_ue->index = ogs_pool_index(&enb_ue_pool, enb_ue); ogs_assert(enb_ue->index > 0 && enb_ue->index <= ogs_app()->max.ue); @@ -1956,10 +1967,6 @@ enb_ue->enb_ostream_id = OGS_NEXT_ID(enb->ostream_id, 1, enb->max_num_of_ostreams-1); - enb_ue->t_s1_holding = ogs_timer_add( - ogs_app()->timer_mgr, mme_timer_s1_holding_timer_expire, enb_ue); - ogs_assert(enb_ue->t_s1_holding); - enb_ue->enb = enb; ogs_list_add(&enb->enb_ue_list, enb_ue); @@ -2044,7 +2051,11 @@ sgw_ue->t_s11_holding = ogs_timer_add( ogs_app()->timer_mgr, mme_timer_s11_holding_timer_expire, sgw_ue); - ogs_assert(sgw_ue->t_s11_holding); + if (!sgw_ue->t_s11_holding) { + ogs_error("ogs_timer_add() failed"); + ogs_pool_free(&sgw_ue_pool, sgw_ue); + return NULL; + } sgw_ue->sgw = sgw; @@ -2256,6 +2267,48 @@ ogs_assert(mme_ue); memset(mme_ue, 0, sizeof *mme_ue); + /* Add All Timers */ + mme_ue->t3413.timer = ogs_timer_add( + ogs_app()->timer_mgr, mme_timer_t3413_expire, mme_ue); + if (!mme_ue->t3413.timer) { + ogs_error("ogs_timer_add() failed"); + ogs_pool_free(&mme_ue_pool, mme_ue); + return NULL; + } + mme_ue->t3413.pkbuf = NULL; + mme_ue->t3422.timer = ogs_timer_add( + ogs_app()->timer_mgr, mme_timer_t3422_expire, mme_ue); + if (!mme_ue->t3422.timer) { + ogs_error("ogs_timer_add() failed"); + ogs_pool_free(&mme_ue_pool, mme_ue); + return NULL; + } + mme_ue->t3422.pkbuf = NULL; + mme_ue->t3450.timer = ogs_timer_add( + ogs_app()->timer_mgr, mme_timer_t3450_expire, mme_ue); + if (!mme_ue->t3450.timer) { + ogs_error("ogs_timer_add() failed"); + ogs_pool_free(&mme_ue_pool, mme_ue); + return NULL; + } + mme_ue->t3450.pkbuf = NULL; + mme_ue->t3460.timer = ogs_timer_add( + ogs_app()->timer_mgr, mme_timer_t3460_expire, mme_ue); + if (!mme_ue->t3460.timer) { + ogs_error("ogs_timer_add() failed"); + ogs_pool_free(&mme_ue_pool, mme_ue); + return NULL; + } + mme_ue->t3460.pkbuf = NULL; + mme_ue->t3470.timer = ogs_timer_add( + ogs_app()->timer_mgr, mme_timer_t3470_expire, mme_ue); + if (!mme_ue->t3470.timer) { + ogs_error("ogs_timer_add() failed"); + ogs_pool_free(&mme_ue_pool, mme_ue); + return NULL; + } + mme_ue->t3470.pkbuf = NULL; + mme_ebi_pool_init(mme_ue); ogs_list_init(&mme_ue->sess_list); @@ -2287,23 +2340,6 @@ mme_ue->csmap = NULL; mme_ue->vlr_ostream_id = 0; - /* Add All Timers */ - mme_ue->t3413.timer = ogs_timer_add( - ogs_app()->timer_mgr, mme_timer_t3413_expire, mme_ue); - mme_ue->t3413.pkbuf = NULL; - mme_ue->t3422.timer = ogs_timer_add( - ogs_app()->timer_mgr, mme_timer_t3422_expire, mme_ue); - mme_ue->t3422.pkbuf = NULL; - mme_ue->t3450.timer = ogs_timer_add( - ogs_app()->timer_mgr, mme_timer_t3450_expire, mme_ue); - mme_ue->t3450.pkbuf = NULL; - mme_ue->t3460.timer = ogs_timer_add( - ogs_app()->timer_mgr, mme_timer_t3460_expire, mme_ue); - mme_ue->t3460.pkbuf = NULL; - mme_ue->t3470.timer = ogs_timer_add( - ogs_app()->timer_mgr, mme_timer_t3470_expire, mme_ue); - mme_ue->t3470.pkbuf = NULL; - mme_ue_fsm_init(mme_ue); ogs_list_add(&self.mme_ue_list, mme_ue); @@ -2391,6 +2427,11 @@ } } +mme_ue_t *mme_ue_cycle(mme_ue_t *mme_ue) +{ + return ogs_pool_cycle(&mme_ue_pool, mme_ue); +} + void mme_ue_fsm_init(mme_ue_t *mme_ue) { mme_event_t e; @@ -2399,8 +2440,7 @@ memset(&e, 0, sizeof(e)); e.mme_ue = mme_ue; - ogs_fsm_create(&mme_ue->sm, emm_state_initial, emm_state_final); - ogs_fsm_init(&mme_ue->sm, &e); + ogs_fsm_init(&mme_ue->sm, emm_state_initial, emm_state_final, &e); } void mme_ue_fsm_fini(mme_ue_t *mme_ue) @@ -2412,7 +2452,6 @@ memset(&e, 0, sizeof(e)); e.mme_ue = mme_ue; ogs_fsm_fini(&mme_ue->sm, &e); - ogs_fsm_delete(&mme_ue->sm); } mme_ue_t *mme_ue_find_by_imsi_bcd(char *imsi_bcd) @@ -3004,8 +3043,7 @@ memset(&e, 0, sizeof(e)); e.bearer = bearer; - ogs_fsm_create(&bearer->sm, esm_state_initial, esm_state_final); - ogs_fsm_init(&bearer->sm, &e); + ogs_fsm_init(&bearer->sm, esm_state_initial, esm_state_final, &e); return bearer; } @@ -3021,7 +3059,6 @@ memset(&e, 0, sizeof(e)); e.bearer = bearer; ogs_fsm_fini(&bearer->sm, &e); - ogs_fsm_delete(&bearer->sm); CLEAR_BEARER_ALL_TIMERS(bearer); ogs_timer_delete(bearer->t3489.timer);
View file
open5gs_2.4.9.tar.xz/src/mme/mme-context.h -> open5gs_2.4.10.tar.xz/src/mme/mme-context.h
Changed
@@ -312,13 +312,22 @@ #define MME_EPS_TYPE_DETACH_REQUEST_TO_UE 6 uint8_t type; uint8_t ksi; - union { - ogs_nas_eps_attach_type_t attach; - ogs_nas_eps_update_type_t update; - ogs_nas_service_type_t service; - ogs_nas_detach_type_t detach; - uint8_t data; - }; + ogs_nas_eps_attach_type_t attach; + ogs_nas_eps_update_type_t update; + ogs_nas_service_type_t service; + ogs_nas_detach_type_t detach; + + /* 1. MME initiated detach request to the UE. + * (nas_eps.type = MME_EPS_TYPE_DETACH_REQUEST_TO_UE) + * 2. If UE is IDLE, Paging sent to the UE + * 3. If UE is wake-up, UE will send Server Request. + * (nas_eps.type = MME_EPS_TYPE_SERVICE_REQUEST) + * + * So, we will lose the MME_EPS_TYPE_DETACH_REQUEST_TO_UE. + * + * We need more variable(nas_eps.detach_type) + * to keep Detach-Type whether UE-initiated or MME-initiaed. */ + uint8_t detach_type; } nas_eps; /* UE identity */ @@ -359,6 +368,7 @@ uint16_t enb_ostream_id; ogs_eps_tai_t tai; ogs_e_cgi_t e_cgi; + ogs_time_t ue_location_timestamp; ogs_plmn_id_t last_visited_plmn_id; #define SECURITY_CONTEXT_IS_VALID(__mME) \ @@ -451,6 +461,34 @@ (((__mME)->enb_ue == NULL) || (enb_ue_cycle((__mME)->enb_ue) == NULL))) enb_ue_t *enb_ue; /* S1 UE context */ + struct { +#define MME_CLEAR_PAGING_INFO(__mME) \ + do { \ + ogs_assert(__mME); \ + (__mME)->paging.type = 0; \ + } while(0) + +#define MME_STORE_PAGING_INFO(__mME, __tYPE, __dATA) \ + do { \ + ogs_assert(__mME); \ + ogs_assert(__tYPE); \ + (__mME)->paging.type = __tYPE; \ + (__mME)->paging.data = __dATA; \ + } while(0) + +#define MME_PAGING_ONGOING(__mME) ((__mME) && ((__mME)->paging.type)) + +#define MME_PAGING_TYPE_DOWNLINK_DATA_NOTIFICATION 1 +#define MME_PAGING_TYPE_CREATE_BEARER 2 +#define MME_PAGING_TYPE_UPDATE_BEARER 3 +#define MME_PAGING_TYPE_DELETE_BEARER 4 +#define MME_PAGING_TYPE_CS_CALL_SERVICE 5 +#define MME_PAGING_TYPE_SMS_SERVICE 6 +#define MME_PAGING_TYPE_DETACH_TO_UE 7 + int type; + void *data; + } paging; + /* SGW UE context */ sgw_ue_t *sgw_ue; @@ -684,9 +722,10 @@ /* Related Context */ mme_ue_t *mme_ue; mme_sess_t *sess; + struct { ogs_gtp_xact_t *xact; - } create, update, delete, notify, current; + } create, update, delete, notify; } mme_bearer_t; void mme_context_init(void); @@ -726,6 +765,7 @@ mme_enb_t *mme_enb_find_by_enb_id(uint32_t enb_id); int mme_enb_set_enb_id(mme_enb_t *enb, uint32_t enb_id); int mme_enb_sock_type(ogs_sock_t *sock); +mme_enb_t *mme_enb_cycle(mme_enb_t *enb); enb_ue_t *enb_ue_add(mme_enb_t *enb, uint32_t enb_ue_s1ap_id); void enb_ue_remove(enb_ue_t *enb_ue); @@ -756,6 +796,7 @@ void mme_ue_hash_remove(mme_ue_t *mme_ue); void mme_ue_remove(mme_ue_t *mme_ue); void mme_ue_remove_all(void); +mme_ue_t *mme_ue_cycle(mme_ue_t *mme_ue); void mme_ue_fsm_init(mme_ue_t *mme_ue); void mme_ue_fsm_fini(mme_ue_t *mme_ue);
View file
open5gs_2.4.9.tar.xz/src/mme/mme-event.c -> open5gs_2.4.10.tar.xz/src/mme/mme-event.c
Changed
@@ -60,42 +60,42 @@ case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case MME_EVT_S1AP_MESSAGE: - return "MME_EVT_S1AP_MESSAGE"; - case MME_EVT_S1AP_TIMER: - return "MME_EVT_S1AP_TIMER"; - case MME_EVT_S1AP_LO_ACCEPT: - return "MME_EVT_S1AP_LO_ACCEPT"; - case MME_EVT_S1AP_LO_SCTP_COMM_UP: - return "MME_EVT_S1AP_LO_SCTP_COMM_UP"; - case MME_EVT_S1AP_LO_CONNREFUSED: - return "MME_EVT_S1AP_LO_CONNREFUSED"; + case MME_EVENT_S1AP_MESSAGE: + return "MME_EVENT_S1AP_MESSAGE"; + case MME_EVENT_S1AP_TIMER: + return "MME_EVENT_S1AP_TIMER"; + case MME_EVENT_S1AP_LO_ACCEPT: + return "MME_EVENT_S1AP_LO_ACCEPT"; + case MME_EVENT_S1AP_LO_SCTP_COMM_UP: + return "MME_EVENT_S1AP_LO_SCTP_COMM_UP"; + case MME_EVENT_S1AP_LO_CONNREFUSED: + return "MME_EVENT_S1AP_LO_CONNREFUSED"; - case MME_EVT_EMM_MESSAGE: - return "MME_EVT_EMM_MESSAGE"; - case MME_EVT_EMM_TIMER: - return "MME_EVT_EMM_TIMER"; - case MME_EVT_ESM_MESSAGE: - return "MME_EVT_ESM_MESSAGE"; - case MME_EVT_ESM_TIMER: - return "MME_EVT_ESM_TIMER"; - case MME_EVT_S11_MESSAGE: - return "MME_EVT_S11_MESSAGE"; - case MME_EVT_S11_TIMER: - return "MME_EVT_S11_TIMER"; - case MME_EVT_S6A_MESSAGE: - return "MME_EVT_S6A_MESSAGE"; - case MME_EVT_S6A_TIMER: - return "MME_EVT_S6A_TIMER"; + case MME_EVENT_EMM_MESSAGE: + return "MME_EVENT_EMM_MESSAGE"; + case MME_EVENT_EMM_TIMER: + return "MME_EVENT_EMM_TIMER"; + case MME_EVENT_ESM_MESSAGE: + return "MME_EVENT_ESM_MESSAGE"; + case MME_EVENT_ESM_TIMER: + return "MME_EVENT_ESM_TIMER"; + case MME_EVENT_S11_MESSAGE: + return "MME_EVENT_S11_MESSAGE"; + case MME_EVENT_S11_TIMER: + return "MME_EVENT_S11_TIMER"; + case MME_EVENT_S6A_MESSAGE: + return "MME_EVENT_S6A_MESSAGE"; + case MME_EVENT_S6A_TIMER: + return "MME_EVENT_S6A_TIMER"; - case MME_EVT_SGSAP_MESSAGE: - return "MME_EVT_SGSAP_MESSAGE"; - case MME_EVT_SGSAP_TIMER: - return "MME_EVT_SGSAP_TIMER"; - case MME_EVT_SGSAP_LO_SCTP_COMM_UP: - return "MME_EVT_SGSAP_LO_SCTP_COMM_UP"; - case MME_EVT_SGSAP_LO_CONNREFUSED: - return "MME_EVT_SGSAP_LO_CONNREFUSED"; + case MME_EVENT_SGSAP_MESSAGE: + return "MME_EVENT_SGSAP_MESSAGE"; + case MME_EVENT_SGSAP_TIMER: + return "MME_EVENT_SGSAP_TIMER"; + case MME_EVENT_SGSAP_LO_SCTP_COMM_UP: + return "MME_EVENT_SGSAP_LO_SCTP_COMM_UP"; + case MME_EVENT_SGSAP_LO_CONNREFUSED: + return "MME_EVENT_SGSAP_LO_CONNREFUSED"; default: break;
View file
open5gs_2.4.9.tar.xz/src/mme/mme-event.h -> open5gs_2.4.10.tar.xz/src/mme/mme-event.h
Changed
@@ -20,7 +20,7 @@ #ifndef MME_EVENT_H #define MME_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { @@ -28,29 +28,29 @@ /* forward declaration */ typedef enum { - MME_EVT_BASE = OGS_FSM_USER_SIG, + MME_EVENT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, - MME_EVT_S1AP_MESSAGE, - MME_EVT_S1AP_TIMER, - MME_EVT_S1AP_LO_ACCEPT, - MME_EVT_S1AP_LO_SCTP_COMM_UP, - MME_EVT_S1AP_LO_CONNREFUSED, - - MME_EVT_EMM_MESSAGE, - MME_EVT_EMM_TIMER, - MME_EVT_ESM_MESSAGE, - MME_EVT_ESM_TIMER, - MME_EVT_S11_MESSAGE, - MME_EVT_S11_TIMER, - MME_EVT_S6A_MESSAGE, - MME_EVT_S6A_TIMER, - - MME_EVT_SGSAP_MESSAGE, - MME_EVT_SGSAP_TIMER, - MME_EVT_SGSAP_LO_SCTP_COMM_UP, - MME_EVT_SGSAP_LO_CONNREFUSED, + MME_EVENT_S1AP_MESSAGE, + MME_EVENT_S1AP_TIMER, + MME_EVENT_S1AP_LO_ACCEPT, + MME_EVENT_S1AP_LO_SCTP_COMM_UP, + MME_EVENT_S1AP_LO_CONNREFUSED, + + MME_EVENT_EMM_MESSAGE, + MME_EVENT_EMM_TIMER, + MME_EVENT_ESM_MESSAGE, + MME_EVENT_ESM_TIMER, + MME_EVENT_S11_MESSAGE, + MME_EVENT_S11_TIMER, + MME_EVENT_S6A_MESSAGE, + MME_EVENT_S6A_TIMER, + + MME_EVENT_SGSAP_MESSAGE, + MME_EVENT_SGSAP_TIMER, + MME_EVENT_SGSAP_LO_SCTP_COMM_UP, + MME_EVENT_SGSAP_LO_CONNREFUSED, - MME_EVT_TOP, + MAX_NUM_OF_MME_EVENT, } mme_event_e; @@ -69,9 +69,10 @@ typedef struct mme_event_s { int id; - ogs_pkbuf_t *pkbuf; int timer_id; + ogs_pkbuf_t *pkbuf; + ogs_sock_t *sock; ogs_sockaddr_t *addr;
View file
open5gs_2.4.9.tar.xz/src/mme/mme-fd-path.c -> open5gs_2.4.10.tar.xz/src/mme/mme-fd-path.c
Changed
@@ -20,6 +20,12 @@ #include "mme-event.h" #include "mme-fd-path.h" +/* handler for Cancel-Location-Request cb */ +static struct disp_hdl *hdl_s6a_clr = NULL; + +/* handler for Insert-Subscriber-Data-Request cb */ +static struct disp_hdl *hdl_s6a_idr = NULL; + static struct session_handler *mme_s6a_reg = NULL; struct sess_state { @@ -373,7 +379,7 @@ out: if (!error) { int rv; - e = mme_event_new(MME_EVT_S6A_MESSAGE); + e = mme_event_new(MME_EVENT_S6A_MESSAGE); ogs_assert(e); e->mme_ue = mme_ue; e->s6a_message = s6a_message; @@ -793,7 +799,7 @@ ogs_assert(ret == 0); mme_ue->network_access_mode = hdr->avp_value->i32; } else { - mme_ue->network_access_mode = 0; + mme_ue->network_access_mode = 0; ogs_warn("no subscribed Network-Access-Mode, defaulting to PACKET_AND_CIRCUIT (0)"); } @@ -1341,7 +1347,7 @@ if (!error) { int rv; - e = mme_event_new(MME_EVT_S6A_MESSAGE); + e = mme_event_new(MME_EVENT_S6A_MESSAGE); ogs_assert(e); e->mme_ue = mme_ue; e->s6a_message = s6a_message; @@ -1365,7 +1371,8 @@ ((ts.tv_nsec - sess_data->ts.tv_nsec) / 1000); if (ogs_diam_logger_self()->stats.nb_recv) { /* Ponderate in the avg */ - ogs_diam_logger_self()->stats.avg = (ogs_diam_logger_self()->stats.avg * + ogs_diam_logger_self()->stats.avg = + (ogs_diam_logger_self()->stats.avg * ogs_diam_logger_self()->stats.nb_recv + dur) / (ogs_diam_logger_self()->stats.nb_recv + 1); /* Min, max */ @@ -1403,39 +1410,423 @@ return; } +/* Callback for incoming Cancel-Location-Request messages */ +static int mme_ogs_diam_s6a_clr_cb( struct msg **msg, struct avp *avp, + struct session *session, void *opaque, enum disp_action *act) +{ + int ret, rv; + + mme_event_t *e = NULL; + mme_ue_t *mme_ue = NULL; + + struct msg *ans, *qry; + ogs_diam_s6a_clr_message_t *clr_message = NULL; + + struct avp_hdr *hdr; + union avp_value val; + + char imsi_bcdOGS_MAX_IMSI_BCD_LEN+1; + + uint32_t result_code = 0; + + ogs_assert(msg); + + ogs_diam_s6a_message_t *s6a_message = NULL; + + ogs_debug("Cancel-Location-Request"); + + s6a_message = ogs_calloc(1, sizeof(ogs_diam_s6a_message_t)); + ogs_assert(s6a_message); + s6a_message->cmd_code = OGS_DIAM_S6A_CMD_CODE_CANCEL_LOCATION; + clr_message = &s6a_message->clr_message; + ogs_assert(clr_message); + + /* Create answer header */ + qry = *msg; + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + ogs_assert(ret == 0); + ans = *msg; + + ret = fd_msg_search_avp(qry, ogs_diam_user_name, &avp); + ogs_assert(ret == 0); + ret = fd_msg_avp_hdr(avp, &hdr); + ogs_assert(ret == 0); + + ogs_cpystrn(imsi_bcd, (char*)hdr->avp_value->os.data, + ogs_min(hdr->avp_value->os.len, OGS_MAX_IMSI_BCD_LEN)+1); + + mme_ue = mme_ue_find_by_imsi_bcd(imsi_bcd); + + if (!mme_ue) { + ogs_error("Cancel Location for Unknown IMSI%s", imsi_bcd); + result_code = OGS_DIAM_S6A_ERROR_USER_UNKNOWN; + goto out; + } + + ret = fd_msg_search_avp(qry, ogs_diam_s6a_cancellation_type, &avp); + ogs_assert(ret == 0); + ret = fd_msg_avp_hdr(avp, &hdr); + ogs_assert(ret == 0); + + /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); + ogs_assert(ret == 0); + + /* Set the Auth-Session-State AVP */ + ret = fd_msg_avp_new(ogs_diam_auth_session_state, 0, &avp); + ogs_assert(ret == 0); + val.i32 = OGS_DIAM_AUTH_SESSION_NO_STATE_MAINTAINED; + ret = fd_msg_avp_setvalue(avp, &val); + ogs_assert(ret == 0); + ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); + ogs_assert(ret == 0); + + ret = fd_msg_search_avp(qry, ogs_diam_s6a_clr_flags, &avp); + ogs_assert(ret == 0); + if (avp) { + ret = fd_msg_avp_hdr(avp, &hdr); + ogs_assert(ret == 0); + clr_message->clr_flags = hdr->avp_value->i32; + } + + /* Set Vendor-Specific-Application-Id AVP */ + ret = ogs_diam_message_vendor_specific_appid_set( + ans, OGS_DIAM_S6A_APPLICATION_ID); + ogs_assert(ret == 0); + + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); + ogs_assert(ret == 0); + + ogs_debug("Cancel-Location-Answer"); + + /* Add this value to the stats */ + ogs_assert( pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert( pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); + + e = mme_event_new(MME_EVENT_S6A_MESSAGE); + ogs_assert(e); + e->mme_ue = mme_ue; + e->s6a_message = s6a_message; + rv = ogs_queue_push(ogs_app()->queue, e); + if (rv != OGS_OK) { + ogs_error("ogs_queue_push() failed:%d", (int)rv); + ogs_free(s6a_message); + mme_event_free(e); + } else { + ogs_pollset_notify(ogs_app()->pollset); + } + + return 0; + +out: + ret = ogs_diam_message_experimental_rescode_set(ans, result_code); + ogs_assert(ret == 0); + + /* Set the Auth-Session-State AVP */ + ret = fd_msg_avp_new(ogs_diam_auth_session_state, 0, &avp); + ogs_assert(ret == 0); + val.i32 = OGS_DIAM_AUTH_SESSION_NO_STATE_MAINTAINED; + ret = fd_msg_avp_setvalue(avp, &val); + ogs_assert(ret == 0); + ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); + ogs_assert(ret == 0); + + /* Set Vendor-Specific-Application-Id AVP */ + ret = ogs_diam_message_vendor_specific_appid_set( + ans, OGS_DIAM_S6A_APPLICATION_ID); + ogs_assert(ret == 0); + + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); + ogs_assert(ret == 0); + + return 0; +} + +/* Callback for incoming Insert-Subscriber-Data-Request messages + * 29.272 5.2.2.1.2 */ +static int mme_ogs_diam_s6a_idr_cb( struct msg **msg, struct avp *avp, + struct session *session, void *opaque, enum disp_action *act) +{ + int ret; + + mme_ue_t *mme_ue = NULL; + + struct msg *ans, *qry; + ogs_diam_s6a_idr_message_t *idr_message = NULL; + + struct avp_hdr *hdr; + union avp_value val; + + char imsi_bcdOGS_MAX_IMSI_BCD_LEN+1; + + uint32_t result_code = 0; + + ogs_assert(msg); + + ogs_diam_s6a_message_t *s6a_message = NULL; + + ogs_debug("Insert-Subscriber-Data-Request"); + + s6a_message = ogs_calloc(1, sizeof(ogs_diam_s6a_message_t)); + ogs_assert(s6a_message); + s6a_message->cmd_code = OGS_DIAM_S6A_CMD_CODE_INSERT_SUBSCRIBER_DATA; + idr_message = &s6a_message->idr_message; + ogs_assert(idr_message); + + /* Create answer header */ + qry = *msg; + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + ogs_assert(ret == 0); + ans = *msg; + + ret = fd_msg_search_avp(qry, ogs_diam_user_name, &avp); + ogs_assert(ret == 0); + ret = fd_msg_avp_hdr(avp, &hdr); + ogs_assert(ret == 0); + + ogs_cpystrn(imsi_bcd, (char*)hdr->avp_value->os.data, + ogs_min(hdr->avp_value->os.len, OGS_MAX_IMSI_BCD_LEN)+1); + + mme_ue = mme_ue_find_by_imsi_bcd(imsi_bcd); + + if (!mme_ue) { + ogs_error("Insert Subscriber Data for Unknown IMSI%s", imsi_bcd); + result_code = OGS_DIAM_S6A_ERROR_USER_UNKNOWN; + goto out; + } + + /* AVP: 'Subscription-Data'(1400) + * The Subscription-Data AVP contains the information related to the user + * profile relevant for EPS and GERAN/UTRAN. + * Reference: 3GPP TS 29.272-f70 + */ + ret = fd_msg_search_avp(*msg, ogs_diam_s6a_subscription_data, &avp); + ogs_assert(ret == 0); + if (avp) { + ret = fd_msg_avp_hdr(avp, &hdr); + ogs_assert(ret == 0); + if (hdr->avp_value->os.len) { + ogs_debug("WIP: Process New Subscription Data"); + } else { + ogs_debug("No Sub Data, ok to check IDR Flags"); + } + } + + ret = fd_msg_search_avp(qry, ogs_diam_s6a_idr_flags, &avp); + ogs_assert(ret == 0); + if (avp) { + ret = fd_msg_avp_hdr(avp, &hdr); + ogs_assert(ret == 0); + idr_message->idr_flags = hdr->avp_value->i32; + } else { + ogs_error("Insert Subscriber Data does not contain any IDR Flags " + "for IMSI%s", imsi_bcd); + /* Set the Origin-Host, Origin-Realm, and Result-Code AVPs */ + ret = fd_msg_rescode_set(ans, + (char*)"DIAMETER_UNABLE_TO_COMPLY", NULL, NULL, 1); + ogs_assert(ret == 0); + goto outnoexp; + } + + if (idr_message->idr_flags & OGS_DIAM_S6A_IDR_FLAGS_EPS_LOCATION_INFO) { + char buf8; + + uint8_t ida_ecgi8; + uint8_t ida_tai5; + ogs_time_t ida_age; + + ogs_nas_plmn_id_t ida_plmn_buf; + char ida_cell_id_hex9; + char ida_tac_hex5; + + uint32_t ida_cell_id = mme_ue->e_cgi.cell_id; + uint16_t ida_tac = mme_ue->tai.tac; + + struct avp *avp_mme_location_information; + struct avp *avp_e_utran_cell_global_identity; + struct avp *avp_tracking_area_identity; + struct avp *avp_age_of_location_information; + + ogs_snprintf(ida_cell_id_hex, sizeof(ida_cell_id_hex), + "%08x", ida_cell_id); + memcpy(ida_ecgi, + ogs_nas_from_plmn_id(&ida_plmn_buf, &mme_ue->e_cgi.plmn_id), 3); + memcpy(ida_ecgi + 3, + OGS_HEX(ida_cell_id_hex, sizeof(ida_cell_id_hex), buf), 5); + + ogs_snprintf(ida_tac_hex, sizeof(ida_tac_hex), "%04x", ida_tac); + memcpy(ida_tai, + ogs_nas_from_plmn_id(&ida_plmn_buf, &mme_ue->tai.plmn_id), 3); + memcpy(ida_tai + 3, OGS_HEX(ida_tac_hex, sizeof(ida_tac_hex), buf), 2); + + ida_age = + (ogs_time_now() - mme_ue->ue_location_timestamp) / 1000000 / 60; + + /* Set the EPS-Location-Information AVP */ + ret = fd_msg_avp_new(ogs_diam_s6a_eps_location_information, 0, &avp); + ogs_assert(ret == 0); + ret = fd_msg_avp_new(ogs_diam_s6a_mme_location_information, + 0, &avp_mme_location_information); + ogs_assert(ret == 0); + + ret = fd_msg_avp_new(ogs_diam_s6a_e_utran_cell_global_identity, + 0, &avp_e_utran_cell_global_identity); + ogs_assert(ret == 0); + val.os.data = ida_ecgi; + val.os.len = 7; + ret = fd_msg_avp_setvalue(avp_e_utran_cell_global_identity, &val); + ogs_assert(ret == 0); + ret = fd_msg_avp_add(avp_mme_location_information, + MSG_BRW_LAST_CHILD, avp_e_utran_cell_global_identity); + ogs_assert(ret == 0); + + ret = fd_msg_avp_new(ogs_diam_s6a_tracking_area_identity, + 0, &avp_tracking_area_identity); + ogs_assert(ret == 0); + val.os.data = ida_tai; + val.os.len = 5; + ret = fd_msg_avp_setvalue(avp_tracking_area_identity, &val); + ogs_assert(ret == 0); + ret = fd_msg_avp_add(avp_mme_location_information, + MSG_BRW_LAST_CHILD, avp_tracking_area_identity); + ogs_assert(ret == 0); + + ret = fd_msg_avp_new(ogs_diam_s6a_age_of_location_information, + 0, &avp_age_of_location_information); + ogs_assert(ret == 0); + val.i32 = ida_age; + ret = fd_msg_avp_setvalue(avp_age_of_location_information, &val); + ogs_assert(ret == 0); + ret = fd_msg_avp_add(avp_mme_location_information, + MSG_BRW_LAST_CHILD, avp_age_of_location_information); + ogs_assert(ret == 0); + + ret = fd_msg_avp_add(avp, + MSG_BRW_LAST_CHILD, avp_mme_location_information); + ogs_assert(ret == 0); + + ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); + ogs_assert(ret == 0); + } else { + ogs_error("Insert Subscriber Data " + "with unsupported IDR Flags for IMSI%s", imsi_bcd); + /* Set the Origin-Host, Origin-Realm, and Result-Code AVPs */ + ret = fd_msg_rescode_set( + ans, (char*)"DIAMETER_UNABLE_TO_COMPLY", NULL, NULL, 1); + ogs_assert(ret == 0); + goto outnoexp; + } + + /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); + ogs_assert(ret == 0); + + /* Set the Auth-Session-State AVP */ + ret = fd_msg_avp_new(ogs_diam_auth_session_state, 0, &avp); + ogs_assert(ret == 0); + val.i32 = OGS_DIAM_AUTH_SESSION_NO_STATE_MAINTAINED; + ret = fd_msg_avp_setvalue(avp, &val); + ogs_assert(ret == 0); + ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); + ogs_assert(ret == 0); + + /* Set Vendor-Specific-Application-Id AVP */ + ret = ogs_diam_message_vendor_specific_appid_set( + ans, OGS_DIAM_S6A_APPLICATION_ID); + ogs_assert(ret == 0); + + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); + ogs_assert(ret == 0); + + ogs_debug("Insert-Subscriber-Data-Answer"); + + /* Add this value to the stats */ + ogs_assert( pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert( pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); + + return 0; + +out: + ret = ogs_diam_message_experimental_rescode_set(ans, result_code); + ogs_assert(ret == 0); +outnoexp: + /* Set the Auth-Session-State AVP */ + ret = fd_msg_avp_new(ogs_diam_auth_session_state, 0, &avp); + ogs_assert(ret == 0); + val.i32 = OGS_DIAM_AUTH_SESSION_NO_STATE_MAINTAINED; + ret = fd_msg_avp_setvalue(avp, &val); + ogs_assert(ret == 0); + ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); + ogs_assert(ret == 0); + + /* Set Vendor-Specific-Application-Id AVP */ + ret = ogs_diam_message_vendor_specific_appid_set( + ans, OGS_DIAM_S6A_APPLICATION_ID); + ogs_assert(ret == 0); + + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); + ogs_assert(ret == 0); + + return 0; +} int mme_fd_init(void) { int ret; + struct disp_when data; ret = ogs_diam_init(FD_MODE_CLIENT, mme_self()->diam_conf_path, mme_self()->diam_config); ogs_assert(ret == 0); - /* Install objects definitions for this application */ - ret = ogs_diam_s6a_init(); + /* Install objects definitions for this application */ + ret = ogs_diam_s6a_init(); ogs_assert(ret == OGS_OK); /* Create handler for sessions */ - ret = fd_sess_handler_create(&mme_s6a_reg, &state_cleanup, NULL, NULL); + ret = fd_sess_handler_create(&mme_s6a_reg, &state_cleanup, NULL, NULL); ogs_assert(ret == 0); - /* Advertise the support for the application in the peer */ - ret = fd_disp_app_support(ogs_diam_s6a_application, ogs_diam_vendor, 1, 0); + /* Specific handler for Cancel-Location-Request */ + data.command = ogs_diam_s6a_cmd_clr; + ret = fd_disp_register(mme_ogs_diam_s6a_clr_cb, DISP_HOW_CC, &data, NULL, + &hdl_s6a_clr); + ogs_assert(ret == 0); + + /* Specific handler for Insert-Subscriber-Data-Request */ + data.command = ogs_diam_s6a_cmd_idr; + ret = fd_disp_register(mme_ogs_diam_s6a_idr_cb, DISP_HOW_CC, &data, NULL, + &hdl_s6a_idr); + ogs_assert(ret == 0); + + /* Advertise the support for the application in the peer */ + ret = fd_disp_app_support(ogs_diam_s6a_application, ogs_diam_vendor, 1, 0); ogs_assert(ret == 0); ret = ogs_diam_start(); ogs_assert(ret == 0); - - return 0; + + return 0; } void mme_fd_final(void) { int ret; - ret = fd_sess_handler_destroy(&mme_s6a_reg, NULL); + ret = fd_sess_handler_destroy(&mme_s6a_reg, NULL); ogs_assert(ret == OGS_OK); + if (hdl_s6a_clr) + (void) fd_disp_unregister(&hdl_s6a_clr, NULL); + + if (hdl_s6a_idr) + (void) fd_disp_unregister(&hdl_s6a_idr, NULL); + ogs_diam_final(); }
View file
open5gs_2.4.9.tar.xz/src/mme/mme-gtp-path.c -> open5gs_2.4.10.tar.xz/src/mme/mme-gtp-path.c
Changed
@@ -61,7 +61,7 @@ } ogs_assert(sgw); - e = mme_event_new(MME_EVT_S11_MESSAGE); + e = mme_event_new(MME_EVENT_S11_MESSAGE); ogs_assert(e); e->gnode = (ogs_gtp_node_t *)sgw; e->pkbuf = pkbuf; @@ -360,7 +360,10 @@ sgw_ue = mme_ue->sgw_ue; ogs_assert(sgw_ue); xact = ogs_gtp_xact_cycle(bearer->create.xact); - ogs_assert(xact); + if (!xact) { + ogs_warn("GTP transaction(CREATE) has already been removed"); + return OGS_OK; + } memset(&h, 0, sizeof(ogs_gtp2_header_t)); h.type = OGS_GTP2_CREATE_BEARER_RESPONSE_TYPE; @@ -396,7 +399,10 @@ sgw_ue = mme_ue->sgw_ue; ogs_assert(sgw_ue); xact = ogs_gtp_xact_cycle(bearer->update.xact); - ogs_assert(xact); + if (!xact) { + ogs_warn("GTP transaction(UPDATE) has already been removed"); + return OGS_OK; + } memset(&h, 0, sizeof(ogs_gtp2_header_t)); h.type = OGS_GTP2_UPDATE_BEARER_RESPONSE_TYPE; @@ -432,7 +438,10 @@ sgw_ue = mme_ue->sgw_ue; ogs_assert(sgw_ue); xact = ogs_gtp_xact_cycle(bearer->delete.xact); - ogs_assert(xact); + if (!xact) { + ogs_warn("GTP transaction(DELETE) has already been removed"); + return OGS_OK; + } memset(&h, 0, sizeof(ogs_gtp2_header_t)); h.type = OGS_GTP2_DELETE_BEARER_RESPONSE_TYPE; @@ -544,7 +553,10 @@ ogs_assert(bearer); xact = ogs_gtp_xact_cycle(bearer->notify.xact); - ogs_assert(xact); + if (!xact) { + ogs_warn("GTP transaction(NOTIFY) has already been removed"); + return OGS_OK; + } mme_ue = bearer->mme_ue; ogs_assert(mme_ue); sgw_ue = mme_ue->sgw_ue;
View file
open5gs_2.4.9.tar.xz/src/mme/mme-init.c -> open5gs_2.4.10.tar.xz/src/mme/mme-init.c
Changed
@@ -114,8 +114,7 @@ ogs_fsm_t mme_sm; int rv; - ogs_fsm_create(&mme_sm, mme_state_initial, mme_state_final); - ogs_fsm_init(&mme_sm, 0); + ogs_fsm_init(&mme_sm, mme_state_initial, mme_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -154,5 +153,4 @@ done: ogs_fsm_fini(&mme_sm, 0); - ogs_fsm_delete(&mme_sm); }
View file
open5gs_2.4.9.tar.xz/src/mme/mme-path.c -> open5gs_2.4.10.tar.xz/src/mme/mme-path.c
Changed
@@ -19,19 +19,32 @@ #include "s1ap-path.h" #include "nas-path.h" +#include "sgsap-path.h" #include "mme-gtp-path.h" #include "mme-path.h" +#include "mme-sm.h" void mme_send_delete_session_or_detach(mme_ue_t *mme_ue) { ogs_assert(mme_ue); - if (SESSION_CONTEXT_IS_AVAILABLE(mme_ue)) { - mme_gtp_send_delete_all_sessions(mme_ue, - OGS_GTP_DELETE_SEND_DETACH_ACCEPT); - } else { - ogs_assert(OGS_OK == - nas_eps_send_detach_accept(mme_ue)); + switch (mme_ue->nas_eps.detach_type) { + case MME_EPS_TYPE_DETACH_REQUEST_FROM_UE: + if (SESSION_CONTEXT_IS_AVAILABLE(mme_ue)) { + mme_gtp_send_delete_all_sessions( + mme_ue, OGS_GTP_DELETE_SEND_DETACH_ACCEPT); + } else { + ogs_assert(OGS_OK == nas_eps_send_detach_accept(mme_ue)); + } + break; + case MME_EPS_TYPE_DETACH_REQUEST_TO_UE: + if (SESSION_CONTEXT_IS_AVAILABLE(mme_ue)) { + mme_gtp_send_delete_all_sessions(mme_ue, OGS_GTP_DELETE_NO_ACTION); + } + break; + default: + ogs_fatal(" Invalid OGS_NAS_EPS TYPE%d", mme_ue->nas_eps.type); + ogs_assert_if_reached(); } } @@ -75,72 +88,127 @@ } } -void mme_send_after_paging(mme_ue_t *mme_ue, uint8_t cause_value) +void mme_send_after_paging(mme_ue_t *mme_ue, bool failed) { - mme_sess_t *sess = NULL; mme_bearer_t *bearer = NULL; ogs_assert(mme_ue); - ogs_list_for_each(&mme_ue->sess_list, sess) { - ogs_list_for_each(&sess->bearer_list, bearer) { - ogs_gtp_xact_t *xact = NULL; - uint8_t type; - - xact = ogs_gtp_xact_cycle(bearer->current.xact); - if (xact) { - /* - * It may conflict with GTP transaction already used. - * To avoid this, check `xact->step` to see if - * the transaction has already been committed. - */ - type = xact->seqxact->step-1.type; - - switch (type) { - case OGS_GTP2_DOWNLINK_DATA_NOTIFICATION_TYPE: - ogs_assert(OGS_OK == - mme_gtp_send_downlink_data_notification_ack( - bearer, cause_value)); - break; - case OGS_GTP2_CREATE_BEARER_REQUEST_TYPE: - if (cause_value == OGS_GTP2_CAUSE_REQUEST_ACCEPTED) { - ogs_assert(OGS_OK == - nas_eps_send_activate_dedicated_bearer_context_request( - bearer)); - } else { - ogs_assert(OGS_OK == - mme_gtp_send_create_bearer_response( - bearer, cause_value)); - } - break; - case OGS_GTP2_UPDATE_BEARER_REQUEST_TYPE: - if (cause_value == OGS_GTP2_CAUSE_REQUEST_ACCEPTED) { - ogs_assert(OGS_OK == - nas_eps_send_modify_bearer_context_request(bearer, - (xact->update_flags & - OGS_GTP_MODIFY_QOS_UPDATE) ? 1 : 0, - (xact->update_flags & - OGS_GTP_MODIFY_TFT_UPDATE) ? 1 : 0)); - } else { - ogs_assert(OGS_OK == - mme_gtp_send_update_bearer_response( - bearer, cause_value)); - } - break; - case OGS_GTP2_DELETE_BEARER_REQUEST_TYPE: - if (cause_value == OGS_GTP2_CAUSE_REQUEST_ACCEPTED) { - ogs_assert(OGS_OK == - nas_eps_send_deactivate_bearer_context_request(bearer)); - } else { - ogs_assert(OGS_OK == - mme_gtp_send_delete_bearer_response( - bearer, cause_value)); - } - break; - default: - break; - } + switch (mme_ue->paging.type) { + case MME_PAGING_TYPE_DOWNLINK_DATA_NOTIFICATION: + bearer = mme_bearer_cycle(mme_ue->paging.data); + if (!bearer) { + ogs_error("No Bearer %d", mme_ue->paging.type); + goto cleanup; + } + + if (failed == true) { + ogs_assert(OGS_OK == + mme_gtp_send_downlink_data_notification_ack( + bearer, OGS_GTP2_CAUSE_UNABLE_TO_PAGE_UE)); + } else { + ogs_assert(OGS_OK == + mme_gtp_send_downlink_data_notification_ack( + bearer, OGS_GTP2_CAUSE_REQUEST_ACCEPTED)); + } + break; + case MME_PAGING_TYPE_CREATE_BEARER: + bearer = mme_bearer_cycle(mme_ue->paging.data); + if (!bearer) { + ogs_error("No Bearer %d", mme_ue->paging.type); + goto cleanup; + } + + if (failed == true) { + ogs_assert(OGS_OK == + mme_gtp_send_create_bearer_response( + bearer, OGS_GTP2_CAUSE_UNABLE_TO_PAGE_UE)); + } else { + ogs_assert(OGS_OK == + nas_eps_send_activate_dedicated_bearer_context_request(bearer)); + } + break; + case MME_PAGING_TYPE_UPDATE_BEARER: + bearer = mme_bearer_cycle(mme_ue->paging.data); + if (!bearer) { + ogs_error("No Bearer %d", mme_ue->paging.type); + goto cleanup; + } + + if (failed == true) { + ogs_assert(OGS_OK == + mme_gtp_send_update_bearer_response( + bearer, OGS_GTP2_CAUSE_UNABLE_TO_PAGE_UE)); + } else { + ogs_gtp_xact_t *xact = ogs_gtp_xact_cycle(bearer->update.xact); + if (!xact) { + ogs_error("No GTP xact"); + goto cleanup; } + + ogs_assert(OGS_OK == + nas_eps_send_modify_bearer_context_request(bearer, + (xact->update_flags & + OGS_GTP_MODIFY_QOS_UPDATE) ? 1 : 0, + (xact->update_flags & + OGS_GTP_MODIFY_TFT_UPDATE) ? 1 : 0)); + } + break; + case MME_PAGING_TYPE_DELETE_BEARER: + bearer = mme_bearer_cycle(mme_ue->paging.data); + if (!bearer) { + ogs_error("No Bearer %d", mme_ue->paging.type); + goto cleanup; } + + if (failed == true) { + ogs_assert(OGS_OK == + mme_gtp_send_delete_bearer_response( + bearer, OGS_GTP2_CAUSE_UNABLE_TO_PAGE_UE)); + } else { + ogs_assert(OGS_OK == + nas_eps_send_deactivate_bearer_context_request(bearer)); + } + break; + case MME_PAGING_TYPE_CS_CALL_SERVICE: + if (failed == true) { + ogs_assert(OGS_OK == + sgsap_send_paging_reject( + mme_ue, SGSAP_SGS_CAUSE_UE_UNREACHABLE)); + } else { + /* Nothing */ + } + break; + case MME_PAGING_TYPE_SMS_SERVICE: + if (failed == true) { + ogs_assert(OGS_OK == + sgsap_send_paging_reject( + mme_ue, SGSAP_SGS_CAUSE_UE_UNREACHABLE)); + } else { + ogs_assert(OGS_OK == + sgsap_send_service_request( + mme_ue, SGSAP_EMM_CONNECTED_MODE)); + } + break; + case MME_PAGING_TYPE_DETACH_TO_UE: + if (failed == true) { + /* Nothing */ + ogs_warn("MME-initiated Detach cannot be invoked"); + } else { + ogs_assert(OGS_OK == nas_eps_send_detach_request(mme_ue)); + if (MME_P_TMSI_IS_AVAILABLE(mme_ue)) { + ogs_assert(OGS_OK == sgsap_send_detach_indication(mme_ue)); + } else { + mme_send_delete_session_or_detach(mme_ue); + } + } + break; + default: + ogs_fatal("Invalid Paging Type%d", mme_ue->paging.type); + ogs_assert_if_reached(); } + +cleanup: + CLEAR_SERVICE_INDICATOR(mme_ue); + MME_CLEAR_PAGING_INFO(mme_ue); }
View file
open5gs_2.4.9.tar.xz/src/mme/mme-path.h -> open5gs_2.4.10.tar.xz/src/mme/mme-path.h
Changed
@@ -30,7 +30,7 @@ void mme_send_delete_session_or_mme_ue_context_release(mme_ue_t *mme_ue); void mme_send_release_access_bearer_or_ue_context_release(enb_ue_t *enb_ue); -void mme_send_after_paging(mme_ue_t *mme_ue, uint8_t cause_value); +void mme_send_after_paging(mme_ue_t *mme_ue, bool failed); #ifdef __cplusplus }
View file
open5gs_2.4.9.tar.xz/src/mme/mme-s11-build.c -> open5gs_2.4.10.tar.xz/src/mme/mme-s11-build.c
Changed
@@ -48,7 +48,7 @@ struct timeval now; struct tm time_exp; char apnOGS_MAX_APN_LEN+1; - + ogs_gtp2_indication_t indication; ogs_assert(sess); @@ -195,14 +195,14 @@ * we need to change position of addresses in struct. */ if (req->pdn_type.u8 == OGS_PDU_SESSION_TYPE_IPV4 && session->session_type == OGS_PDU_SESSION_TYPE_IPV4V6) { - uint32_t addr = session->paa.both.addr; - session->paa.addr = addr; + uint32_t addr = session->paa.both.addr; + session->paa.addr = addr; } if (req->pdn_type.u8 == OGS_PDU_SESSION_TYPE_IPV6 && session->session_type == OGS_PDU_SESSION_TYPE_IPV4V6) { - uint8_t addr16; - memcpy(&addr, session->paa.both.addr6, OGS_IPV6_LEN); - memcpy(session->paa.addr6, &addr, OGS_IPV6_LEN); + uint8_t addr16; + memcpy(&addr, session->paa.both.addr6, OGS_IPV6_LEN); + memcpy(session->paa.addr6, &addr, OGS_IPV6_LEN); } memset(&indication, 0, sizeof(ogs_gtp2_indication_t)); @@ -214,13 +214,13 @@ indication.enb_change_reporting_support_indication = 1; if (req->pdn_type.u8 == OGS_PDU_SESSION_TYPE_IPV4V6) - indication.dual_address_bearer_flag = 1; + indication.dual_address_bearer_flag = 1; if (sess->request_type.value == OGS_NAS_EPS_REQUEST_TYPE_HANDOVER) - indication.handover_indication = 1; + indication.handover_indication = 1; if (create_action == OGS_GTP_CREATE_IN_PATH_SWITCH_REQUEST) - indication.operation_indication = 1; + indication.operation_indication = 1; session->paa.session_type = req->pdn_type.u8; req->pdn_address_allocation.data = &session->paa;
View file
open5gs_2.4.9.tar.xz/src/mme/mme-s11-handler.c -> open5gs_2.4.10.tar.xz/src/mme/mme-s11-handler.c
Changed
@@ -562,15 +562,18 @@ ogs_debug(" MME_S11_TEID%d SGW_S11_TEID%d", mme_ue->mme_s11_teid, source_ue->sgw_s11_teid); - if (action == OGS_GTP_DELETE_SEND_AUTHENTICATION_REQUEST) { + if (action == OGS_GTP_DELETE_NO_ACTION) { + /* No Action to be taken after sessions are deleted during + * MME Initiated detach. S1 will be cleared after receipt + * of the detach accept from UE */ + } else if (action == OGS_GTP_DELETE_SEND_AUTHENTICATION_REQUEST) { if (mme_sess_count(mme_ue) == 1) /* Last Session */ { mme_s6a_send_air(mme_ue, NULL); } } else if (action == OGS_GTP_DELETE_SEND_DETACH_ACCEPT) { if (mme_sess_count(mme_ue) == 1) /* Last Session */ { - ogs_assert(OGS_OK == - nas_eps_send_detach_accept(mme_ue)); + ogs_assert(OGS_OK == nas_eps_send_detach_accept(mme_ue)); } } else if (action == @@ -603,6 +606,20 @@ ogs_error("ENB-S1 Context has already been removed"); } + } else if (action == OGS_GTP_DELETE_SEND_S1_REMOVE_AND_UNLINK) { + if (mme_sess_count(mme_ue) == 1) /* Last Session */ { + enb_ue_t *enb_ue = NULL; + + enb_ue = enb_ue_cycle(mme_ue->enb_ue); + if (enb_ue) { + ogs_assert(OGS_OK == + s1ap_send_ue_context_release_command(enb_ue, + S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, + S1AP_UE_CTX_REL_S1_REMOVE_AND_UNLINK, 0)); + } else + ogs_error("ENB-S1 Context has already been removed"); + } + } else if (action == OGS_GTP_DELETE_HANDLE_PDN_CONNECTIVITY_REQUEST) { if (mme_sess_count(mme_ue) == 1) /* Last Session */ { rv = nas_eps_send_emm_to_esm(mme_ue, @@ -803,7 +820,6 @@ * If GTP-xact Holding timer is expired, * OLD bearer->xact memory will be automatically removed. */ - bearer->current.xact = xact; bearer->create.xact = xact; /* Before Activate DEDICATED bearer, check DEFAULT bearer status */ @@ -812,6 +828,8 @@ if (OGS_FSM_CHECK(&default_bearer->sm, esm_state_active)) { if (ECM_IDLE(mme_ue)) { + MME_STORE_PAGING_INFO(mme_ue, + MME_PAGING_TYPE_CREATE_BEARER, bearer); ogs_assert(OGS_OK == s1ap_send_paging(mme_ue, S1AP_CNDomain_ps)); } else { ogs_assert(OGS_OK == @@ -904,7 +922,6 @@ * If GTP-xact Holding timer is expired, * OLD bearer->xact memory will be automatically removed. */ - bearer->current.xact = xact; bearer->update.xact = xact; if (req->bearer_contexts.bearer_level_qos.presence == 1) { @@ -936,6 +953,8 @@ if (req->bearer_contexts.bearer_level_qos.presence == 1 || req->bearer_contexts.tft.presence == 1) { if (ECM_IDLE(mme_ue)) { + MME_STORE_PAGING_INFO(mme_ue, + MME_PAGING_TYPE_UPDATE_BEARER, bearer); ogs_assert(OGS_OK == s1ap_send_paging(mme_ue, S1AP_CNDomain_ps)); } else { ogs_assert(OGS_OK == @@ -1065,10 +1084,10 @@ * If GTP-xact Holding timer is expired, * OLD bearer->xact memory will be automatically removed. */ - bearer->current.xact = xact; bearer->delete.xact = xact; if (ECM_IDLE(mme_ue)) { + MME_STORE_PAGING_INFO(mme_ue, MME_PAGING_TYPE_DELETE_BEARER, bearer); ogs_assert(OGS_OK == s1ap_send_paging(mme_ue, S1AP_CNDomain_ps)); } else { ogs_assert(OGS_OK == @@ -1293,7 +1312,6 @@ * If GTP-xact Holding timer is expired, * OLD bearer->xact memory will be automatically removed. */ - bearer->current.xact = xact; bearer->notify.xact = xact; if (noti->cause.presence) { @@ -1317,6 +1335,8 @@ * before step 9, the MME shall not send S1 interface paging messages */ if (ECM_IDLE(mme_ue)) { + MME_STORE_PAGING_INFO(mme_ue, + MME_PAGING_TYPE_DOWNLINK_DATA_NOTIFICATION, bearer); ogs_assert(OGS_OK == s1ap_send_paging(mme_ue, S1AP_CNDomain_ps)); } else if (ECM_CONNECTED(mme_ue)) {
View file
open5gs_2.4.9.tar.xz/src/mme/mme-s6a-handler.c -> open5gs_2.4.10.tar.xz/src/mme/mme-s6a-handler.c
Changed
@@ -19,20 +19,39 @@ #include "nas-path.h" #include "s1ap-path.h" +#include "sgsap-path.h" +#include "mme-path.h" #include "mme-sm.h" #include "mme-s6a-handler.h" -void mme_s6a_handle_aia(mme_ue_t *mme_ue, - ogs_diam_s6a_aia_message_t *aia_message) +/* Unfortunately fd doesn't distinguish + * between result-code and experimental-result-code. + * + * However, e.g. 5004 has different meaning + * if used in result-code than in experimental-result-code */ +static uint8_t emm_cause_from_diameter( + const uint32_t *dia_err, const uint32_t *dia_exp_err); + +uint8_t mme_s6a_handle_aia( + mme_ue_t *mme_ue, ogs_diam_s6a_message_t *s6a_message) { + ogs_diam_s6a_aia_message_t *aia_message = NULL; ogs_diam_e_utran_vector_t *e_utran_vector = NULL; ogs_assert(mme_ue); + ogs_assert(s6a_message); + aia_message = &s6a_message->aia_message; ogs_assert(aia_message); e_utran_vector = &aia_message->e_utran_vector; ogs_assert(e_utran_vector); + if (s6a_message->result_code != ER_DIAMETER_SUCCESS) { + ogs_warn("Authentication Information failed %d", + s6a_message->result_code); + return emm_cause_from_diameter(s6a_message->err, s6a_message->exp_err); + } + mme_ue->xres_len = e_utran_vector->xres_len; memcpy(mme_ue->xres, e_utran_vector->xres, mme_ue->xres_len); memcpy(mme_ue->kasme, e_utran_vector->kasme, OGS_SHA256_DIGEST_SIZE); @@ -44,22 +63,31 @@ if (mme_ue->nas_eps.ksi == OGS_NAS_KSI_NO_KEY_IS_AVAILABLE) mme_ue->nas_eps.ksi = 0; - ogs_assert(OGS_OK == - nas_eps_send_authentication_request(mme_ue)); + ogs_assert(OGS_OK == nas_eps_send_authentication_request(mme_ue)); + + return OGS_NAS_EMM_CAUSE_REQUEST_ACCEPTED; } -void mme_s6a_handle_ula(mme_ue_t *mme_ue, - ogs_diam_s6a_ula_message_t *ula_message) +uint8_t mme_s6a_handle_ula( + mme_ue_t *mme_ue, ogs_diam_s6a_message_t *s6a_message) { + ogs_diam_s6a_ula_message_t *ula_message = NULL; ogs_subscription_data_t *subscription_data = NULL; ogs_slice_data_t *slice_data = NULL; - int i; + int i, rv; ogs_assert(mme_ue); + ogs_assert(s6a_message); + ula_message = &s6a_message->ula_message; ogs_assert(ula_message); subscription_data = &ula_message->subscription_data; ogs_assert(subscription_data); + if (s6a_message->result_code != ER_DIAMETER_SUCCESS) { + ogs_error("Update Location failed %d", s6a_message->result_code); + return emm_cause_from_diameter(s6a_message->err, s6a_message->exp_err); + } + ogs_assert(subscription_data->num_of_slice == 1); slice_data = &subscription_data->slice0; @@ -92,7 +120,8 @@ memcpy(&mme_ue->sessioni.smf_ip, &slice_data->sessioni.smf_ip, sizeof(mme_ue->sessioni.smf_ip)); - memcpy(&mme_ue->sessioni.charging_characteristics, &slice_data->sessioni.charging_characteristics, + memcpy(&mme_ue->sessioni.charging_characteristics, + &slice_data->sessioni.charging_characteristics, sizeof(mme_ue->sessioni.charging_characteristics)); mme_ue->sessioni.charging_characteristics_presence = slice_data->sessioni.charging_characteristics_presence; @@ -100,4 +129,114 @@ mme_ue->num_of_session = i; mme_ue->context_identifier = slice_data->context_identifier; + + if (mme_ue->nas_eps.type == MME_EPS_TYPE_ATTACH_REQUEST) { + rv = nas_eps_send_emm_to_esm(mme_ue, + &mme_ue->pdn_connectivity_request); + if (rv != OGS_OK) { + ogs_error("nas_eps_send_emm_to_esm() failed"); + return OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED; + } + } else if (mme_ue->nas_eps.type == MME_EPS_TYPE_TAU_REQUEST) { + ogs_assert(OGS_OK == + nas_eps_send_tau_accept(mme_ue, + S1AP_ProcedureCode_id_InitialContextSetup)); + } else { + ogs_error("Invalid Type%d", mme_ue->nas_eps.type); + return OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED; + } + + return OGS_NAS_EMM_CAUSE_REQUEST_ACCEPTED; +} + +void mme_s6a_handle_clr( + mme_ue_t *mme_ue, ogs_diam_s6a_clr_message_t *clr_message) +{ + ogs_assert(mme_ue); + ogs_assert(clr_message); + + /* Set EPS Detach */ + memset(&mme_ue->nas_eps.detach, 0, sizeof(ogs_nas_detach_type_t)); + + if (clr_message->clr_flags & OGS_DIAM_S6A_CLR_FLAGS_REATTACH_REQUIRED) + mme_ue->nas_eps.detach.value = + OGS_NAS_DETACH_TYPE_TO_UE_RE_ATTACH_REQUIRED; + else + mme_ue->nas_eps.detach.value = + OGS_NAS_DETACH_TYPE_TO_UE_RE_ATTACH_NOT_REQUIRED; + + /* 1. MME initiated detach request to the UE. + * (nas_eps.type = MME_EPS_TYPE_DETACH_REQUEST_TO_UE) + * 2. If UE is IDLE, Paging sent to the UE + * 3. If UE is wake-up, UE will send Server Request. + * (nas_eps.type = MME_EPS_TYPE_SERVICE_REQUEST) + * + * So, we will lose the MME_EPS_TYPE_DETACH_REQUEST_TO_UE. + * + * We need more variable(nas_eps.detach_type) + * to keep Detach-Type whether UE-initiated or MME-initiaed. */ + mme_ue->nas_eps.type = mme_ue->nas_eps.detach_type = + MME_EPS_TYPE_DETACH_REQUEST_TO_UE; + ogs_debug(" OGS_NAS_EPS TYPE%d", mme_ue->nas_eps.type); + + if (OGS_FSM_CHECK(&mme_ue->sm, emm_state_de_registered)) { + /* Remove all trace of subscriber even when detached. */ + mme_ue_hash_remove(mme_ue); + mme_ue_remove(mme_ue); + } else if (ECM_IDLE(mme_ue)) { + MME_STORE_PAGING_INFO(mme_ue, MME_PAGING_TYPE_DETACH_TO_UE, NULL); + ogs_assert(OGS_OK == s1ap_send_paging(mme_ue, S1AP_CNDomain_ps)); + } else { + ogs_assert(OGS_OK == nas_eps_send_detach_request(mme_ue)); + if (MME_P_TMSI_IS_AVAILABLE(mme_ue)) { + ogs_assert(OGS_OK == sgsap_send_detach_indication(mme_ue)); + } else { + mme_send_delete_session_or_detach(mme_ue); + } + } +} + +/* 3GPP TS 29.272 Annex A; Table !.a: + * Mapping from S6a error codes to NAS Cause Codes */ +static uint8_t emm_cause_from_diameter( + const uint32_t *dia_err, const uint32_t *dia_exp_err) +{ + if (dia_exp_err) { + switch (*dia_exp_err) { + case OGS_DIAM_S6A_ERROR_USER_UNKNOWN: /* 5001 */ + return OGS_NAS_EMM_CAUSE_PLMN_NOT_ALLOWED; + case OGS_DIAM_S6A_ERROR_UNKNOWN_EPS_SUBSCRIPTION: /* 5420 */ + /* FIXME: Error diagnostic? */ + return OGS_NAS_EMM_CAUSE_NO_SUITABLE_CELLS_IN_TRACKING_AREA; + case OGS_DIAM_S6A_ERROR_RAT_NOT_ALLOWED: /* 5421 */ + return OGS_NAS_EMM_CAUSE_ROAMING_NOT_ALLOWED_IN_THIS_TRACKING_AREA; + case OGS_DIAM_S6A_ERROR_ROAMING_NOT_ALLOWED: /* 5004 */ + return OGS_NAS_EMM_CAUSE_PLMN_NOT_ALLOWED; + /* return OGS_NAS_EMM_CAUSE_EPS_SERVICES_NOT_ALLOWED_IN_THIS_PLMN; + * (ODB_HPLMN_APN) */ + /* return OGS_NAS_EMM_CAUSE_ESM_FAILURE; (ODB_ALL_APN) */ + case OGS_DIAM_S6A_AUTHENTICATION_DATA_UNAVAILABLE: /* 4181 */ + return OGS_NAS_EMM_CAUSE_NETWORK_FAILURE; + } + } + if (dia_err) { + switch (*dia_err) { + case ER_DIAMETER_AUTHORIZATION_REJECTED: /* 5003 */ + case ER_DIAMETER_UNABLE_TO_DELIVER: /* 3002 */ + case ER_DIAMETER_REALM_NOT_SERVED: /* 3003 */ + return OGS_NAS_EMM_CAUSE_NO_SUITABLE_CELLS_IN_TRACKING_AREA; + case ER_DIAMETER_UNABLE_TO_COMPLY: /* 5012 */ + case ER_DIAMETER_INVALID_AVP_VALUE: /* 5004 */ + case ER_DIAMETER_AVP_UNSUPPORTED: /* 5001 */ + case ER_DIAMETER_MISSING_AVP: /* 5005 */ + case ER_DIAMETER_RESOURCES_EXCEEDED: /* 5006 */ + case ER_DIAMETER_AVP_OCCURS_TOO_MANY_TIMES: /* 5009 */ + return OGS_NAS_EMM_CAUSE_NETWORK_FAILURE; + } + } + + ogs_error("Unexpected Diameter Result Code %d/%d, defaulting to severe " + "network failure", + dia_err ? *dia_err : -1, dia_exp_err ? *dia_exp_err : -1); + return OGS_NAS_EMM_CAUSE_SEVERE_NETWORK_FAILURE; }
View file
open5gs_2.4.9.tar.xz/src/mme/mme-s6a-handler.h -> open5gs_2.4.10.tar.xz/src/mme/mme-s6a-handler.h
Changed
@@ -26,10 +26,12 @@ extern "C" { #endif -void mme_s6a_handle_aia(mme_ue_t *mme_ue, - ogs_diam_s6a_aia_message_t *aia_message); -void mme_s6a_handle_ula(mme_ue_t *mme_ue, - ogs_diam_s6a_ula_message_t *ula_message); +uint8_t mme_s6a_handle_aia( + mme_ue_t *mme_ue, ogs_diam_s6a_message_t *s6a_message); +uint8_t mme_s6a_handle_ula( + mme_ue_t *mme_ue, ogs_diam_s6a_message_t *s6a_message); +void mme_s6a_handle_clr( + mme_ue_t *mme_ue, ogs_diam_s6a_clr_message_t *clr_message); #ifdef __cplusplus }
View file
open5gs_2.4.9.tar.xz/src/mme/mme-sm.c -> open5gs_2.4.10.tar.xz/src/mme/mme-sm.c
Changed
@@ -34,54 +34,6 @@ #include "mme-s6a-handler.h" #include "mme-path.h" -/* 3GPP TS 29.272 Annex A; Table !.a: - * Mapping from S6a error codes to NAS Cause Codes */ -static uint8_t emm_cause_from_diameter( - mme_ue_t *mme_ue, const uint32_t *dia_err, const uint32_t *dia_exp_err) -{ - ogs_assert(mme_ue); - - if (dia_exp_err) { - switch (*dia_exp_err) { - case OGS_DIAM_S6A_ERROR_USER_UNKNOWN: /* 5001 */ - ogs_info("%s User Unknown in HSS DB", mme_ue->imsi_bcd); - return OGS_NAS_EMM_CAUSE_PLMN_NOT_ALLOWED; - case OGS_DIAM_S6A_ERROR_UNKNOWN_EPS_SUBSCRIPTION: /* 5420 */ - /* FIXME: Error diagnostic? */ - return OGS_NAS_EMM_CAUSE_NO_SUITABLE_CELLS_IN_TRACKING_AREA; - case OGS_DIAM_S6A_ERROR_RAT_NOT_ALLOWED: /* 5421 */ - return OGS_NAS_EMM_CAUSE_ROAMING_NOT_ALLOWED_IN_THIS_TRACKING_AREA; - case OGS_DIAM_S6A_ERROR_ROAMING_NOT_ALLOWED: /* 5004 */ - return OGS_NAS_EMM_CAUSE_PLMN_NOT_ALLOWED; - /* return OGS_NAS_EMM_CAUSE_EPS_SERVICES_NOT_ALLOWED_IN_THIS_PLMN; - * (ODB_HPLMN_APN) */ - /* return OGS_NAS_EMM_CAUSE_ESM_FAILURE; (ODB_ALL_APN) */ - case OGS_DIAM_S6A_AUTHENTICATION_DATA_UNAVAILABLE: /* 4181 */ - return OGS_NAS_EMM_CAUSE_NETWORK_FAILURE; - } - } - if (dia_err) { - switch (*dia_err) { - case ER_DIAMETER_AUTHORIZATION_REJECTED: /* 5003 */ - case ER_DIAMETER_UNABLE_TO_DELIVER: /* 3002 */ - case ER_DIAMETER_REALM_NOT_SERVED: /* 3003 */ - return OGS_NAS_EMM_CAUSE_NO_SUITABLE_CELLS_IN_TRACKING_AREA; - case ER_DIAMETER_UNABLE_TO_COMPLY: /* 5012 */ - case ER_DIAMETER_INVALID_AVP_VALUE: /* 5004 */ - case ER_DIAMETER_AVP_UNSUPPORTED: /* 5001 */ - case ER_DIAMETER_MISSING_AVP: /* 5005 */ - case ER_DIAMETER_RESOURCES_EXCEEDED: /* 5006 */ - case ER_DIAMETER_AVP_OCCURS_TOO_MANY_TIMES: /* 5009 */ - return OGS_NAS_EMM_CAUSE_NETWORK_FAILURE; - } - } - - ogs_error("Unexpected Diameter Result Code %d/%d, defaulting to severe " - "network failure", - dia_err ? *dia_err : -1, dia_exp_err ? *dia_exp_err : -1); - return OGS_NAS_EMM_CAUSE_SEVERE_NETWORK_FAILURE; -} - void mme_state_initial(ogs_fsm_t *s, mme_event_t *e) { mme_sm_debug(e); @@ -122,6 +74,7 @@ mme_sess_t *sess = NULL; ogs_diam_s6a_message_t *s6a_message = NULL; + uint8_t emm_cause = 0; ogs_gtp_node_t *gnode = NULL; ogs_gtp_xact_t *xact = NULL; @@ -141,7 +94,7 @@ case OGS_FSM_EXIT_SIG: break; - case MME_EVT_S1AP_LO_ACCEPT: + case MME_EVENT_S1AP_LO_ACCEPT: sock = e->sock; ogs_assert(sock); addr = e->addr; @@ -167,7 +120,7 @@ break; - case MME_EVT_S1AP_LO_SCTP_COMM_UP: + case MME_EVENT_S1AP_LO_SCTP_COMM_UP: sock = e->sock; ogs_assert(sock); addr = e->addr; @@ -197,7 +150,7 @@ break; - case MME_EVT_S1AP_LO_CONNREFUSED: + case MME_EVENT_S1AP_LO_CONNREFUSED: sock = e->sock; ogs_assert(sock); addr = e->addr; @@ -219,7 +172,7 @@ ogs_free(addr); break; - case MME_EVT_S1AP_MESSAGE: + case MME_EVENT_S1AP_MESSAGE: sock = e->sock; ogs_assert(sock); addr = e->addr; @@ -253,7 +206,7 @@ ogs_pkbuf_free(pkbuf); break; - case MME_EVT_S1AP_TIMER: + case MME_EVENT_S1AP_TIMER: enb_ue = e->enb_ue; ogs_assert(enb_ue); @@ -280,7 +233,7 @@ } break; - case MME_EVT_EMM_MESSAGE: + case MME_EVENT_EMM_MESSAGE: enb_ue = e->enb_ue; ogs_assert(enb_ue); pkbuf = e->pkbuf; @@ -356,7 +309,7 @@ ogs_pkbuf_free(pkbuf); break; - case MME_EVT_EMM_TIMER: + case MME_EVENT_EMM_TIMER: mme_ue = e->mme_ue; ogs_assert(mme_ue); ogs_assert(OGS_FSM_STATE(&mme_ue->sm)); @@ -364,7 +317,7 @@ ogs_fsm_dispatch(&mme_ue->sm, e); break; - case MME_EVT_ESM_MESSAGE: + case MME_EVENT_ESM_MESSAGE: mme_ue = e->mme_ue; ogs_assert(mme_ue); @@ -423,7 +376,7 @@ ogs_pkbuf_free(pkbuf); break; - case MME_EVT_ESM_TIMER: + case MME_EVENT_ESM_TIMER: bearer = e->bearer; ogs_assert(bearer); ogs_assert(OGS_FSM_STATE(&bearer->sm)); @@ -431,79 +384,58 @@ ogs_fsm_dispatch(&bearer->sm, e); break; - case MME_EVT_S6A_MESSAGE: + case MME_EVENT_S6A_MESSAGE: mme_ue = e->mme_ue; ogs_assert(mme_ue); s6a_message = e->s6a_message; ogs_assert(s6a_message); - enb_ue = enb_ue_cycle(mme_ue->enb_ue); - if (!enb_ue) { - ogs_error("S1 context has already been removed"); - - ogs_subscription_data_free( - &s6a_message->ula_message.subscription_data); - ogs_free(s6a_message); - break; - } - - if (s6a_message->result_code != ER_DIAMETER_SUCCESS) { - /* Unfortunately fd doesn't distinguish - * between result-code and experimental-result-code. - * - * However, e.g. 5004 has different meaning - * if used in result-code than in experimental-result-code */ - uint8_t emm_cause = emm_cause_from_diameter( - mme_ue, s6a_message->err, s6a_message->exp_err); - - ogs_info("%s Attach reject OGS_NAS_EMM_CAUSE:%d", - mme_ue->imsi_bcd, emm_cause); - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, - emm_cause, OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); - - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command(enb_ue, - S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, - S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0)); - - ogs_subscription_data_free( - &s6a_message->ula_message.subscription_data); - ogs_free(s6a_message); - break; - } - switch (s6a_message->cmd_code) { case OGS_DIAM_S6A_CMD_CODE_AUTHENTICATION_INFORMATION: - mme_s6a_handle_aia(mme_ue, &s6a_message->aia_message); + emm_cause = mme_s6a_handle_aia(mme_ue, s6a_message); + if (emm_cause != OGS_NAS_EMM_CAUSE_REQUEST_ACCEPTED) { + ogs_info("%s Attach reject OGS_NAS_EMM_CAUSE:%d", + mme_ue->imsi_bcd, emm_cause); + enb_ue = enb_ue_cycle(mme_ue->enb_ue); + if (!enb_ue) { + ogs_error("S1 context has already been removed"); + break; + } + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, emm_cause, + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + + ogs_assert(OGS_OK == + s1ap_send_ue_context_release_command(enb_ue, + S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, + S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0)); + } break; case OGS_DIAM_S6A_CMD_CODE_UPDATE_LOCATION: - mme_s6a_handle_ula(mme_ue, &s6a_message->ula_message); - - if (mme_ue->nas_eps.type == MME_EPS_TYPE_ATTACH_REQUEST) { - rv = nas_eps_send_emm_to_esm(mme_ue, - &mme_ue->pdn_connectivity_request); - if (rv != OGS_OK) { - ogs_error("nas_eps_send_emm_to_esm() failed"); - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, - OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + emm_cause = mme_s6a_handle_ula(mme_ue, s6a_message); + if (emm_cause != OGS_NAS_EMM_CAUSE_REQUEST_ACCEPTED) { + ogs_info("%s Attach reject OGS_NAS_EMM_CAUSE:%d", + mme_ue->imsi_bcd, emm_cause); + enb_ue = enb_ue_cycle(mme_ue->enb_ue); + if (!enb_ue) { + ogs_error("S1 context has already been removed"); + break; } - } else if (mme_ue->nas_eps.type == MME_EPS_TYPE_TAU_REQUEST) { ogs_assert(OGS_OK == - nas_eps_send_tau_accept(mme_ue, - S1AP_ProcedureCode_id_InitialContextSetup)); - } else if (mme_ue->nas_eps.type == MME_EPS_TYPE_SERVICE_REQUEST) { - ogs_error("%s Service request", mme_ue->imsi_bcd); - } else if (mme_ue->nas_eps.type == - MME_EPS_TYPE_DETACH_REQUEST_FROM_UE) { - ogs_error("%s Detach request", mme_ue->imsi_bcd); - } else { - ogs_fatal("Invalid Type%d", mme_ue->nas_eps.type); - ogs_assert_if_reached(); + nas_eps_send_attach_reject(mme_ue, emm_cause, + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + + ogs_assert(OGS_OK == + s1ap_send_ue_context_release_command(enb_ue, + S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, + S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0)); } break; + case OGS_DIAM_S6A_CMD_CODE_CANCEL_LOCATION: + mme_s6a_handle_clr(mme_ue, &s6a_message->clr_message); + break; + case OGS_DIAM_S6A_CMD_CODE_INSERT_SUBSCRIBER_DATA: + break; default: ogs_error("Invalid Type%d", s6a_message->cmd_code); break; @@ -512,7 +444,7 @@ ogs_free(s6a_message); break; - case MME_EVT_S11_MESSAGE: + case MME_EVENT_S11_MESSAGE: pkbuf = e->pkbuf; ogs_assert(pkbuf); @@ -634,13 +566,13 @@ >p_message.bearer_resource_failure_indication); break; default: - ogs_warn("Not implmeneted(type:%d)", gtp_message.h.type); + ogs_warn("Not implemented(type:%d)", gtp_message.h.type); break; } ogs_pkbuf_free(pkbuf); break; - case MME_EVT_S11_TIMER: + case MME_EVENT_S11_TIMER: sgw_ue = e->sgw_ue; ogs_assert(sgw_ue); mme_ue = sgw_ue->mme_ue; @@ -671,7 +603,7 @@ break; - case MME_EVT_SGSAP_LO_SCTP_COMM_UP: + case MME_EVENT_SGSAP_LO_SCTP_COMM_UP: sock = e->sock; ogs_assert(sock); addr = e->addr; @@ -698,7 +630,7 @@ ogs_fsm_dispatch(&vlr->sm, e); break; - case MME_EVT_SGSAP_LO_CONNREFUSED: + case MME_EVENT_SGSAP_LO_CONNREFUSED: sock = e->sock; ogs_assert(sock); addr = e->addr; @@ -726,7 +658,7 @@ } break; - case MME_EVT_SGSAP_MESSAGE: + case MME_EVENT_SGSAP_MESSAGE: sock = e->sock; ogs_assert(sock); addr = e->addr; @@ -749,7 +681,7 @@ ogs_pkbuf_free(pkbuf); break; - case MME_EVT_SGSAP_TIMER: + case MME_EVENT_SGSAP_TIMER: vlr = e->vlr; ogs_assert(vlr); ogs_assert(OGS_FSM_STATE(&vlr->sm));
View file
open5gs_2.4.9.tar.xz/src/mme/mme-timer.c -> open5gs_2.4.10.tar.xz/src/mme/mme-timer.c
Changed
@@ -24,40 +24,40 @@ static mme_timer_cfg_t g_mme_timer_cfgMAX_NUM_OF_MME_TIMER = { /* Paging procedure for EPS services initiated */ MME_TIMER_T3413 = - { .max_count = 2, .duration = ogs_time_from_sec(2) }, + { .have = true, .max_count = 2, .duration = ogs_time_from_sec(2) }, /* DETACH REQUEST sent */ MME_TIMER_T3422 = - { .max_count = 4, .duration = ogs_time_from_sec(3) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(3) }, /* ATTACH ACCEPT sent * TRACKING AREA UPDATE ACCEPT sent with GUTI * TRACKING AREA UPDATE ACCEPT sent with TMSI * GUTI REALLOCATION COMMAND sent */ MME_TIMER_T3450 = - { .max_count = 4, .duration = ogs_time_from_sec(6) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(6) }, /* AUTHENTICATION REQUEST sent * SECURITY MODE COMMAND sent */ MME_TIMER_T3460 = - { .max_count = 4, .duration = ogs_time_from_sec(3) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(3) }, /* IDENTITY REQUEST sent */ MME_TIMER_T3470 = - { .max_count = 4, .duration = ogs_time_from_sec(3) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(3) }, /* ESM INFORMATION REQUEST sent */ MME_TIMER_T3489 = - { .max_count = 2, .duration = ogs_time_from_sec(4) }, + { .have = true, .max_count = 2, .duration = ogs_time_from_sec(4) }, MME_TIMER_SGS_CLI_CONN_TO_SRV = - { .duration = ogs_time_from_sec(3) }, + { .have = true, .duration = ogs_time_from_sec(3) }, MME_TIMER_S1_HOLDING = - { .duration = ogs_time_from_sec(30) }, + { .have = true, .duration = ogs_time_from_sec(30) }, MME_TIMER_S11_HOLDING = - { .duration = ogs_time_from_msec(300) }, + { .have = true, .duration = ogs_time_from_msec(300) }, }; static void emm_timer_event_send( @@ -68,6 +68,10 @@ mme_timer_cfg_t *mme_timer_cfg(mme_timer_e id) { ogs_assert(id < MAX_NUM_OF_MME_TIMER); + if (g_mme_timer_cfgid.have != true) { + ogs_fatal("No timer%d configuration", id); + ogs_assert_if_reached(); + } return &g_mme_timer_cfgid; } @@ -125,7 +129,7 @@ mme_event_t *e = NULL; ogs_assert(mme_ue); - e = mme_event_new(MME_EVT_EMM_TIMER); + e = mme_event_new(MME_EVENT_EMM_TIMER); e->timer_id = timer_id; e->mme_ue = mme_ue; @@ -167,7 +171,7 @@ mme_ue = bearer->mme_ue; ogs_assert(bearer); - e = mme_event_new(MME_EVT_ESM_TIMER); + e = mme_event_new(MME_EVENT_ESM_TIMER); e->timer_id = timer_id; e->mme_ue = mme_ue; e->bearer = bearer; @@ -190,7 +194,7 @@ mme_event_t *e = NULL; ogs_assert(data); - e = mme_event_new(MME_EVT_SGSAP_TIMER); + e = mme_event_new(MME_EVENT_SGSAP_TIMER); e->timer_id = MME_TIMER_SGS_CLI_CONN_TO_SRV; e->vlr = data; @@ -210,7 +214,7 @@ ogs_assert(data); enb_ue = data; - e = mme_event_new(MME_EVT_S1AP_TIMER); + e = mme_event_new(MME_EVENT_S1AP_TIMER); e->timer_id = MME_TIMER_S1_HOLDING; e->enb_ue = enb_ue; @@ -231,7 +235,7 @@ ogs_assert(data); sgw_ue = data; - e = mme_event_new(MME_EVT_S11_TIMER); + e = mme_event_new(MME_EVENT_S11_TIMER); e->timer_id = MME_TIMER_S11_HOLDING; e->sgw_ue = sgw_ue;
View file
open5gs_2.4.9.tar.xz/src/mme/mme-timer.h -> open5gs_2.4.10.tar.xz/src/mme/mme-timer.h
Changed
@@ -49,6 +49,7 @@ } mme_timer_e; typedef struct mme_timer_cfg_s { + bool have; int max_count; ogs_time_t duration; } mme_timer_cfg_t;
View file
open5gs_2.4.9.tar.xz/src/mme/nas-path.c -> open5gs_2.4.10.tar.xz/src/mme/nas-path.c
Changed
@@ -28,13 +28,16 @@ int nas_eps_send_to_enb(mme_ue_t *mme_ue, ogs_pkbuf_t *pkbuf) { - enb_ue_t *enb_ue = NULL; + ogs_assert(pkbuf); - ogs_assert(mme_ue); - enb_ue = enb_ue_cycle(mme_ue->enb_ue); - ogs_expect_or_return_val(enb_ue, OGS_ERROR); + mme_ue = mme_ue_cycle(mme_ue); + if (!mme_ue) { + ogs_warn("UE(mme-ue) context has already been removed"); + ogs_pkbuf_free(pkbuf); + return OGS_ERROR; + } - return s1ap_send_to_enb_ue(enb_ue, pkbuf); + return s1ap_send_to_enb_ue(mme_ue->enb_ue, pkbuf); } int nas_eps_send_emm_to_esm(mme_ue_t *mme_ue, @@ -69,22 +72,28 @@ enb_ue_t *enb_ue = NULL; ogs_assert(pkbuf); - ogs_assert(mme_ue); + + mme_ue = mme_ue_cycle(mme_ue); + if (!mme_ue) { + ogs_warn("UE(mme-ue) context has already been removed"); + ogs_pkbuf_free(pkbuf); + return OGS_ERROR; + } + enb_ue = enb_ue_cycle(mme_ue->enb_ue); if (!enb_ue) { - ogs_error("S1 context has already been removed"); + ogs_warn("S1 context has already been removed"); ogs_pkbuf_free(pkbuf); - return OGS_ERROR; - } else { - s1apbuf = s1ap_build_downlink_nas_transport(enb_ue, pkbuf); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + } - rv = nas_eps_send_to_enb(mme_ue, s1apbuf); - ogs_expect(rv == OGS_OK); + s1apbuf = s1ap_build_downlink_nas_transport(enb_ue, pkbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); - return rv; - } + rv = nas_eps_send_to_enb(mme_ue, s1apbuf); + ogs_expect(rv == OGS_OK); + + return rv; } int nas_eps_send_attach_accept(mme_ue_t *mme_ue) @@ -252,6 +261,32 @@ rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); ogs_expect_or_return_val(rv == OGS_OK, rv); + + return rv; +} + +int nas_eps_send_detach_request(mme_ue_t *mme_ue) +{ + int rv; + ogs_pkbuf_t *emmbuf = NULL; + + ogs_debug("%s Detach request to UE", mme_ue->imsi_bcd); + + if (mme_ue->t3422.pkbuf) { + emmbuf = mme_ue->t3422.pkbuf; + ogs_expect_or_return_val(emmbuf, OGS_ERROR); + } else { + emmbuf = emm_build_detach_request(mme_ue); + ogs_expect_or_return_val(emmbuf, OGS_ERROR); + } + + mme_ue->t3422.pkbuf = ogs_pkbuf_copy(emmbuf); + ogs_expect_or_return_val(mme_ue->t3422.pkbuf, OGS_ERROR); + ogs_timer_start(mme_ue->t3422.timer, + mme_timer_cfg(MME_TIMER_T3422)->duration); + + rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); + ogs_expect_or_return_val(rv == OGS_OK, rv); return rv; }
View file
open5gs_2.4.9.tar.xz/src/mme/nas-path.h -> open5gs_2.4.10.tar.xz/src/mme/nas-path.h
Changed
@@ -43,6 +43,7 @@ int nas_eps_send_security_mode_command(mme_ue_t *mme_ue); +int nas_eps_send_detach_request(mme_ue_t *mme_ue); int nas_eps_send_detach_accept(mme_ue_t *mme_ue); int nas_eps_send_pdn_connectivity_reject(
View file
open5gs_2.4.9.tar.xz/src/mme/s1ap-handler.c -> open5gs_2.4.10.tar.xz/src/mme/s1ap-handler.c
Changed
@@ -61,7 +61,7 @@ } } - return number_of_enbs_online >= ogs_app()->max.gnb; + return number_of_enbs_online >= ogs_app()->max.peer; } void s1ap_handle_s1_setup_request(mme_enb_t *enb, ogs_s1ap_message_t *message) @@ -511,6 +511,7 @@ memcpy(&mme_ue->tai, &enb_ue->saved.tai, sizeof(ogs_eps_tai_t)); memcpy(&mme_ue->e_cgi, &enb_ue->saved.e_cgi, sizeof(ogs_e_cgi_t)); + mme_ue->ue_location_timestamp = ogs_time_now(); } else { ogs_fatal("No UE Context in UplinkNASTransport"); ogs_assert_if_reached(); @@ -764,15 +765,8 @@ } } - if (mme_ue->nas_eps.type != MME_EPS_TYPE_ATTACH_REQUEST) - mme_send_after_paging(mme_ue, OGS_GTP2_CAUSE_REQUEST_ACCEPTED); - - if (SMS_SERVICE_INDICATOR(mme_ue)) { - ogs_assert(OGS_OK == - sgsap_send_service_request(mme_ue, SGSAP_EMM_CONNECTED_MODE)); - } - - CLEAR_SERVICE_INDICATOR(mme_ue); + if (MME_PAGING_ONGOING(mme_ue)) + mme_send_after_paging(mme_ue, false); } void s1ap_handle_initial_context_setup_failure( @@ -1904,6 +1898,7 @@ mme_ue->enb_ostream_id = enb_ue->enb_ostream_id; memcpy(&mme_ue->tai, &enb_ue->saved.tai, sizeof(ogs_eps_tai_t)); memcpy(&mme_ue->e_cgi, &enb_ue->saved.e_cgi, sizeof(ogs_e_cgi_t)); + mme_ue->ue_location_timestamp = ogs_time_now(); ogs_assert(UESecurityCapabilities); encryptionAlgorithms = @@ -2946,6 +2941,7 @@ mme_ue->enb_ostream_id = target_ue->enb_ostream_id; memcpy(&mme_ue->tai, &target_ue->saved.tai, sizeof(ogs_eps_tai_t)); memcpy(&mme_ue->e_cgi, &target_ue->saved.e_cgi, sizeof(ogs_e_cgi_t)); + mme_ue->ue_location_timestamp = ogs_time_now(); ogs_assert(OGS_OK == s1ap_send_ue_context_release_command(source_ue,
View file
open5gs_2.4.9.tar.xz/src/mme/s1ap-path.c -> open5gs_2.4.10.tar.xz/src/mme/s1ap-path.c
Changed
@@ -51,8 +51,15 @@ { char bufOGS_ADDRSTRLEN; - ogs_assert(enb); ogs_assert(pkbuf); + + enb = mme_enb_cycle(enb); + if (!enb) { + ogs_warn("eNB has already been removed"); + ogs_pkbuf_free(pkbuf); + return OGS_ERROR; + } + ogs_assert(enb->sctp.sock); if (enb->sctp.sock->fd == INVALID_SOCKET) { ogs_fatal("eNB SCTP socket has already been destroyed"); @@ -77,13 +84,16 @@ int s1ap_send_to_enb_ue(enb_ue_t *enb_ue, ogs_pkbuf_t *pkbuf) { - mme_enb_t *enb = NULL; + ogs_assert(pkbuf); - ogs_assert(enb_ue); - enb = enb_ue->enb; - ogs_assert(enb); + enb_ue = enb_ue_cycle(enb_ue); + if (!enb_ue) { + ogs_warn("S1 context has already been removed"); + ogs_pkbuf_free(pkbuf); + return OGS_ERROR; + } - return s1ap_send_to_enb(enb, pkbuf, enb_ue->enb_ostream_id); + return s1ap_send_to_enb(enb_ue->enb, pkbuf, enb_ue->enb_ostream_id); } int s1ap_delayed_send_to_enb_ue( @@ -95,7 +105,7 @@ if (duration) { mme_event_t *e = NULL; - e = mme_event_new(MME_EVT_S1AP_TIMER); + e = mme_event_new(MME_EVENT_S1AP_TIMER); ogs_assert(e); e->timer = ogs_timer_add( ogs_app()->timer_mgr, mme_timer_s1_delayed_send, e); @@ -125,7 +135,7 @@ ogs_assert(mme_ue); ogs_assert(esmbuf); - e = mme_event_new(MME_EVT_ESM_MESSAGE); + e = mme_event_new(MME_EVENT_ESM_MESSAGE); ogs_assert(e); e->mme_ue = mme_ue; e->pkbuf = esmbuf; @@ -201,7 +211,7 @@ if (nas_eps_security_decode(enb_ue->mme_ue, security_header_type, nasbuf) != OGS_OK) { ogs_error("nas_eps_security_decode failed()"); - return OGS_ERROR; + return OGS_ERROR; } } @@ -209,7 +219,7 @@ ogs_assert(h); if (h->protocol_discriminator == OGS_NAS_PROTOCOL_DISCRIMINATOR_EMM) { int rv; - e = mme_event_new(MME_EVT_EMM_MESSAGE); + e = mme_event_new(MME_EVENT_EMM_MESSAGE); if (!e) { ogs_error("s1ap_send_to_nas() failed"); ogs_pkbuf_free(nasbuf);
View file
open5gs_2.4.9.tar.xz/src/mme/s1ap-sctp.c -> open5gs_2.4.10.tar.xz/src/mme/s1ap-sctp.c
Changed
@@ -79,12 +79,12 @@ #if HAVE_USRSCTP static void usrsctp_recv_handler(struct socket *socket, void *data, int flags) { - int events; + int events; - while ((events = usrsctp_get_events(socket)) && + while ((events = usrsctp_get_events(socket)) && (events & SCTP_EVENT_READ)) { s1ap_recv_handler((ogs_sock_t *)socket); - } + } } #else static void lksctp_accept_handler(short when, ogs_socket_t fd, void *data) @@ -114,7 +114,7 @@ ogs_info("eNB-S1 accepted%s:%d in s1_path module", OGS_ADDR(addr, buf), OGS_PORT(addr)); - s1ap_event_push(MME_EVT_S1AP_LO_ACCEPT, new, addr, NULL, 0, 0); + s1ap_event_push(MME_EVENT_S1AP_LO_ACCEPT, new, addr, NULL, 0, 0); } else { ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno, "accept() failed"); } @@ -164,7 +164,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - s1ap_event_push(MME_EVT_S1AP_LO_SCTP_COMM_UP, + s1ap_event_push(MME_EVENT_S1AP_LO_SCTP_COMM_UP, sock, addr, NULL, not->sn_assoc_change.sac_inbound_streams, not->sn_assoc_change.sac_outbound_streams); @@ -180,7 +180,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - s1ap_event_push(MME_EVT_S1AP_LO_CONNREFUSED, + s1ap_event_push(MME_EVENT_S1AP_LO_CONNREFUSED, sock, addr, NULL, 0, 0); } break; @@ -195,7 +195,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - s1ap_event_push(MME_EVT_S1AP_LO_CONNREFUSED, + s1ap_event_push(MME_EVENT_S1AP_LO_CONNREFUSED, sock, addr, NULL, 0, 0); break; @@ -237,7 +237,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - s1ap_event_push(MME_EVT_S1AP_MESSAGE, sock, addr, pkbuf, 0, 0); + s1ap_event_push(MME_EVENT_S1AP_MESSAGE, sock, addr, pkbuf, 0, 0); return; } else { if (ogs_socket_errno != OGS_EAGAIN) {
View file
open5gs_2.4.9.tar.xz/src/mme/s1ap-sm.c -> open5gs_2.4.10.tar.xz/src/mme/s1ap-sm.c
Changed
@@ -67,7 +67,7 @@ break; case OGS_FSM_EXIT_SIG: break; - case MME_EVT_S1AP_MESSAGE: + case MME_EVENT_S1AP_MESSAGE: pdu = e->s1ap_message; ogs_assert(pdu);
View file
open5gs_2.4.9.tar.xz/src/mme/sgsap-build.c -> open5gs_2.4.10.tar.xz/src/mme/sgsap-build.c
Changed
@@ -19,7 +19,6 @@ #include "mme-context.h" -#include "sgsap-types.h" #include "sgsap-build.h" #include "sgsap-conv.h" @@ -238,7 +237,6 @@ root = ogs_tlv_add(NULL, OGS_TLV_MODE_T1_L1, SGSAP_IE_IMSI_TYPE, SGSAP_IE_IMSI_LEN, 0, nas_mobile_identity_imsi); - sgs_cause = SGSAP_SGS_CAUSE_IMSI_UNKNOWN; ogs_tlv_add(root, OGS_TLV_MODE_T1_L1, SGSAP_IE_SGS_CAUSE_TYPE, SGSAP_IE_SGS_CAUSE_LEN, 0, &sgs_cause);
View file
open5gs_2.4.9.tar.xz/src/mme/sgsap-build.h -> open5gs_2.4.10.tar.xz/src/mme/sgsap-build.h
Changed
@@ -22,6 +22,8 @@ #include "mme-context.h" +#include "sgsap-types.h" + #ifdef __cplusplus extern "C" { #endif
View file
open5gs_2.4.9.tar.xz/src/mme/sgsap-conv.h -> open5gs_2.4.10.tar.xz/src/mme/sgsap-conv.h
Changed
@@ -20,7 +20,7 @@ #ifndef SGSAP_CONV_H #define SGSAP_CONV_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" {
View file
open5gs_2.4.9.tar.xz/src/mme/sgsap-handler.c -> open5gs_2.4.10.tar.xz/src/mme/sgsap-handler.c
Changed
@@ -209,7 +209,7 @@ mme_send_delete_session_or_mme_ue_context_release(mme_ue); return; - + error: ogs_error("Error processing SGsAP LU REJECT"); return; @@ -333,7 +333,7 @@ ogs_nas_eps_imsi_to_bcd(nas_mobile_identity_imsi, nas_mobile_identity_imsi_len, imsi_bcd); mme_ue = mme_ue_find_by_imsi_bcd(imsi_bcd); - } else + } else ogs_expect_or_return(0); if (mme_ue) { @@ -352,11 +352,15 @@ if (ECM_IDLE(mme_ue)) { if (CS_CALL_SERVICE_INDICATOR(mme_ue)) { /* UE will respond Extended Service Request in PS CNDomain*/ + MME_STORE_PAGING_INFO(mme_ue, + MME_PAGING_TYPE_CS_CALL_SERVICE, NULL); ogs_assert(OGS_OK == s1ap_send_paging(mme_ue, S1AP_CNDomain_cs)); } else if (SMS_SERVICE_INDICATOR(mme_ue)) { /* UE will respond Service Request in PS CNDomain*/ + MME_STORE_PAGING_INFO(mme_ue, + MME_PAGING_TYPE_SMS_SERVICE, NULL); ogs_assert(OGS_OK == s1ap_send_paging(mme_ue, S1AP_CNDomain_ps)); } else @@ -382,7 +386,7 @@ ogs_debug(" IMSI%s", imsi_bcd); sgsap_send_to_vlr_with_sid( - vlr, + vlr, sgsap_build_paging_reject( nas_mobile_identity_imsi, nas_mobile_identity_imsi_len, SGSAP_SGS_CAUSE_IMSI_UNKNOWN), @@ -441,7 +445,7 @@ ogs_nas_eps_imsi_to_bcd(nas_mobile_identity_imsi, nas_mobile_identity_imsi_len, imsi_bcd); mme_ue = mme_ue_find_by_imsi_bcd(imsi_bcd); - } else + } else ogs_assert_if_reached(); ogs_expect_or_return(mme_ue); @@ -510,7 +514,7 @@ ogs_nas_eps_imsi_to_bcd(nas_mobile_identity_imsi, nas_mobile_identity_imsi_len, imsi_bcd); mme_ue = mme_ue_find_by_imsi_bcd(imsi_bcd); - } else + } else ogs_expect_or_return(0); if (mme_ue) @@ -567,7 +571,7 @@ ogs_nas_eps_imsi_to_bcd(nas_mobile_identity_imsi, nas_mobile_identity_imsi_len, imsi_bcd); mme_ue = mme_ue_find_by_imsi_bcd(imsi_bcd); - } else + } else ogs_expect_or_return(0); if (mme_ue)
View file
open5gs_2.4.9.tar.xz/src/mme/sgsap-path.c -> open5gs_2.4.10.tar.xz/src/mme/sgsap-path.c
Changed
@@ -22,8 +22,6 @@ #include "mme-event.h" #include "mme-sm.h" -#include "sgsap-types.h" -#include "sgsap-build.h" #include "sgsap-path.h" int sgsap_open() @@ -36,8 +34,7 @@ memset(&e, 0, sizeof(e)); e.vlr = vlr; - ogs_fsm_create(&vlr->sm, sgsap_state_initial, sgsap_state_final); - ogs_fsm_init(&vlr->sm, &e); + ogs_fsm_init(&vlr->sm, sgsap_state_initial, sgsap_state_final, &e); } return OGS_OK; @@ -53,7 +50,6 @@ e.vlr = vlr; ogs_fsm_fini(&vlr->sm, &e); - ogs_fsm_delete(&vlr->sm); } } @@ -179,6 +175,25 @@ return rv; } +int sgsap_send_paging_reject(mme_ue_t *mme_ue, uint8_t sgs_cause) +{ + int rv; + ogs_pkbuf_t *pkbuf = NULL; + ogs_assert(mme_ue); + + ogs_debug("SGSAP PAGING-REJECT"); + ogs_debug(" IMSI%s", mme_ue->imsi_bcd); + + pkbuf = sgsap_build_paging_reject( + &mme_ue->nas_mobile_identity_imsi, + SGSAP_IE_IMSI_LEN, sgs_cause); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); + rv = sgsap_send_to_vlr(mme_ue, pkbuf); + ogs_expect(rv == OGS_OK); + + return rv; +} + int sgsap_send_service_request(mme_ue_t *mme_ue, uint8_t emm_mode) { int rv; @@ -251,4 +266,4 @@ ogs_expect(rv == OGS_OK); return rv; -} \ No newline at end of file +}
View file
open5gs_2.4.9.tar.xz/src/mme/sgsap-path.h -> open5gs_2.4.10.tar.xz/src/mme/sgsap-path.h
Changed
@@ -23,6 +23,8 @@ #include "mme-context.h" #include "mme-event.h" +#include "sgsap-build.h" + #ifdef __cplusplus extern "C" { #endif @@ -45,6 +47,7 @@ int sgsap_send_tmsi_reallocation_complete(mme_ue_t *mme_ue); int sgsap_send_detach_indication(mme_ue_t *mme_ue); int sgsap_send_mo_csfb_indication(mme_ue_t *mme_ue); +int sgsap_send_paging_reject(mme_ue_t *mme_ue, uint8_t sgs_cause); int sgsap_send_service_request(mme_ue_t *mme_ue, uint8_t emm_mode); int sgsap_send_reset_ack(mme_vlr_t *vlr); int sgsap_send_uplink_unitdata(mme_ue_t *mme_ue,
View file
open5gs_2.4.9.tar.xz/src/mme/sgsap-sctp.c -> open5gs_2.4.10.tar.xz/src/mme/sgsap-sctp.c
Changed
@@ -62,9 +62,9 @@ #if HAVE_USRSCTP static void usrsctp_recv_handler(struct socket *socket, void *data, int flags) { - int events; + int events; - while ((events = usrsctp_get_events(socket)) && + while ((events = usrsctp_get_events(socket)) && (events & SCTP_EVENT_READ)) { recv_handler((ogs_sock_t *)socket); } @@ -126,7 +126,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - sgsap_event_push(MME_EVT_SGSAP_LO_SCTP_COMM_UP, + sgsap_event_push(MME_EVENT_SGSAP_LO_SCTP_COMM_UP, sock, addr, NULL, not->sn_assoc_change.sac_inbound_streams, not->sn_assoc_change.sac_outbound_streams); @@ -142,7 +142,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - sgsap_event_push(MME_EVT_SGSAP_LO_CONNREFUSED, + sgsap_event_push(MME_EVENT_SGSAP_LO_CONNREFUSED, sock, addr, NULL, 0, 0); } break; @@ -170,7 +170,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - sgsap_event_push(MME_EVT_SGSAP_LO_CONNREFUSED, + sgsap_event_push(MME_EVENT_SGSAP_LO_CONNREFUSED, sock, addr, NULL, 0, 0); break; case SCTP_PEER_ADDR_CHANGE: @@ -197,7 +197,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - sgsap_event_push(MME_EVT_SGSAP_MESSAGE, sock, addr, pkbuf, 0, 0); + sgsap_event_push(MME_EVENT_SGSAP_MESSAGE, sock, addr, pkbuf, 0, 0); return; } else { ogs_fatal("Invalid flag(0x%x)", flags);
View file
open5gs_2.4.9.tar.xz/src/mme/sgsap-sm.c -> open5gs_2.4.10.tar.xz/src/mme/sgsap-sm.c
Changed
@@ -84,7 +84,7 @@ case OGS_FSM_EXIT_SIG: ogs_timer_stop(vlr->t_conn); break; - case MME_EVT_SGSAP_TIMER: + case MME_EVENT_SGSAP_TIMER: switch(e->timer_id) { case MME_TIMER_SGS_CLI_CONN_TO_SRV: vlr = e->vlr; @@ -108,7 +108,7 @@ break; } break; - case MME_EVT_SGSAP_LO_SCTP_COMM_UP: + case MME_EVENT_SGSAP_LO_SCTP_COMM_UP: OGS_FSM_TRAN(s, sgsap_state_connected); break; default: @@ -135,11 +135,11 @@ break; case OGS_FSM_EXIT_SIG: break; - case MME_EVT_SGSAP_LO_CONNREFUSED: + case MME_EVENT_SGSAP_LO_CONNREFUSED: mme_vlr_close(vlr); OGS_FSM_TRAN(s, sgsap_state_will_connect); break; - case MME_EVT_SGSAP_MESSAGE: + case MME_EVENT_SGSAP_MESSAGE: pkbuf = e->pkbuf; ogs_assert(pkbuf); type = *(unsigned char *)(pkbuf->data);
View file
open5gs_2.4.9.tar.xz/src/nrf/context.c -> open5gs_2.4.10.tar.xz/src/nrf/context.c
Changed
@@ -17,7 +17,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#include "ogs-dbi.h" #include "context.h" static nrf_context_t self; @@ -33,7 +32,6 @@ /* Initialize NRF context */ memset(&self, 0, sizeof(nrf_context_t)); - ogs_log_install_domain(&__ogs_dbi_domain, "dbi", ogs_core()->log.level); ogs_log_install_domain(&__nrf_log_domain, "nrf", ogs_core()->log.level); context_initialized = 1; @@ -47,7 +45,7 @@ ogs_list_for_each_safe( &ogs_sbi_self()->nf_instance_list, next_nf_instance, nf_instance) - nrf_nf_fsm_fini(nf_instance); + if (OGS_FSM_STATE(&nf_instance->sm)) nrf_nf_fsm_fini(nf_instance); context_initialized = 0; }
View file
open5gs_2.4.9.tar.xz/src/nrf/event.h -> open5gs_2.4.10.tar.xz/src/nrf/event.h
Changed
@@ -20,7 +20,7 @@ #ifndef NRF_EVENT_H #define NRF_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { @@ -30,10 +30,10 @@ 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 ogs_sbi_subscription_data_s ogs_sbi_subscription_data_t; typedef enum { - NRF_EVT_BASE = OGS_FSM_USER_SIG, + NRF_EVT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, NRF_EVT_SBI_SERVER, NRF_EVT_SBI_CLIENT, @@ -56,7 +56,7 @@ } sbi; ogs_sbi_nf_instance_t *nf_instance; - ogs_sbi_subscription_t *subscription; + ogs_sbi_subscription_data_t *subscription_data; } nrf_event_t; void nrf_event_init(void);
View file
open5gs_2.4.9.tar.xz/src/nrf/init.c -> open5gs_2.4.10.tar.xz/src/nrf/init.c
Changed
@@ -94,8 +94,7 @@ ogs_fsm_t nrf_sm; int rv; - ogs_fsm_create(&nrf_sm, nrf_state_initial, nrf_state_final); - ogs_fsm_init(&nrf_sm, 0); + ogs_fsm_init(&nrf_sm, nrf_state_initial, nrf_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -134,5 +133,4 @@ done: ogs_fsm_fini(&nrf_sm, 0); - ogs_fsm_delete(&nrf_sm); }
View file
open5gs_2.4.9.tar.xz/src/nrf/meson.build -> open5gs_2.4.10.tar.xz/src/nrf/meson.build
Changed
@@ -32,16 +32,12 @@ libnrf = static_library('nrf', sources : libnrf_sources, - dependencies : libapp_dep, - libdbi_dep, - libsbi_dep, + dependencies : libsbi_dep, install : false) libnrf_dep = declare_dependency( link_with : libnrf, - dependencies : libapp_dep, - libdbi_dep, - libsbi_dep) + dependencies : libsbi_dep) nrf_sources = files(''' app.c
View file
open5gs_2.4.9.tar.xz/src/nrf/nf-sm.c -> open5gs_2.4.10.tar.xz/src/nrf/nf-sm.c
Changed
@@ -30,9 +30,8 @@ memset(&e, 0, sizeof(e)); e.nf_instance = nf_instance; - ogs_fsm_create(&nf_instance->sm, - nrf_nf_state_initial, nrf_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); + ogs_fsm_init(&nf_instance->sm, + nrf_nf_state_initial, nrf_nf_state_final, &e); } void nrf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) @@ -44,7 +43,6 @@ e.nf_instance = nf_instance; ogs_fsm_fini(&nf_instance->sm, &e); - ogs_fsm_delete(&nf_instance->sm); } void nrf_nf_state_initial(ogs_fsm_t *s, nrf_event_t *e)
View file
open5gs_2.4.9.tar.xz/src/nrf/nnrf-build.c -> open5gs_2.4.10.tar.xz/src/nrf/nnrf-build.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,7 @@ #include "nnrf-build.h" ogs_sbi_request_t *nrf_nnrf_nfm_build_nf_status_notify( - ogs_sbi_subscription_t *subscription, + ogs_sbi_subscription_data_t *subscription_data, OpenAPI_notification_event_type_e event, ogs_sbi_nf_instance_t *nf_instance) { @@ -32,14 +32,14 @@ OpenAPI_notification_data_t *NotificationData = NULL; - ogs_assert(subscription); + ogs_assert(subscription_data); ogs_assert(event); ogs_assert(nf_instance); ogs_assert(nf_instance->id); memset(&message, 0, sizeof(message)); message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST; - message.h.uri = subscription->notification_uri; + message.h.uri = subscription_data->notification_uri; message.http.accept = (char *)OGS_SBI_CONTENT_PROBLEM_TYPE; @@ -54,15 +54,20 @@ memset(&header, 0, sizeof(header)); header.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; header.api.version = (char *)OGS_SBI_API_V1; - header.resource.component0 = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; + header.resource.component0 = (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; header.resource.component1 = nf_instance->id; NotificationData->nf_instance_uri = ogs_sbi_server_uri(server, &header); ogs_expect_or_return_val(NotificationData->nf_instance_uri, NULL); if (event != OpenAPI_notification_event_type_NF_DEREGISTERED) { - ogs_expect_or_return_val(nf_instance->nf_profile, NULL); - NotificationData->nf_profile = nf_instance->nf_profile; + NotificationData->nf_profile = + ogs_nnrf_nfm_build_nf_profile( + nf_instance, + subscription_data->subscr_cond.service_name, + NULL, + subscription_data->requester_features); + ogs_expect_or_return_val(NotificationData->nf_profile, NULL); } message.NotificationData = NotificationData; @@ -70,6 +75,9 @@ request = ogs_sbi_build_request(&message); ogs_expect_or_return_val(request, NULL); + if (NotificationData->nf_profile) + ogs_nnrf_nfm_free_nf_profile(NotificationData->nf_profile); + ogs_free(NotificationData->nf_instance_uri); ogs_free(NotificationData);
View file
open5gs_2.4.9.tar.xz/src/nrf/nnrf-build.h -> open5gs_2.4.10.tar.xz/src/nrf/nnrf-build.h
Changed
@@ -28,7 +28,7 @@ #endif ogs_sbi_request_t *nrf_nnrf_nfm_build_nf_status_notify( - ogs_sbi_subscription_t *subscription, + ogs_sbi_subscription_data_t *subscription_data, OpenAPI_notification_event_type_e event, ogs_sbi_nf_instance_t *nf_instance);
View file
open5gs_2.4.9.tar.xz/src/nrf/nnrf-handler.c -> open5gs_2.4.10.tar.xz/src/nrf/nnrf-handler.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -23,7 +23,6 @@ ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) { int status; - bool handled; ogs_sbi_response_t *response = NULL; OpenAPI_nf_profile_t *NFProfile = NULL; @@ -41,14 +40,7 @@ return false; } - /* Store NFProfile */ - nf_instance->nf_profile = OpenAPI_nf_profile_copy( - nf_instance->nf_profile, NFProfile); - - /* ogs_sbi_nnrf_handle_nf_profile() sends error response */ - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) return false; + ogs_sbi_nnrf_handle_nf_profile(nf_instance, NFProfile); if (OGS_FSM_CHECK(&nf_instance->sm, nrf_nf_state_will_register)) { recvmsg->http.location = recvmsg->h.uri; @@ -173,7 +165,7 @@ ogs_sbi_response_t *response = NULL; OpenAPI_subscription_data_t *SubscriptionData = NULL; OpenAPI_subscription_data_subscr_cond_t *SubscrCond = NULL; - ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; ogs_sbi_client_t *client = NULL; ogs_sockaddr_t *addr = NULL; @@ -202,15 +194,16 @@ ogs_uuid_get(&uuid); ogs_uuid_format(id, &uuid); - subscription = ogs_sbi_subscription_add(); - ogs_assert(subscription); - ogs_sbi_subscription_set_id(subscription, id); - ogs_assert(subscription->id); + subscription_data = ogs_sbi_subscription_data_add(); + ogs_assert(subscription_data); + ogs_sbi_subscription_data_set_id(subscription_data, id); + ogs_assert(subscription_data->id); + subscription_data->req_nf_type = SubscriptionData->req_nf_type; if (SubscriptionData->req_nf_instance_id) { - subscription->req_nf_instance_id = + subscription_data->req_nf_instance_id = ogs_strdup(SubscriptionData->req_nf_instance_id); - ogs_expect_or_return_val(subscription->req_nf_instance_id, NULL); + ogs_expect_or_return_val(subscription_data->req_nf_instance_id, NULL); } if (SubscriptionData->subscription_id) { @@ -218,25 +211,45 @@ SubscriptionData->subscription_id); ogs_free(SubscriptionData->subscription_id); } - SubscriptionData->subscription_id = ogs_strdup(subscription->id); + SubscriptionData->subscription_id = ogs_strdup(subscription_data->id); ogs_expect_or_return_val(SubscriptionData->subscription_id, NULL); + if (SubscriptionData->requester_features) { + subscription_data->requester_features = + ogs_uint64_from_string(SubscriptionData->requester_features); + + /* No need to send SubscriptionData->requester_features to the NF */ + ogs_free(SubscriptionData->requester_features); + SubscriptionData->requester_features = NULL; + } else { + subscription_data->requester_features = 0; + } + + OGS_SBI_FEATURES_SET(subscription_data->nrf_supported_features, + OGS_SBI_NNRF_NFM_SERVICE_MAP); + SubscriptionData->nrf_supported_features = + ogs_uint64_to_string(subscription_data->nrf_supported_features); + ogs_expect_or_return_val(SubscriptionData->nrf_supported_features, NULL); + SubscrCond = SubscriptionData->subscr_cond; if (SubscrCond) { - subscription->subscr_cond.nf_type = SubscrCond->nf_type; + subscription_data->subscr_cond.nf_type = SubscrCond->nf_type; + if (SubscrCond->service_name) + subscription_data->subscr_cond.service_name = + ogs_strdup(SubscrCond->service_name); } - subscription->notification_uri = + subscription_data->notification_uri = ogs_strdup(SubscriptionData->nf_status_notification_uri); - ogs_assert(subscription->notification_uri); + ogs_assert(subscription_data->notification_uri); - addr = ogs_sbi_getaddr_from_uri(subscription->notification_uri); + addr = ogs_sbi_getaddr_from_uri(subscription_data->notification_uri); if (!addr) { ogs_assert(true == ogs_sbi_server_send_error( stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Invalid URI", subscription->notification_uri)); - ogs_sbi_subscription_remove(subscription); + recvmsg, "Invalid URI", subscription_data->notification_uri)); + ogs_sbi_subscription_data_remove(subscription_data); return false; } @@ -245,21 +258,21 @@ client = ogs_sbi_client_add(addr); ogs_assert(client); } - OGS_SBI_SETUP_CLIENT(subscription, client); + OGS_SBI_SETUP_CLIENT(subscription_data, client); ogs_freeaddrinfo(addr); - if (subscription->time.validity_duration) { + if (subscription_data->time.validity_duration) { SubscriptionData->validity_time = ogs_sbi_localtime_string( ogs_time_now() + ogs_time_from_sec( - subscription->time.validity_duration)); + subscription_data->time.validity_duration)); ogs_assert(SubscriptionData->validity_time); - subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - nrf_timer_subscription_validity, subscription); - ogs_assert(subscription->t_validity); - ogs_timer_start(subscription->t_validity, - ogs_time_from_sec(subscription->time.validity_duration)); + subscription_data->t_validity = ogs_timer_add(ogs_app()->timer_mgr, + nrf_timer_subscription_validity, subscription_data); + ogs_assert(subscription_data->t_validity); + ogs_timer_start(subscription_data->t_validity, + ogs_time_from_sec(subscription_data->time.validity_duration)); } recvmsg->http.location = recvmsg->h.uri; @@ -275,14 +288,15 @@ bool nrf_nnrf_handle_nf_status_unsubscribe( ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) { - ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; ogs_assert(stream); ogs_assert(recvmsg); - subscription = ogs_sbi_subscription_find(recvmsg->h.resource.component1); - if (subscription) { + subscription_data = ogs_sbi_subscription_data_find( + recvmsg->h.resource.component1); + if (subscription_data) { ogs_sbi_response_t *response = NULL; - ogs_sbi_subscription_remove(subscription); + ogs_sbi_subscription_data_remove(subscription_data); response = ogs_sbi_build_response( recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); @@ -327,7 +341,7 @@ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { if (recvmsg->param.nf_type && - recvmsg->param.nf_type != nf_instance->nf_type) + recvmsg->param.nf_type != nf_instance->nf_type) continue; if (!recvmsg->param.limit || @@ -367,6 +381,7 @@ ogs_sbi_message_t sendmsg; ogs_sbi_response_t *response = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; + uint64_t supported_features = 0; ogs_assert(stream); ogs_assert(recvmsg); @@ -384,13 +399,17 @@ memset(&sendmsg, 0, sizeof(sendmsg)); - ogs_assert(nf_instance->nf_profile); - sendmsg.NFProfile = nf_instance->nf_profile; + OGS_SBI_FEATURES_SET(supported_features, OGS_SBI_NNRF_NFM_SERVICE_MAP); + sendmsg.NFProfile = ogs_nnrf_nfm_build_nf_profile( + nf_instance, NULL, NULL, supported_features); + ogs_expect_or_return_val(sendmsg.NFProfile, NULL); response = ogs_sbi_build_response(&sendmsg, OGS_SBI_HTTP_STATUS_OK); ogs_assert(response); ogs_assert(true == ogs_sbi_server_send_response(stream, response)); + ogs_nnrf_nfm_free_nf_profile(sendmsg.NFProfile); + return true; } @@ -403,6 +422,9 @@ ogs_sbi_discovery_option_t *discovery_option = NULL; OpenAPI_search_result_t *SearchResult = NULL; + OpenAPI_nf_profile_t *NFProfile = NULL; + OpenAPI_lnode_t *node = NULL; + uint64_t supported_features = 0; int i; ogs_assert(stream); @@ -462,28 +484,33 @@ if (nf_instance->nf_type != recvmsg->param.target_nf_type) continue; - if (discovery_option) { - if (discovery_option->target_nf_instance_id && - strcmp(nf_instance->id, - discovery_option->target_nf_instance_id) != 0) - continue; - } + if (ogs_sbi_nf_instance_is_allowed_nf_type( + nf_instance, recvmsg->param.requester_nf_type) == false) + continue; - if (!recvmsg->param.limit || - (recvmsg->param.limit && i < recvmsg->param.limit)) { + if (discovery_option && + ogs_sbi_discovery_option_is_matched( + nf_instance, + recvmsg->param.requester_nf_type, + discovery_option) == false) + continue; - ogs_debug("%s:%d NF-Discovered NF-Type:%s,NF-Status:%s," - "IPv4:%d,IPv6:%d", nf_instance->id, i, - OpenAPI_nf_type_ToString(nf_instance->nf_type), - OpenAPI_nf_status_ToString(nf_instance->nf_status), - nf_instance->num_of_ipv4, nf_instance->num_of_ipv6); - - ogs_assert(nf_instance->nf_profile); - OpenAPI_list_add(SearchResult->nf_instances, - nf_instance->nf_profile); + if (recvmsg->param.limit && i >= recvmsg->param.limit) + break; - i++; - } + ogs_debug("%s:%d NF-Discovered NF-Type:%s,NF-Status:%s," + "IPv4:%d,IPv6:%d", nf_instance->id, i, + OpenAPI_nf_type_ToString(nf_instance->nf_type), + OpenAPI_nf_status_ToString(nf_instance->nf_status), + nf_instance->num_of_ipv4, nf_instance->num_of_ipv6); + + OGS_SBI_FEATURES_SET( + supported_features, OGS_SBI_NNRF_NFM_SERVICE_MAP); + NFProfile = ogs_nnrf_nfm_build_nf_profile( + nf_instance, NULL, discovery_option, supported_features); + OpenAPI_list_add(SearchResult->nf_instances, NFProfile); + + i++; } if (recvmsg->param.limit) SearchResult->num_nf_inst_complete = i; @@ -498,6 +525,10 @@ ogs_assert(response); ogs_assert(true == ogs_sbi_server_send_response(stream, response)); + OpenAPI_list_for_each(SearchResult->nf_instances, node) { + NFProfile = node->data; + if (NFProfile) ogs_nnrf_nfm_free_nf_profile(NFProfile); + } OpenAPI_list_free(SearchResult->nf_instances); if (sendmsg.http.cache_control)
View file
open5gs_2.4.9.tar.xz/src/nrf/nrf-sm.c -> open5gs_2.4.10.tar.xz/src/nrf/nrf-sm.c
Changed
@@ -43,7 +43,7 @@ ogs_sbi_request_t *request = NULL; ogs_sbi_message_t message; ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; ogs_assert(e); @@ -251,11 +251,12 @@ break; case NRF_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->subscription; - ogs_assert(subscription); + subscription_data = e->subscription_data; + ogs_assert(subscription_data); - ogs_info("%s Subscription validity expired", subscription->id); - ogs_sbi_subscription_remove(subscription); + ogs_info("%s Subscription validity expired", + subscription_data->id); + ogs_sbi_subscription_data_remove(subscription_data); break; default:
View file
open5gs_2.4.9.tar.xz/src/nrf/sbi-path.c -> open5gs_2.4.10.tar.xz/src/nrf/sbi-path.c
Changed
@@ -80,26 +80,6 @@ int nrf_sbi_open(void) { - ogs_sbi_nf_instance_t *nf_instance = NULL; - - /* Initialize SCP NF Instance */ - nf_instance = ogs_sbi_self()->scp_instance; - if (nf_instance) { - ogs_sbi_client_t *client = NULL; - - /* Client callback is only used when NF sends to SCP */ - client = nf_instance->client; - ogs_assert(client); - client->cb = client_notify_cb; - } - - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = nrf_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)nrf_nf_state_registered; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR; @@ -112,19 +92,20 @@ ogs_sbi_server_stop_all(); } -bool nrf_nnrf_nfm_send_nf_status_notify(ogs_sbi_subscription_t *subscription, +bool nrf_nnrf_nfm_send_nf_status_notify( + ogs_sbi_subscription_data_t *subscription_data, OpenAPI_notification_event_type_e event, ogs_sbi_nf_instance_t *nf_instance) { ogs_sbi_request_t *request = NULL; ogs_sbi_client_t *client = NULL; - ogs_assert(subscription); - client = subscription->client; + ogs_assert(subscription_data); + client = subscription_data->client; ogs_assert(client); request = nrf_nnrf_nfm_build_nf_status_notify( - subscription, event, nf_instance); + subscription_data, event, nf_instance); ogs_expect_or_return_val(request, false); return ogs_sbi_scp_send_request(client, client_notify_cb, request, NULL); @@ -134,23 +115,41 @@ OpenAPI_notification_event_type_e event, ogs_sbi_nf_instance_t *nf_instance) { - ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; ogs_assert(nf_instance); - ogs_list_for_each(&ogs_sbi_self()->subscription_list, subscription) { + ogs_list_for_each( + &ogs_sbi_self()->subscription_data_list, subscription_data) { + + if (subscription_data->req_nf_instance_id && + strcmp(subscription_data->req_nf_instance_id, nf_instance->id) == 0) + continue; - if (subscription->req_nf_instance_id && - strcmp(subscription->req_nf_instance_id, nf_instance->id) == 0) + if (subscription_data->subscr_cond.nf_type && + subscription_data->subscr_cond.nf_type != nf_instance->nf_type) continue; - if (subscription->subscr_cond.nf_type && - subscription->subscr_cond.nf_type != nf_instance->nf_type) + if (subscription_data->req_nf_type && + ogs_sbi_nf_instance_is_allowed_nf_type( + nf_instance, subscription_data->req_nf_type) == false) continue; + if (subscription_data->subscr_cond.service_name) { + ogs_sbi_nf_service_t *nf_service = + ogs_sbi_nf_service_find_by_name(nf_instance, + subscription_data->subscr_cond.service_name); + if (nf_service == NULL) continue; + + if (subscription_data->req_nf_type && + ogs_sbi_nf_service_is_allowed_nf_type( + nf_service, subscription_data->req_nf_type) == false) + continue; + } + ogs_expect_or_return_val(true == nrf_nnrf_nfm_send_nf_status_notify( - subscription, event, nf_instance), + subscription_data, event, nf_instance), false); }
View file
open5gs_2.4.9.tar.xz/src/nrf/sbi-path.h -> open5gs_2.4.10.tar.xz/src/nrf/sbi-path.h
Changed
@@ -30,7 +30,8 @@ int nrf_sbi_open(void); void nrf_sbi_close(void); -bool nrf_nnrf_nfm_send_nf_status_notify(ogs_sbi_subscription_t *subscription, +bool nrf_nnrf_nfm_send_nf_status_notify( + ogs_sbi_subscription_data_t *subscription_data, OpenAPI_notification_event_type_e event, ogs_sbi_nf_instance_t *nf_instance); bool nrf_nnrf_nfm_send_nf_status_notify_all(
View file
open5gs_2.4.9.tar.xz/src/nrf/timer.c -> open5gs_2.4.10.tar.xz/src/nrf/timer.c
Changed
@@ -19,16 +19,6 @@ #include "context.h" -static nrf_timer_cfg_t g_nrf_timer_cfgMAX_NUM_OF_NRF_TIMER = { - /* Nothing */ -}; - -nrf_timer_cfg_t *nrf_timer_cfg(nrf_timer_e id) -{ - ogs_assert(id < MAX_NUM_OF_NRF_TIMER); - return &g_nrf_timer_cfgid; -} - const char *nrf_timer_get_name(nrf_timer_e id) { switch (id) { @@ -58,7 +48,7 @@ case NRF_TIMER_SUBSCRIPTION_VALIDITY: e = nrf_event_new(NRF_EVT_SBI_TIMER); e->timer_id = timer_id; - e->subscription = data; + e->subscription_data = data; break; default: ogs_fatal("Unknown timer id%d", timer_id); @@ -82,8 +72,3 @@ { timer_send_event(NRF_TIMER_SUBSCRIPTION_VALIDITY, data); } - -void nrf_timer_sbi_client_wait_expire(void *data) -{ - timer_send_event(NRF_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.tar.xz/src/nrf/timer.h -> open5gs_2.4.10.tar.xz/src/nrf/timer.h
Changed
@@ -38,18 +38,10 @@ } nrf_timer_e; -typedef struct nrf_timer_cfg_s { - int max_count; - ogs_time_t duration; -} nrf_timer_cfg_t; - -nrf_timer_cfg_t *nrf_timer_cfg(nrf_timer_e id); - const char *nrf_timer_get_name(nrf_timer_e id); void nrf_timer_nf_instance_no_heartbeat(void *data); void nrf_timer_subscription_validity(void *data); -void nrf_timer_sbi_client_wait_expire(void *data); #ifdef __cplusplus }
View file
open5gs_2.4.9.tar.xz/src/nssf/context.c -> open5gs_2.4.10.tar.xz/src/nssf/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -96,6 +96,10 @@ ogs_assert(nssf_key); if (!strcmp(nssf_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(nssf_key, "service_name")) { + /* handle config in sbi library */ + } else if (!strcmp(nssf_key, "discovery")) { + /* handle config in sbi library */ } else if (!strcmp(nssf_key, "nsi")) { ogs_list_t list, list6; ogs_socknode_t *node = NULL, *node6 = NULL;
View file
open5gs_2.4.9.tar.xz/src/nssf/context.h -> open5gs_2.4.10.tar.xz/src/nssf/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -24,7 +24,6 @@ #include "ogs-sbi.h" #include "nssf-sm.h" -#include "timer.h" #ifdef __cplusplus extern "C" { @@ -41,22 +40,6 @@ ogs_list_t nsi_list; /* NSI List */ } nssf_context_t; -#define NSSF_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - nssf_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, nssf_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } while(0) - void nssf_context_init(void); void nssf_context_final(void); nssf_context_t *nssf_self(void);
View file
open5gs_2.4.9.tar.xz/src/nssf/event.c -> open5gs_2.4.10.tar.xz/src/nssf/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,60 +18,42 @@ */ #include "event.h" -#include "context.h" -static OGS_POOL(pool, nssf_event_t); - -void nssf_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); -} - -void nssf_event_final(void) -{ - ogs_pool_final(&pool); -} - -nssf_event_t *nssf_event_new(nssf_event_e id) +nssf_event_t *nssf_event_new(int id) { nssf_event_t *e = NULL; - ogs_pool_alloc(&pool, &e); + e = ogs_event_size(id, sizeof(nssf_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void nssf_event_free(nssf_event_t *e) -{ - ogs_assert(e); - ogs_pool_free(&pool, e); -} - const char *nssf_event_get_name(nssf_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { - case OGS_FSM_ENTRY_SIG: + switch (e->h.id) { + case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; - case OGS_FSM_EXIT_SIG: + case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case NSSF_EVT_SBI_SERVER: - return "NSSF_EVT_SBI_SERVER"; - case NSSF_EVT_SBI_CLIENT: - return "NSSF_EVT_SBI_CLIENT"; - case NSSF_EVT_SBI_TIMER: - return "NSSF_EVT_SBI_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; - default: - break; + default: + break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.tar.xz/src/nssf/event.h -> open5gs_2.4.10.tar.xz/src/nssf/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,49 +20,19 @@ #ifndef NSSF_EVENT_H #define NSSF_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.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 enum { - NSSF_EVT_BASE = OGS_FSM_USER_SIG, - - NSSF_EVT_SBI_SERVER, - NSSF_EVT_SBI_CLIENT, - NSSF_EVT_SBI_TIMER, - - NSSF_EVT_TOP, - -} nssf_event_e; +typedef struct nssf_ue_s nssf_ue_t; typedef struct nssf_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; - - ogs_timer_t *timer; + ogs_event_t h; } nssf_event_t; -void nssf_event_init(void); -void nssf_event_final(void); - -nssf_event_t *nssf_event_new(nssf_event_e id); -void nssf_event_free(nssf_event_t *e); +nssf_event_t *nssf_event_new(int id); const char *nssf_event_get_name(nssf_event_t *e);
View file
open5gs_2.4.9.tar.xz/src/nssf/init.c -> open5gs_2.4.10.tar.xz/src/nssf/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,7 +30,6 @@ ogs_sbi_context_init(); nssf_context_init(); - nssf_event_init(); rv = ogs_sbi_context_parse_config("nssf", "nrf", "scp"); if (rv != OGS_OK) return rv; @@ -61,7 +60,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - nssf_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -87,8 +86,6 @@ nssf_context_final(); ogs_sbi_context_final(); - - nssf_event_final(); /* Destroy event */ } static void nssf_main(void *data) @@ -96,8 +93,7 @@ ogs_fsm_t nssf_sm; int rv; - ogs_fsm_create(&nssf_sm, nssf_state_initial, nssf_state_final); - ogs_fsm_init(&nssf_sm, 0); + ogs_fsm_init(&nssf_sm, nssf_state_initial, nssf_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -130,11 +126,10 @@ ogs_assert(e); ogs_fsm_dispatch(&nssf_sm, e); - nssf_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&nssf_sm, 0); - ogs_fsm_delete(&nssf_sm); }
View file
open5gs_2.4.9.tar.xz/src/nssf/meson.build -> open5gs_2.4.10.tar.xz/src/nssf/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -18,11 +18,6 @@ libnssf_sources = files(''' context.c event.c - timer.c - - nnrf-build.c - nnrf-handler.c - nf-sm.c nnssf-handler.c @@ -34,14 +29,12 @@ libnssf = static_library('nssf', sources : libnssf_sources, - dependencies : libapp_dep, - libsbi_dep, + dependencies : libsbi_dep, install : false) libnssf_dep = declare_dependency( link_with : libnssf, - dependencies : libapp_dep, - libsbi_dep) + dependencies : libsbi_dep) nssf_sources = files(''' app.c
View file
open5gs_2.4.9.tar.xz/src/nssf/nssf-sm.c -> open5gs_2.4.10.tar.xz/src/nssf/nssf-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -46,7 +46,7 @@ ogs_sbi_request_t *request = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; ogs_sbi_response_t *response = NULL; ogs_sbi_message_t message; @@ -54,17 +54,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case NSSF_EVT_SBI_SERVER: - request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + request = e->h.sbi.request; ogs_assert(request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&message, request); @@ -138,10 +138,10 @@ ogs_sbi_message_free(&message); break; - case NSSF_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - response = e->sbi.response; + response = e->h.sbi.response; ogs_assert(response); rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { @@ -163,43 +163,43 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; - ogs_assert(subscription); + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); 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) { - nssf_nnrf_handle_nf_status_subscribe( - subscription, &message); + ogs_nnrf_handle_nf_status_subscribe( + subscription_data, &message); } else { ogs_error("%s HTTP response error %d", - subscription->id, message.res_status); + subscription_data->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); + ogs_sbi_subscription_data_remove(subscription_data); } else { ogs_error("%s HTTP response error %d", - subscription->id, message.res_status); + subscription_data->id, message.res_status); } break; DEFAULT ogs_error("%s Invalid HTTP method %s", - subscription->id, message.h.method); + subscription_data->id, message.h.method); ogs_assert_if_reached(); END break; @@ -220,43 +220,40 @@ ogs_sbi_response_free(response); break; - case NSSF_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case NSSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case NSSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case NSSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case NSSF_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.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, nssf_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s:%s State machine exception %d", OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case NSSF_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; - ogs_assert(subscription); + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); - ogs_assert(ogs_sbi_self()->nf_instance); ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client, - ogs_sbi_self()->nf_instance->nf_type, - subscription->req_nf_instance_id, - subscription->subscr_cond.nf_type)); + ogs_nnrf_nfm_send_nf_status_subscribe(subscription_data)); - ogs_info("%s Subscription validity expired", subscription->id); - ogs_sbi_subscription_remove(subscription); + ogs_info("Subscription validity expired %s", + subscription_data->id); + ogs_sbi_subscription_data_remove(subscription_data); break; default: ogs_error("Unknown timer%s:%d", - nssf_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break;
View file
open5gs_2.4.9.tar.xz/src/nssf/nssf-sm.h -> open5gs_2.4.10.tar.xz/src/nssf/nssf-sm.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,16 +30,6 @@ void nssf_state_final(ogs_fsm_t *s, nssf_event_t *e); void nssf_state_operational(ogs_fsm_t *s, nssf_event_t *e); -void nssf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void nssf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void nssf_nf_state_initial(ogs_fsm_t *s, nssf_event_t *e); -void nssf_nf_state_final(ogs_fsm_t *s, nssf_event_t *e); -void nssf_nf_state_will_register(ogs_fsm_t *s, nssf_event_t *e); -void nssf_nf_state_registered(ogs_fsm_t *s, nssf_event_t *e); -void nssf_nf_state_de_registered(ogs_fsm_t *s, nssf_event_t *e); -void nssf_nf_state_exception(ogs_fsm_t *s, nssf_event_t *e); - #define nssf_sm_debug(__pe) \ ogs_debug("%s(): %s", __func__, nssf_event_get_name(__pe))
View file
open5gs_2.4.9.tar.xz/src/nssf/sbi-path.c -> open5gs_2.4.10.tar.xz/src/nssf/sbi-path.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -27,17 +27,17 @@ ogs_assert(request); ogs_assert(data); - e = nssf_event_new(NSSF_EVT_SBI_SERVER); + e = nssf_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - nssf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -58,16 +58,16 @@ ogs_assert(response); - e = nssf_event_new(NSSF_EVT_SBI_CLIENT); + e = nssf_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - nssf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -82,42 +82,39 @@ /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_NSSF); ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AMF); + ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_SCP); /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V2, - (char*)OGS_SBI_API_V2_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + if (ogs_sbi_nf_service_is_available( + OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V2, OGS_SBI_API_V2_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + } /* Initialize NRF NF Instance */ - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_sbi_client_t *client = 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. */ - nssf_nf_fsm_init(nf_instance); - } + nf_instance = ogs_sbi_self()->nrf_instance; + if (nf_instance) { + ogs_sbi_client_t *client = 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. */ + ogs_sbi_nf_fsm_init(nf_instance); } - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = nssf_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)nssf_nf_state_registered; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR;
View file
open5gs_2.4.9.tar.xz/src/nssf/sbi-path.h -> open5gs_2.4.10.tar.xz/src/nssf/sbi-path.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,7 @@ #ifndef NSSF_SBI_PATH_H #define NSSF_SBI_PATH_H -#include "nnrf-build.h" +#include "context.h" #ifdef __cplusplus extern "C" {
View file
open5gs_2.4.9.tar.xz/src/pcf/am-sm.c -> open5gs_2.4.10.tar.xz/src/pcf/am-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -50,17 +50,17 @@ pcf_ue = e->pcf_ue; ogs_assert(pcf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case PCF_EVT_SBI_SERVER: - message = e->sbi.message; + case OGS_EVENT_SBI_SERVER: + message = e->h.sbi.message; ogs_assert(message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(message->h.method) @@ -88,10 +88,10 @@ END break; - case PCF_EVT_SBI_CLIENT: - message = e->sbi.message; + case OGS_EVENT_SBI_CLIENT: + message = e->h.sbi.message; ogs_assert(message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(message->h.service.name) @@ -161,7 +161,7 @@ pcf_ue = e->pcf_ue; ogs_assert(pcf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; @@ -185,7 +185,7 @@ pcf_ue = e->pcf_ue; ogs_assert(pcf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break;
View file
open5gs_2.4.9.tar.xz/src/pcf/context.c -> open5gs_2.4.10.tar.xz/src/pcf/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -117,6 +117,10 @@ ogs_assert(pcf_key); if (!strcmp(pcf_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(pcf_key, "service_name")) { + /* handle config in sbi library */ + } else if (!strcmp(pcf_key, "discovery")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", pcf_key); } @@ -157,8 +161,7 @@ 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_fsm_init(&pcf_ue->sm, pcf_am_state_initial, pcf_am_state_final, &e); ogs_list_add(&self.pcf_ue_list, pcf_ue); @@ -176,7 +179,6 @@ 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); @@ -268,8 +270,7 @@ 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_fsm_init(&sess->sm, pcf_sm_state_initial, pcf_sm_state_final, &e); ogs_list_add(&pcf_ue->sess_list, sess); @@ -288,7 +289,6 @@ 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); @@ -442,7 +442,7 @@ ogs_list_for_each(&pcf_ue->sess_list, sess) if (sess->s_nssai.sst == s_nssai->sst && - sess->dnn && strcmp(sess->dnn, dnn) == 0) + sess->dnn && ogs_strcasecmp(sess->dnn, dnn) == 0) number_of_sessions++; return number_of_sessions;
View file
open5gs_2.4.9.tar.xz/src/pcf/context.h -> open5gs_2.4.10.tar.xz/src/pcf/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -26,7 +26,6 @@ #include "ogs-dbi.h" #include "pcf-sm.h" -#include "timer.h" #ifdef __cplusplus extern "C" { @@ -47,22 +46,6 @@ ogs_hash_t *ipv6prefix_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;
View file
open5gs_2.4.9.tar.xz/src/pcf/event.c -> open5gs_2.4.10.tar.xz/src/pcf/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,60 +18,42 @@ */ #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 *pcf_event_new(int id) { pcf_event_t *e = NULL; - ogs_pool_alloc(&pool, &e); + e = ogs_event_size(id, sizeof(pcf_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.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) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { - case OGS_FSM_ENTRY_SIG: + switch (e->h.id) { + case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; - case OGS_FSM_EXIT_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"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; - default: - break; + default: + break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.tar.xz/src/pcf/event.h -> open5gs_2.4.10.tar.xz/src/pcf/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,57 +20,25 @@ #ifndef PCF_EVENT_H #define PCF_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.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 struct pcf_app_s pcf_app_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; + ogs_event_t h; pcf_ue_t *pcf_ue; pcf_sess_t *sess; pcf_app_t *app; - - 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); +pcf_event_t *pcf_event_new(int id); const char *pcf_event_get_name(pcf_event_t *e);
View file
open5gs_2.4.9.tar.xz/src/pcf/init.c -> open5gs_2.4.10.tar.xz/src/pcf/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,7 +30,6 @@ ogs_sbi_context_init(); pcf_context_init(); - pcf_event_init(); rv = ogs_sbi_context_parse_config("pcf", "nrf", "scp"); if (rv != OGS_OK) return rv; @@ -64,7 +63,7 @@ /* 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); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -92,8 +91,6 @@ pcf_context_final(); ogs_sbi_context_final(); - - pcf_event_final(); /* Destroy event */ } static void pcf_main(void *data) @@ -101,8 +98,7 @@ ogs_fsm_t pcf_sm; int rv; - ogs_fsm_create(&pcf_sm, pcf_state_initial, pcf_state_final); - ogs_fsm_init(&pcf_sm, 0); + ogs_fsm_init(&pcf_sm, pcf_state_initial, pcf_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -135,11 +131,10 @@ ogs_assert(e); ogs_fsm_dispatch(&pcf_sm, e); - pcf_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&pcf_sm, 0); - ogs_fsm_delete(&pcf_sm); }
View file
open5gs_2.4.9.tar.xz/src/pcf/meson.build -> open5gs_2.4.10.tar.xz/src/pcf/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -18,12 +18,8 @@ libpcf_sources = files(''' context.c event.c - timer.c - nnrf-build.c nnrf-handler.c - nf-sm.c - npcf-handler.c nudr-build.c @@ -47,17 +43,13 @@ libpcf = static_library('pcf', sources : libpcf_sources, - dependencies : libcrypt_dep, - libapp_dep, - libdbi_dep, + dependencies : libdbi_dep, libsbi_dep, install : false) libpcf_dep = declare_dependency( link_with : libpcf, - dependencies : libcrypt_dep, - libapp_dep, - libdbi_dep, + dependencies : libdbi_dep, libsbi_dep) pcf_sources = files('''
View file
open5gs_2.4.9.tar.xz/src/pcf/nbsf-build.c -> open5gs_2.4.10.tar.xz/src/pcf/nbsf-build.c
Changed
@@ -36,15 +36,14 @@ ogs_sbi_nf_service_t *nf_service = NULL; int i; -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - int fqdn_len; - char fqdnOGS_MAX_FQDN_LEN; -#endif ogs_assert(sess); pcf_ue = sess->pcf_ue; ogs_assert(pcf_ue); + nf_instance = data; + ogs_assert(nf_instance); + memset(&message, 0, sizeof(message)); message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST; message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT; @@ -63,23 +62,12 @@ ogs_expect_or_return_val(sess->dnn, NULL); PcfBinding.dnn = sess->dnn; - nf_instance = ogs_sbi_self()->nf_instance; - ogs_expect_or_return_val(nf_instance, NULL); - nf_service = ogs_list_first(&nf_instance->nf_service_list); + nf_service = ogs_sbi_nf_service_find_by_name( + nf_instance, (char *)OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION); ogs_expect_or_return_val(nf_service, NULL); - if (nf_service->fqdn) { -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - memset(fqdn, 0, sizeof(fqdn)); - fqdn_len = ogs_fqdn_build(fqdn, - nf_service->fqdn, strlen(nf_service->fqdn)); - PcfBinding.pcf_fqdn = ogs_memdup(fqdn, fqdn_len+1); - ogs_expect_or_return_val(PcfBinding.pcf_fqdn, NULL); - PcfBinding.pcf_fqdnfqdn_len = 0; -#else + if (nf_service->fqdn) PcfBinding.pcf_fqdn = ogs_strdup(nf_service->fqdn); -#endif - } PcfIpEndPointList = OpenAPI_list_create(); ogs_assert(PcfIpEndPointList);
View file
open5gs_2.4.9.tar.xz/src/pcf/nnrf-handler.c -> open5gs_2.4.10.tar.xz/src/pcf/nnrf-handler.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,256 +20,32 @@ #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 *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - 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 *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->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_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - 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 *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - pcf_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - nf_instance->reference_count++; - - 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", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - PCF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - PCF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - PCF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -} - void pcf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; - OpenAPI_nf_type_e target_nf_type = 0; + ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; + ogs_sbi_stream_t *stream = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; + pcf_ue_t *pcf_ue = NULL; + pcf_sess_t *sess = NULL; + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; OpenAPI_search_result_t *SearchResult = NULL; - OpenAPI_lnode_t *node = NULL; - bool handled; ogs_assert(recvmsg); ogs_assert(xact); sbi_object = xact->sbi_object; ogs_assert(sbi_object); - target_nf_type = xact->target_nf_type; + service_type = xact->service_type; + ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); ogs_assert(target_nf_type); discovery_option = xact->discovery_option; + stream = xact->assoc_stream; SearchResult = recvmsg->SearchResult; if (!SearchResult) { @@ -277,68 +53,50 @@ 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(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); - - pcf_nf_fsm_init(nf_instance); - - ogs_info("%s (NF-discover) NF registered", nf_instance->id); - } else { - nf_instance->reference_count++; - - 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; - } - - /* TIME : Update validity from NRF */ - if (SearchResult->is_validity_period && - 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); + if (sbi_object->type == OGS_SBI_OBJ_UE_TYPE) { + pcf_ue = (pcf_ue_t *)sbi_object; + ogs_assert(pcf_ue); + } else if (sbi_object->type == OGS_SBI_OBJ_SESS_TYPE) { + sess = (pcf_sess_t *)sbi_object; + ogs_assert(sess); + pcf_ue = sess->pcf_ue; + ogs_assert(pcf_ue); + } else { + ogs_fatal("(NF discover) Not implemented %s:%d", + ogs_sbi_service_type_to_name(service_type), sbi_object->type); + ogs_assert_if_reached(); + } - ogs_info("%s (NF-discover) NF Profile updated", nf_instance->id); - } + ogs_nnrf_handle_nf_discover_search_result(SearchResult); + + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (!nf_instance) { + ogs_error("%s:%d (NF discover) No %s", + pcf_ue ? pcf_ue->supi : "Unknown", + sess ? sess->psi : 0, + ogs_sbi_service_type_to_name(service_type)); + return; } - ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_arrayservice_type, nf_instance); - ogs_expect(true == pcf_sbi_send_request(sbi_object, target_nf_type, xact)); + switch (service_type) { + case OGS_SBI_SERVICE_TYPE_NPCF_POLICYAUTHORIZATION: + ogs_sbi_xact_remove(xact); + + ogs_assert(sess); + ogs_assert(stream); + ogs_assert(true == + pcf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, NULL, + pcf_nbsf_management_build_register, + sess, stream, nf_instance)); + break; + default: + ogs_assert(xact->request); + ogs_expect(true == pcf_sbi_send_request(nf_instance, xact)); + break; + } }
View file
open5gs_2.4.9.tar.xz/src/pcf/nnrf-handler.h -> open5gs_2.4.10.tar.xz/src/pcf/nnrf-handler.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -26,14 +26,6 @@ extern "C" { #endif -void pcf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void pcf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool pcf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - void pcf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg);
View file
open5gs_2.4.9.tar.xz/src/pcf/npcf-handler.c -> open5gs_2.4.10.tar.xz/src/pcf/npcf-handler.c
Changed
@@ -148,7 +148,7 @@ pcf_ue->subscribed_ue_ambr, PolicyAssociationRequest->ue_ambr); ogs_assert(true == - pcf_ue_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL, + pcf_ue_sbi_discover_and_send(OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL, pcf_nudr_dr_build_query_am_data, pcf_ue, stream, NULL)); return true; @@ -164,8 +164,6 @@ OpenAPI_sm_policy_context_data_t *SmPolicyContextData = NULL; OpenAPI_snssai_t *sliceInfo = NULL; - uint64_t supported_features = 0; - ogs_sbi_client_t *client = NULL; ogs_sockaddr_t *addr = NULL; @@ -250,7 +248,7 @@ } if (SmPolicyContextData->supp_feat) { - supported_features = + uint64_t supported_features = ogs_uint64_from_string(SmPolicyContextData->supp_feat); sess->smpolicycontrol_features &= supported_features; } else { @@ -298,7 +296,8 @@ sess->subscribed_default_qos, SmPolicyContextData->subs_def_qos); ogs_assert(true == - pcf_sess_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL, + pcf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL, pcf_nudr_dr_build_query_sm_data, sess, stream, NULL)); return true; @@ -352,7 +351,8 @@ ogs_assert(true == ogs_sbi_server_send_response(stream, response)); } else { ogs_assert(true == - pcf_sess_sbi_discover_and_send(OpenAPI_nf_type_BSF, NULL, + pcf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, NULL, pcf_nbsf_management_build_de_register, sess, stream, NULL)); }
View file
open5gs_2.4.9.tar.xz/src/pcf/nudr-handler.c -> open5gs_2.4.10.tar.xz/src/pcf/nudr-handler.c
Changed
@@ -186,6 +186,9 @@ SWITCH(recvmsg->h.resource.component3) CASE(OGS_SBI_RESOURCE_NAME_SM_DATA) + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; + if (!recvmsg->SmPolicyData) { strerror = ogs_msprintf("%s:%d No SmPolicyData", pcf_ue->supi, sess->psi); @@ -193,9 +196,28 @@ goto cleanup; } - ogs_assert(true == - pcf_sess_sbi_discover_and_send(OpenAPI_nf_type_BSF, NULL, - pcf_nbsf_management_build_register, sess, stream, NULL)); + service_type = OGS_SBI_SERVICE_TYPE_NPCF_POLICYAUTHORIZATION; + + nf_instance = sess->sbi.service_type_arrayservice_type.nf_instance; + if (!nf_instance) { + nf_instance = + ogs_sbi_nf_instance_find_by_service_type(service_type); + if (nf_instance) + OGS_SBI_SETUP_NF_INSTANCE( + sess->sbi.service_type_arrayservice_type, + nf_instance); + } + + if (nf_instance) { + ogs_assert(true == + pcf_sess_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, NULL, + pcf_nbsf_management_build_register, + sess, stream, nf_instance)); + } else { + ogs_expect(true == + pcf_sess_sbi_discover_only(sess, stream, service_type)); + } return true;
View file
open5gs_2.4.9.tar.xz/src/pcf/pcf-sm.c -> open5gs_2.4.10.tar.xz/src/pcf/pcf-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -42,14 +42,14 @@ ogs_sbi_request_t *request = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = 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; - OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; + ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; pcf_ue_t *pcf_ue = NULL; pcf_sess_t *sess = NULL; @@ -59,17 +59,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case PCF_EVT_SBI_SERVER: - request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + request = e->h.sbi.request; ogs_assert(request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&message, request); @@ -100,7 +100,7 @@ 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); + ogs_nnrf_handle_nf_status_notify(stream, &message); break; DEFAULT @@ -160,7 +160,7 @@ ogs_assert(OGS_FSM_STATE(&pcf_ue->sm)); e->pcf_ue = pcf_ue; - e->sbi.message = &message; + e->h.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); @@ -179,17 +179,20 @@ 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); - ogs_debug("%s:%d PCF session added", - pcf_ue->supi, sess->psi); - } + if (!pcf_ue) { + pcf_ue = pcf_ue_add( + message.SmPolicyContextData->supi); + ogs_assert(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); + ogs_debug("%s:%d PCF session added", + pcf_ue->supi, sess->psi); } } } @@ -214,7 +217,7 @@ ogs_assert(OGS_FSM_STATE(&sess->sm)); e->sess = sess; - e->sbi.message = &message; + e->h.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", @@ -265,7 +268,7 @@ e->sess = sess; e->app = app_session; - e->sbi.message = &message; + e->h.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", @@ -286,10 +289,10 @@ ogs_sbi_message_free(&message); break; - case PCF_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - response = e->sbi.response; + response = e->h.sbi.response; ogs_assert(response); rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { @@ -311,43 +314,43 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; - ogs_assert(subscription); + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); 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); + ogs_nnrf_handle_nf_status_subscribe( + subscription_data, &message); } else { ogs_error("%s HTTP response error %d", - subscription->id, message.res_status); + subscription_data->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); + ogs_sbi_subscription_data_remove(subscription_data); } else { ogs_error("%s HTTP response error %d", - subscription->id, message.res_status); + subscription_data->id, message.res_status); } break; DEFAULT ogs_error("%s Invalid HTTP method %s", - subscription->id, message.h.method); + subscription_data->id, message.h.method); ogs_assert_if_reached(); END break; @@ -362,7 +365,7 @@ CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); SWITCH(message.h.method) @@ -392,7 +395,7 @@ CASE(OGS_SBI_RESOURCE_NAME_POLICY_DATA) SWITCH(message.h.resource.component3) CASE(OGS_SBI_RESOURCE_NAME_AM_DATA) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -406,7 +409,7 @@ pcf_ue = (pcf_ue_t *)sbi_xact->sbi_object; ogs_assert(pcf_ue); - e->sbi.data = sbi_xact->assoc_stream; + e->h.sbi.data = sbi_xact->assoc_stream; ogs_sbi_xact_remove(sbi_xact); @@ -418,7 +421,7 @@ } e->pcf_ue = pcf_ue; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&pcf_ue->sm, e); if (OGS_FSM_CHECK(&pcf_ue->sm, pcf_am_state_exception)) { @@ -428,7 +431,7 @@ break; CASE(OGS_SBI_RESOURCE_NAME_SM_DATA) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -442,7 +445,7 @@ sess = (pcf_sess_t *)sbi_xact->sbi_object; ogs_assert(sess); - e->sbi.data = sbi_xact->assoc_stream; + e->h.sbi.data = sbi_xact->assoc_stream; ogs_sbi_xact_remove(sbi_xact); @@ -458,7 +461,7 @@ ogs_assert(pcf_ue); e->sess = sess; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&sess->sm, e); if (OGS_FSM_CHECK(&sess->sm, pcf_sm_state_exception)) { @@ -487,7 +490,7 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_PCF_BINDINGS) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -501,7 +504,7 @@ sess = (pcf_sess_t *)sbi_xact->sbi_object; ogs_assert(sess); - e->sbi.data = sbi_xact->assoc_stream; + e->h.sbi.data = sbi_xact->assoc_stream; ogs_sbi_xact_remove(sbi_xact); @@ -517,7 +520,7 @@ ogs_assert(pcf_ue); e->sess = sess; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&sess->sm, e); if (OGS_FSM_CHECK(&sess->sm, pcf_sm_state_exception)) { @@ -547,42 +550,39 @@ ogs_sbi_response_free(response); break; - case PCF_EVT_SBI_TIMER: + case OGS_EVENT_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; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.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)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s:%s State machine exception %d", OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case PCF_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; - ogs_assert(subscription); + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); - ogs_assert(ogs_sbi_self()->nf_instance); ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client, - ogs_sbi_self()->nf_instance->nf_type, - subscription->req_nf_instance_id, - subscription->subscr_cond.nf_type)); + ogs_nnrf_nfm_send_nf_status_subscribe(subscription_data)); - ogs_info("%s Subscription validity expired", subscription->id); - ogs_sbi_subscription_remove(subscription); + ogs_info("%s Subscription validity expired", + subscription_data->id); + ogs_sbi_subscription_data_remove(subscription_data); break; - case PCF_TIMER_SBI_CLIENT_WAIT: - sbi_xact = e->sbi.data; + case OGS_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_object = sbi_xact->sbi_object; @@ -591,7 +591,7 @@ stream = sbi_xact->assoc_stream; ogs_assert(stream); - target_nf_type = sbi_xact->target_nf_type; + service_type = sbi_xact->service_type; ogs_sbi_xact_remove(sbi_xact); @@ -623,7 +623,8 @@ default: ogs_fatal("Not implemented %s:%d", - OpenAPI_nf_type_ToString(target_nf_type), sbi_object->type); + ogs_sbi_service_type_to_name(service_type), + sbi_object->type); ogs_assert_if_reached(); } @@ -636,7 +637,7 @@ default: ogs_error("Unknown timer%s:%d", - pcf_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break;
View file
open5gs_2.4.9.tar.xz/src/pcf/pcf-sm.h -> open5gs_2.4.10.tar.xz/src/pcf/pcf-sm.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,16 +30,6 @@ 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);
View file
open5gs_2.4.9.tar.xz/src/pcf/sbi-path.c -> open5gs_2.4.10.tar.xz/src/pcf/sbi-path.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -27,17 +27,17 @@ ogs_assert(request); ogs_assert(data); - e = pcf_event_new(PCF_EVT_SBI_SERVER); + e = pcf_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - pcf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -58,16 +58,16 @@ ogs_assert(response); - e = pcf_event_new(PCF_EVT_SBI_CLIENT); + e = pcf_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - pcf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -79,57 +79,93 @@ ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; + bool smpolicycontrol_enabled = false; + bool policyauthorization_enabled = false; + /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_PCF); ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AMF); ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_SMF); - ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_NEF); - ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AF); + ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_SCP); /* 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); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_NEF); - - 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); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_NEF); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AF); + if (ogs_sbi_nf_service_is_available( + OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + } + + if (ogs_sbi_nf_service_is_available( + OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF); + + smpolicycontrol_enabled = true; + } + + if (ogs_sbi_nf_service_is_available( + OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + + policyauthorization_enabled = true; + } + + if ((smpolicycontrol_enabled == true && + policyauthorization_enabled == false) || + (smpolicycontrol_enabled == false && + policyauthorization_enabled == true)) { + ogs_fatal("CHECK CONFIGURATION:"); + ogs_fatal(" %s - %s", + OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL, + smpolicycontrol_enabled ? "enabled" : "disabled"); + ogs_fatal(" %s - %s", + OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION, + policyauthorization_enabled ? "enabled" : "disabled"); + ogs_fatal("Only one of %s and %s cannot be enabled.", + OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL, + OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION); + ogs_fatal("They can be enabled or disabled together."); + + return OGS_ERROR; + } /* Initialize NRF NF Instance */ - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_sbi_client_t *client = 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); - } - } - - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = pcf_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)pcf_nf_state_registered; + nf_instance = ogs_sbi_self()->nrf_instance; + if (nf_instance) { + ogs_sbi_client_t *client = 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. */ + ogs_sbi_nf_fsm_init(nf_instance); + } + + /* Build Subscription-Data */ + ogs_sbi_subscription_data_build_default( + OpenAPI_nf_type_BSF, OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT); + ogs_sbi_subscription_data_build_default( + OpenAPI_nf_type_UDR, OGS_SBI_SERVICE_NAME_NUDR_DR); if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR; @@ -143,76 +179,35 @@ ogs_sbi_server_stop_all(); } -bool pcf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - void *data) +bool pcf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data) { - ogs_sbi_nf_instance_t *nf_instance = NULL; - - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); - if (!nf_instance) { - pcf_ue_t *pcf_ue = NULL; - pcf_sess_t *sess = NULL; - - 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(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(target_nf_type)); - break; - default: - ogs_fatal("(NF discover) Not implemented %s:%d", - OpenAPI_nf_type_ToString(target_nf_type), - sbi_object->type); - ogs_assert_if_reached(); - } - - return false; - } + ogs_assert(nf_instance); return ogs_sbi_send_request(nf_instance, client_cb, data); } static bool pcf_sbi_discover_and_send( ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_build_f build, void *context, ogs_sbi_stream_t *stream, void *data) { ogs_sbi_xact_t *xact = NULL; - OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; - - ogs_assert(ogs_sbi_self()->nf_instance); - requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; - ogs_assert(requester_nf_type); - ogs_assert(target_nf_type); + ogs_assert(service_type); ogs_assert(sbi_object); ogs_assert(stream); ogs_assert(build); xact = ogs_sbi_xact_add( - sbi_object, target_nf_type, discovery_option, + sbi_object, service_type, discovery_option, build, context, data); ogs_expect_or_return_val(xact, false); xact->assoc_stream = stream; - if (ogs_sbi_discover_and_send( - sbi_object, - target_nf_type, requester_nf_type, discovery_option, - client_cb, xact) != true) { + if (ogs_sbi_discover_and_send(xact, client_cb) != true) { ogs_error("ogs_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); return false; @@ -222,13 +217,13 @@ } bool pcf_ue_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(pcf_ue_t *pcf_ue, void *data), pcf_ue_t *pcf_ue, ogs_sbi_stream_t *stream, void *data) { if (pcf_sbi_discover_and_send( - &pcf_ue->sbi, target_nf_type, discovery_option, + &pcf_ue->sbi, service_type, discovery_option, (ogs_sbi_build_f)build, pcf_ue, stream, data) != true) { ogs_error("pcf_ue_sbi_discover_and_send() failed"); ogs_assert(true == @@ -241,14 +236,31 @@ return true; } +bool pcf_sess_sbi_discover_only( + pcf_sess_t *sess, ogs_sbi_stream_t *stream, + ogs_sbi_service_type_e service_type) +{ + ogs_sbi_xact_t *xact = NULL; + + ogs_assert(sess); + ogs_assert(service_type); + + xact = ogs_sbi_xact_add(&sess->sbi, service_type, NULL, NULL, NULL, NULL); + ogs_expect_or_return_val(xact, false); + + xact->assoc_stream = stream; + + return ogs_sbi_discover_only(xact, client_cb); +} + bool pcf_sess_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(pcf_sess_t *sess, void *data), pcf_sess_t *sess, ogs_sbi_stream_t *stream, void *data) { if (pcf_sbi_discover_and_send( - &sess->sbi, target_nf_type, discovery_option, + &sess->sbi, service_type, discovery_option, (ogs_sbi_build_f)build, sess, stream, data) != true) { ogs_error("pcf_sess_sbi_discover_and_send() failed"); ogs_assert(true ==
View file
open5gs_2.4.9.tar.xz/src/pcf/sbi-path.h -> open5gs_2.4.10.tar.xz/src/pcf/sbi-path.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,6 @@ #ifndef PCF_SBI_PATH_H #define PCF_SBI_PATH_H -#include "nnrf-build.h" #include "nudr-build.h" #include "nbsf-build.h" #include "namf-build.h" @@ -34,20 +33,20 @@ int pcf_sbi_open(void); void pcf_sbi_close(void); -bool pcf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - void *data); +bool pcf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data); bool pcf_ue_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(pcf_ue_t *pcf_ue, void *data), pcf_ue_t *pcf_ue, ogs_sbi_stream_t *stream, void *data); bool pcf_sess_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(pcf_sess_t *sess, void *data), pcf_sess_t *sess, ogs_sbi_stream_t *stream, void *data); +bool pcf_sess_sbi_discover_only( + pcf_sess_t *sess, ogs_sbi_stream_t *stream, + ogs_sbi_service_type_e service_type); bool pcf_sbi_send_am_policy_control_notify(pcf_ue_t *pcf_ue); bool pcf_sbi_send_smpolicycontrol_update_notify(
View file
open5gs_2.4.9.tar.xz/src/pcf/sm-sm.c -> open5gs_2.4.10.tar.xz/src/pcf/sm-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -54,17 +54,17 @@ pcf_ue = sess->pcf_ue; ogs_assert(pcf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case PCF_EVT_SBI_SERVER: - message = e->sbi.message; + case OGS_EVENT_SBI_SERVER: + message = e->h.sbi.message; ogs_assert(message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(message->h.service.name) @@ -158,10 +158,10 @@ END break; - case PCF_EVT_SBI_CLIENT: - message = e->sbi.message; + case OGS_EVENT_SBI_CLIENT: + message = e->h.sbi.message; ogs_assert(message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(message->h.service.name) @@ -285,7 +285,7 @@ pcf_ue = sess->pcf_ue; ogs_assert(pcf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; @@ -314,7 +314,7 @@ pcf_ue = sess->pcf_ue; ogs_assert(pcf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break;
View file
open5gs_2.4.9.tar.xz/src/pcrf/pcrf-fd-path.c -> open5gs_2.4.10.tar.xz/src/pcrf/pcrf-fd-path.c
Changed
@@ -36,7 +36,7 @@ rv = ogs_diam_start(); ogs_assert(rv == 0); - return OGS_OK; + return OGS_OK; } void pcrf_fd_final(void)
View file
open5gs_2.4.9.tar.xz/src/pcrf/pcrf-gx-path.c -> open5gs_2.4.10.tar.xz/src/pcrf/pcrf-gx-path.c
Changed
@@ -188,10 +188,10 @@ static int pcrf_gx_fb_cb(struct msg **msg, struct avp *avp, struct session *sess, void *opaque, enum disp_action *act) { - /* This CB should never be called */ - ogs_warn("Unexpected message received!"); - - return ENOTSUP; + /* This CB should never be called */ + ogs_warn("Unexpected message received!"); + + return ENOTSUP; } static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp, @@ -200,7 +200,7 @@ int rv; int ret = 0, i; - struct msg *ans, *qry; + struct msg *ans, *qry; struct avp *avpch1, *avpch2; struct avp_hdr *hdr; union avp_value val; @@ -211,7 +211,7 @@ uint32_t cc_request_type = OGS_DIAM_GX_CC_REQUEST_TYPE_INITIAL_REQUEST; uint32_t cc_request_number = 0; uint32_t result_code = OGS_DIAM_MISSING_AVP; - + ogs_debug("Credit-Control-Request"); ogs_assert(msg); @@ -219,9 +219,9 @@ /* Initialize Message */ memset(&gx_message, 0, sizeof(ogs_diam_gx_message_t)); - /* Create answer header */ - qry = *msg; - ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + /* Create answer header */ + qry = *msg; + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); ogs_assert(ret == 0); ans = *msg; @@ -578,8 +578,8 @@ } } - /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ - ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_SUCCESS", NULL, NULL, 1); + /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_SUCCESS", NULL, NULL, 1); ogs_assert(ret == 0); if (cc_request_type != OGS_DIAM_GX_CC_REQUEST_TYPE_TERMINATION_REQUEST) { @@ -591,23 +591,23 @@ state_cleanup(sess_data, NULL, NULL); } - /* Send the answer */ - ret = fd_msg_send(msg, NULL, NULL); + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_debug("Credit-Control-Answer"); - /* Add this value to the stats */ - ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); - ogs_diam_logger_self()->stats.nb_echoed++; - ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) ==0); + /* Add this value to the stats */ + ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) ==0); ogs_session_data_free(&gx_message.session_data); return 0; out: - /* Set the Result-Code */ + /* Set the Result-Code */ if (result_code == OGS_DIAM_AVP_UNSUPPORTED) { ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_AVP_UNSUPPORTED", NULL, NULL, 1); @@ -636,7 +636,7 @@ } } - ret = fd_msg_send(msg, NULL, NULL); + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_session_data_free(&gx_message.session_data); @@ -1144,50 +1144,50 @@ int pcrf_gx_init(void) { int ret; - struct disp_when data; + struct disp_when data; ogs_thread_mutex_init(&sess_state_mutex); ogs_pool_init(&sess_state_pool, ogs_app()->pool.sess); ogs_pool_init(&rx_sess_state_pool, ogs_app()->pool.sess); - /* Install objects definitions for this application */ - ret = ogs_diam_gx_init(); + /* Install objects definitions for this application */ + ret = ogs_diam_gx_init(); ogs_assert(ret == 0); /* Create handler for sessions */ - ret = fd_sess_handler_create(&pcrf_gx_reg, state_cleanup, NULL, NULL); + ret = fd_sess_handler_create(&pcrf_gx_reg, state_cleanup, NULL, NULL); ogs_assert(ret == 0); - memset(&data, 0, sizeof(data)); - data.app = ogs_diam_gx_application; - - ret = fd_disp_register(pcrf_gx_fb_cb, DISP_HOW_APPID, &data, NULL, + memset(&data, 0, sizeof(data)); + data.app = ogs_diam_gx_application; + + ret = fd_disp_register(pcrf_gx_fb_cb, DISP_HOW_APPID, &data, NULL, &hdl_gx_fb); ogs_assert(ret == 0); - - data.command = ogs_diam_gx_cmd_ccr; - ret = fd_disp_register(pcrf_gx_ccr_cb, DISP_HOW_CC, &data, NULL, + + data.command = ogs_diam_gx_cmd_ccr; + ret = fd_disp_register(pcrf_gx_ccr_cb, DISP_HOW_CC, &data, NULL, &hdl_gx_ccr); ogs_assert(ret == 0); - /* Advertise the support for the application in the peer */ - ret = fd_disp_app_support(ogs_diam_gx_application, ogs_diam_vendor, 1, 0); + /* Advertise the support for the application in the peer */ + ret = fd_disp_app_support(ogs_diam_gx_application, ogs_diam_vendor, 1, 0); ogs_assert(ret == 0); - return OGS_OK; + return OGS_OK; } void pcrf_gx_final(void) { int ret; - ret = fd_sess_handler_destroy(&pcrf_gx_reg, NULL); + ret = fd_sess_handler_destroy(&pcrf_gx_reg, NULL); ogs_assert(ret == 0); - if (hdl_gx_fb) - (void) fd_disp_unregister(&hdl_gx_fb, NULL); - if (hdl_gx_ccr) - (void) fd_disp_unregister(&hdl_gx_ccr, NULL); + if (hdl_gx_fb) + (void) fd_disp_unregister(&hdl_gx_fb, NULL); + if (hdl_gx_ccr) + (void) fd_disp_unregister(&hdl_gx_ccr, NULL); ogs_pool_final(&sess_state_pool); ogs_pool_final(&rx_sess_state_pool);
View file
open5gs_2.4.9.tar.xz/src/pcrf/pcrf-init.c -> open5gs_2.4.10.tar.xz/src/pcrf/pcrf-init.c
Changed
@@ -43,7 +43,7 @@ initialized = 1; - return OGS_OK; + return OGS_OK; } void pcrf_terminate(void) @@ -54,6 +54,6 @@ ogs_dbi_final(); pcrf_context_final(); - - return; + + return; }
View file
open5gs_2.4.9.tar.xz/src/pcrf/pcrf-rx-path.c -> open5gs_2.4.10.tar.xz/src/pcrf/pcrf-rx-path.c
Changed
@@ -81,10 +81,10 @@ static int pcrf_rx_fb_cb(struct msg **msg, struct avp *avp, struct session *sess, void *opaque, enum disp_action *act) { - /* This CB should never be called */ - ogs_warn("Unexpected message received!"); - - return ENOTSUP; + /* This CB should never be called */ + ogs_warn("Unexpected message received!"); + + return ENOTSUP; } static int pcrf_rx_aar_cb( struct msg **msg, struct avp *avp, @@ -93,7 +93,7 @@ int rv; int ret; - struct msg *ans, *qry; + struct msg *ans, *qry; struct avp *avpch1, *avpch2, *avpch3; struct avp_hdr *hdr; union avp_value val; @@ -110,7 +110,7 @@ uint32_t result_code = OGS_DIAM_RX_DIAMETER_IP_CAN_SESSION_NOT_AVAILABLE; ogs_debug("PCRF AA-Request"); - + ogs_assert(msg); ogs_assert(sess); @@ -129,9 +129,9 @@ memset(&rx_message, 0, sizeof(ogs_diam_rx_message_t)); rx_message.cmd_code = OGS_DIAM_RX_CMD_CODE_AA; - /* Create answer header */ - qry = *msg; - ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + /* Create answer header */ + qry = *msg; + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); ogs_assert(ret == 0); ans = *msg; @@ -359,8 +359,8 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ - ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_SUCCESS", NULL, NULL, 1); + /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_SUCCESS", NULL, NULL, 1); ogs_assert(ret == 0); /* Store this value in the session */ @@ -368,16 +368,16 @@ ogs_assert(ret == 0); ogs_assert(sess_data == NULL); - /* Send the answer */ - ret = fd_msg_send(msg, NULL, NULL); + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_debug("PCRF AA-Answer"); - /* Add this value to the stats */ - ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); - ogs_diam_logger_self()->stats.nb_echoed++; - ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); + /* Add this value to the stats */ + ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); ogs_ims_data_free(&rx_message.ims_data); @@ -401,7 +401,7 @@ ogs_assert(ret == 0); } - ret = fd_msg_send(msg, NULL, NULL); + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); state_cleanup(sess_data, NULL, NULL); @@ -604,7 +604,7 @@ int rv; int ret; - struct msg *ans, *qry; + struct msg *ans, *qry; struct avp_hdr *hdr; union avp_value val; struct sess_state *sess_data = NULL; @@ -614,7 +614,7 @@ uint32_t result_code = OGS_DIAM_RX_DIAMETER_IP_CAN_SESSION_NOT_AVAILABLE; ogs_debug("PCRF Session-Termination-Request"); - + ogs_assert(msg); ogs_assert(sess); @@ -628,9 +628,9 @@ memset(&rx_message, 0, sizeof(ogs_diam_rx_message_t)); rx_message.cmd_code = OGS_DIAM_RX_CMD_CODE_SESSION_TERMINATION; - /* Create answer header */ - qry = *msg; - ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + /* Create answer header */ + qry = *msg; + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); ogs_assert(ret == 0); ans = *msg; @@ -684,20 +684,20 @@ } } - /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ - ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_SUCCESS", NULL, NULL, 1); + /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_SUCCESS", NULL, NULL, 1); ogs_assert(ret == 0); - /* Send the answer */ - ret = fd_msg_send(msg, NULL, NULL); + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_debug("PCRF Session-Termination-Answer"); - /* Add this value to the stats */ - ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); - ogs_diam_logger_self()->stats.nb_echoed++; - ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); + /* Add this value to the stats */ + ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); state_cleanup(sess_data, NULL, NULL); ogs_ims_data_free(&rx_message.ims_data); @@ -723,7 +723,7 @@ ogs_assert(ret == 0); } - ret = fd_msg_send(msg, NULL, NULL); + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_debug("PCRF Session-Termination-Answer"); @@ -736,59 +736,59 @@ int pcrf_rx_init(void) { int ret; - struct disp_when data; + struct disp_when data; ogs_thread_mutex_init(&sess_state_mutex); ogs_pool_init(&sess_state_pool, ogs_app()->pool.sess); - /* Install objects definitions for this application */ - ret = ogs_diam_rx_init(); + /* Install objects definitions for this application */ + ret = ogs_diam_rx_init(); ogs_assert(ret == 0); /* Create handler for sessions */ - ret = fd_sess_handler_create(&pcrf_rx_reg, state_cleanup, NULL, NULL); + ret = fd_sess_handler_create(&pcrf_rx_reg, state_cleanup, NULL, NULL); ogs_assert(ret == 0); - /* Fallback CB if command != unexpected message received */ - memset(&data, 0, sizeof(data)); - data.app = ogs_diam_rx_application; - - ret = fd_disp_register(pcrf_rx_fb_cb, DISP_HOW_APPID, &data, NULL, + /* Fallback CB if command != unexpected message received */ + memset(&data, 0, sizeof(data)); + data.app = ogs_diam_rx_application; + + ret = fd_disp_register(pcrf_rx_fb_cb, DISP_HOW_APPID, &data, NULL, &hdl_rx_fb); ogs_assert(ret == 0); - - /* Specific handler for AA-Request */ - data.command = ogs_diam_rx_cmd_aar; - ret = fd_disp_register(pcrf_rx_aar_cb, DISP_HOW_CC, &data, NULL, + + /* Specific handler for AA-Request */ + data.command = ogs_diam_rx_cmd_aar; + ret = fd_disp_register(pcrf_rx_aar_cb, DISP_HOW_CC, &data, NULL, &hdl_rx_aar); ogs_assert(ret == 0); - /* Specific handler for STR-Request */ - data.command = ogs_diam_rx_cmd_str; - ret = fd_disp_register(pcrf_rx_str_cb, DISP_HOW_CC, &data, NULL, + /* Specific handler for STR-Request */ + data.command = ogs_diam_rx_cmd_str; + ret = fd_disp_register(pcrf_rx_str_cb, DISP_HOW_CC, &data, NULL, &hdl_rx_str); ogs_assert(ret == 0); - /* Advertise the support for the application in the peer */ - ret = fd_disp_app_support(ogs_diam_rx_application, ogs_diam_vendor, 1, 0); + /* Advertise the support for the application in the peer */ + ret = fd_disp_app_support(ogs_diam_rx_application, ogs_diam_vendor, 1, 0); ogs_assert(ret == 0); - return OGS_OK; + return OGS_OK; } void pcrf_rx_final(void) { int ret; - ret = fd_sess_handler_destroy(&pcrf_rx_reg, NULL); + ret = fd_sess_handler_destroy(&pcrf_rx_reg, NULL); ogs_assert(ret == 0); - if (hdl_rx_fb) - (void) fd_disp_unregister(&hdl_rx_fb, NULL); - if (hdl_rx_aar) - (void) fd_disp_unregister(&hdl_rx_aar, NULL); - if (hdl_rx_str) - (void) fd_disp_unregister(&hdl_rx_str, NULL); + if (hdl_rx_fb) + (void) fd_disp_unregister(&hdl_rx_fb, NULL); + if (hdl_rx_aar) + (void) fd_disp_unregister(&hdl_rx_aar, NULL); + if (hdl_rx_str) + (void) fd_disp_unregister(&hdl_rx_str, NULL); ogs_pool_final(&sess_state_pool); ogs_thread_mutex_destroy(&sess_state_mutex);
View file
open5gs_2.4.9.tar.xz/src/scp/context.c -> open5gs_2.4.10.tar.xz/src/scp/context.c
Changed
@@ -96,6 +96,10 @@ ogs_assert(scp_key); if (!strcmp(scp_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(scp_key, "service_name")) { + /* handle config in sbi library */ + } else if (!strcmp(scp_key, "discovery")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", scp_key); }
View file
open5gs_2.4.9.tar.xz/src/scp/context.h -> open5gs_2.4.10.tar.xz/src/scp/context.h
Changed
@@ -23,7 +23,6 @@ #include "ogs-sbi.h" #include "ogs-app.h" -#include "timer.h" #include "scp-sm.h" #ifdef __cplusplus @@ -39,22 +38,6 @@ ogs_list_t conn_list; } scp_context_t; -#define SCP_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - scp_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, scp_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } while(0) - typedef struct scp_conn_s scp_conn_t; typedef struct scp_conn_s {
View file
open5gs_2.4.9.tar.xz/src/scp/event.c -> open5gs_2.4.10.tar.xz/src/scp/event.c
Changed
@@ -18,60 +18,42 @@ */ #include "event.h" -#include "context.h" -static OGS_POOL(pool, scp_event_t); - -void scp_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); -} - -void scp_event_final(void) -{ - ogs_pool_final(&pool); -} - -scp_event_t *scp_event_new(scp_event_e id) +scp_event_t *scp_event_new(int id) { scp_event_t *e = NULL; - ogs_pool_alloc(&pool, &e); + e = ogs_event_size(id, sizeof(scp_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void scp_event_free(scp_event_t *e) -{ - ogs_assert(e); - ogs_pool_free(&pool, e); -} - const char *scp_event_get_name(scp_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { - case OGS_FSM_ENTRY_SIG: + switch (e->h.id) { + case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; - case OGS_FSM_EXIT_SIG: + case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case SCP_EVT_SBI_SERVER: - return "SCP_EVT_SBI_SERVER"; - case SCP_EVT_SBI_CLIENT: - return "SCP_EVT_SBI_CLIENT"; - case SCP_EVT_SBI_TIMER: - return "SCP_EVT_SBI_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; - default: - break; + default: + break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.tar.xz/src/scp/event.h -> open5gs_2.4.10.tar.xz/src/scp/event.h
Changed
@@ -20,52 +20,23 @@ #ifndef SCP_EVENT_H #define SCP_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { #endif typedef struct scp_sess_s scp_sess_t; -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 enum { - SCP_EVT_BASE = OGS_FSM_USER_SIG, - - SCP_EVT_SBI_SERVER, - SCP_EVT_SBI_CLIENT, - SCP_EVT_SBI_TIMER, - - SCP_EVT_TOP, - -} scp_event_e; - typedef struct scp_event_s { - int id; - ogs_pkbuf_t *pkbuf; - int timer_id; - - struct { - ogs_sbi_request_t *request; - ogs_sbi_response_t *response; - void *data; - int state; - - ogs_sbi_message_t *message; - } sbi; + ogs_event_t h; ogs_sbi_nf_instance_t *nf_instance; scp_sess_t *sess; } scp_event_t; -void scp_event_init(void); -void scp_event_final(void); - -scp_event_t *scp_event_new(scp_event_e id); -void scp_event_free(scp_event_t *e); +scp_event_t *scp_event_new(int id); const char *scp_event_get_name(scp_event_t *e);
View file
open5gs_2.4.9.tar.xz/src/scp/init.c -> open5gs_2.4.10.tar.xz/src/scp/init.c
Changed
@@ -32,7 +32,6 @@ ogs_sbi_context_init(); scp_context_init(); - scp_event_init(); rv = ogs_sbi_context_parse_config("scp", "nrf", "next_scp"); if (rv != OGS_OK) return rv; @@ -63,7 +62,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - scp_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -88,10 +87,7 @@ scp_sbi_close(); scp_context_final(); - ogs_sbi_context_final(); - - scp_event_final(); /* Destroy event */ } static void scp_main(void *data) @@ -99,8 +95,7 @@ ogs_fsm_t scp_sm; int rv; - ogs_fsm_create(&scp_sm, scp_state_initial, scp_state_final); - ogs_fsm_init(&scp_sm, 0); + ogs_fsm_init(&scp_sm, scp_state_initial, scp_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -133,11 +128,10 @@ ogs_assert(e); ogs_fsm_dispatch(&scp_sm, e); - scp_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&scp_sm, 0); - ogs_fsm_delete(&scp_sm); }
View file
open5gs_2.4.9.tar.xz/src/scp/meson.build -> open5gs_2.4.10.tar.xz/src/scp/meson.build
Changed
@@ -18,12 +18,8 @@ libscp_sources = files(''' context.c event.c - timer.c - nnrf-build.c nnrf-handler.c - nf-sm.c - nscp-handler.c sbi-path.c @@ -34,15 +30,13 @@ libscp = static_library('scp', sources : libscp_sources, - dependencies : libapp_dep, - libcrypt_dep, + dependencies : libcrypt_dep, libsbi_dep, install : false) libscp_dep = declare_dependency( link_with : libscp, - dependencies : libapp_dep, - libcrypt_dep, + dependencies : libcrypt_dep, libsbi_dep) scp_sources = files('''
View file
open5gs_2.4.9.tar.xz/src/scp/nnrf-handler.c -> open5gs_2.4.10.tar.xz/src/scp/nnrf-handler.c
Changed
@@ -20,252 +20,24 @@ #include "sbi-path.h" #include "nnrf-handler.h" -void scp_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void scp_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->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_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - 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, - scp_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 scp_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - scp_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - nf_instance->reference_count++; - - OGS_FSM_TRAN(&nf_instance->sm, scp_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - SCP_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - SCP_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - SCP_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -} - void scp_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; - OpenAPI_nf_type_e target_nf_type = 0; + ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; OpenAPI_search_result_t *SearchResult = NULL; - OpenAPI_lnode_t *node = NULL; - bool handled; ogs_assert(recvmsg); ogs_assert(xact); sbi_object = xact->sbi_object; ogs_assert(sbi_object); - target_nf_type = xact->target_nf_type; + service_type = xact->service_type; + ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); ogs_assert(target_nf_type); discovery_option = xact->discovery_option; @@ -276,74 +48,18 @@ 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(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); - - scp_nf_fsm_init(nf_instance); - - ogs_info("%s (NF-discover) NF registered", nf_instance->id); - } else { - nf_instance->reference_count++; - - OGS_FSM_TRAN(&nf_instance->sm, scp_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("ogs_sbi_nnrf_handle_nf_profile() failed %s", - nf_instance->id); - SCP_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); - SCP_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } + ogs_nnrf_handle_nf_discover_search_result(SearchResult); - /* TIME : Update validity from NRF */ - if (SearchResult->is_validity_period && - 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_sbi_select_nf(sbi_object, target_nf_type, discovery_option); - - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); if (!nf_instance) { ogs_error("(NF discover) No %s", - OpenAPI_nf_type_ToString(target_nf_type)); - } else { - scp_sbi_send(nf_instance, xact); + ogs_sbi_service_type_to_name(service_type)); + return; } + + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_arrayservice_type, nf_instance); + + ogs_expect(true == scp_sbi_send_request(nf_instance, xact)); }
View file
open5gs_2.4.9.tar.xz/src/scp/nnrf-handler.h -> open5gs_2.4.10.tar.xz/src/scp/nnrf-handler.h
Changed
@@ -26,14 +26,6 @@ extern "C" { #endif -void scp_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void scp_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool scp_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - void scp_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg);
View file
open5gs_2.4.9.tar.xz/src/scp/sbi-path.c -> open5gs_2.4.10.tar.xz/src/scp/sbi-path.c
Changed
@@ -32,21 +32,11 @@ /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_SCP); - /* Initialize SCP NF Instance */ - nf_instance = ogs_sbi_self()->scp_instance; - if (nf_instance) { - ogs_sbi_client_t *client = NULL; - - /* Client callback is only used when NF sends to SCP */ - client = nf_instance->client; - ogs_assert(client); - client->cb = client_cb; - } - /* Initialize NRF NF Instance */ nf_instance = ogs_sbi_self()->nrf_instance; if (nf_instance) { @@ -59,15 +49,18 @@ /* NFRegister is sent and the response is received * by the above client callback. */ - scp_nf_fsm_init(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); } - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = scp_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)scp_nf_state_registered; + /* Build Subscription-Data */ + ogs_sbi_subscription_data_build_default(OpenAPI_nf_type_AMF, NULL); + ogs_sbi_subscription_data_build_default(OpenAPI_nf_type_AUSF, NULL); + ogs_sbi_subscription_data_build_default(OpenAPI_nf_type_BSF, NULL); + ogs_sbi_subscription_data_build_default(OpenAPI_nf_type_NSSF, NULL); + ogs_sbi_subscription_data_build_default(OpenAPI_nf_type_PCF, NULL); + ogs_sbi_subscription_data_build_default(OpenAPI_nf_type_SMF, NULL); + ogs_sbi_subscription_data_build_default(OpenAPI_nf_type_UDM, NULL); + ogs_sbi_subscription_data_build_default(OpenAPI_nf_type_UDR, NULL); if (ogs_sbi_server_start_all(request_handler) != OGS_OK) return OGS_ERROR; @@ -259,17 +252,17 @@ } else if (headers.discovery) { scp_event_t *e = NULL; - e = scp_event_new(SCP_EVT_SBI_SERVER); + e = scp_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = source; - e->sbi.data = stream; + e->h.sbi.request = source; + e->h.sbi.data = stream; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(source); - scp_event_free(e); + ogs_event_free(e); return OGS_ERROR; } } else { @@ -279,17 +272,17 @@ ogs_assert(source); ogs_assert(data); - e = scp_event_new(SCP_EVT_SBI_SERVER); + e = scp_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = source; - e->sbi.data = data; + e->h.sbi.request = source; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(source); - scp_event_free(e); + ogs_event_free(e); return OGS_ERROR; } } @@ -344,47 +337,44 @@ ogs_assert(response); - e = scp_event_new(SCP_EVT_SBI_CLIENT); + e = scp_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - scp_event_free(e); + ogs_event_free(e); return OGS_ERROR; } return OGS_OK; } - -bool scp_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact) +bool scp_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data) { - return ogs_sbi_send_request(nf_instance, client_cb, xact); + ogs_assert(nf_instance); + + return ogs_sbi_send_request(nf_instance, client_cb, data); } bool scp_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(scp_conn_t *conn, void *data), scp_conn_t *conn, ogs_sbi_stream_t *stream, void *data) { ogs_sbi_xact_t *xact = NULL; - OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; - - ogs_assert(ogs_sbi_self()->nf_instance); - requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; - ogs_assert(requester_nf_type); + ogs_assert(service_type); ogs_assert(conn); ogs_assert(stream); ogs_assert(build); xact = ogs_sbi_xact_add( - &conn->sbi, target_nf_type, discovery_option, + &conn->sbi, service_type, discovery_option, (ogs_sbi_build_f)build, conn, data); if (!xact) { ogs_error("scp_sbi_discover_and_send() failed"); @@ -397,10 +387,7 @@ xact->assoc_stream = stream; - if (ogs_sbi_discover_and_send( - &conn->sbi, - target_nf_type, requester_nf_type, discovery_option, - client_cb, xact) != true) { + if (ogs_sbi_discover_and_send(xact, client_cb) != true) { ogs_error("scp_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); ogs_assert(true ==
View file
open5gs_2.4.9.tar.xz/src/scp/sbi-path.h -> open5gs_2.4.10.tar.xz/src/scp/sbi-path.h
Changed
@@ -20,7 +20,7 @@ #ifndef SCP_SBI_PATH_H #define SCP_SBI_PATH_H -#include "nnrf-build.h" +#include "context.h" #ifdef __cplusplus extern "C" { @@ -29,10 +29,9 @@ int scp_sbi_open(void); void scp_sbi_close(void); -bool scp_sbi_send(ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_xact_t *xact); - +bool scp_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data); bool scp_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(scp_conn_t *conn, void *data), scp_conn_t *conn, ogs_sbi_stream_t *stream, void *data);
View file
open5gs_2.4.9.tar.xz/src/scp/scp-sm.c -> open5gs_2.4.10.tar.xz/src/scp/scp-sm.c
Changed
@@ -45,7 +45,7 @@ ogs_sbi_request_t *request = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; ogs_sbi_response_t *response = NULL; ogs_sbi_message_t message; ogs_sbi_xact_t *sbi_xact = NULL; @@ -54,17 +54,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case SCP_EVT_SBI_SERVER: - request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + request = e->h.sbi.request; ogs_assert(request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&message, request); @@ -95,7 +95,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - scp_nnrf_handle_nf_status_notify(stream, &message); + ogs_nnrf_handle_nf_status_notify(stream, &message); break; DEFAULT @@ -195,10 +195,10 @@ ogs_sbi_message_free(&message); break; - case SCP_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - response = e->sbi.response; + response = e->h.sbi.response; ogs_assert(response); rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { @@ -220,24 +220,24 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; - ogs_assert(subscription); + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); 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) { - scp_nnrf_handle_nf_status_subscribe( - subscription, &message); + ogs_nnrf_handle_nf_status_subscribe( + subscription_data, &message); } else { ogs_error("HTTP response error : %d", message.res_status); @@ -246,7 +246,7 @@ CASE(OGS_SBI_HTTP_METHOD_DELETE) if (message.res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT) { - ogs_sbi_subscription_remove(subscription); + ogs_sbi_subscription_data_remove(subscription_data); } else { ogs_error("HTTP response error : %d", message.res_status); @@ -269,7 +269,7 @@ CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); SWITCH(message.h.method) @@ -303,42 +303,39 @@ ogs_sbi_response_free(response); break; - case SCP_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case SCP_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case SCP_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case SCP_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case SCP_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.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, scp_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s:%s State machine exception %d", OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case SCP_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; - ogs_assert(subscription); + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); - ogs_assert(ogs_sbi_self()->nf_instance); ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client, - ogs_sbi_self()->nf_instance->nf_type, - subscription->req_nf_instance_id, - subscription->subscr_cond.nf_type)); + ogs_nnrf_nfm_send_nf_status_subscribe(subscription_data)); - ogs_info("Subscription validity expired %s", subscription->id); - ogs_sbi_subscription_remove(subscription); + ogs_info("Subscription validity expired %s", + subscription_data->id); + ogs_sbi_subscription_data_remove(subscription_data); break; - case SCP_TIMER_SBI_CLIENT_WAIT: - sbi_xact = e->sbi.data; + case OGS_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); stream = sbi_xact->assoc_stream; @@ -358,7 +355,7 @@ default: ogs_error("Unknown timer%s:%d", - scp_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break;
View file
open5gs_2.4.9.tar.xz/src/scp/scp-sm.h -> open5gs_2.4.10.tar.xz/src/scp/scp-sm.h
Changed
@@ -31,16 +31,6 @@ void scp_state_operational(ogs_fsm_t *s, scp_event_t *e); void scp_state_exception(ogs_fsm_t *s, scp_event_t *e); -void scp_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void scp_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void scp_nf_state_initial(ogs_fsm_t *s, scp_event_t *e); -void scp_nf_state_final(ogs_fsm_t *s, scp_event_t *e); -void scp_nf_state_will_register(ogs_fsm_t *s, scp_event_t *e); -void scp_nf_state_registered(ogs_fsm_t *s, scp_event_t *e); -void scp_nf_state_de_registered(ogs_fsm_t *s, scp_event_t *e); -void scp_nf_state_exception(ogs_fsm_t *s, scp_event_t *e); - #define scp_sm_debug(__pe) \ ogs_debug("%s(): %s", __func__, scp_event_get_name(__pe))
View file
open5gs_2.4.9.tar.xz/src/sgwc/event.h -> open5gs_2.4.10.tar.xz/src/sgwc/event.h
Changed
@@ -20,7 +20,7 @@ #ifndef SGWC_EVENT_H #define SGWC_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { @@ -34,7 +34,7 @@ typedef struct sgwc_bearer_s sgwc_bearer_t; typedef enum { - SGWC_EVT_BASE = OGS_FSM_USER_SIG, + SGWC_EVT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, SGWC_EVT_S11_MESSAGE, SGWC_EVT_S5C_MESSAGE, @@ -49,9 +49,10 @@ typedef struct sgwc_event_s { int id; - ogs_pkbuf_t *pkbuf; int timer_id; + ogs_pkbuf_t *pkbuf; + ogs_gtp_node_t *gnode; ogs_gtp2_message_t *gtp_message;
View file
open5gs_2.4.9.tar.xz/src/sgwc/init.c -> open5gs_2.4.10.tar.xz/src/sgwc/init.c
Changed
@@ -97,8 +97,7 @@ ogs_fsm_t sgwc_sm; int rv; - ogs_fsm_create(&sgwc_sm, sgwc_state_initial, sgwc_state_final); - ogs_fsm_init(&sgwc_sm, 0); + ogs_fsm_init(&sgwc_sm, sgwc_state_initial, sgwc_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -137,5 +136,4 @@ done: ogs_fsm_fini(&sgwc_sm, 0); - ogs_fsm_delete(&sgwc_sm); }
View file
open5gs_2.4.9.tar.xz/src/sgwc/meson.build -> open5gs_2.4.10.tar.xz/src/sgwc/meson.build
Changed
@@ -45,16 +45,12 @@ libsgwc = static_library('sgwc', sources : libsgwc_sources, - dependencies : libapp_dep, - libgtp_dep, - libpfcp_dep, + dependencies : libpfcp_dep, install : false) libsgwc_dep = declare_dependency( link_with : libsgwc, - dependencies : libapp_dep, - libgtp_dep, - libpfcp_dep) + dependencies : libpfcp_dep) sgwc_sources = files(''' app.c
View file
open5gs_2.4.9.tar.xz/src/sgwc/pfcp-path.c -> open5gs_2.4.10.tar.xz/src/sgwc/pfcp-path.c
Changed
@@ -34,8 +34,7 @@ ogs_assert(node->t_association); } - ogs_fsm_create(&node->sm, sgwc_pfcp_state_initial, sgwc_pfcp_state_final); - ogs_fsm_init(&node->sm, &e); + ogs_fsm_init(&node->sm, sgwc_pfcp_state_initial, sgwc_pfcp_state_final, &e); } static void pfcp_node_fsm_fini(ogs_pfcp_node_t *node) @@ -48,7 +47,6 @@ e.pfcp_node = node; ogs_fsm_fini(&node->sm, &e); - ogs_fsm_delete(&node->sm); if (node->t_association) ogs_timer_delete(node->t_association); @@ -378,9 +376,6 @@ ogs_pkbuf_t *sxabuf = NULL; ogs_pfcp_header_t h; - ogs_assert(xact); - xact->local_seid = sess->sgwc_sxa_seid; - memset(&h, 0, sizeof(ogs_pfcp_header_t)); h.type = OGS_PFCP_SESSION_REPORT_RESPONSE_TYPE; h.seid = sess->sgwu_sxa_seid;
View file
open5gs_2.4.9.tar.xz/src/sgwc/sgwc-sm.c -> open5gs_2.4.10.tar.xz/src/sgwc/sgwc-sm.c
Changed
@@ -304,7 +304,7 @@ sess, gtp_xact, recvbuf, >p_message); break; default: - ogs_warn("Not implmeneted(type:%d)", gtp_message.h.type); + ogs_warn("Not implemented(type:%d)", gtp_message.h.type); break; } ogs_pkbuf_free(recvbuf);
View file
open5gs_2.4.9.tar.xz/src/sgwc/sxa-handler.c -> open5gs_2.4.10.tar.xz/src/sgwc/sxa-handler.c
Changed
@@ -157,7 +157,6 @@ ogs_debug("Session Establishment Response"); - ogs_assert(sess); ogs_assert(pfcp_xact); ogs_assert(pfcp_rsp); ogs_assert(recv_message); @@ -172,6 +171,11 @@ cause_value = OGS_GTP2_CAUSE_REQUEST_ACCEPTED; + if (!sess) { + ogs_error("No Context"); + cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND; + } + if (pfcp_rsp->up_f_seid.presence == 0) { ogs_error("No UP F-SEID"); cause_value = OGS_GTP2_CAUSE_MANDATORY_IE_MISSING; @@ -449,7 +453,6 @@ ogs_debug("Session Modification Response"); - ogs_assert(sess); ogs_assert(pfcp_xact); ogs_assert(pfcp_rsp); @@ -459,12 +462,31 @@ cause_value = OGS_GTP2_CAUSE_REQUEST_ACCEPTED; if (flags & OGS_PFCP_MODIFY_SESSION) { + if (!sess) { + ogs_error("No Context"); + + sess = pfcp_xact->data; + ogs_assert(sess); + + cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND; + } + sgwc_ue = sess->sgwc_ue; ogs_assert(sgwc_ue); } else { bearer = pfcp_xact->data; ogs_assert(bearer); + + if (!sess) { + ogs_error("No Context"); + + sess = bearer->sess; + ogs_assert(sess); + + cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND; + } + sgwc_ue = bearer->sgwc_ue; ogs_assert(sgwc_ue); } @@ -1185,12 +1207,16 @@ ogs_debug("Session Deletion Response"); - ogs_assert(sess); ogs_assert(pfcp_xact); ogs_assert(pfcp_rsp); cause_value = OGS_GTP2_CAUSE_REQUEST_ACCEPTED; + if (!sess) { + ogs_error("No Context"); + cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND; + } + if (pfcp_rsp->cause.presence) { if (pfcp_rsp->cause.u8 != OGS_PFCP_CAUSE_REQUEST_ACCEPTED) { ogs_warn("PFCP Cause%d : Not Accepted", pfcp_rsp->cause.u8);
View file
open5gs_2.4.9.tar.xz/src/sgwu/event.h -> open5gs_2.4.10.tar.xz/src/sgwu/event.h
Changed
@@ -20,7 +20,7 @@ #ifndef SGWU_EVENT_H #define SGWU_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { @@ -33,7 +33,7 @@ typedef struct sgwu_bearer_s sgwu_bearer_t; typedef enum { - SGWU_EVT_BASE = OGS_FSM_USER_SIG, + SGWU_EVT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, SGWU_EVT_SXA_MESSAGE, SGWU_EVT_SXA_TIMER, @@ -45,9 +45,10 @@ typedef struct sgwu_event_s { int id; - ogs_pkbuf_t *pkbuf; int timer_id; + ogs_pkbuf_t *pkbuf; + ogs_gtp_node_t *gnode; ogs_pfcp_node_t *pfcp_node;
View file
open5gs_2.4.9.tar.xz/src/sgwu/init.c -> open5gs_2.4.10.tar.xz/src/sgwu/init.c
Changed
@@ -94,8 +94,7 @@ ogs_fsm_t sgwu_sm; int rv; - ogs_fsm_create(&sgwu_sm, sgwu_state_initial, sgwu_state_final); - ogs_fsm_init(&sgwu_sm, 0); + ogs_fsm_init(&sgwu_sm, sgwu_state_initial, sgwu_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -134,5 +133,4 @@ done: ogs_fsm_fini(&sgwu_sm, 0); - ogs_fsm_delete(&sgwu_sm); }
View file
open5gs_2.4.9.tar.xz/src/sgwu/meson.build -> open5gs_2.4.10.tar.xz/src/sgwu/meson.build
Changed
@@ -39,16 +39,12 @@ libsgwu = static_library('sgwu', sources : libsgwu_sources, - dependencies : libapp_dep, - libgtp_dep, - libpfcp_dep, + dependencies : libpfcp_dep, install : false) libsgwu_dep = declare_dependency( link_with : libsgwu, - dependencies : libapp_dep, - libgtp_dep, - libpfcp_dep) + dependencies : libpfcp_dep) sgwu_sources = files(''' app.c
View file
open5gs_2.4.9.tar.xz/src/sgwu/pfcp-path.c -> open5gs_2.4.10.tar.xz/src/sgwu/pfcp-path.c
Changed
@@ -34,8 +34,7 @@ ogs_assert(node->t_association); } - ogs_fsm_create(&node->sm, sgwu_pfcp_state_initial, sgwu_pfcp_state_final); - ogs_fsm_init(&node->sm, &e); + ogs_fsm_init(&node->sm, sgwu_pfcp_state_initial, sgwu_pfcp_state_final, &e); } static void pfcp_node_fsm_fini(ogs_pfcp_node_t *node) @@ -48,7 +47,6 @@ e.pfcp_node = node; ogs_fsm_fini(&node->sm, &e); - ogs_fsm_delete(&node->sm); if (node->t_association) ogs_timer_delete(node->t_association);
View file
open5gs_2.4.9.tar.xz/src/smf/context.c -> open5gs_2.4.10.tar.xz/src/smf/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -831,6 +831,10 @@ /* handle config in pfcp library */ } else if (!strcmp(smf_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(smf_key, "service_name")) { + /* handle config in sbi library */ + } else if (!strcmp(smf_key, "discovery")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", smf_key); } @@ -1109,8 +1113,7 @@ memset(&e, 0, sizeof(e)); e.sess = sess; - ogs_fsm_create(&sess->sm, smf_gsm_state_initial, smf_gsm_state_final); - ogs_fsm_init(&sess->sm, &e); + ogs_fsm_init(&sess->sm, smf_gsm_state_initial, smf_gsm_state_final, &e); sess->smf_ue = smf_ue; @@ -1319,8 +1322,7 @@ memset(&e, 0, sizeof(e)); e.sess = sess; - ogs_fsm_create(&sess->sm, smf_gsm_state_initial, smf_gsm_state_final); - ogs_fsm_init(&sess->sm, &e); + ogs_fsm_init(&sess->sm, smf_gsm_state_initial, smf_gsm_state_final, &e); sess->smf_ue = smf_ue; @@ -1600,7 +1602,6 @@ memset(&e, 0, sizeof(e)); e.sess = sess; ogs_fsm_fini(&sess->sm, &e); - ogs_fsm_delete(&sess->sm); OGS_TLV_CLEAR_DATA(&sess->gtp.ue_pco); OGS_TLV_CLEAR_DATA(&sess->gtp.user_location_information); @@ -2647,22 +2648,22 @@ const ogs_pco_ipcp_t *ipcp, size_t ipcp_len, enum ogs_pco_ipcp_options opt, size_t opt_minlen) { - const uint8_t *cur_opt = (const uint8_t *)ipcp->options; + const uint8_t *cur_opt = (const uint8_t *)ipcp->options; - /* iterate over Options and check if protocol contained */ - while (cur_opt + sizeof(struct ogs_pco_ipcp_options_s) <= + /* iterate over Options and check if protocol contained */ + while (cur_opt + sizeof(struct ogs_pco_ipcp_options_s) <= (uint8_t*)ipcp + ipcp_len) { - const struct ogs_pco_ipcp_options_s *cur_opt_hdr = + const struct ogs_pco_ipcp_options_s *cur_opt_hdr = (const struct ogs_pco_ipcp_options_s *)cur_opt; - /* length value includes 2 bytes type/length */ - if (cur_opt_hdr->len < 2) - return NULL; - if (cur_opt_hdr->type == opt && - cur_opt_hdr->len >= 2 + opt_minlen) - return cur_opt; - cur_opt += cur_opt_hdr->len; - } - return NULL; + /* length value includes 2 bytes type/length */ + if (cur_opt_hdr->len < 2) + return NULL; + if (cur_opt_hdr->type == opt && + cur_opt_hdr->len >= 2 + opt_minlen) + return cur_opt; + cur_opt += cur_opt_hdr->len; + } + return NULL; } #include "../version.h"
View file
open5gs_2.4.9.tar.xz/src/smf/context.h -> open5gs_2.4.10.tar.xz/src/smf/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -126,21 +126,6 @@ ogs_list_t sess_list; } smf_ue_t; -#define SMF_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - smf_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, smf_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } while(0) #define SMF_SESS_CLEAR(__sESS) \ do { \ smf_ue_t *smf_ue = NULL; \ @@ -285,6 +270,8 @@ * of POST /npcf-smpolocycontrol/v1/policies */ char *policy_association_id; + OpenAPI_up_cnx_state_e up_cnx_state; + /* PLMN ID & NID */ ogs_plmn_id_t plmn_id;
View file
open5gs_2.4.9.tar.xz/src/smf/event.c -> open5gs_2.4.10.tar.xz/src/smf/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,52 +18,26 @@ */ #include "event.h" -#include "context.h" -static OGS_POOL(pool, smf_event_t); -static ogs_thread_mutex_t smf_event_alloc_mutex; - -void smf_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); - ogs_thread_mutex_init(&smf_event_alloc_mutex); -} - -void smf_event_final(void) -{ - ogs_pool_final(&pool); - ogs_thread_mutex_destroy(&smf_event_alloc_mutex); -} - -smf_event_t *smf_event_new(smf_event_e id) +smf_event_t *smf_event_new(int id) { smf_event_t *e = NULL; - ogs_thread_mutex_lock(&smf_event_alloc_mutex); - ogs_pool_alloc(&pool, &e); - ogs_thread_mutex_unlock(&smf_event_alloc_mutex); + e = ogs_event_size(id, sizeof(smf_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void smf_event_free(smf_event_t *e) -{ - ogs_assert(e); - ogs_thread_mutex_lock(&smf_event_alloc_mutex); - ogs_pool_free(&pool, e); - ogs_thread_mutex_unlock(&smf_event_alloc_mutex); -} - const char *smf_event_get_name(smf_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; case OGS_FSM_EXIT_SIG: @@ -86,12 +60,12 @@ case SMF_EVT_N4_NO_HEARTBEAT: return "SMF_EVT_N4_NO_HEARTBEAT"; - case SMF_EVT_SBI_SERVER: - return "SMF_EVT_SBI_SERVER"; - case SMF_EVT_SBI_CLIENT: - return "SMF_EVT_SBI_CLIENT"; - case SMF_EVT_SBI_TIMER: - return "SMF_EVT_SBI_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; case SMF_EVT_NGAP_MESSAGE: return "SMF_EVT_NGAP_MESSAGE"; @@ -107,5 +81,6 @@ break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.tar.xz/src/smf/event.h -> open5gs_2.4.10.tar.xz/src/smf/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,8 +20,7 @@ #ifndef SMF_EVENT_H #define SMF_EVENT_H -#include "ogs-core.h" -#include "ogs-gtp.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { @@ -29,6 +28,8 @@ typedef struct ogs_gtp_node_s ogs_gtp_node_t; typedef struct ogs_gtp_xact_s ogs_gtp_xact_t; +typedef struct ogs_gtp1_message_s ogs_gtp1_message_t; +typedef struct ogs_gtp2_message_s ogs_gtp2_message_t; typedef struct ogs_pfcp_node_s ogs_pfcp_node_t; typedef struct ogs_pfcp_xact_s ogs_pfcp_xact_t; typedef struct ogs_pfcp_message_s ogs_pfcp_message_t; @@ -38,16 +39,12 @@ typedef struct smf_sess_s smf_sess_t; typedef struct smf_upf_s smf_upf_t; typedef struct smf_gtp_node_s smf_gtp_node_t; -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_subscription_s ogs_sbi_subscription_t; typedef struct ogs_nas_5gs_message_s ogs_nas_5gs_message_t; typedef struct NGAP_NGAP_PDU ogs_ngap_message_t; typedef long NGAP_ProcedureCode_t; typedef enum { - SMF_EVT_BASE = OGS_FSM_USER_SIG, + SMF_EVT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, SMF_EVT_S5C_MESSAGE, SMF_EVT_S6B_MESSAGE, @@ -59,10 +56,6 @@ SMF_EVT_N4_TIMER, SMF_EVT_N4_NO_HEARTBEAT, - SMF_EVT_SBI_SERVER, - SMF_EVT_SBI_CLIENT, - SMF_EVT_SBI_TIMER, - SMF_EVT_NGAP_MESSAGE, SMF_EVT_NGAP_TIMER, @@ -74,9 +67,9 @@ } smf_event_e; typedef struct smf_event_s { - int id; + ogs_event_t h; + ogs_pkbuf_t *pkbuf; - int timer_id; smf_gtp_node_t *gnode; ogs_gtp_xact_t *gtp_xact; @@ -97,15 +90,6 @@ }; struct { - ogs_sbi_request_t *request; - ogs_sbi_response_t *response; - void *data; - int state; - - ogs_sbi_message_t *message; - } sbi; - - struct { int type; ogs_ngap_message_t *message; } ngap; @@ -118,11 +102,7 @@ smf_sess_t *sess; } smf_event_t; -void smf_event_init(void); -void smf_event_final(void); - -smf_event_t *smf_event_new(smf_event_e id); -void smf_event_free(smf_event_t *e); +smf_event_t *smf_event_new(int id); const char *smf_event_get_name(smf_event_t *e);
View file
open5gs_2.4.9.tar.xz/src/smf/fd-path.c -> open5gs_2.4.10.tar.xz/src/smf/fd-path.c
Changed
@@ -41,7 +41,7 @@ rv = smf_gy_init(); ogs_assert(rv == OGS_OK); - rv = ogs_diam_rx_init(); + rv = ogs_diam_rx_init(); ogs_assert(rv == 0); rv = smf_s6b_init(); ogs_assert(rv == OGS_OK); @@ -49,11 +49,18 @@ rv = ogs_diam_start(); ogs_assert(rv == 0); - return OGS_OK; + return OGS_OK; } void smf_fd_final(void) { + if (smf_self()->diam_conf_path == NULL && + (smf_self()->diam_config->cnf_diamid == NULL || + smf_self()->diam_config->cnf_diamrlm == NULL || + smf_self()->diam_config->cnf_addr == NULL)) { + return; + } + smf_gx_final(); smf_s6b_final();
View file
open5gs_2.4.9.tar.xz/src/smf/gn-handler.c -> open5gs_2.4.10.tar.xz/src/smf/gn-handler.c
Changed
@@ -295,8 +295,8 @@ } ogs_info("UE IMSI%s APN%s IPv4%s IPv6%s", - smf_ue->imsi_bcd, - sess->session.name, + smf_ue->imsi_bcd, + sess->session.name, sess->ipv4 ? OGS_INET_NTOP(&sess->ipv4->addr, buf1) : "", sess->ipv6 ? OGS_INET6_NTOP(&sess->ipv6->addr, buf2) : ""); @@ -314,6 +314,18 @@ return OGS_GTP1_CAUSE_NO_RESOURCES_AVAILABLE; } + /* PCO */ + if (req->protocol_configuration_options.presence) { + OGS_TLV_STORE_DATA(&sess->gtp.ue_pco, + &req->protocol_configuration_options); + } else { + /* + * Clear contents to reflect whether PCO IE was included or not as part + * of Delete PDP context request + */ + OGS_TLV_CLEAR_DATA(&sess->gtp.ue_pco); + } + ogs_debug(" SGW_S5C_TEID0x%x SMF_N4_TEID0x%x", sess->sgw_s5c_teid, sess->smf_n4_teid); return OGS_GTP1_CAUSE_REQUEST_ACCEPTED; @@ -460,6 +472,12 @@ if (req->protocol_configuration_options.presence) { OGS_TLV_STORE_DATA(&sess->gtp.ue_pco, &req->protocol_configuration_options); + } else { + /* + * Clear contents to reflect whether PCO IE was included or not as part + * of Update PDP context request + */ + OGS_TLV_CLEAR_DATA(&sess->gtp.ue_pco); } memset(&h, 0, sizeof(ogs_gtp2_header_t));
View file
open5gs_2.4.9.tar.xz/src/smf/gsm-handler.c -> open5gs_2.4.10.tar.xz/src/smf/gsm-handler.c
Changed
@@ -67,7 +67,7 @@ } ogs_assert(true == - smf_sbi_discover_and_send(OpenAPI_nf_type_UDM, NULL, + smf_sbi_discover_and_send(OGS_SBI_SERVICE_TYPE_NUDM_SDM, NULL, smf_nudm_sdm_build_get, sess, stream, 0, (char *)OGS_SBI_RESOURCE_NAME_SM_DATA));
View file
open5gs_2.4.9.tar.xz/src/smf/gsm-sm.c -> open5gs_2.4.10.tar.xz/src/smf/gsm-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -235,7 +235,7 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: /* reset state: */ sess->sm_data.gx_ccr_init_in_flight = false; @@ -294,14 +294,14 @@ break; default: - ogs_error("Not implmeneted(type:%d)", gtp2_message->h.type); + ogs_error("Not implemented(type:%d)", gtp2_message->h.type); } break; - case SMF_EVT_SBI_SERVER: - sbi_message = e->sbi.message; + case OGS_EVENT_SBI_SERVER: + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(sbi_message->h.service.name) @@ -342,7 +342,7 @@ ogs_assert(nas_message); sess = e->sess; ogs_assert(sess); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); smf_ue = sess->smf_ue; ogs_assert(smf_ue); @@ -397,7 +397,7 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case SMF_EVT_GX_MESSAGE: gx_message = e->gx_message; ogs_assert(gx_message); @@ -482,14 +482,14 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case SMF_EVT_SBI_CLIENT: - sbi_message = e->sbi.message; + case OGS_EVENT_SBI_CLIENT: + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); sess = e->sess; @@ -499,7 +499,7 @@ SWITCH(sbi_message->h.service.name) CASE(OGS_SBI_SERVICE_NAME_NUDM_SDM) - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(sbi_message->h.resource.component1) @@ -545,8 +545,8 @@ break; CASE(OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL) - stream = e->sbi.data; - state = e->sbi.state; + stream = e->h.sbi.data; + state = e->h.sbi.state; SWITCH(sbi_message->h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_SM_POLICIES) @@ -648,7 +648,7 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case SMF_EVT_N4_MESSAGE: pfcp_xact = e->pfcp_xact; ogs_assert(pfcp_xact); @@ -757,7 +757,7 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; @@ -808,14 +808,14 @@ break; default: - ogs_error("Not implmeneted(type:%d)", gtp2_message->h.type); + ogs_error("Not implemented(type:%d)", gtp2_message->h.type); } break; - case SMF_EVT_SBI_SERVER: - sbi_message = e->sbi.message; + case OGS_EVENT_SBI_SERVER: + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(sbi_message->h.service.name) @@ -849,8 +849,8 @@ END break; - case SMF_EVT_SBI_CLIENT: - sbi_message = e->sbi.message; + case OGS_EVENT_SBI_CLIENT: + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); sess = e->sess; @@ -860,7 +860,7 @@ SWITCH(sbi_message->h.service.name) CASE(OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL) - stream = e->sbi.data; + stream = e->h.sbi.data; SWITCH(sbi_message->h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_SM_POLICIES) @@ -940,7 +940,7 @@ SWITCH(sbi_message->h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXTS) smf_namf_comm_handle_n1_n2_message_transfer( - sess, e->sbi.state, sbi_message); + sess, e->h.sbi.state, sbi_message); break; DEFAULT @@ -963,7 +963,7 @@ ogs_assert(nas_message); sess = e->sess; ogs_assert(sess); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); smf_ue = sess->smf_ue; ogs_assert(smf_ue); @@ -996,7 +996,8 @@ NGAP_CauseNas_normal_release; ogs_assert(true == - smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + smf_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NPCF_SMPOLICYCONTROL, NULL, smf_npcf_smpolicycontrol_build_delete, sess, stream, OGS_PFCP_DELETE_TRIGGER_UE_REQUESTED, ¶m)); @@ -1023,7 +1024,7 @@ case SMF_EVT_NGAP_MESSAGE: sess = e->sess; ogs_assert(sess); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); smf_ue = sess->smf_ue; ogs_assert(smf_ue); @@ -1160,7 +1161,7 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: /* Since `pfcp_xact->epc` is not avaiable, * we'll use `sess->epc` */ @@ -1170,12 +1171,12 @@ smf_epc_pfcp_send_session_deletion_request(sess, e->gtp_xact)); } else { /* 5GC */ - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); ogs_assert(OGS_OK == smf_5gc_pfcp_send_session_deletion_request( - sess, stream, e->sbi.state)); + sess, stream, e->h.sbi.state)); } break; @@ -1286,7 +1287,7 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: /* reset state: */ sess->sm_data.gx_cca_term_err = ER_DIAMETER_SUCCESS; @@ -1413,16 +1414,16 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case SMF_EVT_SBI_SERVER: - sbi_message = e->sbi.message; + case OGS_EVENT_SBI_SERVER: + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(sbi_message->h.service.name) @@ -1453,8 +1454,8 @@ END break; - case SMF_EVT_SBI_CLIENT: - sbi_message = e->sbi.message; + case OGS_EVENT_SBI_CLIENT: + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); sess = e->sess; @@ -1467,7 +1468,7 @@ SWITCH(sbi_message->h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXTS) smf_namf_comm_handle_n1_n2_message_transfer( - sess, e->sbi.state, sbi_message); + sess, e->h.sbi.state, sbi_message); break; DEFAULT @@ -1488,7 +1489,7 @@ case SMF_EVT_NGAP_MESSAGE: sess = e->sess; ogs_assert(sess); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); smf_ue = sess->smf_ue; ogs_assert(smf_ue); @@ -1535,7 +1536,7 @@ ogs_assert(nas_message); sess = e->sess; ogs_assert(sess); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); smf_ue = sess->smf_ue; ogs_assert(smf_ue); @@ -1572,7 +1573,7 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: SMF_SESS_CLEAR(sess); break; @@ -1601,7 +1602,7 @@ smf_ue = sess->smf_ue; ogs_assert(smf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: ogs_error("%s:%d State machine exception", smf_ue->supi, sess->psi); SMF_SESS_CLEAR(sess);
View file
open5gs_2.4.9.tar.xz/src/smf/gtp-path.c -> open5gs_2.4.10.tar.xz/src/smf/gtp-path.c
Changed
@@ -108,7 +108,7 @@ if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_pkbuf_free(e->pkbuf); - smf_event_free(e); + ogs_event_free(e); } }
View file
open5gs_2.4.9.tar.xz/src/smf/gx-path.c -> open5gs_2.4.10.tar.xz/src/smf/gx-path.c
Changed
@@ -116,7 +116,7 @@ if (sess->gx_sid) { /* Retrieve session by Session-Id */ size_t sidlen = strlen(sess->gx_sid); - ret = fd_sess_fromsid_msg((os0_t)sess->gx_sid, sidlen, &session, &new); + ret = fd_sess_fromsid_msg((os0_t)sess->gx_sid, sidlen, &session, &new); ogs_assert(ret == 0); ogs_assert(new == 0); @@ -538,6 +538,25 @@ } } + /* 3GPP-Charging-Characteristics, 3GPP TS 29.061 16.4.7.2 13 */ + if (sess->gtp.charging_characteristics.presence && + sess->gtp.charging_characteristics.len > 0) { + uint8_t oct1, oct2; + char digits5; + ret = fd_msg_avp_new(ogs_diam_gx_3gpp_charging_characteristics, 0, &avp); + ogs_assert(ret == 0); + oct1 = ((uint8_t*)sess->gtp.charging_characteristics.data)0; + oct2 = (sess->gtp.charging_characteristics.len > 1) ? + ((uint8_t*)sess->gtp.charging_characteristics.data)1 : 0; + ogs_snprintf(digits, sizeof(digits), "%02x%02x", oct1, oct2); + val.os.data = (uint8_t*)&digits0; + val.os.len = 4; + ret = fd_msg_avp_setvalue(avp, &val); + ogs_assert(ret == 0); + ret = fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp); + ogs_assert(ret == 0); + } + /* Set Called-Station-Id */ ret = fd_msg_avp_new(ogs_diam_gx_called_station_id, 0, &avp); ogs_assert(ret == 0); @@ -1008,7 +1027,7 @@ ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_session_data_free(&gx_message->session_data); ogs_free(gx_message); - smf_event_free(e); + ogs_event_free(e); } else { ogs_pollset_notify(ogs_app()->pollset); } @@ -1078,10 +1097,10 @@ static int smf_gx_fb_cb(struct msg **msg, struct avp *avp, struct session *sess, void *opaque, enum disp_action *act) { - /* This CB should never be called */ - ogs_warn("Unexpected message received!"); + /* This CB should never be called */ + ogs_warn("Unexpected message received!"); - return ENOTSUP; + return ENOTSUP; } static int smf_gx_rar_cb( struct msg **msg, struct avp *avp, @@ -1090,7 +1109,7 @@ int rv; int ret; - struct msg *ans, *qry; + struct msg *ans, *qry; struct avp *avpch1; struct avp_hdr *hdr; union avp_value val; @@ -1113,9 +1132,9 @@ /* Set Credit Control Command */ gx_message->cmd_code = OGS_DIAM_GX_CMD_RE_AUTH; - /* Create answer header */ - qry = *msg; - ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + /* Create answer header */ + qry = *msg; + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); ogs_assert(ret == 0); ans = *msg; @@ -1251,7 +1270,7 @@ ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_session_data_free(&gx_message->session_data); ogs_free(gx_message); - smf_event_free(e); + ogs_event_free(e); } else { ogs_pollset_notify(ogs_app()->pollset); } @@ -1265,8 +1284,8 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ - ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_SUCCESS", NULL, NULL, 1); + /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_SUCCESS", NULL, NULL, 1); ogs_assert(ret == 0); /* Store this value in the session */ @@ -1274,16 +1293,16 @@ ogs_assert(ret == 0); ogs_assert(sess_data == NULL); - /* Send the answer */ - ret = fd_msg_send(msg, NULL, NULL); + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_debug("Re-Auth-Answer"); - /* Add this value to the stats */ - ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); - ogs_diam_logger_self()->stats.nb_echoed++; - ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); + /* Add this value to the stats */ + ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); return 0; @@ -1313,49 +1332,49 @@ int smf_gx_init(void) { int ret; - struct disp_when data; + struct disp_when data; ogs_thread_mutex_init(&sess_state_mutex); ogs_pool_init(&sess_state_pool, ogs_app()->pool.sess); - /* Install objects definitions for this application */ - ret = ogs_diam_gx_init(); + /* Install objects definitions for this application */ + ret = ogs_diam_gx_init(); ogs_assert(ret == 0); /* Create handler for sessions */ - ret = fd_sess_handler_create(&smf_gx_reg, state_cleanup, NULL, NULL); + ret = fd_sess_handler_create(&smf_gx_reg, state_cleanup, NULL, NULL); ogs_assert(ret == 0); - memset(&data, 0, sizeof(data)); - data.app = ogs_diam_gx_application; + memset(&data, 0, sizeof(data)); + data.app = ogs_diam_gx_application; - ret = fd_disp_register(smf_gx_fb_cb, DISP_HOW_APPID, &data, NULL, + ret = fd_disp_register(smf_gx_fb_cb, DISP_HOW_APPID, &data, NULL, &hdl_gx_fb); ogs_assert(ret == 0); - data.command = ogs_diam_gx_cmd_rar; - ret = fd_disp_register(smf_gx_rar_cb, DISP_HOW_CC, &data, NULL, + data.command = ogs_diam_gx_cmd_rar; + ret = fd_disp_register(smf_gx_rar_cb, DISP_HOW_CC, &data, NULL, &hdl_gx_rar); ogs_assert(ret == 0); - /* Advertise the support for the application in the peer */ - ret = fd_disp_app_support(ogs_diam_gx_application, ogs_diam_vendor, 1, 0); + /* Advertise the support for the application in the peer */ + ret = fd_disp_app_support(ogs_diam_gx_application, ogs_diam_vendor, 1, 0); ogs_assert(ret == 0); - return OGS_OK; + return OGS_OK; } void smf_gx_final(void) { int ret; - ret = fd_sess_handler_destroy(&smf_gx_reg, NULL); + ret = fd_sess_handler_destroy(&smf_gx_reg, NULL); ogs_assert(ret == 0); - if (hdl_gx_fb) - (void) fd_disp_unregister(&hdl_gx_fb, NULL); - if (hdl_gx_rar) - (void) fd_disp_unregister(&hdl_gx_rar, NULL); + if (hdl_gx_fb) + (void) fd_disp_unregister(&hdl_gx_fb, NULL); + if (hdl_gx_rar) + (void) fd_disp_unregister(&hdl_gx_rar, NULL); ogs_pool_final(&sess_state_pool); ogs_thread_mutex_destroy(&sess_state_mutex);
View file
open5gs_2.4.9.tar.xz/src/smf/gy-path.c -> open5gs_2.4.10.tar.xz/src/smf/gy-path.c
Changed
@@ -441,7 +441,7 @@ oct1 = ((uint8_t*)sess->gtp.charging_characteristics.data)0; oct2 = (sess->gtp.charging_characteristics.len > 1) ? ((uint8_t*)sess->gtp.charging_characteristics.data)1 : 0; - snprintf(digits, sizeof(digits), "%02x%02x", oct1, oct2); + ogs_snprintf(digits, sizeof(digits), "%02x%02x", oct1, oct2); val.os.data = (uint8_t*)&digits0; val.os.len = 4; ret = fd_msg_avp_setvalue(avpch2, &val); @@ -582,7 +582,7 @@ if (sess->gy_sid) { /* Retrieve session by Session-Id */ size_t sidlen = strlen(sess->gy_sid); - ret = fd_sess_fromsid_msg((os0_t)sess->gy_sid, sidlen, &session, &new); + ret = fd_sess_fromsid_msg((os0_t)sess->gy_sid, sidlen, &session, &new); ogs_assert(ret == 0); ogs_assert(new == 0); @@ -1106,7 +1106,7 @@ if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_free(gy_message); - smf_event_free(e); + ogs_event_free(e); } else { ogs_pollset_notify(ogs_app()->pollset); } @@ -1175,10 +1175,10 @@ static int smf_gy_fb_cb(struct msg **msg, struct avp *avp, struct session *sess, void *opaque, enum disp_action *act) { - /* This CB should never be called */ - ogs_warn("Unexpected message received!"); + /* This CB should never be called */ + ogs_warn("Unexpected message received!"); - return ENOTSUP; + return ENOTSUP; } static int smf_gy_rar_cb( struct msg **msg, struct avp *avp, @@ -1187,7 +1187,7 @@ int rv; int ret; - struct msg *ans; + struct msg *ans; union avp_value val; struct sess_state *sess_data = NULL; @@ -1207,8 +1207,8 @@ /* Set Credit Control Command */ gy_message->cmd_code = OGS_DIAM_GY_CMD_RE_AUTH; - /* Create answer header */ - ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + /* Create answer header */ + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); ogs_assert(ret == 0); ans = *msg; @@ -1235,7 +1235,7 @@ if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_free(gy_message); - smf_event_free(e); + ogs_event_free(e); } else { ogs_pollset_notify(ogs_app()->pollset); } @@ -1249,8 +1249,8 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ - ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_SUCCESS", NULL, NULL, 1); + /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_SUCCESS", NULL, NULL, 1); ogs_assert(ret == 0); /* Store this value in the session */ @@ -1258,16 +1258,16 @@ ogs_assert(ret == 0); ogs_assert(sess_data == NULL); - /* Send the answer */ - ret = fd_msg_send(msg, NULL, NULL); + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); ogs_debug("Re-Auth-Answer"); - /* Add this value to the stats */ - ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); - ogs_diam_logger_self()->stats.nb_echoed++; - ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); + /* Add this value to the stats */ + ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); return 0; @@ -1296,49 +1296,49 @@ int smf_gy_init(void) { int ret; - struct disp_when data; + struct disp_when data; ogs_thread_mutex_init(&sess_state_mutex); ogs_pool_init(&sess_state_pool, ogs_app()->pool.sess); - /* Install objects definitions for this application */ - ret = ogs_diam_gy_init(); + /* Install objects definitions for this application */ + ret = ogs_diam_gy_init(); ogs_assert(ret == 0); /* Create handler for sessions */ - ret = fd_sess_handler_create(&smf_gy_reg, state_cleanup, NULL, NULL); + ret = fd_sess_handler_create(&smf_gy_reg, state_cleanup, NULL, NULL); ogs_assert(ret == 0); - memset(&data, 0, sizeof(data)); - data.app = ogs_diam_gy_application; + memset(&data, 0, sizeof(data)); + data.app = ogs_diam_gy_application; - ret = fd_disp_register(smf_gy_fb_cb, DISP_HOW_APPID, &data, NULL, + ret = fd_disp_register(smf_gy_fb_cb, DISP_HOW_APPID, &data, NULL, &hdl_gy_fb); ogs_assert(ret == 0); - data.command = ogs_diam_gy_cmd_rar; - ret = fd_disp_register(smf_gy_rar_cb, DISP_HOW_CC, &data, NULL, + data.command = ogs_diam_gy_cmd_rar; + ret = fd_disp_register(smf_gy_rar_cb, DISP_HOW_CC, &data, NULL, &hdl_gy_rar); ogs_assert(ret == 0); - /* Advertise the support for the application in the peer */ - ret = fd_disp_app_support(ogs_diam_gy_application, NULL, 1, 0); + /* Advertise the support for the application in the peer */ + ret = fd_disp_app_support(ogs_diam_gy_application, NULL, 1, 0); ogs_assert(ret == 0); - return OGS_OK; + return OGS_OK; } void smf_gy_final(void) { int ret; - ret = fd_sess_handler_destroy(&smf_gy_reg, NULL); + ret = fd_sess_handler_destroy(&smf_gy_reg, NULL); ogs_assert(ret == 0); - if (hdl_gy_fb) - (void) fd_disp_unregister(&hdl_gy_fb, NULL); - if (hdl_gy_rar) - (void) fd_disp_unregister(&hdl_gy_rar, NULL); + if (hdl_gy_fb) + (void) fd_disp_unregister(&hdl_gy_fb, NULL); + if (hdl_gy_rar) + (void) fd_disp_unregister(&hdl_gy_rar, NULL); ogs_pool_final(&sess_state_pool); ogs_thread_mutex_destroy(&sess_state_mutex);
View file
open5gs_2.4.9.tar.xz/src/smf/init.c -> open5gs_2.4.10.tar.xz/src/smf/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -39,7 +39,6 @@ ogs_sbi_context_init(); smf_context_init(); - smf_event_init(); rv = ogs_gtp_xact_init(); if (rv != OGS_OK) return rv; @@ -100,7 +99,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - smf_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -138,8 +137,6 @@ ogs_pfcp_xact_final(); ogs_gtp_xact_final(); - - smf_event_final(); /* Destroy event */ } static void smf_main(void *data) @@ -147,8 +144,7 @@ ogs_fsm_t smf_sm; int rv; - ogs_fsm_create(&smf_sm, smf_state_initial, smf_state_final); - ogs_fsm_init(&smf_sm, 0); + ogs_fsm_init(&smf_sm, smf_state_initial, smf_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -181,11 +177,10 @@ ogs_assert(e); ogs_fsm_dispatch(&smf_sm, e); - smf_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&smf_sm, 0); - ogs_fsm_delete(&smf_sm); }
View file
open5gs_2.4.9.tar.xz/src/smf/meson.build -> open5gs_2.4.10.tar.xz/src/smf/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -51,7 +51,6 @@ n4-build.h n4-handler.h binding.h - nnrf-build.h nnrf-handler.h nudm-build.h nudm-handler.h @@ -74,7 +73,6 @@ timer.c context.c smf-sm.c - nf-sm.c gsm-sm.c pfcp-sm.c gtp-path.c @@ -92,7 +90,6 @@ n4-build.c n4-handler.c binding.c - nnrf-build.c nnrf-handler.c nudm-build.c nudm-handler.c @@ -113,29 +110,25 @@ libsmf = static_library('smf', sources : libsmf_sources, - dependencies : libapp_dep, - libmetrics_dep, + dependencies : libmetrics_dep, libsbi_dep, libngap_dep, libnas_5gs_dep, libdiameter_gx_dep, libdiameter_gy_dep, libdiameter_s6b_dep, - libgtp_dep, libpfcp_dep, install : false) libsmf_dep = declare_dependency( link_with : libsmf, - dependencies : libapp_dep, - libmetrics_dep, + dependencies : libmetrics_dep, libsbi_dep, libngap_dep, libnas_5gs_dep, libdiameter_gx_dep, libdiameter_gy_dep, libdiameter_s6b_dep, - libgtp_dep, libpfcp_dep) smf_sources = files('''
View file
open5gs_2.4.9.tar.xz/src/smf/n4-handler.c -> open5gs_2.4.10.tar.xz/src/smf/n4-handler.c
Changed
@@ -18,7 +18,6 @@ */ #include "context.h" -#include "timer.h" #include "s5c-build.h" #include "pfcp-path.h" #include "gtp-path.h" @@ -255,7 +254,6 @@ ogs_debug("Session Modification Response 5gc"); - ogs_assert(sess); ogs_assert(xact); ogs_assert(rsp); @@ -280,6 +278,11 @@ status = OGS_SBI_HTTP_STATUS_OK; + if (!sess) { + ogs_error("No Context"); + status = OGS_SBI_HTTP_STATUS_NOT_FOUND; + } + if (rsp->cause.presence) { if (rsp->cause.u8 != OGS_PFCP_CAUSE_REQUEST_ACCEPTED) { ogs_warn("PFCP Cause %d : Not Accepted", rsp->cause.u8); @@ -397,7 +400,14 @@ } else { sess->paging.ue_requested_pdu_session_establishment_done = true; - ogs_assert(true == ogs_sbi_send_http_status_no_content(stream)); + + if (sess->up_cnx_state == OpenAPI_up_cnx_state_ACTIVATING) { + sess->up_cnx_state = OpenAPI_up_cnx_state_ACTIVATED; + smf_sbi_send_sm_context_updated_data_up_cnx_state( + sess, stream, OpenAPI_up_cnx_state_ACTIVATED); + } else { + ogs_assert(true == ogs_sbi_send_http_status_no_content(stream)); + } } } else if (flags & OGS_PFCP_MODIFY_DEACTIVATE) { @@ -794,7 +804,6 @@ OGS_LIST(pdr_to_create_list); - ogs_assert(sess); ogs_assert(xact); ogs_assert(rsp); @@ -823,6 +832,11 @@ ogs_pfcp_xact_commit(xact); + if (!sess) { + ogs_error("No Context"); + return; + } + if (rsp->cause.presence) { if (rsp->cause.u8 != OGS_PFCP_CAUSE_REQUEST_ACCEPTED) { ogs_error("PFCP Cause %d : Not Accepted", rsp->cause.u8); @@ -1098,7 +1112,6 @@ uint16_t pdr_id = 0; unsigned int i; - ogs_assert(sess); ogs_assert(pfcp_xact); ogs_assert(pfcp_req); @@ -1106,6 +1119,11 @@ cause_value = OGS_GTP2_CAUSE_REQUEST_ACCEPTED; + if (!sess) { + ogs_error("No Context"); + cause_value = OGS_PFCP_CAUSE_SESSION_CONTEXT_NOT_FOUND; + } + if (pfcp_req->report_type.presence == 0) { ogs_error("No Report Type"); cause_value = OGS_GTP2_CAUSE_MANDATORY_IE_MISSING; @@ -1118,6 +1136,7 @@ return; } + ogs_assert(sess); report_type.value = pfcp_req->report_type.u8; if (report_type.downlink_data_report) {
View file
open5gs_2.4.9.tar.xz/src/smf/nas-path.c -> open5gs_2.4.10.tar.xz/src/smf/nas-path.c
Changed
@@ -31,12 +31,12 @@ e = smf_event_new(SMF_EVT_5GSM_MESSAGE); ogs_assert(e); e->sess = sess; - e->sbi.data = stream; + e->h.sbi.data = stream; e->pkbuf = pkbuf; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_pkbuf_free(e->pkbuf); - smf_event_free(e); + ogs_event_free(e); } }
View file
open5gs_2.4.9.tar.xz/src/smf/ngap-handler.c -> open5gs_2.4.10.tar.xz/src/smf/ngap-handler.c
Changed
@@ -151,8 +151,18 @@ sess, stream, OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_ACTIVATE, 0)); } else { +#if 0 /* Modified by pull request #1729 */ /* ACTIVATED Is NOT Included in RESPONSE */ ogs_assert(true == ogs_sbi_send_http_status_no_content(stream)); +#else + if (sess->up_cnx_state == OpenAPI_up_cnx_state_ACTIVATING) { + sess->up_cnx_state = OpenAPI_up_cnx_state_ACTIVATED; + smf_sbi_send_sm_context_updated_data_up_cnx_state( + sess, stream, OpenAPI_up_cnx_state_ACTIVATED); + } else { + ogs_assert(true == ogs_sbi_send_http_status_no_content(stream)); + } +#endif } rv = OGS_OK;
View file
open5gs_2.4.9.tar.xz/src/smf/ngap-path.c -> open5gs_2.4.10.tar.xz/src/smf/ngap-path.c
Changed
@@ -31,13 +31,13 @@ e = smf_event_new(SMF_EVT_NGAP_MESSAGE); ogs_assert(e); e->sess = sess; - e->sbi.data = stream; + e->h.sbi.data = stream; e->pkbuf = pkbuf; e->ngap.type = type; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_pkbuf_free(e->pkbuf); - smf_event_free(e); + ogs_event_free(e); } -} \ No newline at end of file +}
View file
open5gs_2.4.9.tar.xz/src/smf/nnrf-handler.c -> open5gs_2.4.10.tar.xz/src/smf/nnrf-handler.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,252 +20,24 @@ #include "sbi-path.h" #include "nnrf-handler.h" -void smf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void smf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->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_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - 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, - smf_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 smf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - smf_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - nf_instance->reference_count++; - - OGS_FSM_TRAN(&nf_instance->sm, smf_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - SMF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - SMF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - SMF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -} - void smf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; - OpenAPI_nf_type_e target_nf_type = 0; + ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; OpenAPI_search_result_t *SearchResult = NULL; - OpenAPI_lnode_t *node = NULL; - bool handled; ogs_assert(recvmsg); ogs_assert(xact); sbi_object = xact->sbi_object; ogs_assert(sbi_object); - target_nf_type = xact->target_nf_type; + service_type = xact->service_type; + ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); ogs_assert(target_nf_type); discovery_option = xact->discovery_option; @@ -276,68 +48,18 @@ 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(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); - - smf_nf_fsm_init(nf_instance); + ogs_nnrf_handle_nf_discover_search_result(SearchResult); - ogs_info("%s (NF-discover) NF registered", nf_instance->id); - } else { - nf_instance->reference_count++; - - OGS_FSM_TRAN(&nf_instance->sm, smf_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("ogs_sbi_nnrf_handle_nf_profile() failed %s", - nf_instance->id); - SMF_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); - SMF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - /* TIME : Update validity from NRF */ - if (SearchResult->is_validity_period && - 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); - } + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (!nf_instance) { + ogs_error("(NF discover) No %s", + ogs_sbi_service_type_to_name(service_type)); + return; } - ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_arrayservice_type, nf_instance); - ogs_expect(true == smf_sbi_send_request(sbi_object, target_nf_type, xact)); + ogs_expect(true == smf_sbi_send_request(nf_instance, xact)); }
View file
open5gs_2.4.9.tar.xz/src/smf/nnrf-handler.h -> open5gs_2.4.10.tar.xz/src/smf/nnrf-handler.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -26,14 +26,6 @@ extern "C" { #endif -void smf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void smf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool smf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - void smf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg);
View file
open5gs_2.4.9.tar.xz/src/smf/npcf-handler.c -> open5gs_2.4.10.tar.xz/src/smf/npcf-handler.c
Changed
@@ -276,8 +276,6 @@ char buf1OGS_ADDRSTRLEN; char buf2OGS_ADDRSTRLEN; - uint64_t supported_features; - char *strerror = NULL; smf_ue_t *smf_ue = NULL; @@ -345,7 +343,7 @@ /* SBI Features */ if (SmPolicyDecision->supp_feat) { - supported_features = + uint64_t supported_features = ogs_uint64_from_string(SmPolicyDecision->supp_feat); sess->smpolicycontrol_features &= supported_features; } else { @@ -495,7 +493,7 @@ &ul_pdr->ue_ip_addr, &ul_pdr->ue_ip_addr_len)); ogs_info("UE SUPI%s DNN%s IPv4%s IPv6%s", - smf_ue->supi, sess->session.name, + smf_ue->supi, sess->session.name, sess->ipv4 ? OGS_INET_NTOP(&sess->ipv4->addr, buf1) : "", sess->ipv6 ? OGS_INET6_NTOP(&sess->ipv6->addr, buf2) : ""); @@ -683,7 +681,8 @@ memset(¶m, 0, sizeof(param)); ogs_assert(true == - smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + smf_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NPCF_SMPOLICYCONTROL, NULL, smf_npcf_smpolicycontrol_build_delete, sess, NULL, OGS_PFCP_DELETE_TRIGGER_PCF_INITIATED, ¶m));
View file
open5gs_2.4.9.tar.xz/src/smf/nsmf-handler.c -> open5gs_2.4.10.tar.xz/src/smf/nsmf-handler.c
Changed
@@ -350,6 +350,8 @@ } else if (SmContextUpdateData->up_cnx_state) { + sess->up_cnx_state = SmContextUpdateData->up_cnx_state; + if (SmContextUpdateData->up_cnx_state == OpenAPI_up_cnx_state_DEACTIVATED) { @@ -590,7 +592,8 @@ param.ue_timezone = true; ogs_assert(true == - smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + smf_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NPCF_SMPOLICYCONTROL, NULL, smf_npcf_smpolicycontrol_build_delete, sess, stream, OGS_PFCP_DELETE_TRIGGER_AMF_UPDATE_SM_CONTEXT, ¶m)); @@ -666,7 +669,8 @@ if (sess->policy_association_id) { ogs_assert(true == - smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + smf_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NPCF_SMPOLICYCONTROL, NULL, smf_npcf_smpolicycontrol_build_delete, sess, stream, OGS_PFCP_DELETE_TRIGGER_AMF_RELEASE_SM_CONTEXT, ¶m));
View file
open5gs_2.4.9.tar.xz/src/smf/nudm-handler.c -> open5gs_2.4.10.tar.xz/src/smf/nudm-handler.c
Changed
@@ -288,7 +288,8 @@ ogs_free(sendmsg.http.location); ogs_assert(true == - smf_sbi_discover_and_send(OpenAPI_nf_type_PCF, NULL, + smf_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NPCF_SMPOLICYCONTROL, NULL, smf_npcf_smpolicycontrol_build_create, sess, stream, 0, NULL)); return true;
View file
open5gs_2.4.9.tar.xz/src/smf/pfcp-path.c -> open5gs_2.4.10.tar.xz/src/smf/pfcp-path.c
Changed
@@ -74,8 +74,7 @@ ogs_assert(node->t_association); } - ogs_fsm_create(&node->sm, smf_pfcp_state_initial, smf_pfcp_state_final); - ogs_fsm_init(&node->sm, &e); + ogs_fsm_init(&node->sm, smf_pfcp_state_initial, smf_pfcp_state_final, &e); } static void pfcp_node_fsm_fini(ogs_pfcp_node_t *node) @@ -88,7 +87,6 @@ e.pfcp_node = node; ogs_fsm_fini(&node->sm, &e); - ogs_fsm_delete(&node->sm); if (node->t_association) ogs_timer_delete(node->t_association); @@ -159,7 +157,7 @@ if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_pkbuf_free(e->pkbuf); - smf_event_free(e); + ogs_event_free(e); } } @@ -692,9 +690,6 @@ ogs_pkbuf_t *sxabuf = NULL; ogs_pfcp_header_t h; - ogs_assert(xact); - xact->local_seid = sess->smf_n4_seid; - memset(&h, 0, sizeof(ogs_pfcp_header_t)); h.type = OGS_PFCP_SESSION_REPORT_RESPONSE_TYPE; h.seid = sess->upf_n4_seid;
View file
open5gs_2.4.9.tar.xz/src/smf/pfcp-sm.c -> open5gs_2.4.10.tar.xz/src/smf/pfcp-sm.c
Changed
@@ -82,7 +82,7 @@ addr = node->sa_list; ogs_assert(addr); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: if (node->t_association) { ogs_timer_start(node->t_association, @@ -99,7 +99,7 @@ break; case SMF_EVT_N4_TIMER: - switch(e->timer_id) { + switch(e->h.timer_id) { case SMF_TIMER_PFCP_ASSOCIATION: node = e->pfcp_node; ogs_assert(node); @@ -115,7 +115,7 @@ break; default: ogs_error("Unknown timer%s:%d", - smf_timer_get_name(e->timer_id), e->timer_id); + smf_timer_get_name(e->h.timer_id), e->h.timer_id); break; } break; @@ -169,7 +169,7 @@ addr = node->sa_list; ogs_assert(addr); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: ogs_info("PFCP associated"); ogs_timer_start(node->t_no_heartbeat, @@ -224,15 +224,18 @@ if (!sess) { ogs_gtp_xact_t *gtp_xact = xact->assoc_xact; - ogs_assert(gtp_xact); + if (!gtp_xact) { + ogs_error("No associated GTP transaction"); + break; + } if (gtp_xact->gtp_version == 1) ogs_gtp1_send_error_message(gtp_xact, 0, - OGS_GTP1_CREATE_PDP_CONTEXT_RESPONSE_TYPE, - OGS_GTP1_CAUSE_CONTEXT_NOT_FOUND); + OGS_GTP1_CREATE_PDP_CONTEXT_RESPONSE_TYPE, + OGS_GTP1_CAUSE_CONTEXT_NOT_FOUND); else ogs_gtp2_send_error_message(gtp_xact, 0, - OGS_GTP2_CREATE_SESSION_RESPONSE_TYPE, - OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND); + OGS_GTP2_CREATE_SESSION_RESPONSE_TYPE, + OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND); break; } ogs_fsm_dispatch(&sess->sm, e); @@ -255,19 +258,20 @@ if (!sess) { ogs_gtp_xact_t *gtp_xact = xact->assoc_xact; - if (!gtp_xact) - break; + if (!gtp_xact) { + ogs_error("No associated GTP transaction"); + break; + } if (gtp_xact->gtp_version == 1) ogs_gtp1_send_error_message(gtp_xact, 0, - OGS_GTP1_CREATE_PDP_CONTEXT_RESPONSE_TYPE, - OGS_GTP1_CAUSE_CONTEXT_NOT_FOUND); + OGS_GTP1_DELETE_PDP_CONTEXT_RESPONSE_TYPE, + OGS_GTP1_CAUSE_CONTEXT_NOT_FOUND); else ogs_gtp2_send_error_message(gtp_xact, 0, - OGS_GTP2_CREATE_SESSION_RESPONSE_TYPE, - OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND); + OGS_GTP2_DELETE_SESSION_RESPONSE_TYPE, + OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND); break; } - ogs_fsm_dispatch(&sess->sm, e); break; @@ -286,7 +290,7 @@ break; case SMF_EVT_N4_TIMER: - switch(e->timer_id) { + switch(e->h.timer_id) { case SMF_TIMER_PFCP_NO_HEARTBEAT: node = e->pfcp_node; ogs_assert(node); @@ -296,7 +300,7 @@ break; default: ogs_error("Unknown timer%s:%d", - smf_timer_get_name(e->timer_id), e->timer_id); + smf_timer_get_name(e->h.timer_id), e->h.timer_id); break; } break; @@ -318,7 +322,7 @@ smf_sm_debug(e); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: @@ -349,7 +353,7 @@ rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); - smf_event_free(e); + ogs_event_free(e); } break; case OGS_PFCP_ASSOCIATION_SETUP_REQUEST_TYPE:
View file
open5gs_2.4.9.tar.xz/src/smf/s5c-handler.c -> open5gs_2.4.10.tar.xz/src/smf/s5c-handler.c
Changed
@@ -253,8 +253,8 @@ ogs_assert(OGS_PFCP_CAUSE_REQUEST_ACCEPTED == smf_sess_set_ue_ip(sess)); ogs_info("UE IMSI%s APN%s IPv4%s IPv6%s", - smf_ue->imsi_bcd, - sess->session.name, + smf_ue->imsi_bcd, + sess->session.name, sess->ipv4 ? OGS_INET_NTOP(&sess->ipv4->addr, buf1) : "", sess->ipv6 ? OGS_INET6_NTOP(&sess->ipv6->addr, buf2) : ""); @@ -410,6 +410,23 @@ } } + /* PCO + * 3GPP TS 29.274 version 10.5.0, Table 7.2.9.1-1 + * If the UE includes the PCO IE, then the MME/SGSN shall copy + * the content of this IE transparently from the PCO IE included by the UE. + * If SGW receives the PCO IE, SGW shall forward it to PGW. + */ + if (req->protocol_configuration_options.presence) { + OGS_TLV_STORE_DATA(&sess->gtp.ue_pco, + &req->protocol_configuration_options); + } else { + /* + * Clear contents to reflect whether PCO IE was included or not as part + * of session deletion procedure + */ + OGS_TLV_CLEAR_DATA(&sess->gtp.ue_pco); + } + ogs_debug(" SGW_S5C_TEID0x%x SMF_N4_TEID0x%x", sess->sgw_s5c_teid, sess->smf_n4_teid);
View file
open5gs_2.4.9.tar.xz/src/smf/s6b-path.c -> open5gs_2.4.10.tar.xz/src/smf/s6b-path.c
Changed
@@ -65,10 +65,10 @@ static int smf_s6b_fb_cb(struct msg **msg, struct avp *avp, struct session *sess, void *opaque, enum disp_action *act) { - /* This CB should never be called */ - ogs_warn("Unexpected message received!"); + /* This CB should never be called */ + ogs_warn("Unexpected message received!"); - return ENOTSUP; + return ENOTSUP; } void smf_s6b_send_aar(smf_sess_t *sess, ogs_gtp_xact_t *xact) @@ -111,7 +111,7 @@ if (sess->s6b_sid) { /* Retrieve session by Session-Id */ size_t sidlen = strlen(sess->s6b_sid); - ret = fd_sess_fromsid_msg((os0_t)sess->s6b_sid, sidlen, &session, &new); + ret = fd_sess_fromsid_msg((os0_t)sess->s6b_sid, sidlen, &session, &new); ogs_assert(ret == 0); ogs_assert(new == 0); @@ -714,7 +714,7 @@ if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_free(s6b_message); - smf_event_free(e); + ogs_event_free(e); } else { ogs_pollset_notify(ogs_app()->pollset); } @@ -772,42 +772,42 @@ int smf_s6b_init(void) { int ret; - struct disp_when data; + struct disp_when data; ogs_thread_mutex_init(&sess_state_mutex); ogs_pool_init(&sess_state_pool, ogs_app()->pool.sess); - /* Install objects definitions for this application */ - ret = ogs_diam_s6b_init(); + /* Install objects definitions for this application */ + ret = ogs_diam_s6b_init(); ogs_assert(ret == 0); /* Create handler for sessions */ - ret = fd_sess_handler_create(&smf_s6b_reg, state_cleanup, NULL, NULL); + ret = fd_sess_handler_create(&smf_s6b_reg, state_cleanup, NULL, NULL); ogs_assert(ret == 0); - memset(&data, 0, sizeof(data)); - data.app = ogs_diam_s6b_application; + memset(&data, 0, sizeof(data)); + data.app = ogs_diam_s6b_application; - ret = fd_disp_register(smf_s6b_fb_cb, DISP_HOW_APPID, &data, NULL, + ret = fd_disp_register(smf_s6b_fb_cb, DISP_HOW_APPID, &data, NULL, &hdl_s6b_fb); ogs_assert(ret == 0); - /* Advertise the support for the application in the peer */ - ret = fd_disp_app_support(ogs_diam_s6b_application, ogs_diam_vendor, 1, 0); + /* Advertise the support for the application in the peer */ + ret = fd_disp_app_support(ogs_diam_s6b_application, ogs_diam_vendor, 1, 0); ogs_assert(ret == 0); - return OGS_OK; + return OGS_OK; } void smf_s6b_final(void) { int ret; - ret = fd_sess_handler_destroy(&smf_s6b_reg, NULL); + ret = fd_sess_handler_destroy(&smf_s6b_reg, NULL); ogs_assert(ret == 0); - if (hdl_s6b_fb) - (void) fd_disp_unregister(&hdl_s6b_fb, NULL); + if (hdl_s6b_fb) + (void) fd_disp_unregister(&hdl_s6b_fb, NULL); ogs_pool_final(&sess_state_pool); ogs_thread_mutex_destroy(&sess_state_mutex);
View file
open5gs_2.4.9.tar.xz/src/smf/sbi-path.c -> open5gs_2.4.10.tar.xz/src/smf/sbi-path.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -29,17 +29,17 @@ ogs_assert(request); ogs_assert(data); - e = smf_event_new(SMF_EVT_SBI_SERVER); + e = smf_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - smf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -60,16 +60,16 @@ ogs_assert(response); - e = smf_event_new(SMF_EVT_SBI_CLIENT); + e = smf_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - smf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -84,41 +84,45 @@ /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_SMF); ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AMF); + ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_SCP); /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + if (ogs_sbi_nf_service_is_available(OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + } /* Initialize NRF NF Instance */ - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_sbi_client_t *client = 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. */ - smf_nf_fsm_init(nf_instance); - } - } - - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = smf_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)smf_nf_state_registered; + nf_instance = ogs_sbi_self()->nrf_instance; + if (nf_instance) { + ogs_sbi_client_t *client = 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. */ + ogs_sbi_nf_fsm_init(nf_instance); + } + + /* Build Subscription-Data */ + ogs_sbi_subscription_data_build_default( + OpenAPI_nf_type_AMF, OGS_SBI_SERVICE_NAME_NAMF_COMM); + ogs_sbi_subscription_data_build_default( + OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL); + ogs_sbi_subscription_data_build_default( + OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_SDM); if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR; @@ -132,25 +136,15 @@ ogs_sbi_server_stop_all(); } -bool smf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - void *data) +bool smf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data) { - ogs_sbi_nf_instance_t *nf_instance = NULL; - - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); - if (!nf_instance) { - ogs_error("(NF discover) No %s", - OpenAPI_nf_type_ToString(target_nf_type)); - return false; - } + ogs_assert(nf_instance); return ogs_sbi_send_request(nf_instance, client_cb, data); } bool smf_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(smf_sess_t *sess, void *data), smf_sess_t *sess, ogs_sbi_stream_t *stream, int state, void *data) @@ -158,20 +152,14 @@ smf_ue_t *smf_ue = NULL; ogs_sbi_xact_t *xact = NULL; - OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; - + ogs_assert(service_type); ogs_assert(sess); smf_ue = sess->smf_ue; ogs_assert(smf_ue); - - ogs_assert(ogs_sbi_self()->nf_instance); - requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; - ogs_assert(requester_nf_type); - ogs_assert(build); xact = ogs_sbi_xact_add( - &sess->sbi, target_nf_type, discovery_option, + &sess->sbi, service_type, discovery_option, (ogs_sbi_build_f)build, sess, data); if (!xact) { ogs_error("smf_sbi_discover_and_send() failed"); @@ -185,10 +173,7 @@ xact->state = state; xact->assoc_stream = stream; - if (ogs_sbi_discover_and_send( - &sess->sbi, - target_nf_type, requester_nf_type, discovery_option, - client_cb, xact) != true) { + if (ogs_sbi_discover_and_send(xact, client_cb) != true) { ogs_error("smf_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); @@ -208,24 +193,15 @@ { smf_ue_t *smf_ue = NULL; ogs_sbi_xact_t *xact = NULL; - - OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; - OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; - ogs_assert(param); - ogs_assert(param->state); - ogs_assert(param->n1smbuf || param->n2smbuf); - ogs_assert(sess); smf_ue = sess->smf_ue; ogs_assert(smf_ue); - ogs_assert(ogs_sbi_self()->nf_instance); - requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; - ogs_assert(requester_nf_type); - - target_nf_type = OpenAPI_nf_type_AMF; + ogs_assert(param); + ogs_assert(param->state); + ogs_assert(param->n1smbuf || param->n2smbuf); discovery_option = ogs_sbi_discovery_option_new(); ogs_assert(discovery_option); @@ -233,7 +209,7 @@ discovery_option, sess->serving_nf_id); xact = ogs_sbi_xact_add( - &sess->sbi, target_nf_type, discovery_option, + &sess->sbi, OGS_SBI_SERVICE_TYPE_NAMF_COMM, discovery_option, (ogs_sbi_build_f)smf_namf_comm_build_n1_n2_message_transfer, sess, param); if (!xact) { @@ -243,10 +219,7 @@ xact->state = param->state; - if (ogs_sbi_discover_and_send( - &sess->sbi, - target_nf_type, requester_nf_type, discovery_option, - client_cb, xact) != true) { + if (ogs_sbi_discover_and_send(xact, client_cb) != true) { ogs_error("smf_namf_comm_send_n1_n2_message_transfer() failed"); ogs_sbi_xact_remove(xact); }
View file
open5gs_2.4.9.tar.xz/src/smf/sbi-path.h -> open5gs_2.4.10.tar.xz/src/smf/sbi-path.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,6 @@ #ifndef SMF_SBI_PATH_H #define SMF_SBI_PATH_H -#include "nnrf-build.h" #include "nudm-build.h" #include "namf-build.h" #include "gsm-build.h" @@ -34,12 +33,9 @@ int smf_sbi_open(void); void smf_sbi_close(void); -bool smf_sbi_send_request( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - void *data); +bool smf_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data); bool smf_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(smf_sess_t *sess, void *data), smf_sess_t *sess, ogs_sbi_stream_t *stream, int state, void *data);
View file
open5gs_2.4.9.tar.xz/src/smf/smf-sm.c -> open5gs_2.4.10.tar.xz/src/smf/smf-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -72,7 +72,7 @@ ogs_sbi_request_t *sbi_request = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; ogs_sbi_response_t *sbi_response = NULL; ogs_sbi_message_t sbi_message; ogs_sbi_xact_t *sbi_xact = NULL; @@ -84,7 +84,7 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; @@ -192,7 +192,7 @@ sess, gtp_xact, >p2_message.bearer_resource_command); break; default: - ogs_warn("Not implmeneted(type:%d)", gtp2_message.h.type); + ogs_warn("Not implemented(type:%d)", gtp2_message.h.type); break; } ogs_pkbuf_free(recvbuf); @@ -272,7 +272,7 @@ ogs_error("Rx unexpected Error Indication in GTPC port"); break; default: - ogs_warn("Not implmeneted(type:%d)", gtp1_message.h.type); + ogs_warn("Not implemented(type:%d)", gtp1_message.h.type); break; } ogs_pkbuf_free(recvbuf); @@ -418,10 +418,10 @@ ogs_fsm_dispatch(&pfcp_node->sm, e); break; - case SMF_EVT_SBI_SERVER: - sbi_request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + sbi_request = e->h.sbi.request; ogs_assert(sbi_request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&sbi_message, sbi_request); @@ -461,7 +461,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(sbi_message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - smf_nnrf_handle_nf_status_notify(stream, &sbi_message); + ogs_nnrf_handle_nf_status_notify(stream, &sbi_message); break; DEFAULT @@ -535,7 +535,7 @@ ogs_assert(OGS_FSM_STATE(&sess->sm)); e->sess = sess; - e->sbi.message = &sbi_message; + e->h.sbi.message = &sbi_message; ogs_fsm_dispatch(&sess->sm, e); } break; @@ -624,10 +624,10 @@ ogs_sbi_message_free(&sbi_message); break; - case SMF_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - sbi_response = e->sbi.response; + sbi_response = e->h.sbi.response; ogs_assert(sbi_response); rv = ogs_sbi_parse_response(&sbi_message, sbi_response); if (rv != OGS_OK) { @@ -658,24 +658,24 @@ SWITCH(sbi_message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &sbi_message; + e->h.sbi.message = &sbi_message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; - ogs_assert(subscription); + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); SWITCH(sbi_message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) if (sbi_message.res_status == OGS_SBI_HTTP_STATUS_CREATED || sbi_message.res_status == OGS_SBI_HTTP_STATUS_OK) { - smf_nnrf_handle_nf_status_subscribe( - subscription, &sbi_message); + ogs_nnrf_handle_nf_status_subscribe( + subscription_data, &sbi_message); } else { ogs_error("HTTP response error : %d", sbi_message.res_status); @@ -685,7 +685,7 @@ CASE(OGS_SBI_HTTP_METHOD_DELETE) if (sbi_message.res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT) { - ogs_sbi_subscription_remove(subscription); + ogs_sbi_subscription_data_remove(subscription_data); } else { ogs_error("HTTP response error : %d", sbi_message.res_status); @@ -708,7 +708,7 @@ CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) SWITCH(sbi_message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); SWITCH(sbi_message.h.method) @@ -736,7 +736,7 @@ 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; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -750,8 +750,8 @@ sess = (smf_sess_t *)sbi_xact->sbi_object; ogs_assert(sess); - e->sbi.data = sbi_xact->assoc_stream; - e->sbi.state = sbi_xact->state; + e->h.sbi.data = sbi_xact->assoc_stream; + e->h.sbi.state = sbi_xact->state; ogs_sbi_xact_remove(sbi_xact); @@ -767,7 +767,7 @@ ogs_assert(OGS_FSM_STATE(&sess->sm)); e->sess = sess; - e->sbi.message = &sbi_message; + e->h.sbi.message = &sbi_message; ogs_fsm_dispatch(&sess->sm, e); break; @@ -781,42 +781,39 @@ ogs_sbi_response_free(sbi_response); break; - case SMF_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case SMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case SMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case SMF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case SMF_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.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, smf_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s:%s State machine exception %d", OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case SMF_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; - ogs_assert(subscription); + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); - ogs_assert(ogs_sbi_self()->nf_instance); ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client, - ogs_sbi_self()->nf_instance->nf_type, - subscription->req_nf_instance_id, - subscription->subscr_cond.nf_type)); + ogs_nnrf_nfm_send_nf_status_subscribe(subscription_data)); - ogs_info("Subscription validity expired %s", subscription->id); - ogs_sbi_subscription_remove(subscription); + ogs_info("Subscription validity expired %s", + subscription_data->id); + ogs_sbi_subscription_data_remove(subscription_data); break; - case SMF_TIMER_SBI_CLIENT_WAIT: - sbi_xact = e->sbi.data; + case OGS_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); stream = sbi_xact->assoc_stream; @@ -836,14 +833,14 @@ default: ogs_error("Unknown timer%s:%d", - smf_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break; case SMF_EVT_5GSM_MESSAGE: sess = e->sess; ogs_assert(sess); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); pkbuf = e->pkbuf; ogs_assert(pkbuf); @@ -868,7 +865,7 @@ case SMF_EVT_NGAP_MESSAGE: sess = e->sess; ogs_assert(sess); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); pkbuf = e->pkbuf; ogs_assert(pkbuf);
View file
open5gs_2.4.9.tar.xz/src/smf/smf-sm.h -> open5gs_2.4.10.tar.xz/src/smf/smf-sm.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -31,16 +31,6 @@ void smf_state_operational(ogs_fsm_t *s, smf_event_t *e); void smf_state_exception(ogs_fsm_t *s, smf_event_t *e); -void smf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void smf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void smf_nf_state_initial(ogs_fsm_t *s, smf_event_t *e); -void smf_nf_state_final(ogs_fsm_t *s, smf_event_t *e); -void smf_nf_state_will_register(ogs_fsm_t *s, smf_event_t *e); -void smf_nf_state_registered(ogs_fsm_t *s, smf_event_t *e); -void smf_nf_state_de_registered(ogs_fsm_t *s, smf_event_t *e); -void smf_nf_state_exception(ogs_fsm_t *s, smf_event_t *e); - void smf_gsm_state_initial(ogs_fsm_t *s, smf_event_t *e); void smf_gsm_state_final(ogs_fsm_t *s, smf_event_t *e); void smf_gsm_state_wait_epc_auth_initial(ogs_fsm_t *s, smf_event_t *e);
View file
open5gs_2.4.9.tar.xz/src/smf/timer.c -> open5gs_2.4.10.tar.xz/src/smf/timer.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -17,33 +17,32 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#include "timer.h" -#include "event.h" #include "context.h" -const char *smf_timer_get_name(smf_timer_e id) +const char *smf_timer_get_name(int timer_id) { - switch (id) { + switch (timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + return OGS_TIMER_NAME_NF_INSTANCE_REGISTRATION_INTERVAL; + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + return OGS_TIMER_NAME_NF_INSTANCE_HEARTBEAT_INTERVAL; + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + return OGS_TIMER_NAME_NF_INSTANCE_NO_HEARTBEAT; + case OGS_TIMER_NF_INSTANCE_VALIDITY: + return OGS_TIMER_NAME_NF_INSTANCE_VALIDITY; + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + return OGS_TIMER_NAME_SUBSCRIPTION_VALIDITY; + case OGS_TIMER_SBI_CLIENT_WAIT: + return OGS_TIMER_NAME_SBI_CLIENT_WAIT; case SMF_TIMER_PFCP_ASSOCIATION: return "SMF_TIMER_PFCP_ASSOCIATION"; case SMF_TIMER_PFCP_NO_HEARTBEAT: return "SMF_TIMER_PFCP_NO_HEARTBEAT"; - case SMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "SMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case SMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "SMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case SMF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "SMF_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case SMF_TIMER_NF_INSTANCE_VALIDITY: - return "SMF_TIMER_NF_INSTANCE_VALIDITY"; - case SMF_TIMER_SUBSCRIPTION_VALIDITY: - return "SMF_TIMER_SUBSCRIPTION_VALIDITY"; - case SMF_TIMER_SBI_CLIENT_WAIT: - return "SMF_TIMER_SBI_CLIENT_WAIT"; default: break; } + ogs_error("Unknown Timer%d", timer_id); return "UNKNOWN_TIMER"; } @@ -58,32 +57,9 @@ case SMF_TIMER_PFCP_NO_HEARTBEAT: e = smf_event_new(SMF_EVT_N4_TIMER); ogs_assert(e); - e->timer_id = timer_id; + e->h.timer_id = timer_id; e->pfcp_node = data; break; - case SMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case SMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case SMF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case SMF_TIMER_NF_INSTANCE_VALIDITY: - case SMF_TIMER_SUBSCRIPTION_VALIDITY: - e = smf_event_new(SMF_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - case SMF_TIMER_SBI_CLIENT_WAIT: - e = smf_event_new(SMF_EVT_SBI_TIMER); - if (!e) { - ogs_sbi_xact_t *sbi_xact = data; - ogs_assert(sbi_xact); - - ogs_error("timer_send_event() failed"); - ogs_sbi_xact_remove(sbi_xact); - return; - } - e->timer_id = timer_id; - e->sbi.data = data; - break; default: ogs_fatal("Unknown timer id%d", timer_id); ogs_assert_if_reached(); @@ -93,8 +69,8 @@ rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed %d in %s", - (int)rv, smf_timer_get_name(e->timer_id)); - smf_event_free(e); + (int)rv, smf_timer_get_name(timer_id)); + ogs_event_free(e); } } @@ -107,33 +83,3 @@ { timer_send_event(SMF_TIMER_PFCP_NO_HEARTBEAT, data); } - -void smf_timer_nf_instance_registration_interval(void *data) -{ - timer_send_event(SMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void smf_timer_nf_instance_heartbeat_interval(void *data) -{ - timer_send_event(SMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void smf_timer_nf_instance_no_heartbeat(void *data) -{ - timer_send_event(SMF_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void smf_timer_nf_instance_validity(void *data) -{ - timer_send_event(SMF_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void smf_timer_subscription_validity(void *data) -{ - timer_send_event(SMF_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void smf_timer_sbi_client_wait_expire(void *data) -{ - timer_send_event(SMF_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.tar.xz/src/smf/timer.h -> open5gs_2.4.10.tar.xz/src/smf/timer.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,7 @@ #ifndef SMF_TIMER_H #define SMF_TIMER_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { @@ -28,34 +28,20 @@ /* forward declaration */ typedef enum { - SMF_TIMER_BASE = 0, + SMF_TIMER_BASE = OGS_MAX_NUM_OF_PROTO_TIMER, SMF_TIMER_PFCP_ASSOCIATION, SMF_TIMER_PFCP_NO_HEARTBEAT, - SMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - SMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - SMF_TIMER_NF_INSTANCE_NO_HEARTBEAT, - SMF_TIMER_NF_INSTANCE_VALIDITY, - SMF_TIMER_SUBSCRIPTION_VALIDITY, - SMF_TIMER_SBI_CLIENT_WAIT, - MAX_NUM_OF_SMF_TIMER, } smf_timer_e; -const char *smf_timer_get_name(smf_timer_e id); +const char *smf_timer_get_name(int timer_id); void smf_timer_pfcp_association(void *data); void smf_timer_pfcp_no_heartbeat(void *data); -void smf_timer_nf_instance_registration_interval(void *data); -void smf_timer_nf_instance_heartbeat_interval(void *data); -void smf_timer_nf_instance_no_heartbeat(void *data); -void smf_timer_nf_instance_validity(void *data); -void smf_timer_subscription_validity(void *data); -void smf_timer_sbi_client_wait_expire(void *data); - #ifdef __cplusplus } #endif
View file
open5gs_2.4.9.tar.xz/src/udm/context.c -> open5gs_2.4.10.tar.xz/src/udm/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -102,6 +102,10 @@ ogs_assert(udm_key); if (!strcmp(udm_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(udm_key, "service_name")) { + /* handle config in sbi library */ + } else if (!strcmp(udm_key, "discovery")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", udm_key); } @@ -133,14 +137,13 @@ ogs_assert(udm_ue->suci); ogs_hash_set(self.suci_hash, udm_ue->suci, strlen(udm_ue->suci), udm_ue); - udm_ue->supi = ogs_supi_from_suci(udm_ue->suci); + udm_ue->supi = ogs_supi_from_supi_or_suci(udm_ue->suci); ogs_assert(udm_ue->supi); ogs_hash_set(self.supi_hash, udm_ue->supi, strlen(udm_ue->supi), udm_ue); memset(&e, 0, sizeof(e)); e.udm_ue = udm_ue; - ogs_fsm_create(&udm_ue->sm, udm_ue_state_initial, udm_ue_state_final); - ogs_fsm_init(&udm_ue->sm, &e); + ogs_fsm_init(&udm_ue->sm, udm_ue_state_initial, udm_ue_state_final, &e); ogs_list_add(&self.udm_ue_list, udm_ue); @@ -158,7 +161,6 @@ memset(&e, 0, sizeof(e)); e.udm_ue = udm_ue; ogs_fsm_fini(&udm_ue->sm, &e); - ogs_fsm_delete(&udm_ue->sm); /* Free SBI object memory */ ogs_sbi_object_free(&udm_ue->sbi);
View file
open5gs_2.4.9.tar.xz/src/udm/context.h -> open5gs_2.4.10.tar.xz/src/udm/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -25,7 +25,6 @@ #include "ogs-sbi.h" #include "udm-sm.h" -#include "timer.h" #ifdef __cplusplus extern "C" { @@ -72,22 +71,6 @@ OpenAPI_auth_type_e auth_type; OpenAPI_rat_type_e rat_type; - -#define UDM_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - udm_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, udm_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } while(0) }; void udm_context_init(void);
View file
open5gs_2.4.9.tar.xz/src/udm/event.c -> open5gs_2.4.10.tar.xz/src/udm/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,60 +18,41 @@ */ #include "event.h" -#include "context.h" -static OGS_POOL(pool, udm_event_t); - -void udm_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); -} - -void udm_event_final(void) -{ - ogs_pool_final(&pool); -} - -udm_event_t *udm_event_new(udm_event_e id) +udm_event_t *udm_event_new(int id) { udm_event_t *e = NULL; - ogs_pool_alloc(&pool, &e); + e = ogs_event_size(id, sizeof(udm_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void udm_event_free(udm_event_t *e) -{ - ogs_assert(e); - ogs_pool_free(&pool, e); -} - const char *udm_event_get_name(udm_event_t *e) { if (e == NULL) return OGS_FSM_NAME_INIT_SIG; - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case UDM_EVT_SBI_SERVER: - return "UDM_EVT_SBI_SERVER"; - case UDM_EVT_SBI_CLIENT: - return "UDM_EVT_SBI_CLIENT"; - case UDM_EVT_SBI_TIMER: - return "UDM_EVT_SBI_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; default: break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.tar.xz/src/udm/event.h -> open5gs_2.4.10.tar.xz/src/udm/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,53 +20,21 @@ #ifndef UDM_EVENT_H #define UDM_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.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 udm_ue_s udm_ue_t; -typedef enum { - UDM_EVT_BASE = OGS_FSM_USER_SIG, - - UDM_EVT_SBI_SERVER, - UDM_EVT_SBI_CLIENT, - UDM_EVT_SBI_TIMER, - - UDM_EVT_TOP, - -} udm_event_e; - typedef struct udm_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; + ogs_event_t h; udm_ue_t *udm_ue; - - ogs_timer_t *timer; } udm_event_t; -void udm_event_init(void); -void udm_event_final(void); - -udm_event_t *udm_event_new(udm_event_e id); -void udm_event_free(udm_event_t *e); +udm_event_t *udm_event_new(int id); const char *udm_event_get_name(udm_event_t *e);
View file
open5gs_2.4.9.tar.xz/src/udm/init.c -> open5gs_2.4.10.tar.xz/src/udm/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,7 +30,6 @@ ogs_sbi_context_init(); udm_context_init(); - udm_event_init(); rv = ogs_sbi_context_parse_config("udm", "nrf", "scp"); if (rv != OGS_OK) return rv; @@ -61,7 +60,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - udm_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -87,8 +86,6 @@ udm_context_final(); ogs_sbi_context_final(); - - udm_event_final(); /* Destroy event */ } static void udm_main(void *data) @@ -96,8 +93,7 @@ ogs_fsm_t udm_sm; int rv; - ogs_fsm_create(&udm_sm, udm_state_initial, udm_state_final); - ogs_fsm_init(&udm_sm, 0); + ogs_fsm_init(&udm_sm, udm_state_initial, udm_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -130,11 +126,10 @@ ogs_assert(e); ogs_fsm_dispatch(&udm_sm, e); - udm_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&udm_sm, 0); - ogs_fsm_delete(&udm_sm); }
View file
open5gs_2.4.9.tar.xz/src/udm/meson.build -> open5gs_2.4.10.tar.xz/src/udm/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -18,12 +18,8 @@ libudm_sources = files(''' context.c event.c - timer.c - nnrf-build.c nnrf-handler.c - nf-sm.c - nudm-handler.c nudr-build.c @@ -38,16 +34,12 @@ libudm = static_library('udm', sources : libudm_sources, - dependencies : libapp_dep, - libcrypt_dep, - libsbi_dep, + dependencies : libsbi_dep, install : false) libudm_dep = declare_dependency( link_with : libudm, - dependencies : libapp_dep, - libcrypt_dep, - libsbi_dep) + dependencies : libsbi_dep) udm_sources = files(''' app.c
View file
open5gs_2.4.9.tar.xz/src/udm/nnrf-handler.c -> open5gs_2.4.10.tar.xz/src/udm/nnrf-handler.c
Changed
@@ -20,252 +20,24 @@ #include "sbi-path.h" #include "nnrf-handler.h" -void udm_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void udm_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->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_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - 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, - udm_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 udm_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - udm_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - nf_instance->reference_count++; - - OGS_FSM_TRAN(&nf_instance->sm, udm_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - UDM_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - UDM_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - UDM_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -} - void udm_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; - OpenAPI_nf_type_e target_nf_type = 0; + ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; OpenAPI_search_result_t *SearchResult = NULL; - OpenAPI_lnode_t *node = NULL; - bool handled; ogs_assert(recvmsg); ogs_assert(xact); sbi_object = xact->sbi_object; ogs_assert(sbi_object); - target_nf_type = xact->target_nf_type; + service_type = xact->service_type; + ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); ogs_assert(target_nf_type); discovery_option = xact->discovery_option; @@ -276,68 +48,18 @@ 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(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); - - udm_nf_fsm_init(nf_instance); + ogs_nnrf_handle_nf_discover_search_result(SearchResult); - ogs_info("%s (NF-discover) NF registered", nf_instance->id); - } else { - nf_instance->reference_count++; - - OGS_FSM_TRAN(&nf_instance->sm, udm_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); - UDM_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); - UDM_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - /* TIME : Update validity from NRF */ - if (SearchResult->is_validity_period && - 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); - } + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (!nf_instance) { + ogs_error("(NF discover) No %s", + ogs_sbi_service_type_to_name(service_type)); + return; } - ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_arrayservice_type, nf_instance); - ogs_expect(true == udm_sbi_send_request(sbi_object, target_nf_type, xact)); + ogs_expect(true == udm_sbi_send_request(nf_instance, xact)); }
View file
open5gs_2.4.9.tar.xz/src/udm/nnrf-handler.h -> open5gs_2.4.10.tar.xz/src/udm/nnrf-handler.h
Changed
@@ -26,14 +26,6 @@ extern "C" { #endif -void udm_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void udm_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool udm_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - void udm_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg);
View file
open5gs_2.4.9.tar.xz/src/udm/nudm-handler.c -> open5gs_2.4.10.tar.xz/src/udm/nudm-handler.c
Changed
@@ -74,7 +74,7 @@ if (!ResynchronizationInfo) { ogs_assert(true == - udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL, + udm_sbi_discover_and_send(OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL, udm_nudr_dr_build_authentication_subscription, udm_ue, stream, NULL)); @@ -163,7 +163,7 @@ ogs_uint64_to_buffer(sqn, OGS_SQN_LEN, udm_ue->sqn); ogs_assert(true == - udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL, + udm_sbi_discover_and_send(OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL, udm_nudr_dr_build_authentication_subscription, udm_ue, stream, udm_ue->sqn)); } @@ -233,7 +233,7 @@ udm_ue->auth_event, message->AuthEvent); ogs_assert(true == - udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL, + udm_sbi_discover_and_send(OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL, udm_nudr_dr_build_update_authentication_status, udm_ue, stream, NULL)); @@ -332,7 +332,7 @@ message->Amf3GppAccessRegistration); ogs_assert(true == - udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL, + udm_sbi_discover_and_send(OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL, udm_nudr_dr_build_update_amf_context, udm_ue, stream, NULL)); return true; @@ -439,7 +439,7 @@ } ogs_assert(true == - udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL, + udm_sbi_discover_and_send(OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL, udm_nudr_dr_build_patch_amf_context, udm_ue, stream, PatchItemList));
View file
open5gs_2.4.9.tar.xz/src/udm/sbi-path.c -> open5gs_2.4.10.tar.xz/src/udm/sbi-path.c
Changed
@@ -27,17 +27,17 @@ ogs_assert(request); ogs_assert(data); - e = udm_event_new(UDM_EVT_SBI_SERVER); + e = udm_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - udm_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -58,16 +58,16 @@ ogs_assert(response); - e = udm_event_new(UDM_EVT_SBI_CLIENT); + e = udm_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - udm_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -82,56 +82,61 @@ /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_UDM); ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AMF); ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_SMF); ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_AUSF); + ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_SCP); /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NUDM_UEAU); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AUSF); - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NUDM_UECM); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NUDM_SDM); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V2, - (char*)OGS_SBI_API_V2_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF); + if (ogs_sbi_nf_service_is_available(OGS_SBI_SERVICE_NAME_NUDM_UEAU)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NUDM_UEAU); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AUSF); + } + + if (ogs_sbi_nf_service_is_available(OGS_SBI_SERVICE_NAME_NUDM_UECM)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NUDM_UECM); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + } + + if (ogs_sbi_nf_service_is_available(OGS_SBI_SERVICE_NAME_NUDM_SDM)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NUDM_SDM); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V2, OGS_SBI_API_V2_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_AMF); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_SMF); + } /* Initialize NRF NF Instance */ - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_sbi_client_t *client = 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. */ - udm_nf_fsm_init(nf_instance); - } - } - - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = udm_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)udm_nf_state_registered; + nf_instance = ogs_sbi_self()->nrf_instance; + if (nf_instance) { + ogs_sbi_client_t *client = 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. */ + ogs_sbi_nf_fsm_init(nf_instance); + } + + /* Build Subscription-Data */ + ogs_sbi_subscription_data_build_default(OpenAPI_nf_type_UDR, NULL); if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR; @@ -145,43 +150,28 @@ ogs_sbi_server_stop_all(); } -bool udm_sbi_send_request( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - void *data) +bool udm_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data) { - ogs_sbi_nf_instance_t *nf_instance = NULL; - - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); - if (!nf_instance) { - ogs_error("(NF discover) No %s", - OpenAPI_nf_type_ToString(target_nf_type)); - return false; - } + ogs_assert(nf_instance); return ogs_sbi_send_request(nf_instance, client_cb, data); } bool udm_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(udm_ue_t *udm_ue, void *data), udm_ue_t *udm_ue, ogs_sbi_stream_t *stream, void *data) { ogs_sbi_xact_t *xact = NULL; - OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; - - ogs_assert(ogs_sbi_self()->nf_instance); - requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; - ogs_assert(requester_nf_type); - ogs_assert(target_nf_type); + ogs_assert(service_type); ogs_assert(udm_ue); ogs_assert(stream); ogs_assert(build); xact = ogs_sbi_xact_add( - &udm_ue->sbi, target_nf_type, discovery_option, + &udm_ue->sbi, service_type, discovery_option, (ogs_sbi_build_f)build, udm_ue, data); if (!xact) { ogs_error("udm_sbi_discover_and_send() failed"); @@ -194,10 +184,7 @@ xact->assoc_stream = stream; - if (ogs_sbi_discover_and_send( - &udm_ue->sbi, - target_nf_type, requester_nf_type, discovery_option, - client_cb, xact) != true) { + if (ogs_sbi_discover_and_send(xact, client_cb) != true) { ogs_error("udm_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); ogs_assert(true ==
View file
open5gs_2.4.9.tar.xz/src/udm/sbi-path.h -> open5gs_2.4.10.tar.xz/src/udm/sbi-path.h
Changed
@@ -20,7 +20,6 @@ #ifndef UDM_SBI_PATH_H #define UDM_SBI_PATH_H -#include "nnrf-build.h" #include "nudr-build.h" #ifdef __cplusplus @@ -30,12 +29,9 @@ int udm_sbi_open(void); void udm_sbi_close(void); -bool udm_sbi_send_request( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - void *data); +bool udm_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data); bool udm_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(udm_ue_t *udm_ue, void *data), udm_ue_t *udm_ue, ogs_sbi_stream_t *stream, void *data);
View file
open5gs_2.4.9.tar.xz/src/udm/udm-sm.c -> open5gs_2.4.10.tar.xz/src/udm/udm-sm.c
Changed
@@ -43,7 +43,7 @@ ogs_sbi_request_t *request = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; ogs_sbi_response_t *response = NULL; ogs_sbi_message_t message; ogs_sbi_xact_t *sbi_xact = NULL; @@ -54,17 +54,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case UDM_EVT_SBI_SERVER: - request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + request = e->h.sbi.request; ogs_assert(request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&message, request); @@ -103,7 +103,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - udm_nnrf_handle_nf_status_notify(stream, &message); + ogs_nnrf_handle_nf_status_notify(stream, &message); break; DEFAULT @@ -178,7 +178,7 @@ ogs_assert(OGS_FSM_STATE(&udm_ue->sm)); e->udm_ue = udm_ue; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&udm_ue->sm, e); if (OGS_FSM_CHECK(&udm_ue->sm, udm_ue_state_exception)) { ogs_error("%s State machine exception", udm_ue->suci); @@ -198,10 +198,10 @@ ogs_sbi_message_free(&message); break; - case UDM_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - response = e->sbi.response; + response = e->h.sbi.response; ogs_assert(response); rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { @@ -231,43 +231,43 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; - ogs_assert(subscription); + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); 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) { - udm_nnrf_handle_nf_status_subscribe( - subscription, &message); + ogs_nnrf_handle_nf_status_subscribe( + subscription_data, &message); } else { ogs_error("%s HTTP response error %d", - subscription->id, message.res_status); + subscription_data->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); + ogs_sbi_subscription_data_remove(subscription_data); } else { ogs_error("%s HTTP response error %d", - subscription->id, message.res_status); + subscription_data->id, message.res_status); } break; DEFAULT ogs_error("%s Invalid HTTP method %s", - subscription->id, message.h.method); + subscription_data->id, message.h.method); ogs_assert_if_reached(); END break; @@ -282,7 +282,7 @@ CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); SWITCH(message.h.method) @@ -310,7 +310,7 @@ CASE(OGS_SBI_SERVICE_NAME_NUDR_DR) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTION_DATA) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -324,7 +324,7 @@ udm_ue = (udm_ue_t *)sbi_xact->sbi_object; ogs_assert(udm_ue); - e->sbi.data = sbi_xact->assoc_stream; + e->h.sbi.data = sbi_xact->assoc_stream; ogs_sbi_xact_remove(sbi_xact); @@ -335,7 +335,7 @@ } e->udm_ue = udm_ue; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&udm_ue->sm, e); if (OGS_FSM_CHECK(&udm_ue->sm, udm_ue_state_exception)) { @@ -361,42 +361,39 @@ ogs_sbi_response_free(response); break; - case UDM_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case UDM_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case UDM_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case UDM_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case UDM_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.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, udm_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s:%s State machine exception %d", OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case UDM_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; - ogs_assert(subscription); + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); - ogs_assert(ogs_sbi_self()->nf_instance); ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client, - ogs_sbi_self()->nf_instance->nf_type, - subscription->req_nf_instance_id, - subscription->subscr_cond.nf_type)); + ogs_nnrf_nfm_send_nf_status_subscribe(subscription_data)); - ogs_info("%s Subscription validity expired", subscription->id); - ogs_sbi_subscription_remove(subscription); + ogs_info("%s Subscription validity expired", + subscription_data->id); + ogs_sbi_subscription_data_remove(subscription_data); break; - case UDM_TIMER_SBI_CLIENT_WAIT: - sbi_xact = e->sbi.data; + case OGS_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); stream = sbi_xact->assoc_stream; @@ -413,7 +410,7 @@ default: ogs_error("Unknown timer%s:%d", - udm_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break;
View file
open5gs_2.4.9.tar.xz/src/udm/udm-sm.h -> open5gs_2.4.10.tar.xz/src/udm/udm-sm.h
Changed
@@ -30,16 +30,6 @@ void udm_state_final(ogs_fsm_t *s, udm_event_t *e); void udm_state_operational(ogs_fsm_t *s, udm_event_t *e); -void udm_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void udm_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void udm_nf_state_initial(ogs_fsm_t *s, udm_event_t *e); -void udm_nf_state_final(ogs_fsm_t *s, udm_event_t *e); -void udm_nf_state_will_register(ogs_fsm_t *s, udm_event_t *e); -void udm_nf_state_registered(ogs_fsm_t *s, udm_event_t *e); -void udm_nf_state_de_registered(ogs_fsm_t *s, udm_event_t *e); -void udm_nf_state_exception(ogs_fsm_t *s, udm_event_t *e); - void udm_ue_state_initial(ogs_fsm_t *s, udm_event_t *e); 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);
View file
open5gs_2.4.9.tar.xz/src/udm/ue-sm.c -> open5gs_2.4.10.tar.xz/src/udm/ue-sm.c
Changed
@@ -48,17 +48,17 @@ udm_ue = e->udm_ue; ogs_assert(udm_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case UDM_EVT_SBI_SERVER: - message = e->sbi.message; + case OGS_EVENT_SBI_SERVER: + message = e->h.sbi.message; ogs_assert(message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(message->h.service.name) @@ -143,7 +143,8 @@ CASE(OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA) CASE(OGS_SBI_RESOURCE_NAME_SM_DATA) ogs_assert(true == - udm_sbi_discover_and_send(OpenAPI_nf_type_UDR, NULL, + udm_sbi_discover_and_send( + OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL, udm_nudr_dr_build_query_subscription_provisioned, udm_ue, stream, message)); break; @@ -181,13 +182,13 @@ END break; - case UDM_EVT_SBI_CLIENT: - message = e->sbi.message; + case OGS_EVENT_SBI_CLIENT: + message = e->h.sbi.message; ogs_assert(message); udm_ue = e->udm_ue; ogs_assert(udm_ue); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(message->h.service.name) @@ -252,7 +253,7 @@ udm_ue = e->udm_ue; ogs_assert(udm_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break;
View file
open5gs_2.4.9.tar.xz/src/udr/context.c -> open5gs_2.4.10.tar.xz/src/udr/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -84,6 +84,10 @@ ogs_assert(udr_key); if (!strcmp(udr_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(udr_key, "service_name")) { + /* handle config in sbi library */ + } else if (!strcmp(udr_key, "discovery")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", udr_key); }
View file
open5gs_2.4.9.tar.xz/src/udr/context.h -> open5gs_2.4.10.tar.xz/src/udr/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -25,7 +25,6 @@ #include "ogs-sbi.h" #include "udr-sm.h" -#include "timer.h" #ifdef __cplusplus extern "C" { @@ -41,22 +40,6 @@ typedef struct udr_context_s { } udr_context_t; -#define UDR_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - udr_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, udr_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } while(0) - void udr_context_init(void); void udr_context_final(void); udr_context_t *udr_self(void);
View file
open5gs_2.4.9.tar.xz/src/udr/event.c -> open5gs_2.4.10.tar.xz/src/udr/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,60 +18,42 @@ */ #include "event.h" -#include "context.h" -static OGS_POOL(pool, udr_event_t); - -void udr_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); -} - -void udr_event_final(void) -{ - ogs_pool_final(&pool); -} - -udr_event_t *udr_event_new(udr_event_e id) +udr_event_t *udr_event_new(int id) { udr_event_t *e = NULL; - ogs_pool_alloc(&pool, &e); + e = ogs_event_size(id, sizeof(udr_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void udr_event_free(udr_event_t *e) -{ - ogs_assert(e); - ogs_pool_free(&pool, e); -} - const char *udr_event_get_name(udr_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { - case OGS_FSM_ENTRY_SIG: + switch (e->h.id) { + case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; - case OGS_FSM_EXIT_SIG: + case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case UDR_EVT_SBI_SERVER: - return "UDR_EVT_SBI_SERVER"; - case UDR_EVT_SBI_CLIENT: - return "UDR_EVT_SBI_CLIENT"; - case UDR_EVT_SBI_TIMER: - return "UDR_EVT_SBI_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; - default: - break; + default: + break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.tar.xz/src/udr/event.h -> open5gs_2.4.10.tar.xz/src/udr/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,49 +20,17 @@ #ifndef UDR_EVENT_H #define UDR_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.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 enum { - UDR_EVT_BASE = OGS_FSM_USER_SIG, - - UDR_EVT_SBI_SERVER, - UDR_EVT_SBI_CLIENT, - UDR_EVT_SBI_TIMER, - - UDR_EVT_TOP, - -} udr_event_e; - typedef struct udr_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; - - ogs_timer_t *timer; + ogs_event_t h; } udr_event_t; -void udr_event_init(void); -void udr_event_final(void); - -udr_event_t *udr_event_new(udr_event_e id); -void udr_event_free(udr_event_t *e); +udr_event_t *udr_event_new(int id); const char *udr_event_get_name(udr_event_t *e);
View file
open5gs_2.4.9.tar.xz/src/udr/init.c -> open5gs_2.4.10.tar.xz/src/udr/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,7 +30,6 @@ ogs_sbi_context_init(); udr_context_init(); - udr_event_init(); rv = ogs_sbi_context_parse_config("udr", "nrf", "scp"); if (rv != OGS_OK) return rv; @@ -64,7 +63,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - udr_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -92,8 +91,6 @@ udr_context_final(); ogs_sbi_context_final(); - - udr_event_final(); /* Destroy event */ } static void udr_main(void *data) @@ -101,8 +98,7 @@ ogs_fsm_t udr_sm; int rv; - ogs_fsm_create(&udr_sm, udr_state_initial, udr_state_final); - ogs_fsm_init(&udr_sm, 0); + ogs_fsm_init(&udr_sm, udr_state_initial, udr_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -135,11 +131,10 @@ ogs_assert(e); ogs_fsm_dispatch(&udr_sm, e); - udr_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&udr_sm, 0); - ogs_fsm_delete(&udr_sm); }
View file
open5gs_2.4.9.tar.xz/src/udr/meson.build -> open5gs_2.4.10.tar.xz/src/udr/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -18,11 +18,6 @@ libudr_sources = files(''' context.c event.c - timer.c - - nnrf-build.c - nnrf-handler.c - nf-sm.c nudr-handler.c @@ -34,15 +29,13 @@ libudr = static_library('udr', sources : libudr_sources, - dependencies : libapp_dep, - libdbi_dep, + dependencies : libdbi_dep, libsbi_dep, install : false) libudr_dep = declare_dependency( link_with : libudr, - dependencies : libapp_dep, - libdbi_dep, + dependencies : libdbi_dep, libsbi_dep) udr_sources = files('''
View file
open5gs_2.4.9.tar.xz/src/udr/nudr-handler.c -> open5gs_2.4.10.tar.xz/src/udr/nudr-handler.c
Changed
@@ -18,7 +18,6 @@ */ #include "sbi-path.h" -#include "nnrf-handler.h" #include "nudr-handler.h" bool udr_nudr_dr_handle_subscription_authentication(
View file
open5gs_2.4.9.tar.xz/src/udr/sbi-path.c -> open5gs_2.4.10.tar.xz/src/udr/sbi-path.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -27,17 +27,17 @@ ogs_assert(request); ogs_assert(data); - e = udr_event_new(UDR_EVT_SBI_SERVER); + e = udr_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - udr_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -58,16 +58,16 @@ ogs_assert(response); - e = udr_event_new(UDR_EVT_SBI_CLIENT); + e = udr_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - udr_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -82,44 +82,40 @@ /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_UDR); ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_PCF); ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_UDM); + ogs_sbi_nf_instance_add_allowed_nf_type(nf_instance, OpenAPI_nf_type_SCP); /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NUDR_DR); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_PCF); - ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_UDM); + if (ogs_sbi_nf_service_is_available(OGS_SBI_SERVICE_NAME_NUDR_DR)) { + service = ogs_sbi_nf_service_build_default( + nf_instance, OGS_SBI_SERVICE_NAME_NUDR_DR); + ogs_assert(service); + ogs_sbi_nf_service_add_version( + service, OGS_SBI_API_V1, OGS_SBI_API_V1_0_0, NULL); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_PCF); + ogs_sbi_nf_service_add_allowed_nf_type(service, OpenAPI_nf_type_UDM); + } /* Initialize NRF NF Instance */ - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_sbi_client_t *client = 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. */ - udr_nf_fsm_init(nf_instance); - } + nf_instance = ogs_sbi_self()->nrf_instance; + if (nf_instance) { + ogs_sbi_client_t *client = 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. */ + ogs_sbi_nf_fsm_init(nf_instance); } - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = udr_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)udr_nf_state_registered; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR;
View file
open5gs_2.4.9.tar.xz/src/udr/sbi-path.h -> open5gs_2.4.10.tar.xz/src/udr/sbi-path.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,7 @@ #ifndef UDR_SBI_PATH_H #define UDR_SBI_PATH_H -#include "nnrf-build.h" +#include "context.h" #ifdef __cplusplus extern "C" {
View file
open5gs_2.4.9.tar.xz/src/udr/udr-sm.c -> open5gs_2.4.10.tar.xz/src/udr/udr-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,7 +18,6 @@ */ #include "sbi-path.h" -#include "nnrf-handler.h" #include "nudr-handler.h" void udr_state_initial(ogs_fsm_t *s, udr_event_t *e) @@ -45,7 +44,7 @@ ogs_sbi_request_t *request = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; ogs_sbi_response_t *response = NULL; ogs_sbi_message_t message; @@ -53,17 +52,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case UDR_EVT_SBI_SERVER: - request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + request = e->h.sbi.request; ogs_assert(request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&message, request); @@ -94,7 +93,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - udr_nnrf_handle_nf_status_notify(stream, &message); + ogs_nnrf_handle_nf_status_notify(stream, &message); break; DEFAULT @@ -188,10 +187,10 @@ ogs_sbi_message_free(&message); break; - case UDR_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - response = e->sbi.response; + response = e->h.sbi.response; ogs_assert(response); rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { @@ -213,43 +212,43 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; - ogs_assert(subscription); + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); 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) { - udr_nnrf_handle_nf_status_subscribe( - subscription, &message); + ogs_nnrf_handle_nf_status_subscribe( + subscription_data, &message); } else { ogs_error("%s HTTP response error %d", - subscription->id, message.res_status); + subscription_data->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); + ogs_sbi_subscription_data_remove(subscription_data); } else { ogs_error("%s HTTP response error %d", - subscription->id, message.res_status); + subscription_data->id, message.res_status); } break; DEFAULT ogs_error("%s Invalid HTTP method %s", - subscription->id, message.h.method); + subscription_data->id, message.h.method); ogs_assert_if_reached(); END break; @@ -270,42 +269,39 @@ ogs_sbi_response_free(response); break; - case UDR_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case UDR_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case UDR_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case UDR_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case UDR_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.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, udr_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s State machine exception %d", - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case UDR_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; - ogs_assert(subscription); + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); - ogs_assert(ogs_sbi_self()->nf_instance); ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client, - ogs_sbi_self()->nf_instance->nf_type, - subscription->req_nf_instance_id, - subscription->subscr_cond.nf_type)); + ogs_nnrf_nfm_send_nf_status_subscribe(subscription_data)); - ogs_info("%s Subscription validity expired", subscription->id); - ogs_sbi_subscription_remove(subscription); + ogs_info("%s Subscription validity expired", + subscription_data->id); + ogs_sbi_subscription_data_remove(subscription_data); break; default: ogs_error("Unknown timer%s:%d", - udr_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break;
View file
open5gs_2.4.9.tar.xz/src/udr/udr-sm.h -> open5gs_2.4.10.tar.xz/src/udr/udr-sm.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. *
View file
open5gs_2.4.9.tar.xz/src/upf/event.h -> open5gs_2.4.10.tar.xz/src/upf/event.h
Changed
@@ -20,7 +20,7 @@ #ifndef UPF_EVENT_H #define UPF_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { @@ -32,7 +32,7 @@ typedef struct upf_sess_s upf_sess_t; typedef enum { - UPF_EVT_BASE = OGS_FSM_USER_SIG, + UPF_EVT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, UPF_EVT_N4_MESSAGE, UPF_EVT_N4_TIMER, @@ -44,9 +44,10 @@ typedef struct upf_event_s { int id; - ogs_pkbuf_t *pkbuf; int timer_id; + ogs_pkbuf_t *pkbuf; + ogs_pfcp_node_t *pfcp_node; ogs_pfcp_xact_t *pfcp_xact; ogs_pfcp_message_t *pfcp_message;
View file
open5gs_2.4.9.tar.xz/src/upf/init.c -> open5gs_2.4.10.tar.xz/src/upf/init.c
Changed
@@ -97,8 +97,7 @@ ogs_fsm_t upf_sm; int rv; - ogs_fsm_create(&upf_sm, upf_state_initial, upf_state_final); - ogs_fsm_init(&upf_sm, 0); + ogs_fsm_init(&upf_sm, upf_state_initial, upf_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -137,5 +136,4 @@ done: ogs_fsm_fini(&upf_sm, 0); - ogs_fsm_delete(&upf_sm); }
View file
open5gs_2.4.9.tar.xz/src/upf/meson.build -> open5gs_2.4.10.tar.xz/src/upf/meson.build
Changed
@@ -86,8 +86,6 @@ libupf = static_library('upf', sources : libupf_sources, dependencies : - libapp_dep, - libgtp_dep, libpfcp_dep, libtun_dep, libarp_nd_dep, @@ -97,8 +95,6 @@ libupf_dep = declare_dependency( link_with : libupf, dependencies : - libapp_dep, - libgtp_dep, libpfcp_dep, libtun_dep, libarp_nd_dep,
View file
open5gs_2.4.9.tar.xz/src/upf/pfcp-path.c -> open5gs_2.4.10.tar.xz/src/upf/pfcp-path.c
Changed
@@ -37,8 +37,7 @@ ogs_assert(node->t_association); } - ogs_fsm_create(&node->sm, upf_pfcp_state_initial, upf_pfcp_state_final); - ogs_fsm_init(&node->sm, &e); + ogs_fsm_init(&node->sm, upf_pfcp_state_initial, upf_pfcp_state_final, &e); } static void pfcp_node_fsm_fini(ogs_pfcp_node_t *node) @@ -51,7 +50,6 @@ e.pfcp_node = node; ogs_fsm_fini(&node->sm, &e); - ogs_fsm_delete(&node->sm); if (node->t_association) ogs_timer_delete(node->t_association);
View file
open5gs_2.4.9.tar.xz/tests/af/af-sm.c -> open5gs_2.4.10.tar.xz/tests/af/af-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -48,7 +48,7 @@ ogs_sbi_request_t *request = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_subscription_t *subscription = NULL; + ogs_sbi_subscription_data_t *subscription_data = NULL; ogs_sbi_response_t *response = NULL; ogs_sbi_message_t message; ogs_sbi_xact_t *sbi_xact = NULL; @@ -57,17 +57,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case AF_EVT_SBI_SERVER: - request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + request = e->h.sbi.request; ogs_assert(request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&message, request); @@ -98,7 +98,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - af_nnrf_handle_nf_status_notify(stream, &message); + ogs_nnrf_handle_nf_status_notify(stream, &message); break; DEFAULT @@ -189,10 +189,10 @@ ogs_sbi_message_free(&message); break; - case AF_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - response = e->sbi.response; + response = e->h.sbi.response; ogs_assert(response); rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { @@ -214,24 +214,24 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; - ogs_assert(subscription); + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); 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) { - af_nnrf_handle_nf_status_subscribe( - subscription, &message); + ogs_nnrf_handle_nf_status_subscribe( + subscription_data, &message); } else { ogs_error("HTTP response error : %d", message.res_status); @@ -240,7 +240,7 @@ CASE(OGS_SBI_HTTP_METHOD_DELETE) if (message.res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT) { - ogs_sbi_subscription_remove(subscription); + ogs_sbi_subscription_data_remove(subscription_data); } else { ogs_error("HTTP response error : %d", message.res_status); @@ -263,7 +263,7 @@ CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); SWITCH(message.h.method) @@ -291,7 +291,7 @@ CASE(OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_PCF_BINDINGS) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -331,7 +331,7 @@ CASE(OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_APP_SESSIONS) - sess = e->sbi.data; + sess = e->h.sbi.data; ogs_assert(sess); if (message.h.resource.component1) { @@ -393,40 +393,37 @@ ogs_sbi_response_free(response); break; - case AF_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case AF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case AF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case AF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case AF_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.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, af_nf_state_exception)) - ogs_error("State machine exception %d", e->timer_id); + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) + ogs_error("State machine exception %d", e->h.timer_id); break; - case AF_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; - ogs_assert(subscription); + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription_data = e->h.sbi.data; + ogs_assert(subscription_data); - ogs_assert(ogs_sbi_self()->nf_instance); ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(subscription->client, - ogs_sbi_self()->nf_instance->nf_type, - subscription->req_nf_instance_id, - subscription->subscr_cond.nf_type)); + ogs_nnrf_nfm_send_nf_status_subscribe(subscription_data)); - ogs_info("Subscription validity expired %s", subscription->id); - ogs_sbi_subscription_remove(subscription); + ogs_info("Subscription validity expired %s", + subscription_data->id); + ogs_sbi_subscription_data_remove(subscription_data); break; - case AF_TIMER_SBI_CLIENT_WAIT: - sbi_xact = e->sbi.data; + case OGS_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); stream = sbi_xact->assoc_stream; @@ -446,16 +443,16 @@ default: ogs_error("Unknown timer%s:%d", - af_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break; - case AF_EVT_SBI_LOCAL: + case AF_EVENT_SBI_LOCAL: ogs_assert(e); switch(e->local_id) { case AF_LOCAL_DISCOVER_AND_SEND: - af_sbi_discover_and_send(e->local.target_nf_type, NULL, + af_sbi_discover_and_send(e->local.service_type, NULL, e->local.build, e->sess, e->local.data); break; case AF_LOCAL_SEND_TO_PCF:
View file
open5gs_2.4.9.tar.xz/tests/af/af-sm.h -> open5gs_2.4.10.tar.xz/tests/af/af-sm.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -31,16 +31,6 @@ void af_state_operational(ogs_fsm_t *s, af_event_t *e); void af_state_exception(ogs_fsm_t *s, af_event_t *e); -void af_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void af_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void af_nf_state_initial(ogs_fsm_t *s, af_event_t *e); -void af_nf_state_final(ogs_fsm_t *s, af_event_t *e); -void af_nf_state_will_register(ogs_fsm_t *s, af_event_t *e); -void af_nf_state_registered(ogs_fsm_t *s, af_event_t *e); -void af_nf_state_de_registered(ogs_fsm_t *s, af_event_t *e); -void af_nf_state_exception(ogs_fsm_t *s, af_event_t *e); - #define af_sm_debug(__pe) \ ogs_debug("%s(): %s", __func__, af_event_get_name(__pe))
View file
open5gs_2.4.9.tar.xz/tests/af/context.c -> open5gs_2.4.10.tar.xz/tests/af/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -111,6 +111,10 @@ ogs_assert(af_key); if (!strcmp(af_key, "sbi")) { /* handle config in sbi library */ + } else if (!strcmp(af_key, "service_name")) { + /* handle config in sbi library */ + } else if (!strcmp(af_key, "discovery")) { + /* handle config in sbi library */ } else ogs_warn("unknown key `%s`", af_key); }
View file
open5gs_2.4.9.tar.xz/tests/af/context.h -> open5gs_2.4.10.tar.xz/tests/af/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -24,7 +24,6 @@ #include "ogs-app.h" #include "event.h" -#include "timer.h" #include "local.h" #include "af-sm.h" @@ -46,22 +45,6 @@ ogs_list_t sess_list; } af_context_t; -#define AF_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - af_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, af_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } while(0) - typedef struct af_sess_s af_sess_t; typedef struct af_sess_s {
View file
open5gs_2.4.9.tar.xz/tests/af/event.c -> open5gs_2.4.10.tar.xz/tests/af/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -19,60 +19,44 @@ #include "context.h" -static OGS_POOL(pool, af_event_t); - -void af_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); -} - -void af_event_final(void) -{ - ogs_pool_final(&pool); -} - -af_event_t *af_event_new(af_event_e id) +af_event_t *af_event_new(int id) { af_event_t *e = NULL; - ogs_pool_alloc(&pool, &e); + e = ogs_event_size(id, sizeof(af_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void af_event_free(af_event_t *e) -{ - ogs_assert(e); - ogs_pool_free(&pool, e); -} - const char *af_event_get_name(af_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case AF_EVT_SBI_SERVER: - return "AF_EVT_SBI_SERVER"; - case AF_EVT_SBI_CLIENT: - return "AF_EVT_SBI_CLIENT"; - case AF_EVT_SBI_TIMER: - return "AF_EVT_SBI_TIMER"; - case AF_EVT_SBI_LOCAL: - return "AF_EVT_SBI_LOCAL"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; + + case AF_EVENT_SBI_LOCAL: + return "AF_EVENT_SBI_LOCAL"; default: break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.tar.xz/tests/af/event.h -> open5gs_2.4.10.tar.xz/tests/af/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,59 +20,39 @@ #ifndef AF_EVENT_H #define AF_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { #endif typedef struct af_sess_s af_sess_t; -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_subscription_s ogs_sbi_subscription_t; typedef enum { - AF_EVT_BASE = OGS_FSM_USER_SIG, + AF_EVENT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, - AF_EVT_SBI_SERVER, - AF_EVT_SBI_CLIENT, - AF_EVT_SBI_TIMER, - AF_EVT_SBI_LOCAL, + AF_EVENT_SBI_LOCAL, - AF_EVT_TOP, + MAX_NUM_OF_AF_EVENT, } af_event_e; typedef struct af_event_s { - int id; - ogs_pkbuf_t *pkbuf; - int timer_id; + ogs_event_t h; int local_id; + ogs_pkbuf_t *pkbuf; + struct { - OpenAPI_nf_type_e target_nf_type; + ogs_sbi_service_type_e service_type; void *data; ogs_sbi_request_t *(*build)(af_sess_t *sess, void *data); } local; - struct { - ogs_sbi_request_t *request; - ogs_sbi_response_t *response; - void *data; - int state; - - ogs_sbi_message_t *message; - } sbi; - af_sess_t *sess; } af_event_t; -void af_event_init(void); -void af_event_final(void); - -af_event_t *af_event_new(af_event_e id); -void af_event_free(af_event_t *e); +af_event_t *af_event_new(int id); const char *af_event_get_name(af_event_t *e);
View file
open5gs_2.4.9.tar.xz/tests/af/init.c -> open5gs_2.4.10.tar.xz/tests/af/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -32,7 +32,6 @@ ogs_sbi_context_init(); af_context_init(); - af_event_init(); rv = ogs_sbi_context_parse_config("af", "nrf", "scp"); if (rv != OGS_OK) return rv; @@ -63,7 +62,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - af_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -88,10 +87,7 @@ af_sbi_close(); af_context_final(); - ogs_sbi_context_final(); - - af_event_final(); /* Destroy event */ } static void af_main(void *data) @@ -99,8 +95,7 @@ ogs_fsm_t af_sm; int rv; - ogs_fsm_create(&af_sm, af_state_initial, af_state_final); - ogs_fsm_init(&af_sm, 0); + ogs_fsm_init(&af_sm, af_state_initial, af_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -133,11 +128,10 @@ ogs_assert(e); ogs_fsm_dispatch(&af_sm, e); - af_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&af_sm, 0); - ogs_fsm_delete(&af_sm); }
View file
open5gs_2.4.9.tar.xz/tests/af/init.h -> open5gs_2.4.10.tar.xz/tests/af/init.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. *
View file
open5gs_2.4.9.tar.xz/tests/af/local.c -> open5gs_2.4.10.tar.xz/tests/af/local.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -31,28 +31,29 @@ return "UNKNOWN_LOCAL"; } -void af_local_discover_and_send(OpenAPI_nf_type_e target_nf_type, +void af_local_discover_and_send( + ogs_sbi_service_type_e service_type, af_sess_t *sess, void *data, ogs_sbi_request_t *(*build)(af_sess_t *sess, void *data)) { int rv; af_event_t *e = NULL; - e = af_event_new(AF_EVT_SBI_LOCAL); + e = af_event_new(AF_EVENT_SBI_LOCAL); ogs_assert(e); e->local_id = AF_LOCAL_DISCOVER_AND_SEND; e->sess = sess; - e->local.target_nf_type = target_nf_type; + e->local.service_type = service_type; e->local.data = data; e->local.build = build; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed %d in %s", - (int)rv, af_timer_get_name(e->timer_id)); - af_event_free(e); + (int)rv, af_local_get_name(e->local_id)); + ogs_event_free(e); } else { ogs_pollset_notify(ogs_app()->pollset); } @@ -65,7 +66,7 @@ int rv; af_event_t *e = NULL; - e = af_event_new(AF_EVT_SBI_LOCAL); + e = af_event_new(AF_EVENT_SBI_LOCAL); ogs_assert(e); e->local_id = AF_LOCAL_SEND_TO_PCF; @@ -77,8 +78,8 @@ rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed %d in %s", - (int)rv, af_timer_get_name(e->timer_id)); - af_event_free(e); + (int)rv, af_local_get_name(e->local_id)); + ogs_event_free(e); } else { ogs_pollset_notify(ogs_app()->pollset); }
View file
open5gs_2.4.9.tar.xz/tests/af/local.h -> open5gs_2.4.10.tar.xz/tests/af/local.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -39,7 +39,8 @@ const char *af_local_get_name(af_local_e id); -void af_local_discover_and_send(OpenAPI_nf_type_e target_nf_type, +void af_local_discover_and_send( + ogs_sbi_service_type_e service_type, af_sess_t *sess, void *data, ogs_sbi_request_t *(*build)(af_sess_t *sess, void *data));
View file
open5gs_2.4.9.tar.xz/tests/af/meson.build -> open5gs_2.4.10.tar.xz/tests/af/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -18,12 +18,9 @@ libaf_sources = files(''' context.c event.c - timer.c local.c - nnrf-build.c nnrf-handler.c - nf-sm.c nbsf-build.c nbsf-handler.c
View file
open5gs_2.4.9.tar.xz/tests/af/nbsf-handler.c -> open5gs_2.4.10.tar.xz/tests/af/nbsf-handler.c
Changed
@@ -28,9 +28,6 @@ OpenAPI_pcf_binding_t *PcfBinding = NULL; OpenAPI_list_t *PcfIpEndPointList = NULL; OpenAPI_lnode_t *node = NULL; -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - char fqdnOGS_MAX_FQDN_LEN; -#endif ogs_assert(sess); ogs_assert(recvmsg); @@ -46,19 +43,10 @@ } if (PcfBinding->pcf_fqdn) { -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - ogs_assert(0 < ogs_fqdn_parse(fqdn, PcfBinding->pcf_fqdn, - ogs_min(strlen(PcfBinding->pcf_fqdn), OGS_MAX_FQDN_LEN))); - if (sess->pcf.fqdn) - ogs_free(sess->pcf.fqdn); - sess->pcf.fqdn = ogs_strdup(fqdn); - ogs_assert(sess->pcf.fqdn); -#else if (sess->pcf.fqdn) ogs_free(sess->pcf.fqdn); sess->pcf.fqdn = ogs_strdup(PcfBinding->pcf_fqdn); ogs_assert(sess->pcf.fqdn); -#endif } PcfIpEndPointList = PcfBinding->pcf_ip_end_points;
View file
open5gs_2.4.9.tar.xz/tests/af/nnrf-handler.c -> open5gs_2.4.10.tar.xz/tests/af/nnrf-handler.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,256 +20,24 @@ #include "sbi-path.h" #include "nnrf-handler.h" -void af_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->nf_profile_changes_ind == true) { - if (NFProfile->heart_beat_timer) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; - } else { - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; - } -} - -void af_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->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_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - 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, - af_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 af_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - af_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - nf_instance->reference_count++; - - OGS_FSM_TRAN(&nf_instance->sm, af_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - AF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - AF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - AF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -} - void af_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; - OpenAPI_nf_type_e target_nf_type = 0; + ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; ogs_sbi_discovery_option_t *discovery_option = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; + OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL; OpenAPI_search_result_t *SearchResult = NULL; - OpenAPI_lnode_t *node = NULL; - bool handled; ogs_assert(recvmsg); ogs_assert(xact); sbi_object = xact->sbi_object; ogs_assert(sbi_object); - target_nf_type = xact->target_nf_type; + service_type = xact->service_type; + ogs_assert(service_type); + target_nf_type = ogs_sbi_service_type_to_nf_type(service_type); ogs_assert(target_nf_type); discovery_option = xact->discovery_option; @@ -280,67 +48,18 @@ 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(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); - - af_nf_fsm_init(nf_instance); + ogs_nnrf_handle_nf_discover_search_result(SearchResult); - ogs_info("%s (NF-discover) NF registered", nf_instance->id); - } else { - nf_instance->reference_count++; - - OGS_FSM_TRAN(&nf_instance->sm, af_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("ogs_sbi_nnrf_handle_nf_profile() failed %s", - nf_instance->id); - AF_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); - AF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - /* 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); - } + nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( + target_nf_type, discovery_option); + if (!nf_instance) { + ogs_error("(NF discover) No %s", + ogs_sbi_service_type_to_name(service_type)); + return; } - ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option); + OGS_SBI_SETUP_NF_INSTANCE( + sbi_object->service_type_arrayservice_type, nf_instance); - ogs_expect(true == af_sbi_send_request(sbi_object, target_nf_type, xact)); + ogs_expect(true == af_sbi_send_request(nf_instance, xact)); }
View file
open5gs_2.4.9.tar.xz/tests/af/nnrf-handler.h -> open5gs_2.4.10.tar.xz/tests/af/nnrf-handler.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -26,14 +26,6 @@ extern "C" { #endif -void af_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void af_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool af_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - void af_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg);
View file
open5gs_2.4.9.tar.xz/tests/af/sbi-path.c -> open5gs_2.4.10.tar.xz/tests/af/sbi-path.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -27,17 +27,17 @@ ogs_assert(request); ogs_assert(data); - e = af_event_new(AF_EVT_SBI_SERVER); + e = af_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - af_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -58,16 +58,16 @@ ogs_assert(response); - e = af_event_new(AF_EVT_SBI_CLIENT); + e = af_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - af_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -77,49 +77,37 @@ int af_sbi_open(void) { ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_nf_service_t *service = NULL; /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); /* Build NF instance information. It will be transmitted to NRF. */ ogs_sbi_nf_instance_build_default(nf_instance, OpenAPI_nf_type_AF); - /* Build NF service information. It will be transmitted to NRF. */ - service = ogs_sbi_nf_service_build_default(nf_instance, - (char*)OGS_SBI_SERVICE_NAME_NAF_EVENTEXPOSURE); - ogs_assert(service); - ogs_sbi_nf_service_add_version(service, (char*)OGS_SBI_API_V1, - (char*)OGS_SBI_API_V1_0_0, NULL); - /* Initialize NRF NF Instance */ - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_sbi_client_t *client = 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. */ - af_nf_fsm_init(nf_instance); - } - } - - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = af_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)af_nf_state_registered; + nf_instance = ogs_sbi_self()->nrf_instance; + if (nf_instance) { + ogs_sbi_client_t *client = 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. */ + ogs_sbi_nf_fsm_init(nf_instance); + } + + /* Build Subscription-Data */ + ogs_sbi_subscription_data_build_default( + OpenAPI_nf_type_BSF, OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT); if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR; - return OGS_OK; } @@ -129,68 +117,34 @@ ogs_sbi_server_stop_all(); } -bool af_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance) +bool af_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data) { - ogs_sbi_request_t *request = NULL; - ogs_sbi_client_t *client = NULL; - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - request = af_nnrf_nfm_build_register(); - ogs_expect_or_return_val(request, false); - return ogs_sbi_client_send_request( - client, client->cb, request, nf_instance); -} - -bool af_sbi_send_request( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - void *data) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - nf_instance = OGS_SBI_NF_INSTANCE(sbi_object, target_nf_type); - if (!nf_instance) { - ogs_error("(NF discover) No %s", - OpenAPI_nf_type_ToString(target_nf_type)); - return false; - } return ogs_sbi_send_request(nf_instance, client_cb, data); } void af_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(af_sess_t *sess, void *data), af_sess_t *sess, void *data) { ogs_sbi_xact_t *xact = NULL; - OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL; - - ogs_assert(ogs_sbi_self()->nf_instance); - requester_nf_type = ogs_sbi_self()->nf_instance->nf_type; - ogs_assert(requester_nf_type); - - ogs_assert(target_nf_type); + ogs_assert(service_type); ogs_assert(sess); ogs_assert(build); xact = ogs_sbi_xact_add( - &sess->sbi, target_nf_type, discovery_option, + &sess->sbi, service_type, discovery_option, (ogs_sbi_build_f)build, sess, data); if (!xact) { ogs_error("af_sbi_discover_and_send() failed"); return; } - if (ogs_sbi_discover_and_send( - &sess->sbi, - target_nf_type, requester_nf_type, discovery_option, - client_cb, xact) != true) { + if (ogs_sbi_discover_and_send(xact, client_cb) != true) { ogs_error("af_sbi_discover_and_send() failed"); return; }
View file
open5gs_2.4.9.tar.xz/tests/af/sbi-path.h -> open5gs_2.4.10.tar.xz/tests/af/sbi-path.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,6 @@ #ifndef AF_SBI_PATH_H #define AF_SBI_PATH_H -#include "nnrf-build.h" #include "nbsf-build.h" #include "npcf-build.h" @@ -31,14 +30,9 @@ int af_sbi_open(void); void af_sbi_close(void); -bool af_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance); - -bool af_sbi_send_request( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - void *data); +bool af_sbi_send_request(ogs_sbi_nf_instance_t *nf_instance, void *data); void af_sbi_discover_and_send( - OpenAPI_nf_type_e target_nf_type, + ogs_sbi_service_type_e service_type, ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_request_t *(*build)(af_sess_t *sess, void *data), af_sess_t *sess, void *data);
View file
open5gs_2.4.9.tar.xz/tests/attach/abts-main.c -> open5gs_2.4.10.tar.xz/tests/attach/abts-main.c
Changed
@@ -20,6 +20,7 @@ #include "test-app.h" abts_suite *test_s1setup(abts_suite *suite); +abts_suite *test_simple(abts_suite *suite); abts_suite *test_guti(abts_suite *suite); abts_suite *test_auth(abts_suite *suite); abts_suite *test_idle(abts_suite *suite); @@ -32,6 +33,7 @@ abts_suite *(*func)(abts_suite *suite); } alltests = { {test_s1setup}, + {test_simple}, {test_guti}, {test_auth}, {test_idle},
View file
open5gs_2.4.9.tar.xz/tests/attach/meson.build -> open5gs_2.4.10.tar.xz/tests/attach/meson.build
Changed
@@ -18,6 +18,7 @@ testapp_attach_sources = files(''' abts-main.c s1setup-test.c + simple-test.c guti-test.c auth-test.c idle-test.c
View file
open5gs_2.4.10.tar.xz/tests/attach/simple-test.c
Added
@@ -0,0 +1,288 @@ +/* + * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#include "test-common.h" + +static void test1_func(abts_case *tc, void *data) +{ + int rv; + ogs_socknode_t *s1ap; + ogs_socknode_t *gtpu; + ogs_pkbuf_t *emmbuf; + ogs_pkbuf_t *esmbuf; + ogs_pkbuf_t *sendbuf; + ogs_pkbuf_t *recvbuf; + ogs_s1ap_message_t message; + + ogs_nas_5gs_mobile_identity_suci_t mobile_identity_suci; + test_ue_t *test_ue = NULL; + test_sess_t *sess = NULL; + test_bearer_t *bearer = NULL; + + uint32_t enb_ue_s1ap_id; + uint64_t mme_ue_s1ap_id; + + bson_t *doc = NULL; + + /* Setup Test UE & Session Context */ + memset(&mobile_identity_suci, 0, sizeof(mobile_identity_suci)); + + mobile_identity_suci.h.supi_format = OGS_NAS_5GS_SUPI_FORMAT_IMSI; + mobile_identity_suci.h.type = OGS_NAS_5GS_MOBILE_IDENTITY_SUCI; + mobile_identity_suci.routing_indicator1 = 0; + mobile_identity_suci.routing_indicator2 = 0xf; + mobile_identity_suci.routing_indicator3 = 0xf; + mobile_identity_suci.routing_indicator4 = 0xf; + mobile_identity_suci.protection_scheme_id = OGS_NAS_5GS_NULL_SCHEME; + mobile_identity_suci.home_network_pki_value = 0; + mobile_identity_suci.scheme_output0 = 0x37; + mobile_identity_suci.scheme_output1 = 0x46; + mobile_identity_suci.scheme_output2 = 0; + mobile_identity_suci.scheme_output3 = 0; + mobile_identity_suci.scheme_output4 = 0x06; + + test_ue = test_ue_add_by_suci(&mobile_identity_suci, 13); + ogs_assert(test_ue); + + test_ue->e_cgi.cell_id = 0x1079baf0; + test_ue->nas.ksi = 0; + test_ue->nas.value = OGS_NAS_ATTACH_TYPE_COMBINED_EPS_IMSI_ATTACH; + + test_ue->k_string = "465b5ce8b199b49faa5f0a2ee238a6bc"; + test_ue->opc_string = "e8ed289deba952e4283b54e88e6183ca"; + + sess = test_sess_add_by_apn(test_ue, "internet", OGS_GTP2_RAT_TYPE_EUTRAN); + ogs_assert(sess); + + /* eNB connects to MME */ + s1ap = tests1ap_client(AF_INET); + ABTS_PTR_NOTNULL(tc, s1ap); + + /* eNB connects to SGW */ + gtpu = test_gtpu_server(1, AF_INET); + ABTS_PTR_NOTNULL(tc, gtpu); + + /* Send S1-Setup Reqeust */ + sendbuf = test_s1ap_build_s1_setup_request( + S1AP_ENB_ID_PR_macroENB_ID, 0x54f64); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive S1-Setup Response */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(NULL, recvbuf); + + /********** Insert Subscriber in Database */ + doc = test_db_new_simple(test_ue); + ABTS_PTR_NOTNULL(tc, doc); + ABTS_INT_EQUAL(tc, OGS_OK, test_db_insert_ue(test_ue, doc)); + + /* Send Attach Request */ + memset(&sess->pdn_connectivity_param, + 0, sizeof(sess->pdn_connectivity_param)); + sess->pdn_connectivity_param.eit = 1; + sess->pdn_connectivity_param.request_type = + OGS_NAS_EPS_REQUEST_TYPE_INITIAL; + esmbuf = testesm_build_pdn_connectivity_request(sess, false); + ABTS_PTR_NOTNULL(tc, esmbuf); + + memset(&test_ue->attach_request_param, + 0, sizeof(test_ue->attach_request_param)); + test_ue->attach_request_param.drx_parameter = 1; + test_ue->attach_request_param.ms_network_capability = 1; + test_ue->attach_request_param.tmsi_status = 1; + test_ue->attach_request_param.mobile_station_classmark_2 = 1; + test_ue->attach_request_param.ue_usage_setting = 1; + emmbuf = testemm_build_attach_request(test_ue, esmbuf, true, false); + ABTS_PTR_NOTNULL(tc, emmbuf); + + memset(&test_ue->initial_ue_param, 0, sizeof(test_ue->initial_ue_param)); + sendbuf = test_s1ap_build_initial_ue_message( + test_ue, emmbuf, S1AP_RRC_Establishment_Cause_mo_Signalling, false); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive Authentication Request */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send Authentication response */ + emmbuf = testemm_build_authentication_response(test_ue); + ABTS_PTR_NOTNULL(tc, emmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, emmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive Security mode Command */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send Security mode complete */ + test_ue->mobile_identity_imeisv_presence = true; + emmbuf = testemm_build_security_mode_complete(test_ue); + ABTS_PTR_NOTNULL(tc, emmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, emmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive ESM Information Request */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send ESM Information Response */ + sess->esm_information_param.pco = 1; + esmbuf = testesm_build_esm_information_response(sess); + ABTS_PTR_NOTNULL(tc, esmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, esmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive Initial Context Setup Request + + * Attach Accept + + * Activate Default Bearer Context Request */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send UE Capability Info Indication */ + sendbuf = tests1ap_build_ue_radio_capability_info_indication(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send Initial Context Setup Response */ + sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send Attach Complete + Activate default EPS bearer cotext accept */ + test_ue->nr_cgi.cell_id = 0x1234502; + bearer = test_bearer_find_by_ue_ebi(test_ue, 5); + ogs_assert(bearer); + esmbuf = testesm_build_activate_default_eps_bearer_context_accept( + bearer, false); + ABTS_PTR_NOTNULL(tc, esmbuf); + emmbuf = testemm_build_attach_complete(test_ue, esmbuf); + ABTS_PTR_NOTNULL(tc, emmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, emmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive EMM information */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send GTP-U Router Solicitation */ + rv = test_gtpu_send_slacc_rs(gtpu, bearer); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U Router Solicitation */ + recvbuf = test_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + testgtpu_recv(test_ue, recvbuf); + + /* Send GTP-U ICMP Packet */ + rv = test_gtpu_send_ping(gtpu, bearer, TEST_PING_IPV4); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U ICMP Packet */ + recvbuf = test_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + ogs_pkbuf_free(recvbuf); + +#if !defined(__FreeBSD__) + /* Send GTP-U ICMP Packet */ + rv = test_gtpu_send_ping(gtpu, bearer, TEST_PING_IPV6); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U ICMP Packet */ + recvbuf = test_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + ogs_pkbuf_free(recvbuf); +#endif + + /* Send Detach Request */ + emmbuf = testemm_build_detach_request(test_ue, 1, true, false); + ABTS_PTR_NOTNULL(tc, emmbuf); + sendbuf = test_s1ap_build_initial_ue_message( + test_ue, emmbuf, S1AP_RRC_Establishment_Cause_mo_Signalling, true); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive OLD UE Context Release Command */ + enb_ue_s1ap_id = test_ue->enb_ue_s1ap_id; + + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send OLD UE Context Release Complete */ + sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + test_ue->enb_ue_s1ap_id = enb_ue_s1ap_id; + + /* Receive UE Context Release Command */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send UE Context Release Complete */ + sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + ogs_msleep(300); + + /********** Remove Subscriber in Database */ + ABTS_INT_EQUAL(tc, OGS_OK, test_db_remove_ue(test_ue)); + + /* eNB disonncect from MME */ + testenb_s1ap_close(s1ap); + + /* eNB disonncect from SGW */ + test_gtpu_close(gtpu); + + test_ue_remove(test_ue); +} + +abts_suite *test_simple(abts_suite *suite) +{ + suite = ADD_SUITE(suite) + + abts_run_test(suite, test1_func, NULL); + + return suite; +}
View file
open5gs_2.4.9.tar.xz/tests/common/emm-build.c -> open5gs_2.4.10.tar.xz/tests/common/emm-build.c
Changed
@@ -301,8 +301,8 @@ milenage_f2345(test_ue->opc, test_ue->k, test_ue->rand, res, ck, ik, ak, NULL); - for (i = 0; i < 6; i++) - sqni = test_ue->autni ^ aki; + for (i = 0; i < 6; i++) + sqni = test_ue->autni ^ aki; ogs_nas_from_plmn_id(&nas_plmn_id, &test_ue->e_tai.plmn_id); ogs_auc_kasme(ck, ik, &nas_plmn_id, sqn, ak, test_ue->kasme);
View file
open5gs_2.4.9.tar.xz/tests/common/s1ap-build.c -> open5gs_2.4.10.tar.xz/tests/common/s1ap-build.c
Changed
@@ -1717,10 +1717,10 @@ S1AP_ENB_UE_S1AP_ID_t *ENB_UE_S1AP_ID = NULL; S1AP_ENB_StatusTransfer_TransparentContainer_t *ENB_StatusTransfer_TransparentContainer = NULL; - S1AP_Bearers_SubjectToStatusTransferList_t + S1AP_Bearers_SubjectToStatusTransferList_t *Bearers_SubjectToStatusTransferList = NULL; - S1AP_Bearers_SubjectToStatusTransfer_ItemIEs_t *ie2 = NULL; - S1AP_Bearers_SubjectToStatusTransfer_Item_t *item = NULL; + S1AP_Bearers_SubjectToStatusTransfer_ItemIEs_t *ie2 = NULL; + S1AP_Bearers_SubjectToStatusTransfer_Item_t *item = NULL; ogs_assert(test_ue);
View file
open5gs_2.4.9.tar.xz/tests/core/fsm-test.c -> open5gs_2.4.10.tar.xz/tests/core/fsm-test.c
Changed
@@ -41,12 +41,6 @@ void bomb_setting(bomb_t *s, tick_event_t *e); void bomb_timing(bomb_t *s, tick_event_t *e); -void bomb_create(bomb_t *s, uint8_t defuse) -{ - ogs_fsm_create(&s->fsm, &bomb_initial, 0); - s->defuse = defuse; -} - void bomb_initial(bomb_t *s, tick_event_t *e) { s->timeout = 10; @@ -98,9 +92,8 @@ bomb_t bomb; tick_event_t tick_event; - bomb_create(&bomb, 14); - - ogs_fsm_init(&bomb, 0); + ogs_fsm_init(&bomb, &bomb_initial, 0, 0); + bomb.defuse = 14; ABTS_PTR_EQUAL(tc, &bomb_setting, OGS_FSM_STATE(&bomb)); ABTS_INT_EQUAL(tc, 10, bomb.timeout); @@ -246,9 +239,7 @@ set_event_t set_event; time_event_t time_event; - ogs_fsm_create(&alarm.fsm, &alarm_initial, 0); - - ogs_fsm_init(&alarm, 0); + ogs_fsm_init(&alarm, &alarm_initial, 0, 0); ABTS_PTR_EQUAL(tc, &alarm_off, OGS_FSM_STATE(&alarm)); ABTS_INT_EQUAL(tc, 1200, alarm.time);
View file
open5gs_2.4.9.tar.xz/tests/core/tlv-test.c -> open5gs_2.4.10.tar.xz/tests/core/tlv-test.c
Changed
@@ -305,7 +305,7 @@ ogs_tlv_free_all(parsed_tlv); ABTS_INT_EQUAL(tc, ogs_tlv_pool_avail(), ogs_core()->tlv.pool); - return; + return; } /* basic encoding/decoding/finding Test */ @@ -467,7 +467,7 @@ ogs_tlv_test_check_embed_ogs_tlv_test(tc, root_tlv, mode); - return; + return; } @@ -858,23 +858,23 @@ abts_run_test(suite, test1_func, (void*)OGS_TLV_MODE_T2_L2); abts_run_test(suite, test2_func, (void*)OGS_TLV_MODE_T2_L2); - abts_run_test(suite, test3_func, (void*)OGS_TLV_MODE_T2_L2); - abts_run_test(suite, test4_func, (void*)OGS_TLV_MODE_T2_L2); - abts_run_test(suite, test5_func, (void*)OGS_TLV_MODE_T2_L2); + abts_run_test(suite, test3_func, (void*)OGS_TLV_MODE_T2_L2); + abts_run_test(suite, test4_func, (void*)OGS_TLV_MODE_T2_L2); + abts_run_test(suite, test5_func, (void*)OGS_TLV_MODE_T2_L2); abts_run_test(suite, test1_func, (void*)OGS_TLV_MODE_T1_L1); abts_run_test(suite, test5_func, (void*)OGS_TLV_MODE_T1_L1); abts_run_test(suite, test1_func, (void*)OGS_TLV_MODE_T1_L2); abts_run_test(suite, test2_func, (void*)OGS_TLV_MODE_T1_L2); - abts_run_test(suite, test3_func, (void*)OGS_TLV_MODE_T1_L2); - abts_run_test(suite, test4_func, (void*)OGS_TLV_MODE_T1_L2); - abts_run_test(suite, test5_func, (void*)OGS_TLV_MODE_T1_L2); + abts_run_test(suite, test3_func, (void*)OGS_TLV_MODE_T1_L2); + abts_run_test(suite, test4_func, (void*)OGS_TLV_MODE_T1_L2); + abts_run_test(suite, test5_func, (void*)OGS_TLV_MODE_T1_L2); abts_run_test(suite, test1_func, (void*)OGS_TLV_MODE_T1_L2_I1); abts_run_test(suite, test2_func, (void*)OGS_TLV_MODE_T1_L2_I1); - abts_run_test(suite, test3_func, (void*)OGS_TLV_MODE_T1_L2_I1); - abts_run_test(suite, test4_func, (void*)OGS_TLV_MODE_T1_L2_I1); - abts_run_test(suite, test5_func, (void*)OGS_TLV_MODE_T1_L2_I1); + abts_run_test(suite, test3_func, (void*)OGS_TLV_MODE_T1_L2_I1); + abts_run_test(suite, test4_func, (void*)OGS_TLV_MODE_T1_L2_I1); + abts_run_test(suite, test5_func, (void*)OGS_TLV_MODE_T1_L2_I1); - abts_run_test(suite, test6_func, NULL); + abts_run_test(suite, test6_func, NULL); return suite; }
View file
open5gs_2.4.9.tar.xz/tests/non3gpp/diameter-s6b-path.c -> open5gs_2.4.10.tar.xz/tests/non3gpp/diameter-s6b-path.c
Changed
@@ -69,10 +69,10 @@ static int test_s6b_fb_cb(struct msg **msg, struct avp *avp, struct session *sess, void *opaque, enum disp_action *act) { - /* This CB should never be called */ - ogs_warn("Unexpected message received!"); - - return ENOTSUP; + /* This CB should never be called */ + ogs_warn("Unexpected message received!"); + + return ENOTSUP; } static int test_s6b_aar_cb( struct msg **msg, struct avp *avp, @@ -81,7 +81,7 @@ int rv; int ret = 0, i; - struct msg *ans, *qry; + struct msg *ans, *qry; struct avp *avpch1, *avpch2; struct avp_hdr *hdr; union avp_value val; @@ -91,9 +91,9 @@ ogs_assert(msg); - /* Create answer header */ - qry = *msg; - ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + /* Create answer header */ + qry = *msg; + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); ogs_assert(ret == 0); ans = *msg; @@ -151,8 +151,8 @@ ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp); ogs_assert(ret == 0); - /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ - ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_SUCCESS", NULL, NULL, 1); + /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_SUCCESS", NULL, NULL, 1); ogs_assert(ret == 0); /* Store this value in the session */ @@ -160,19 +160,19 @@ ogs_assert(ret == 0); ogs_assert(sess_data == NULL); - /* Send the answer */ - ret = fd_msg_send(msg, NULL, NULL); + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); - /* Add this value to the stats */ - ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); - ogs_diam_logger_self()->stats.nb_echoed++; - ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) ==0); + /* Add this value to the stats */ + ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) ==0); return 0; out: - /* Set the Result-Code */ + /* Set the Result-Code */ if (result_code == OGS_DIAM_AVP_UNSUPPORTED) { ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_AVP_UNSUPPORTED", NULL, NULL, 1); @@ -196,7 +196,7 @@ ogs_assert(sess_data == NULL); } - ret = fd_msg_send(msg, NULL, NULL); + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); return 0; @@ -208,7 +208,7 @@ int rv; int ret = 0, i; - struct msg *ans, *qry; + struct msg *ans, *qry; struct avp *avpch1, *avpch2; struct avp_hdr *hdr; union avp_value val; @@ -218,9 +218,9 @@ ogs_assert(msg); - /* Create answer header */ - qry = *msg; - ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + /* Create answer header */ + qry = *msg; + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); ogs_assert(ret == 0); ans = *msg; @@ -251,8 +251,8 @@ goto out; } - /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ - ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_SUCCESS", NULL, NULL, 1); + /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_SUCCESS", NULL, NULL, 1); ogs_assert(ret == 0); /* Store this value in the session */ @@ -260,19 +260,19 @@ ogs_assert(ret == 0); ogs_assert(sess_data == NULL); - /* Send the answer */ - ret = fd_msg_send(msg, NULL, NULL); + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); - /* Add this value to the stats */ - ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); - ogs_diam_logger_self()->stats.nb_echoed++; - ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) ==0); + /* Add this value to the stats */ + ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) ==0); return 0; out: - /* Set the Result-Code */ + /* Set the Result-Code */ if (result_code == OGS_DIAM_AVP_UNSUPPORTED) { ret = fd_msg_rescode_set(ans, (char *)"DIAMETER_AVP_UNSUPPORTED", NULL, NULL, 1); @@ -296,7 +296,7 @@ ogs_assert(sess_data == NULL); } - ret = fd_msg_send(msg, NULL, NULL); + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); return 0; @@ -305,57 +305,57 @@ int test_s6b_init(void) { int ret; - struct disp_when data; + struct disp_when data; ogs_thread_mutex_init(&sess_state_mutex); ogs_pool_init(&sess_state_pool, ogs_app()->pool.sess); - /* Install objects definitions for this application */ - ret = ogs_diam_s6b_init(); + /* Install objects definitions for this application */ + ret = ogs_diam_s6b_init(); ogs_assert(ret == 0); /* Create handler for sessions */ - ret = fd_sess_handler_create(&test_s6b_reg, &state_cleanup, NULL, NULL); + ret = fd_sess_handler_create(&test_s6b_reg, &state_cleanup, NULL, NULL); ogs_assert(ret == 0); - /* Fallback CB if command != unexpected message received */ - memset(&data, 0, sizeof(data)); - data.app = ogs_diam_s6b_application; + /* Fallback CB if command != unexpected message received */ + memset(&data, 0, sizeof(data)); + data.app = ogs_diam_s6b_application; - ret = fd_disp_register(test_s6b_fb_cb, DISP_HOW_APPID, &data, NULL, + ret = fd_disp_register(test_s6b_fb_cb, DISP_HOW_APPID, &data, NULL, &hdl_s6b_fb); ogs_assert(ret == 0); - data.command = ogs_diam_rx_cmd_aar; - ret = fd_disp_register(test_s6b_aar_cb, DISP_HOW_CC, &data, NULL, + data.command = ogs_diam_rx_cmd_aar; + ret = fd_disp_register(test_s6b_aar_cb, DISP_HOW_CC, &data, NULL, &hdl_s6b_aar); ogs_assert(ret == 0); - data.command = ogs_diam_rx_cmd_str; - ret = fd_disp_register(test_s6b_str_cb, DISP_HOW_CC, &data, NULL, + data.command = ogs_diam_rx_cmd_str; + ret = fd_disp_register(test_s6b_str_cb, DISP_HOW_CC, &data, NULL, &hdl_s6b_str); ogs_assert(ret == 0); - - /* Advertise the support for the application in the peer */ - ret = fd_disp_app_support(ogs_diam_s6b_application, ogs_diam_vendor, 1, 0); + + /* Advertise the support for the application in the peer */ + ret = fd_disp_app_support(ogs_diam_s6b_application, ogs_diam_vendor, 1, 0); ogs_assert(ret == 0); - return 0; + return 0; } void test_s6b_final(void) { int ret; - ret = fd_sess_handler_destroy(&test_s6b_reg, NULL); + ret = fd_sess_handler_destroy(&test_s6b_reg, NULL); ogs_assert(ret == OGS_OK); - if (hdl_s6b_fb) - (void) fd_disp_unregister(&hdl_s6b_fb, NULL); - if (hdl_s6b_aar) - (void) fd_disp_unregister(&hdl_s6b_aar, NULL); - if (hdl_s6b_str) - (void) fd_disp_unregister(&hdl_s6b_str, NULL); + if (hdl_s6b_fb) + (void) fd_disp_unregister(&hdl_s6b_fb, NULL); + if (hdl_s6b_aar) + (void) fd_disp_unregister(&hdl_s6b_aar, NULL); + if (hdl_s6b_str) + (void) fd_disp_unregister(&hdl_s6b_str, NULL); ogs_pool_final(&sess_state_pool); ogs_thread_mutex_destroy(&sess_state_mutex);
View file
open5gs_2.4.9.tar.xz/tests/non3gpp/diameter-swx-path.c -> open5gs_2.4.10.tar.xz/tests/non3gpp/diameter-swx-path.c
Changed
@@ -57,10 +57,10 @@ static int test_swx_fb_cb(struct msg **msg, struct avp *avp, struct session *sess, void *opaque, enum disp_action *act) { - /* This CB should never be called */ - ogs_warn("Unexpected message received!"); - - return ENOTSUP; + /* This CB should never be called */ + ogs_warn("Unexpected message received!"); + + return ENOTSUP; } void test_swx_send(test_sess_t *sess, bool handover_ind, @@ -629,38 +629,38 @@ int test_swx_init(void) { int ret; - struct disp_when data; + struct disp_when data; - /* Install objects definitions for this application */ - ret = ogs_diam_swx_init(); + /* Install objects definitions for this application */ + ret = ogs_diam_swx_init(); ogs_assert(ret == 0); /* Create handler for sessions */ - ret = fd_sess_handler_create(&test_swx_reg, &state_cleanup, NULL, NULL); + ret = fd_sess_handler_create(&test_swx_reg, &state_cleanup, NULL, NULL); ogs_assert(ret == 0); - /* Fallback CB if command != unexpected message received */ - memset(&data, 0, sizeof(data)); - data.app = ogs_diam_swx_application; + /* Fallback CB if command != unexpected message received */ + memset(&data, 0, sizeof(data)); + data.app = ogs_diam_swx_application; - ret = fd_disp_register(test_swx_fb_cb, DISP_HOW_APPID, &data, NULL, + ret = fd_disp_register(test_swx_fb_cb, DISP_HOW_APPID, &data, NULL, &hdl_swx_fb); ogs_assert(ret == 0); - - /* Advertise the support for the application in the peer */ - ret = fd_disp_app_support(ogs_diam_swx_application, ogs_diam_vendor, 1, 0); + + /* Advertise the support for the application in the peer */ + ret = fd_disp_app_support(ogs_diam_swx_application, ogs_diam_vendor, 1, 0); ogs_assert(ret == 0); - return 0; + return 0; } void test_swx_final(void) { int ret; - ret = fd_sess_handler_destroy(&test_swx_reg, NULL); + ret = fd_sess_handler_destroy(&test_swx_reg, NULL); ogs_assert(ret == OGS_OK); - if (hdl_swx_fb) - (void) fd_disp_unregister(&hdl_swx_fb, NULL); + if (hdl_swx_fb) + (void) fd_disp_unregister(&hdl_swx_fb, NULL); }
View file
open5gs_2.4.9.tar.xz/tests/non3gpp/gtp-path.c -> open5gs_2.4.10.tar.xz/tests/non3gpp/gtp-path.c
Changed
@@ -117,7 +117,7 @@ xact, sess, >p_message.delete_bearer_request); break; default: - ogs_error("Not implmeneted(type:%d)", gtp_message.h.type); + ogs_error("Not implemented(type:%d)", gtp_message.h.type); break; }
View file
open5gs_2.4.9.tar.xz/tests/non3gpp/s2b-build.c -> open5gs_2.4.10.tar.xz/tests/non3gpp/s2b-build.c
Changed
@@ -59,11 +59,11 @@ memset(>p_message, 0, sizeof(ogs_gtp2_message_t)); if (handover_ind == true) { - memset(&indication, 0, sizeof(ogs_gtp2_indication_t)); - indication.handover_indication = 1; - req->indication_flags.presence = 1; - req->indication_flags.data = &indication; - req->indication_flags.len = sizeof(ogs_gtp2_indication_t); + memset(&indication, 0, sizeof(ogs_gtp2_indication_t)); + indication.handover_indication = 1; + req->indication_flags.presence = 1; + req->indication_flags.data = &indication; + req->indication_flags.len = sizeof(ogs_gtp2_indication_t); } ogs_assert(test_ue->imsi_len);
View file
open5gs_2.4.9.tar.xz/tests/non3gpp/test-fd-path.c -> open5gs_2.4.10.tar.xz/tests/non3gpp/test-fd-path.c
Changed
@@ -69,18 +69,18 @@ int test_fd_init(void) { int ret; - struct disp_when data; + struct disp_when data; test_diam_config(); ret = ogs_diam_init(FD_MODE_CLIENT, NULL, &diam_config); ogs_assert(ret == 0); - ret = ogs_diam_s6a_init(); + ret = ogs_diam_s6a_init(); ogs_assert(ret == 0); - ret = ogs_diam_cx_init(); + ret = ogs_diam_cx_init(); ogs_assert(ret == 0); - ret = ogs_diam_rx_init(); + ret = ogs_diam_rx_init(); ogs_assert(ret == 0); test_swx_init(); @@ -89,7 +89,7 @@ ret = ogs_diam_start(); ogs_assert(ret == 0); - return 0; + return 0; } void test_fd_final(void)
View file
open5gs_2.4.9.tar.xz/tests/registration/abts-main.c -> open5gs_2.4.10.tar.xz/tests/registration/abts-main.c
Changed
@@ -19,6 +19,7 @@ #include "test-app.h" +abts_suite *test_simple(abts_suite *suite); abts_suite *test_guti(abts_suite *suite); abts_suite *test_auth(abts_suite *suite); abts_suite *test_idle(abts_suite *suite); @@ -33,6 +34,7 @@ const struct testlist { abts_suite *(*func)(abts_suite *suite); } alltests = { + {test_simple}, {test_guti}, {test_auth}, {test_idle},
View file
open5gs_2.4.9.tar.xz/tests/registration/meson.build -> open5gs_2.4.10.tar.xz/tests/registration/meson.build
Changed
@@ -17,6 +17,7 @@ test5gc_registration_sources = files(''' abts-main.c + simple-test.c guti-test.c auth-test.c idle-test.c
View file
open5gs_2.4.10.tar.xz/tests/registration/simple-test.c
Added
@@ -0,0 +1,333 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#include "test-common.h" + +static void test1_func(abts_case *tc, void *data) +{ + int rv; + ogs_socknode_t *ngap; + ogs_socknode_t *gtpu; + ogs_pkbuf_t *gmmbuf; + ogs_pkbuf_t *gsmbuf; + ogs_pkbuf_t *nasbuf; + ogs_pkbuf_t *sendbuf; + ogs_pkbuf_t *recvbuf; + ogs_ngap_message_t message; + int i; + + ogs_nas_5gs_mobile_identity_suci_t mobile_identity_suci; + test_ue_t *test_ue = NULL; + test_sess_t *sess = NULL; + test_bearer_t *qos_flow = NULL; + + bson_t *doc = NULL; + + /* Setup Test UE & Session Context */ + memset(&mobile_identity_suci, 0, sizeof(mobile_identity_suci)); + + mobile_identity_suci.h.supi_format = OGS_NAS_5GS_SUPI_FORMAT_IMSI; + mobile_identity_suci.h.type = OGS_NAS_5GS_MOBILE_IDENTITY_SUCI; + mobile_identity_suci.routing_indicator1 = 0; + mobile_identity_suci.routing_indicator2 = 0xf; + mobile_identity_suci.routing_indicator3 = 0xf; + mobile_identity_suci.routing_indicator4 = 0xf; + mobile_identity_suci.protection_scheme_id = OGS_NAS_5GS_NULL_SCHEME; + mobile_identity_suci.home_network_pki_value = 0; + mobile_identity_suci.scheme_output0 = 0; + mobile_identity_suci.scheme_output1 = 0; + mobile_identity_suci.scheme_output2 = 0x20; + mobile_identity_suci.scheme_output3 = 0x31; + mobile_identity_suci.scheme_output4 = 0x90; + + test_ue = test_ue_add_by_suci(&mobile_identity_suci, 13); + ogs_assert(test_ue); + + test_ue->nr_cgi.cell_id = 0x40001; + + test_ue->nas.registration.tsc = 0; + test_ue->nas.registration.ksi = OGS_NAS_KSI_NO_KEY_IS_AVAILABLE; + test_ue->nas.registration.follow_on_request = 1; + test_ue->nas.registration.value = OGS_NAS_5GS_REGISTRATION_TYPE_INITIAL; + + test_ue->k_string = "465b5ce8b199b49faa5f0a2ee238a6bc"; + test_ue->opc_string = "e8ed289deba952e4283b54e88e6183ca"; + + /* gNB connects to AMF */ + ngap = testngap_client(AF_INET); + ABTS_PTR_NOTNULL(tc, ngap); + + /* gNB connects to UPF */ + gtpu = test_gtpu_server(1, AF_INET); + ABTS_PTR_NOTNULL(tc, gtpu); + + /* Send NG-Setup Reqeust */ + sendbuf = testngap_build_ng_setup_request(0x4000, 22); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive NG-Setup Response */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + + /********** Insert Subscriber in Database */ + doc = test_db_new_simple(test_ue); + ABTS_PTR_NOTNULL(tc, doc); + ABTS_INT_EQUAL(tc, OGS_OK, test_db_insert_ue(test_ue, doc)); + + /* Send Registration request */ + test_ue->registration_request_param.guti = 1; + gmmbuf = testgmm_build_registration_request(test_ue, NULL, false, false); + ABTS_PTR_NOTNULL(tc, gmmbuf); + + test_ue->registration_request_param.gmm_capability = 1; + test_ue->registration_request_param.s1_ue_network_capability = 1; + test_ue->registration_request_param.requested_nssai = 1; + test_ue->registration_request_param.last_visited_registered_tai = 1; + test_ue->registration_request_param.ue_usage_setting = 1; + nasbuf = testgmm_build_registration_request(test_ue, NULL, false, false); + ABTS_PTR_NOTNULL(tc, nasbuf); + + sendbuf = testngap_build_initial_ue_message(test_ue, gmmbuf, + NGAP_RRCEstablishmentCause_mo_Signalling, false, true); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive Identity request */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + + /* Send Identity response */ + gmmbuf = testgmm_build_identity_response(test_ue); + ABTS_PTR_NOTNULL(tc, gmmbuf); + sendbuf = testngap_build_uplink_nas_transport(test_ue, gmmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive Authentication request */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + + /* Send Authentication response */ + gmmbuf = testgmm_build_authentication_response(test_ue); + ABTS_PTR_NOTNULL(tc, gmmbuf); + sendbuf = testngap_build_uplink_nas_transport(test_ue, gmmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive Security mode command */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + + /* Send Security mode complete */ + gmmbuf = testgmm_build_security_mode_complete(test_ue, nasbuf); + ABTS_PTR_NOTNULL(tc, gmmbuf); + sendbuf = testngap_build_uplink_nas_transport(test_ue, gmmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive InitialContextSetupRequest + + * Registration accept */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + ABTS_INT_EQUAL(tc, + NGAP_ProcedureCode_id_InitialContextSetup, + test_ue->ngap_procedure_code); + + /* Send UERadioCapabilityInfoIndication */ + sendbuf = testngap_build_ue_radio_capability_info_indication(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send InitialContextSetupResponse */ + sendbuf = testngap_build_initial_context_setup_response(test_ue, false); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send Registration complete */ + gmmbuf = testgmm_build_registration_complete(test_ue); + ABTS_PTR_NOTNULL(tc, gmmbuf); + sendbuf = testngap_build_uplink_nas_transport(test_ue, gmmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive Configuration update command */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + + /* Send PDU session establishment request */ + sess = test_sess_add_by_dnn_and_psi(test_ue, "internet", 5); + ogs_assert(sess); + + sess->ul_nas_transport_param.request_type = + OGS_NAS_5GS_REQUEST_TYPE_INITIAL; + sess->ul_nas_transport_param.dnn = 1; + sess->ul_nas_transport_param.s_nssai = 0; + + sess->pdu_session_establishment_param.ssc_mode = 1; + sess->pdu_session_establishment_param.epco = 1; + + gsmbuf = testgsm_build_pdu_session_establishment_request(sess); + ABTS_PTR_NOTNULL(tc, gsmbuf); + gmmbuf = testgmm_build_ul_nas_transport(sess, + OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, gsmbuf); + ABTS_PTR_NOTNULL(tc, gmmbuf); + sendbuf = testngap_build_uplink_nas_transport(test_ue, gmmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive PDUSessionResourceSetupRequest + + * DL NAS transport + + * PDU session establishment accept */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + ABTS_INT_EQUAL(tc, + NGAP_ProcedureCode_id_PDUSessionResourceSetup, + test_ue->ngap_procedure_code); + + /* Send GTP-U ICMP Packet */ + qos_flow = test_qos_flow_find_by_qfi(sess, 1); + ogs_assert(qos_flow); + rv = test_gtpu_send_ping(gtpu, qos_flow, TEST_PING_IPV4); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send PDUSessionResourceSetupResponse */ + sendbuf = testngap_sess_build_pdu_session_resource_setup_response(sess); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U ICMP Packet */ + recvbuf = testgnb_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + ogs_pkbuf_free(recvbuf); + + /* Send GTP-U ICMP Packet */ + rv = test_gtpu_send_ping(gtpu, qos_flow, TEST_PING_IPV4); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U ICMP Packet */ + recvbuf = testgnb_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + ogs_pkbuf_free(recvbuf); + + /* Send GTP-U Router Solicitation */ + rv = test_gtpu_send_slacc_rs(gtpu, qos_flow); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U Router Advertisement */ + recvbuf = test_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + testgtpu_recv(test_ue, recvbuf); + +#if !defined(__FreeBSD__) + /* Send GTP-U ICMP Packet */ + rv = test_gtpu_send_ping(gtpu, qos_flow, TEST_PING_IPV6); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U ICMP Packet */ + recvbuf = test_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + ogs_pkbuf_free(recvbuf); +#endif + + /* Send UEContextReleaseRequest */ + sendbuf = testngap_build_ue_context_release_request(test_ue, + NGAP_Cause_PR_radioNetwork, NGAP_CauseRadioNetwork_user_inactivity, + true); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive UEContextReleaseCommand */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + ABTS_INT_EQUAL(tc, + NGAP_ProcedureCode_id_UEContextRelease, + test_ue->ngap_procedure_code); + + /* Send UEContextReleaseComplete */ + sendbuf = testngap_build_ue_context_release_complete(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send De-registration request */ + gmmbuf = testgmm_build_de_registration_request(test_ue, 1, true, false); + ABTS_PTR_NOTNULL(tc, gmmbuf); + sendbuf = testngap_build_initial_ue_message(test_ue, gmmbuf, + NGAP_RRCEstablishmentCause_mo_Signalling, true, false); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive UEContextReleaseCommand */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + ABTS_INT_EQUAL(tc, + NGAP_ProcedureCode_id_UEContextRelease, + test_ue->ngap_procedure_code); + + /* Send UEContextReleaseComplete */ + sendbuf = testngap_build_ue_context_release_complete(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + ogs_msleep(300); + + /********** Remove Subscriber in Database */ + ABTS_INT_EQUAL(tc, OGS_OK, test_db_remove_ue(test_ue)); + + /* gNB disonncect from UPF */ + testgnb_gtpu_close(gtpu); + + /* gNB disonncect from AMF */ + testgnb_ngap_close(ngap); + + /* Clear Test UE Context */ + test_ue_remove(test_ue); +} + +abts_suite *test_simple(abts_suite *suite) +{ + suite = ADD_SUITE(suite) + + abts_run_test(suite, test1_func, NULL); + + return suite; +}
View file
open5gs_2.4.9.tar.xz/tests/unit/sbi-message-test.c -> open5gs_2.4.10.tar.xz/tests/unit/sbi-message-test.c
Changed
@@ -22,11 +22,11 @@ static void sbi_message_test1(abts_case *tc, void *data) { - cJSON *item = NULL; + cJSON *item = NULL; OpenAPI_lnode_t *entry; - OpenAPI_nf_profile_t *nf_profile1; - OpenAPI_nf_profile_t *nf_profile2; + OpenAPI_nf_profile_t *nf_profile1; + OpenAPI_nf_profile_t *nf_profile2; OpenAPI_udr_info_t *udr_info1; OpenAPI_udr_info_t *udr_info2; @@ -41,9 +41,9 @@ nf_profile1 = ogs_calloc(1, sizeof(*nf_profile1)); ABTS_PTR_NOTNULL(tc, nf_profile1); - nf_profile1->nf_instance_id = "NF_INSTANCE_ID"; - nf_profile1->nf_type = OpenAPI_nf_type_SMF; - nf_profile1->nf_status = OpenAPI_nf_status_REGISTERED; + nf_profile1->nf_instance_id = "NF_INSTANCE_ID"; + nf_profile1->nf_type = OpenAPI_nf_type_SMF; + nf_profile1->nf_status = OpenAPI_nf_status_REGISTERED; memset(plmn_id1, 0, sizeof(plmn_id1)); @@ -83,7 +83,7 @@ identity_range1->end = "9"; OpenAPI_list_add(udr_info1->gpsi_ranges, identity_range1); - item = OpenAPI_nf_profile_convertToJSON(nf_profile1); + item = OpenAPI_nf_profile_convertToJSON(nf_profile1); ABTS_PTR_NOTNULL(tc, item); #if 0 @@ -94,7 +94,7 @@ } #endif - nf_profile2 = OpenAPI_nf_profile_parseFromJSON(item); + nf_profile2 = OpenAPI_nf_profile_parseFromJSON(item); ABTS_PTR_NOTNULL(tc, nf_profile2); ABTS_STR_EQUAL(tc, @@ -170,27 +170,27 @@ cJSON_Delete(item); - OpenAPI_nf_profile_free(nf_profile2); + OpenAPI_nf_profile_free(nf_profile2); } static void sbi_message_test2(abts_case *tc, void *data) { - cJSON *item = NULL; + cJSON *item = NULL; OpenAPI_lnode_t *entry; OpenAPI_nf_group_cond_t *nf_group_cond1; OpenAPI_nf_group_cond_t *nf_group_cond2; - OpenAPI_smf_info_t *smf_info1; - OpenAPI_smf_info_t *smf_info2; + OpenAPI_smf_info_t *smf_info1; + OpenAPI_smf_info_t *smf_info2; OpenAPI_access_type_e access_type; nf_group_cond1 = ogs_calloc(1, sizeof(*nf_group_cond1)); ABTS_PTR_NOTNULL(tc, nf_group_cond1); - nf_group_cond1->nf_type = OpenAPI_nf_group_cond_NFTYPE_UDR; - nf_group_cond1->nf_group_id = "group"; + nf_group_cond1->nf_type = OpenAPI_nf_group_cond_NFTYPE_UDR; + nf_group_cond1->nf_group_id = "group"; - item = OpenAPI_nf_group_cond_convertToJSON(nf_group_cond1); + item = OpenAPI_nf_group_cond_convertToJSON(nf_group_cond1); ABTS_PTR_NOTNULL(tc, item); #if 0 @@ -201,7 +201,7 @@ } #endif - nf_group_cond2 = OpenAPI_nf_group_cond_parseFromJSON(item); + nf_group_cond2 = OpenAPI_nf_group_cond_parseFromJSON(item); ABTS_PTR_NOTNULL(tc, nf_group_cond2); ABTS_STR_EQUAL(tc, @@ -218,7 +218,7 @@ smf_info1 = ogs_calloc(1, sizeof(*smf_info1)); ABTS_PTR_NOTNULL(tc, smf_info1); smf_info1->s_nssai_smf_info_list = OpenAPI_list_create(); - smf_info1->pgw_fqdn = "PGW_FQDN"; + smf_info1->pgw_fqdn = "PGW_FQDN"; smf_info1->access_type = OpenAPI_list_create(); ABTS_PTR_NOTNULL(tc, smf_info1->access_type); @@ -226,7 +226,7 @@ (void*)OpenAPI_access_type_3GPP_ACCESS); OpenAPI_list_add(smf_info1->access_type, (void*)OpenAPI_access_type_NON_3GPP_ACCESS); - item = OpenAPI_smf_info_convertToJSON(smf_info1); + item = OpenAPI_smf_info_convertToJSON(smf_info1); ABTS_PTR_NOTNULL(tc, item); #if 0 @@ -237,7 +237,7 @@ } #endif - smf_info2 = OpenAPI_smf_info_parseFromJSON(item); + smf_info2 = OpenAPI_smf_info_parseFromJSON(item); ABTS_PTR_NOTNULL(tc, smf_info2); ABTS_STR_EQUAL(tc, @@ -270,11 +270,11 @@ static void sbi_message_test3(abts_case *tc, void *data) { - cJSON *item = NULL; + cJSON *item = NULL; OpenAPI_lnode_t *entry; - OpenAPI_nrf_info_t *nrf_info1; - OpenAPI_nrf_info_t *nrf_info2; + OpenAPI_nrf_info_t *nrf_info1; + OpenAPI_nrf_info_t *nrf_info2; OpenAPI_map_t *served_pcf_info1 = NULL; OpenAPI_map_t *served_pcf_info2 = NULL; @@ -301,7 +301,7 @@ OpenAPI_list_add(nrf_info1->served_pcf_info, served_pcf_info1); OpenAPI_list_add(nrf_info1->served_pcf_info, served_pcf_info2); - item = OpenAPI_nrf_info_convertToJSON(nrf_info1); + item = OpenAPI_nrf_info_convertToJSON(nrf_info1); ABTS_PTR_NOTNULL(tc, item); #if 0 @@ -317,7 +317,7 @@ ogs_free(pcf_info1); ogs_free(pcf_info2); - nrf_info2 = OpenAPI_nrf_info_parseFromJSON(item); + nrf_info2 = OpenAPI_nrf_info_parseFromJSON(item); ABTS_PTR_NOTNULL(tc, nrf_info2); ABTS_INT_EQUAL(tc, nrf_info1->served_pcf_info->count, @@ -625,6 +625,165 @@ ogs_free(content); } +static void sbi_message_test7(abts_case *tc, void *data) +{ + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_NRF, + ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NNRF_NFM)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NNRF_NFM, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NNRF_NFM)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NNRF_NFM, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NNRF_NFM)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_UDM, + ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NUDM_SDM)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NUDM_SDM, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NUDM_SDM)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NUDM_SDM, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NUDM_SDM)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_AMF, + ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NAMF_COMM)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NAMF_COMM, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NAMF_COMM)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NAMF_COMM, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NAMF_COMM)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_SMF, + ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_AUSF, + ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NAUSF_AUTH)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NAUSF_AUTH, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NAUSF_AUTH)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NAUSF_AUTH)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_NEF, + ogs_sbi_service_type_to_nf_type( + OGS_SBI_SERVICE_TYPE_NNEF_PFDMANAGEMENT)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NNEF_PFDMANAGEMENT, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NNEF_PFDMANAGEMENT)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NNEF_PFDMANAGEMENT, + ogs_sbi_service_type_from_name( + OGS_SBI_SERVICE_NAME_NNEF_PFDMANAGEMENT)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_PCF, + ogs_sbi_service_type_to_nf_type( + OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL, + ogs_sbi_service_type_to_name( + OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL, + ogs_sbi_service_type_from_name( + OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_SMSF, + ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NSMSF_SMS)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NSMSF_SMS, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NSMSF_SMS)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NSMSF_SMS, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NSMSF_SMS)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_NSSF, + ogs_sbi_service_type_to_nf_type( + OGS_SBI_SERVICE_TYPE_NNSSF_NSSELECTION)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NNSSF_NSSELECTION)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NNSSF_NSSELECTION, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_UDR, + ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NUDR_DR)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NUDR_DR, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NUDR_DR)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NUDR_DR, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NUDR_DR)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_LMF, + ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NLMF_LOC)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NLMF_LOC, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NLMF_LOC)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NLMF_LOC, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NLMF_LOC)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_5G_EIR, + ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_N5G_EIR_EIC)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_N5G_EIR_EIC, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_N5G_EIR_EIC)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_N5G_EIR_EIC, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_N5G_EIR_EIC)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_BSF, + ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_CHF, + ogs_sbi_service_type_to_nf_type( + OGS_SBI_SERVICE_TYPE_NCHF_SPENDINGLIMITCONTROL)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NCHF_SPENDINGLIMITCONTROL, + ogs_sbi_service_type_to_name( + OGS_SBI_SERVICE_TYPE_NCHF_SPENDINGLIMITCONTROL)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NCHF_SPENDINGLIMITCONTROL, + ogs_sbi_service_type_from_name( + OGS_SBI_SERVICE_NAME_NCHF_SPENDINGLIMITCONTROL)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_NWDAF, + ogs_sbi_service_type_to_nf_type( + OGS_SBI_SERVICE_TYPE_NNWDAF_EVENTSSUBSCRIPTION)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NNWDAF_EVENTSSUBSCRIPTION, + ogs_sbi_service_type_to_name( + OGS_SBI_SERVICE_TYPE_NNWDAF_EVENTSSUBSCRIPTION)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NNWDAF_EVENTSSUBSCRIPTION, + ogs_sbi_service_type_from_name( + OGS_SBI_SERVICE_NAME_NNWDAF_EVENTSSUBSCRIPTION)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_GMLC, + ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NGMLC_LOC)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NGMLC_LOC, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NGMLC_LOC)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NGMLC_LOC, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NGMLC_LOC)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_UCMF, + ogs_sbi_service_type_to_nf_type( + OGS_SBI_SERVICE_TYPE_NUCMF_PROVISIONING)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NUCMF_PROVISIONING, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NUCMF_PROVISIONING)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NUCMF_PROVISIONING, + ogs_sbi_service_type_from_name( + OGS_SBI_SERVICE_NAME_NUCMF_PROVISIONING)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_HSS, + ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NHSS_SDM)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NHSS_SDM, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NHSS_SDM)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NHSS_SDM, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NHSS_SDM)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_SEPP, + ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NSEPP_TELESCOPIC)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NSEPP_TELESCOPIC, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NSEPP_TELESCOPIC)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NSEPP_TELESCOPIC, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NSEPP_TELESCOPIC)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_SOR_AF, + ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NSORAF_SOR)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NSORAF_SOR, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NSORAF_SOR)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NSORAF_SOR, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NSORAF_SOR)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_SPAF, + ogs_sbi_service_type_to_nf_type( + OGS_SBI_SERVICE_TYPE_NSPAF_SECURED_PACKET)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NSPAF_SECURED_PACKET, + ogs_sbi_service_type_to_name( + OGS_SBI_SERVICE_TYPE_NSPAF_SECURED_PACKET)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NSPAF_SECURED_PACKET, + ogs_sbi_service_type_from_name( + OGS_SBI_SERVICE_NAME_NSPAF_SECURED_PACKET)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_UDSF, + ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NUDSF_DR)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NUDSF_DR, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NUDSF_DR)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NUDSF_DR, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NUDSF_DR)); + ABTS_INT_EQUAL(tc, OpenAPI_nf_type_NSSAAF, + ogs_sbi_service_type_to_nf_type(OGS_SBI_SERVICE_TYPE_NNSSAAF_NSSAA)); + ABTS_STR_EQUAL(tc, OGS_SBI_SERVICE_NAME_NNSSAAF_NSSAA, + ogs_sbi_service_type_to_name(OGS_SBI_SERVICE_TYPE_NNSSAAF_NSSAA)); + ABTS_INT_EQUAL(tc, OGS_SBI_SERVICE_TYPE_NNSSAAF_NSSAA, + ogs_sbi_service_type_from_name(OGS_SBI_SERVICE_NAME_NNSSAAF_NSSAA)); +} + abts_suite *test_sbi_message(abts_suite *suite) { suite = ADD_SUITE(suite) @@ -635,6 +794,7 @@ abts_run_test(suite, sbi_message_test4, NULL); abts_run_test(suite, sbi_message_test5, NULL); abts_run_test(suite, sbi_message_test6, NULL); + abts_run_test(suite, sbi_message_test7, NULL); return suite; }
View file
open5gs_2.4.9.tar.xz/tests/volte/abts-main.c -> open5gs_2.4.10.tar.xz/tests/volte/abts-main.c
Changed
@@ -23,6 +23,7 @@ abts_suite *test_bearer(abts_suite *suite); abts_suite *test_session(abts_suite *suite); +abts_suite *test_simple(abts_suite *suite); abts_suite *test_rx(abts_suite *suite); abts_suite *test_video(abts_suite *suite); abts_suite *test_cx(abts_suite *suite); @@ -32,6 +33,7 @@ } alltests = { {test_bearer}, {test_session}, + {test_simple}, {test_rx}, {test_video}, {test_cx},
View file
open5gs_2.4.9.tar.xz/tests/volte/diameter-cx-path.c -> open5gs_2.4.10.tar.xz/tests/volte/diameter-cx-path.c
Changed
@@ -63,10 +63,10 @@ static int test_cx_fb_cb(struct msg **msg, struct avp *avp, struct session *sess, void *opaque, enum disp_action *act) { - /* This CB should never be called */ - ogs_warn("Unexpected message received!"); - - return ENOTSUP; + /* This CB should never be called */ + ogs_warn("Unexpected message received!"); + + return ENOTSUP; } void test_cx_send_uar(test_ue_t *test_ue, int id_type) @@ -485,8 +485,8 @@ /* Set the Server-Name AVP */ ret = fd_msg_avp_new(ogs_diam_cx_server_name, 0, &avp); ogs_assert(ret == 0); - val.os.data = (os0_t)fd_g_config->cnf_diamid; - val.os.len = fd_g_config->cnf_diamid_len; + val.os.data = (os0_t)fd_g_config->cnf_diamid; + val.os.len = fd_g_config->cnf_diamid_len; ret = fd_msg_avp_setvalue(avp, &val); ogs_assert(ret == 0); ret = fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp); @@ -735,8 +735,8 @@ /* Set the Server-Name AVP */ ret = fd_msg_avp_new(ogs_diam_cx_server_name, 0, &avp); ogs_assert(ret == 0); - val.os.data = (os0_t)fd_g_config->cnf_diamid; - val.os.len = fd_g_config->cnf_diamid_len; + val.os.data = (os0_t)fd_g_config->cnf_diamid; + val.os.len = fd_g_config->cnf_diamid_len; ret = fd_msg_avp_setvalue(avp, &val); ogs_assert(ret == 0); ret = fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp); @@ -1129,38 +1129,38 @@ int test_cx_init(void) { int ret; - struct disp_when data; + struct disp_when data; - /* Install objects definitions for this application */ - ret = ogs_diam_cx_init(); + /* Install objects definitions for this application */ + ret = ogs_diam_cx_init(); ogs_assert(ret == 0); /* Create handler for sessions */ - ret = fd_sess_handler_create(&test_cx_reg, &state_cleanup, NULL, NULL); + ret = fd_sess_handler_create(&test_cx_reg, &state_cleanup, NULL, NULL); ogs_assert(ret == 0); - /* Fallback CB if command != unexpected message received */ - memset(&data, 0, sizeof(data)); - data.app = ogs_diam_cx_application; + /* Fallback CB if command != unexpected message received */ + memset(&data, 0, sizeof(data)); + data.app = ogs_diam_cx_application; - ret = fd_disp_register(test_cx_fb_cb, DISP_HOW_APPID, &data, NULL, + ret = fd_disp_register(test_cx_fb_cb, DISP_HOW_APPID, &data, NULL, &hdl_cx_fb); ogs_assert(ret == 0); - - /* Advertise the support for the application in the peer */ - ret = fd_disp_app_support(ogs_diam_cx_application, ogs_diam_vendor, 1, 0); + + /* Advertise the support for the application in the peer */ + ret = fd_disp_app_support(ogs_diam_cx_application, ogs_diam_vendor, 1, 0); ogs_assert(ret == 0); - return 0; + return 0; } void test_cx_final(void) { int ret; - ret = fd_sess_handler_destroy(&test_cx_reg, NULL); + ret = fd_sess_handler_destroy(&test_cx_reg, NULL); ogs_assert(ret == OGS_OK); - if (hdl_cx_fb) - (void) fd_disp_unregister(&hdl_cx_fb, NULL); + if (hdl_cx_fb) + (void) fd_disp_unregister(&hdl_cx_fb, NULL); }
View file
open5gs_2.4.9.tar.xz/tests/volte/diameter-rx-path.c -> open5gs_2.4.10.tar.xz/tests/volte/diameter-rx-path.c
Changed
@@ -60,10 +60,10 @@ static int pcscf_rx_fb_cb(struct msg **msg, struct avp *avp, struct session *sess, void *opaque, enum disp_action *act) { - /* This CB should never be called */ - ogs_warn("Unexpected message received!"); - - return ENOTSUP; + /* This CB should never be called */ + ogs_warn("Unexpected message received!"); + + return ENOTSUP; } void test_rx_send_aar_audio(uint8_t **rx_sid, @@ -115,7 +115,7 @@ if (*rx_sid) { /* Retrieve session by Session-Id */ size_t sidlen = strlen((char *)*rx_sid); - ret = fd_sess_fromsid_msg(*rx_sid, sidlen, &session, &new); + ret = fd_sess_fromsid_msg(*rx_sid, sidlen, &session, &new); ogs_assert(ret == 0); ogs_assert(new == 0); @@ -612,7 +612,7 @@ if (*rx_sid) { /* Retrieve session by Session-Id */ size_t sidlen = strlen((char *)*rx_sid); - ret = fd_sess_fromsid_msg(*rx_sid, sidlen, &session, &new); + ret = fd_sess_fromsid_msg(*rx_sid, sidlen, &session, &new); ogs_assert(ret == 0); ogs_assert(new == 0); @@ -1290,7 +1290,7 @@ if (*rx_sid) { /* Retrieve session by Session-Id */ size_t sidlen = strlen((char *)*rx_sid); - ret = fd_sess_fromsid_msg(*rx_sid, sidlen, &session, &new); + ret = fd_sess_fromsid_msg(*rx_sid, sidlen, &session, &new); ogs_assert(ret == 0); ogs_assert(new == 0); @@ -1789,7 +1789,7 @@ int rv; int ret; - struct msg *ans, *qry; + struct msg *ans, *qry; struct avp *avpch1, *avpch2, *avpch3; struct avp_hdr *hdr; union avp_value val; @@ -1804,9 +1804,9 @@ ogs_assert(ret == 0); ogs_assert(sess_data); - /* Create answer header */ - qry = *msg; - ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); + /* Create answer header */ + qry = *msg; + ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0); ogs_assert(ret == 0); ans = *msg; @@ -1838,8 +1838,8 @@ ogs_error("no_Abort-Cause "); } - /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ - ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); + /* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */ + ret = fd_msg_rescode_set(ans, (char*)"DIAMETER_SUCCESS", NULL, NULL, 1); ogs_assert(ret == 0); /* Store this value in the session */ @@ -1850,14 +1850,14 @@ ogs_assert(ret == 0); ogs_assert(sess_data == NULL); - /* Send the answer */ - ret = fd_msg_send(msg, NULL, NULL); + /* Send the answer */ + ret = fd_msg_send(msg, NULL, NULL); ogs_assert(ret == 0); - /* Add this value to the stats */ - ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); - ogs_diam_logger_self()->stats.nb_echoed++; - ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); + /* Add this value to the stats */ + ogs_assert(pthread_mutex_lock(&ogs_diam_logger_self()->stats_lock) == 0); + ogs_diam_logger_self()->stats.nb_echoed++; + ogs_assert(pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); test_rx_send_str(sid); @@ -2102,48 +2102,48 @@ int test_rx_init(void) { int ret; - struct disp_when data; + struct disp_when data; test_cx_init(); - /* Install objects definitions for this application */ - ret = ogs_diam_rx_init(); + /* Install objects definitions for this application */ + ret = ogs_diam_rx_init(); ogs_assert(ret == 0); /* Create handler for sessions */ - ret = fd_sess_handler_create(&pcscf_rx_reg, state_cleanup, NULL, NULL); + ret = fd_sess_handler_create(&pcscf_rx_reg, state_cleanup, NULL, NULL); ogs_assert(ret == 0); - /* Fallback CB if command != unexpected message received */ - memset(&data, 0, sizeof(data)); - data.app = ogs_diam_rx_application; + /* Fallback CB if command != unexpected message received */ + memset(&data, 0, sizeof(data)); + data.app = ogs_diam_rx_application; - ret = fd_disp_register(pcscf_rx_fb_cb, DISP_HOW_APPID, &data, NULL, + ret = fd_disp_register(pcscf_rx_fb_cb, DISP_HOW_APPID, &data, NULL, &hdl_rx_fb); ogs_assert(ret == 0); - - /* Specific handler for Abort-Session-Request */ - data.command = ogs_diam_rx_cmd_asr; - ret = fd_disp_register(pcscf_rx_asr_cb, DISP_HOW_CC, &data, NULL, + + /* Specific handler for Abort-Session-Request */ + data.command = ogs_diam_rx_cmd_asr; + ret = fd_disp_register(pcscf_rx_asr_cb, DISP_HOW_CC, &data, NULL, &hdl_rx_asr); ogs_assert(ret == 0); - /* Advertise the support for the application in the peer */ - ret = fd_disp_app_support(ogs_diam_rx_application, ogs_diam_vendor, 1, 0); + /* Advertise the support for the application in the peer */ + ret = fd_disp_app_support(ogs_diam_rx_application, ogs_diam_vendor, 1, 0); ogs_assert(ret == 0); - return 0; + return 0; } void test_rx_final(void) { int ret; - ret = fd_sess_handler_destroy(&pcscf_rx_reg, NULL); + ret = fd_sess_handler_destroy(&pcscf_rx_reg, NULL); ogs_assert(ret == 0); - if (hdl_rx_fb) - (void) fd_disp_unregister(&hdl_rx_fb, NULL); - if (hdl_rx_asr) - (void) fd_disp_unregister(&hdl_rx_asr, NULL); + if (hdl_rx_fb) + (void) fd_disp_unregister(&hdl_rx_fb, NULL); + if (hdl_rx_asr) + (void) fd_disp_unregister(&hdl_rx_asr, NULL); }
View file
open5gs_2.4.9.tar.xz/tests/volte/meson.build -> open5gs_2.4.10.tar.xz/tests/volte/meson.build
Changed
@@ -24,6 +24,7 @@ abts-main.c bearer-test.c session-test.c + simple-test.c rx-test.c video-test.c cx-test.c
View file
open5gs_2.4.10.tar.xz/tests/volte/simple-test.c
Added
@@ -0,0 +1,392 @@ +/* + * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#include "test-common.h" +#include "test-fd-path.h" + +static void test1_func(abts_case *tc, void *data) +{ + int rv; + ogs_socknode_t *s1ap; + ogs_socknode_t *gtpu; + ogs_pkbuf_t *emmbuf; + ogs_pkbuf_t *esmbuf; + ogs_pkbuf_t *sendbuf; + ogs_pkbuf_t *recvbuf; + ogs_s1ap_message_t message; + + uint8_t *rx_sid = NULL; + + ogs_nas_5gs_mobile_identity_suci_t mobile_identity_suci; + test_ue_t *test_ue = NULL; + test_sess_t *sess = NULL; + test_bearer_t *bearer = NULL; + + uint32_t enb_ue_s1ap_id; + uint64_t mme_ue_s1ap_id; + + bson_t *doc = NULL; + + /* Setup Test UE & Session Context */ + memset(&mobile_identity_suci, 0, sizeof(mobile_identity_suci)); + + mobile_identity_suci.h.supi_format = OGS_NAS_5GS_SUPI_FORMAT_IMSI; + mobile_identity_suci.h.type = OGS_NAS_5GS_MOBILE_IDENTITY_SUCI; + mobile_identity_suci.routing_indicator1 = 0; + mobile_identity_suci.routing_indicator2 = 0xf; + mobile_identity_suci.routing_indicator3 = 0xf; + mobile_identity_suci.routing_indicator4 = 0xf; + mobile_identity_suci.protection_scheme_id = OGS_NAS_5GS_NULL_SCHEME; + mobile_identity_suci.home_network_pki_value = 0; + mobile_identity_suci.scheme_output0 = 0x10; + mobile_identity_suci.scheme_output1 = 0x32; + mobile_identity_suci.scheme_output2 = 0x54; + mobile_identity_suci.scheme_output3 = 0x86; + mobile_identity_suci.scheme_output4 = 0x91; + + test_ue = test_ue_add_by_suci(&mobile_identity_suci, 13); + ogs_assert(test_ue); + + test_ue->e_cgi.cell_id = 0x1079baf; + test_ue->nas.ksi = 0; + test_ue->nas.value = OGS_NAS_ATTACH_TYPE_COMBINED_EPS_IMSI_ATTACH; + + test_ue->k_string = "465b5ce8b199b49faa5f0a2ee238a6bc"; + test_ue->opc_string = "e8ed289deba952e4283b54e88e6183ca"; + + sess = test_sess_add_by_apn(test_ue, "internet", OGS_GTP2_RAT_TYPE_EUTRAN); + ogs_assert(sess); + + /* eNB connects to MME */ + s1ap = tests1ap_client(AF_INET); + ABTS_PTR_NOTNULL(tc, s1ap); + + /* eNB connects to SGW */ + gtpu = test_gtpu_server(1, AF_INET); + ABTS_PTR_NOTNULL(tc, gtpu); + + /* Send S1-Setup Reqeust */ + sendbuf = test_s1ap_build_s1_setup_request( + S1AP_ENB_ID_PR_macroENB_ID, 0x54f64); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive S1-Setup Response */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(NULL, recvbuf); + + /********** Insert Subscriber in Database */ + doc = test_db_new_ims(test_ue); + ABTS_PTR_NOTNULL(tc, doc); + ABTS_INT_EQUAL(tc, OGS_OK, test_db_insert_ue(test_ue, doc)); + + /* Send Attach Request */ + memset(&sess->pdn_connectivity_param, + 0, sizeof(sess->pdn_connectivity_param)); + sess->pdn_connectivity_param.eit = 1; + sess->pdn_connectivity_param.request_type = + OGS_NAS_EPS_REQUEST_TYPE_INITIAL; + esmbuf = testesm_build_pdn_connectivity_request(sess, false); + ABTS_PTR_NOTNULL(tc, esmbuf); + + memset(&test_ue->attach_request_param, + 0, sizeof(test_ue->attach_request_param)); + test_ue->attach_request_param.drx_parameter = 1; + test_ue->attach_request_param.ms_network_capability = 1; + test_ue->attach_request_param.tmsi_status = 1; + test_ue->attach_request_param.mobile_station_classmark_2 = 1; + test_ue->attach_request_param.ue_usage_setting = 1; + emmbuf = testemm_build_attach_request(test_ue, esmbuf, true, false); + ABTS_PTR_NOTNULL(tc, emmbuf); + + memset(&test_ue->initial_ue_param, 0, sizeof(test_ue->initial_ue_param)); + sendbuf = test_s1ap_build_initial_ue_message( + test_ue, emmbuf, S1AP_RRC_Establishment_Cause_mo_Signalling, false); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive Authentication Request */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send Authentication response */ + emmbuf = testemm_build_authentication_response(test_ue); + ABTS_PTR_NOTNULL(tc, emmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, emmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive Security mode Command */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send Security mode complete */ + test_ue->mobile_identity_imeisv_presence = true; + emmbuf = testemm_build_security_mode_complete(test_ue); + ABTS_PTR_NOTNULL(tc, emmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, emmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive ESM Information Request */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send ESM Information Response */ + sess->esm_information_param.pco = 1; + esmbuf = testesm_build_esm_information_response(sess); + ABTS_PTR_NOTNULL(tc, esmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, esmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive InitialContextSetupRequest + + * Attach Accept + + * Activate Default Bearer Context Request */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send UE Capability Info Indication */ + sendbuf = tests1ap_build_ue_radio_capability_info_indication(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send InitialContextSetupResponse */ + sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send Attach Complete + Activate default EPS bearer cotext accept */ + test_ue->nr_cgi.cell_id = 0x1234502; + bearer = test_bearer_find_by_ue_ebi(test_ue, 5); + ogs_assert(bearer); + esmbuf = testesm_build_activate_default_eps_bearer_context_accept( + bearer, false); + ABTS_PTR_NOTNULL(tc, esmbuf); + emmbuf = testemm_build_attach_complete(test_ue, esmbuf); + ABTS_PTR_NOTNULL(tc, emmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, emmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive EMM information */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send GTP-U ICMP Packet */ + rv = test_gtpu_send_ping(gtpu, bearer, TEST_PING_IPV4); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U ICMP Packet */ + recvbuf = test_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + ogs_pkbuf_free(recvbuf); + + /* Send PDN Connectivity Request */ + sess = test_sess_add_by_apn(test_ue, "ims", OGS_GTP2_RAT_TYPE_EUTRAN); + ogs_assert(sess); + sess->pti = 5; + + sess->pdn_connectivity_param.apn = 1; + sess->pdn_connectivity_param.pco = 1; + sess->pdn_connectivity_param.request_type = + OGS_NAS_EPS_REQUEST_TYPE_INITIAL; + esmbuf = testesm_build_pdn_connectivity_request(sess, true); + ABTS_PTR_NOTNULL(tc, esmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, esmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive E-RABSetupRequest + + * Activate default EPS bearer context request */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + ABTS_INT_EQUAL(tc, + S1AP_ProcedureCode_id_E_RABSetup, + test_ue->s1ap_procedure_code); + + /* Send E-RABSetupResponse */ + bearer = test_bearer_find_by_ue_ebi(test_ue, 6); + ogs_assert(bearer); + sendbuf = test_s1ap_build_e_rab_setup_response(bearer); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send Activate default EPS bearer context accept */ + esmbuf = testesm_build_activate_default_eps_bearer_context_accept( + bearer, true); + ABTS_PTR_NOTNULL(tc, esmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, esmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send GTP-U ICMP Packet */ + rv = test_gtpu_send_ping(gtpu, bearer, TEST_PING_IPV4); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U ICMP Packet */ + recvbuf = test_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + ogs_pkbuf_free(recvbuf); + + /* Send AA-Request */ + test_rx_send_aar_audio(&rx_sid, sess, + OGS_DIAM_RX_SUBSCRIPTION_ID_TYPE_END_USER_IMSI, 1, 1); + + /* Receive E-RABSetupRequest + + * Activate dedicated EPS bearer context request */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + ABTS_INT_EQUAL(tc, + S1AP_ProcedureCode_id_E_RABSetup, + test_ue->s1ap_procedure_code); + + /* Send E-RABSetupResponse */ + bearer = test_bearer_find_by_ue_ebi(test_ue, 7); + ogs_assert(bearer); + sendbuf = test_s1ap_build_e_rab_setup_response(bearer); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send Activate dedicated EPS bearer context accept */ + esmbuf = testesm_build_activate_dedicated_eps_bearer_context_accept(bearer); + ABTS_PTR_NOTNULL(tc, esmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, esmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* DELAY is needed in dedicated EPS bearer */ + ogs_msleep(100); + + /* Send GTP-U ICMP Packet */ + rv = test_gtpu_send_ping(gtpu, bearer, TEST_PING_IPV4); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U ICMP Packet */ + recvbuf = test_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + ogs_pkbuf_free(recvbuf); + + /* Send Session-Termination-Request */ + test_rx_send_str(rx_sid); + + /* Receive E-RABReleaseCommand + + * Dectivate EPS bearer context request */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + ABTS_INT_EQUAL(tc, + S1AP_ProcedureCode_id_E_RABRelease, + test_ue->s1ap_procedure_code); + + /* Send E-RABReleaseResponse */ + sendbuf = test_s1ap_build_e_rab_release_response(bearer); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send Deactivate EPS bearer context accept */ + esmbuf = testesm_build_deactivate_eps_bearer_context_accept(bearer); + ABTS_PTR_NOTNULL(tc, esmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, esmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Test Bearer Remove */ + test_bearer_remove(bearer); + + /* Send Detach Request */ + emmbuf = testemm_build_detach_request(test_ue, 1, true, false); + ABTS_PTR_NOTNULL(tc, emmbuf); + sendbuf = test_s1ap_build_initial_ue_message( + test_ue, emmbuf, S1AP_RRC_Establishment_Cause_mo_Signalling, true); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive OLD UEContextReleaseCommand */ + enb_ue_s1ap_id = test_ue->enb_ue_s1ap_id; + + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send OLD UEContextReleaseComplete */ + sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + test_ue->enb_ue_s1ap_id = enb_ue_s1ap_id; + + /* Receive UEContextReleaseCommand */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send UEContextReleaseComplete */ + sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + ogs_msleep(300); + + /********** Remove Subscriber in Database */ + ABTS_INT_EQUAL(tc, OGS_OK, test_db_remove_ue(test_ue)); + + /* eNB disonncect from MME */ + testenb_s1ap_close(s1ap); + + /* eNB disonncect from SGW */ + test_gtpu_close(gtpu); + + test_ue_remove(test_ue); +} + +abts_suite *test_simple(abts_suite *suite) +{ + suite = ADD_SUITE(suite) + + abts_run_test(suite, test1_func, NULL); + + return suite; +}
View file
open5gs_2.4.9.tar.xz/tests/volte/test-fd-path.c -> open5gs_2.4.10.tar.xz/tests/volte/test-fd-path.c
Changed
@@ -69,7 +69,7 @@ int test_fd_init(void) { int ret; - struct disp_when data; + struct disp_when data; test_diam_config(); @@ -82,7 +82,7 @@ ret = ogs_diam_start(); ogs_assert(ret == 0); - return 0; + return 0; } void test_fd_final(void)
View file
open5gs_2.4.9.tar.xz/tests/vonr/abts-main.c -> open5gs_2.4.10.tar.xz/tests/vonr/abts-main.c
Changed
@@ -22,6 +22,7 @@ abts_suite *test_qos_flow(abts_suite *suite); abts_suite *test_session(abts_suite *suite); +abts_suite *test_simple(abts_suite *suite); abts_suite *test_af(abts_suite *suite); abts_suite *test_video(abts_suite *suite); @@ -30,6 +31,7 @@ } alltests = { {test_qos_flow}, {test_session}, + {test_simple}, {test_af}, {test_video}, {NULL},
View file
open5gs_2.4.9.tar.xz/tests/vonr/af-test.c -> open5gs_2.4.10.tar.xz/tests/vonr/af-test.c
Changed
@@ -303,7 +303,9 @@ af_sess->dnn = ogs_strdup(sess->dnn); ogs_assert(af_sess->dnn); - af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess, NULL, + af_local_discover_and_send( + OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, + af_sess, NULL, af_nbsf_management_build_discover); /* Wait for PCF-Discovery */ @@ -1027,7 +1029,9 @@ af_sess->dnn = ogs_strdup(sess->dnn); ogs_assert(af_sess->dnn); - af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess, NULL, + af_local_discover_and_send( + OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, + af_sess, NULL, af_nbsf_management_build_discover); /* Wait for PCF-Discovery */ @@ -1461,7 +1465,9 @@ af_sess->dnn = ogs_strdup(sess->dnn); ogs_assert(af_sess->dnn); - af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess, NULL, + af_local_discover_and_send( + OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, + af_sess, NULL, af_nbsf_management_build_discover); /* Wait for PCF-Discovery */ @@ -1970,7 +1976,9 @@ af_sess->dnn = ogs_strdup(sess->dnn); ogs_assert(af_sess->dnn); - af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess, NULL, + af_local_discover_and_send( + OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, + af_sess, NULL, af_nbsf_management_build_discover); /* Wait for PCF-Discovery */ @@ -2565,7 +2573,9 @@ af_sess->dnn = ogs_strdup(sess->dnn); ogs_assert(af_sess->dnn); - af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess, NULL, + af_local_discover_and_send( + OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, + af_sess, NULL, af_nbsf_management_build_discover); /* Wait for PCF-Discovery */ @@ -3263,7 +3273,9 @@ af_sess1->dnn = ogs_strdup(sess->dnn); ogs_assert(af_sess1->dnn); - af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess1, NULL, + af_local_discover_and_send( + OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, + af_sess1, NULL, af_nbsf_management_build_discover); /* Wait for PCF-Discovery */ @@ -3329,7 +3341,9 @@ af_sess2->dnn = ogs_strdup(sess->dnn); ogs_assert(af_sess2->dnn); - af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess2, NULL, + af_local_discover_and_send( + OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, + af_sess2, NULL, af_nbsf_management_build_discover); /* Wait for PCF-Discovery */ @@ -3801,7 +3815,9 @@ af_sess->dnn = ogs_strdup(sess->dnn); ogs_assert(af_sess->dnn); - af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess, NULL, + af_local_discover_and_send( + OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, + af_sess, NULL, af_nbsf_management_build_discover); /* Wait for PCF-Discovery */
View file
open5gs_2.4.9.tar.xz/tests/vonr/meson.build -> open5gs_2.4.10.tar.xz/tests/vonr/meson.build
Changed
@@ -19,6 +19,7 @@ abts-main.c qos-flow-test.c session-test.c + simple-test.c af-test.c video-test.c '''.split())
View file
open5gs_2.4.10.tar.xz/tests/vonr/simple-test.c
Added
@@ -0,0 +1,493 @@ +/* + * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#include "test-common.h" +#include "af/sbi-path.h" + +static void test1_func(abts_case *tc, void *data) +{ + int rv; + ogs_socknode_t *ngap; + ogs_socknode_t *gtpu; + ogs_pkbuf_t *gmmbuf; + ogs_pkbuf_t *gsmbuf; + ogs_pkbuf_t *nasbuf; + ogs_pkbuf_t *sendbuf; + ogs_pkbuf_t *recvbuf; + ogs_ngap_message_t message; + int i; + + uint8_t tmpOGS_MAX_SDU_LEN; + char *_gtp_payload = "34ff0024" + "0000000100000085 010002004500001c 0c0b000040015a7a 0a2d00010a2d0002" + "00000964cd7c291f"; + + ogs_nas_5gs_mobile_identity_suci_t mobile_identity_suci; + test_ue_t *test_ue = NULL; + test_sess_t *sess = NULL; + test_bearer_t *qos_flow = NULL; + + af_sess_t *af_sess = NULL; + af_npcf_policyauthorization_param_t af_param; + + bson_t *doc = NULL; + + /* Setup Test UE & Session Context */ + memset(&mobile_identity_suci, 0, sizeof(mobile_identity_suci)); + + mobile_identity_suci.h.supi_format = OGS_NAS_5GS_SUPI_FORMAT_IMSI; + mobile_identity_suci.h.type = OGS_NAS_5GS_MOBILE_IDENTITY_SUCI; + mobile_identity_suci.routing_indicator1 = 0; + mobile_identity_suci.routing_indicator2 = 0xf; + mobile_identity_suci.routing_indicator3 = 0xf; + mobile_identity_suci.routing_indicator4 = 0xf; + mobile_identity_suci.protection_scheme_id = OGS_NAS_5GS_NULL_SCHEME; + mobile_identity_suci.home_network_pki_value = 0; + mobile_identity_suci.scheme_output0 = 0; + mobile_identity_suci.scheme_output1 = 0; + mobile_identity_suci.scheme_output2 = 0x20; + mobile_identity_suci.scheme_output3 = 0x31; + mobile_identity_suci.scheme_output4 = 0x90; + + test_ue = test_ue_add_by_suci(&mobile_identity_suci, 13); + ogs_assert(test_ue); + + test_ue->nr_cgi.cell_id = 0x40001; + + test_ue->nas.registration.tsc = 0; + test_ue->nas.registration.ksi = OGS_NAS_KSI_NO_KEY_IS_AVAILABLE; + test_ue->nas.registration.follow_on_request = 1; + test_ue->nas.registration.value = OGS_NAS_5GS_REGISTRATION_TYPE_INITIAL; + + test_ue->k_string = "465b5ce8b199b49faa5f0a2ee238a6bc"; + test_ue->opc_string = "e8ed289deba952e4283b54e88e6183ca"; + + /* gNB connects to AMF */ + ngap = testngap_client(AF_INET); + ABTS_PTR_NOTNULL(tc, ngap); + + /* gNB connects to UPF */ + gtpu = test_gtpu_server(1, AF_INET); + ABTS_PTR_NOTNULL(tc, gtpu); + + /* Send NG-Setup Reqeust */ + sendbuf = testngap_build_ng_setup_request(0x4000, 22); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive NG-Setup Response */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + + /********** Insert Subscriber in Database */ + doc = test_db_new_ims(test_ue); + ABTS_PTR_NOTNULL(tc, doc); + ABTS_INT_EQUAL(tc, OGS_OK, test_db_insert_ue(test_ue, doc)); + + /* Send Registration request */ + test_ue->registration_request_param.guti = 1; + gmmbuf = testgmm_build_registration_request(test_ue, NULL, false, false); + ABTS_PTR_NOTNULL(tc, gmmbuf); + + test_ue->registration_request_param.gmm_capability = 1; + test_ue->registration_request_param.requested_nssai = 1; + test_ue->registration_request_param.last_visited_registered_tai = 1; + test_ue->registration_request_param.ue_usage_setting = 1; + nasbuf = testgmm_build_registration_request(test_ue, NULL, false, false); + ABTS_PTR_NOTNULL(tc, nasbuf); + + sendbuf = testngap_build_initial_ue_message(test_ue, gmmbuf, + NGAP_RRCEstablishmentCause_mo_Signalling, false, true); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive Identity request */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + + /* Send Identity response */ + gmmbuf = testgmm_build_identity_response(test_ue); + ABTS_PTR_NOTNULL(tc, gmmbuf); + sendbuf = testngap_build_uplink_nas_transport(test_ue, gmmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive Authentication request */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + + /* Send Authentication response */ + gmmbuf = testgmm_build_authentication_response(test_ue); + ABTS_PTR_NOTNULL(tc, gmmbuf); + sendbuf = testngap_build_uplink_nas_transport(test_ue, gmmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive Security mode command */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + + /* Send Security mode complete */ + gmmbuf = testgmm_build_security_mode_complete(test_ue, nasbuf); + ABTS_PTR_NOTNULL(tc, gmmbuf); + sendbuf = testngap_build_uplink_nas_transport(test_ue, gmmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive InitialContextSetupRequest + + * Registration accept */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + ABTS_INT_EQUAL(tc, + NGAP_ProcedureCode_id_InitialContextSetup, + test_ue->ngap_procedure_code); + + /* Send UERadioCapabilityInfoIndication */ + sendbuf = testngap_build_ue_radio_capability_info_indication(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send InitialContextSetupResponse */ + sendbuf = testngap_build_initial_context_setup_response(test_ue, false); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send Registration complete */ + gmmbuf = testgmm_build_registration_complete(test_ue); + ABTS_PTR_NOTNULL(tc, gmmbuf); + sendbuf = testngap_build_uplink_nas_transport(test_ue, gmmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive Configuration update command */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + + /* Send PDU session establishment request */ + sess = test_sess_add_by_dnn_and_psi(test_ue, "internet", 5); + ogs_assert(sess); + + sess->ul_nas_transport_param.request_type = + OGS_NAS_5GS_REQUEST_TYPE_INITIAL; + sess->ul_nas_transport_param.dnn = 1; + sess->ul_nas_transport_param.s_nssai = 1; + + sess->pdu_session_establishment_param.ssc_mode = 1; + sess->pdu_session_establishment_param.epco = 1; + + gsmbuf = testgsm_build_pdu_session_establishment_request(sess); + ABTS_PTR_NOTNULL(tc, gsmbuf); + gmmbuf = testgmm_build_ul_nas_transport(sess, + OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, gsmbuf); + ABTS_PTR_NOTNULL(tc, gmmbuf); + sendbuf = testngap_build_uplink_nas_transport(test_ue, gmmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive PDUSessionResourceSetupRequest + + * DL NAS transport + + * PDU session establishment accept */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + ABTS_INT_EQUAL(tc, + NGAP_ProcedureCode_id_PDUSessionResourceSetup, + test_ue->ngap_procedure_code); + + /* Send GTP-U ICMP Packet */ + qos_flow = test_qos_flow_find_by_qfi(sess, 1); + ogs_assert(qos_flow); + rv = test_gtpu_send_ping(gtpu, qos_flow, TEST_PING_IPV4); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send PDUSessionResourceSetupResponse */ + sendbuf = testngap_sess_build_pdu_session_resource_setup_response(sess); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U ICMP Packet */ + recvbuf = testgnb_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + ogs_pkbuf_free(recvbuf); + + /* Send GTP-U ICMP Packet */ + rv = test_gtpu_send_ping(gtpu, qos_flow, TEST_PING_IPV4); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U ICMP Packet */ + recvbuf = testgnb_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + ogs_pkbuf_free(recvbuf); + + /* Send GTP-U Router Solicitation */ + rv = test_gtpu_send_slacc_rs(gtpu, qos_flow); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U Router Advertisement */ + recvbuf = test_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + testgtpu_recv(test_ue, recvbuf); + + /* Send PDU session establishment request */ + sess = test_sess_add_by_dnn_and_psi(test_ue, "ims", 6); + ogs_assert(sess); + + sess->ul_nas_transport_param.request_type = + OGS_NAS_5GS_REQUEST_TYPE_INITIAL; + sess->ul_nas_transport_param.dnn = 1; + sess->ul_nas_transport_param.s_nssai = 1; + + sess->pdu_session_establishment_param.ssc_mode = 1; + sess->pdu_session_establishment_param.epco = 1; + + gsmbuf = testgsm_build_pdu_session_establishment_request(sess); + ABTS_PTR_NOTNULL(tc, gsmbuf); + gmmbuf = testgmm_build_ul_nas_transport(sess, + OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, gsmbuf); + ABTS_PTR_NOTNULL(tc, gmmbuf); + sendbuf = testngap_build_uplink_nas_transport(test_ue, gmmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive PDU session establishment accept */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + + /* Send PDUSessionResourceSetupResponse */ + sendbuf = testngap_sess_build_pdu_session_resource_setup_response(sess); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Add AF-Session */ + af_sess = af_sess_add_by_ue_address(&sess->ue_ip); + ogs_assert(af_sess); + + af_sess->supi = ogs_strdup(test_ue->supi); + ogs_assert(af_sess->supi); + + af_sess->dnn = ogs_strdup(sess->dnn); + ogs_assert(af_sess->dnn); + + af_local_discover_and_send( + OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, + af_sess, NULL, + af_nbsf_management_build_discover); + + /* Wait for PCF-Discovery */ + ogs_msleep(100); + + /* Send AF-Session : CREATE */ + memset(&af_param, 0, sizeof(af_param)); + af_param.med_type = OpenAPI_media_type_AUDIO; + af_param.qos_type = 1; + af_param.flow_type = 99; /* For ping test */ + + af_local_send_to_pcf(af_sess, &af_param, + af_npcf_policyauthorization_build_create); + + /* Receive PDUSessionResourceModifyRequest + + * DL NAS transport + + * PDU session modification command */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + ABTS_INT_EQUAL(tc, + NGAP_ProcedureCode_id_PDUSessionResourceModify, + test_ue->ngap_procedure_code); + + /* Send PDU session resource modify response */ + qos_flow = test_qos_flow_find_by_qfi(sess, 2); + ogs_assert(qos_flow); + + sendbuf = testngap_build_qos_flow_resource_modify_response(qos_flow); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send PDU session resource modify complete */ + sess->ul_nas_transport_param.request_type = + OGS_NAS_5GS_REQUEST_TYPE_MODIFICATION_REQUEST; + sess->ul_nas_transport_param.dnn = 0; + sess->ul_nas_transport_param.s_nssai = 0; + + sess->pdu_session_establishment_param.ssc_mode = 0; + sess->pdu_session_establishment_param.epco = 0; + + gsmbuf = testgsm_build_pdu_session_modification_complete(sess); + ABTS_PTR_NOTNULL(tc, gsmbuf); + gmmbuf = testgmm_build_ul_nas_transport(sess, + OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, gsmbuf); + ABTS_PTR_NOTNULL(tc, gmmbuf); + sendbuf = testngap_build_uplink_nas_transport(test_ue, gmmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Wait for PDU session resource modify complete */ + ogs_msleep(100); + + /* Send GTP-U ICMP Packet */ + qos_flow = test_qos_flow_find_by_qfi(sess, 2); + ogs_assert(qos_flow); + rv = test_gtpu_send_ping(gtpu, qos_flow, TEST_PING_IPV4); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U ICMP Packet */ + recvbuf = testgnb_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + ogs_pkbuf_free(recvbuf); + + /* Waiting for creating dedicated QoS flow in PFCP protocol */ + ogs_msleep(100); + + /* Send AF-Session : DELETE */ + af_local_send_to_pcf(af_sess, NULL, + af_npcf_policyauthorization_build_delete); + + /* Receive PDUSessionResourceModifyRequest + + * DL NAS transport + + * PDU session modification command */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + ABTS_INT_EQUAL(tc, + NGAP_ProcedureCode_id_PDUSessionResourceModify, + test_ue->ngap_procedure_code); + + /* Send PDU session resource modify response */ + qos_flow = test_qos_flow_find_by_qfi(sess, 2); + ogs_assert(qos_flow); + + sendbuf = testngap_build_qos_flow_resource_release_response(qos_flow); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send PDU session resource modify complete */ + sess->ul_nas_transport_param.request_type = + OGS_NAS_5GS_REQUEST_TYPE_MODIFICATION_REQUEST; + sess->ul_nas_transport_param.dnn = 0; + sess->ul_nas_transport_param.s_nssai = 0; + + sess->pdu_session_establishment_param.ssc_mode = 0; + sess->pdu_session_establishment_param.epco = 0; + + gsmbuf = testgsm_build_pdu_session_modification_complete(sess); + ABTS_PTR_NOTNULL(tc, gsmbuf); + gmmbuf = testgmm_build_ul_nas_transport(sess, + OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, gsmbuf); + ABTS_PTR_NOTNULL(tc, gmmbuf); + sendbuf = testngap_build_uplink_nas_transport(test_ue, gmmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Wait for PDU session resource modify complete */ + ogs_msleep(100); + + /* Test Bearer Remove */ + test_bearer_remove(qos_flow); + + /* Send UEContextReleaseRequest */ + sendbuf = testngap_build_ue_context_release_request(test_ue, + NGAP_Cause_PR_radioNetwork, NGAP_CauseRadioNetwork_user_inactivity, + true); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive UEContextReleaseCommand */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + ABTS_INT_EQUAL(tc, + NGAP_ProcedureCode_id_UEContextRelease, + test_ue->ngap_procedure_code); + + /* Send UEContextReleaseComplete */ + sendbuf = testngap_build_ue_context_release_complete(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send De-registration request */ + gmmbuf = testgmm_build_de_registration_request(test_ue, 1, true, false); + ABTS_PTR_NOTNULL(tc, gmmbuf); + sendbuf = testngap_build_initial_ue_message(test_ue, gmmbuf, + NGAP_RRCEstablishmentCause_mo_Signalling, true, false); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive UEContextReleaseCommand */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(test_ue, recvbuf); + ABTS_INT_EQUAL(tc, + NGAP_ProcedureCode_id_UEContextRelease, + test_ue->ngap_procedure_code); + + /* Send UEContextReleaseComplete */ + sendbuf = testngap_build_ue_context_release_complete(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + ogs_msleep(300); + + /********** Remove Subscriber in Database */ + ABTS_INT_EQUAL(tc, OGS_OK, test_db_remove_ue(test_ue)); + + /* gNB disonncect from UPF */ + testgnb_gtpu_close(gtpu); + + /* gNB disonncect from AMF */ + testgnb_ngap_close(ngap); + + /* Clear Test UE Context */ + test_ue_remove(test_ue); +} + +abts_suite *test_simple(abts_suite *suite) +{ + suite = ADD_SUITE(suite) + + abts_run_test(suite, test1_func, NULL); + + return suite; +}
View file
open5gs_2.4.9.tar.xz/tests/vonr/video-test.c -> open5gs_2.4.10.tar.xz/tests/vonr/video-test.c
Changed
@@ -303,7 +303,9 @@ af_sess->dnn = ogs_strdup(sess->dnn); ogs_assert(af_sess->dnn); - af_local_discover_and_send(OpenAPI_nf_type_BSF, af_sess, NULL, + af_local_discover_and_send( + OGS_SBI_SERVICE_TYPE_NBSF_MANAGEMENT, + af_sess, NULL, af_nbsf_management_build_discover); /* Wait for PCF-Discovery */
View file
open5gs_2.4.9.tar.xz/webui/package-lock.json -> open5gs_2.4.10.tar.xz/webui/package-lock.json
Changed
@@ -6,7 +6,7 @@ "packages": { "": { "name": "open5gs", - "version": "2.4.3", + "version": "2.4.7", "license": "AGPL-3.0", "dependencies": { "axios": "^0.16.2",
View file
open5gs_2.4.9.tar.xz/webui/src/components/Profile/View.js -> open5gs_2.4.10.tar.xz/webui/src/components/Profile/View.js
Changed
@@ -300,7 +300,7 @@ </div> } <div className="body" style={{color:oc.gray5}}> - <div className="medium_data">DNN/APN</div> + <div className="large_data">DNN/APN</div> <div className="medium_data">Type</div> <div className="small_data">5QI/QCI</div> <div className="small_data">ARP</div> @@ -313,7 +313,7 @@ slice.session.map(session => <div key={session.name}> <div className="body"> - <div className="medium_data">{session.name}</div> + <div className="large_data">{session.name}</div> <div className="medium_data">{ session.type === 1 ? "IPv4" : session.type === 2 ? "IPv6" : @@ -397,7 +397,7 @@ session.pcc_rule.map((pcc_rule, index) => <div key={index}> <div className="body"> - <div className="medium_data"></div> + <div className="large_data"></div> <div className="medium_data"></div> <div className="small_data">{pcc_rule.qos.index}</div> <div className="small_data">{pcc_rule.qos.arp.priority_level}</div>
View file
open5gs_2.4.9.tar.xz/webui/src/components/Subscriber/View.js -> open5gs_2.4.10.tar.xz/webui/src/components/Subscriber/View.js
Changed
@@ -299,7 +299,7 @@ </div> } <div className="body" style={{color:oc.gray5}}> - <div className="medium_data">DNN/APN</div> + <div className="large_data">DNN/APN</div> <div className="medium_data">Type</div> <div className="small_data">5QI/QCI</div> <div className="small_data">ARP</div> @@ -312,7 +312,7 @@ slice.session.map(session => <div key={session.name}> <div className="body"> - <div className="medium_data">{session.name}</div> + <div className="large_data">{session.name}</div> <div className="medium_data">{ session.type === 1 ? "IPv4" : session.type === 2 ? "IPv6" : @@ -396,7 +396,7 @@ session.pcc_rule.map((pcc_rule, index) => <div key={index}> <div className="body"> - <div className="medium_data"></div> + <div className="large_data"></div> <div className="medium_data"></div> <div className="small_data">{pcc_rule.qos.index}</div> <div className="small_data">{pcc_rule.qos.arp.priority_level}</div>
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-3gpp-types.c
Deleted
@@ -1,1012 +0,0 @@ -/* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "ogs-core.h" - -#define PLMN_ID_DIGIT1(x) (((x) / 100) % 10) -#define PLMN_ID_DIGIT2(x) (((x) / 10) % 10) -#define PLMN_ID_DIGIT3(x) ((x) % 10) - -uint32_t ogs_plmn_id_hexdump(void *plmn_id) -{ - uint32_t hex; - ogs_assert(plmn_id); - memcpy(&hex, plmn_id, sizeof(ogs_plmn_id_t)); - hex = be32toh(hex) >> 8; - return hex; -} - -uint16_t ogs_plmn_id_mcc(ogs_plmn_id_t *plmn_id) -{ - return plmn_id->mcc1 * 100 + plmn_id->mcc2 * 10 + plmn_id->mcc3; -} -uint16_t ogs_plmn_id_mnc(ogs_plmn_id_t *plmn_id) -{ - return plmn_id->mnc1 == 0xf ? plmn_id->mnc2 * 10 + plmn_id->mnc3 : - plmn_id->mnc1 * 100 + plmn_id->mnc2 * 10 + plmn_id->mnc3; -} -uint16_t ogs_plmn_id_mnc_len(ogs_plmn_id_t *plmn_id) -{ - return plmn_id->mnc1 == 0xf ? 2 : 3; -} - -void *ogs_plmn_id_build(ogs_plmn_id_t *plmn_id, - uint16_t mcc, uint16_t mnc, uint16_t mnc_len) -{ - plmn_id->mcc1 = PLMN_ID_DIGIT1(mcc); - plmn_id->mcc2 = PLMN_ID_DIGIT2(mcc); - plmn_id->mcc3 = PLMN_ID_DIGIT3(mcc); - - if (mnc_len == 2) - plmn_id->mnc1 = 0xf; - else - plmn_id->mnc1 = PLMN_ID_DIGIT1(mnc); - - plmn_id->mnc2 = PLMN_ID_DIGIT2(mnc); - plmn_id->mnc3 = PLMN_ID_DIGIT3(mnc); - - return plmn_id; -} - -void *ogs_nas_from_plmn_id( - ogs_nas_plmn_id_t *ogs_nas_plmn_id, ogs_plmn_id_t *plmn_id) -{ - memcpy(ogs_nas_plmn_id, plmn_id, OGS_PLMN_ID_LEN); - if (plmn_id->mnc1 != 0xf) { - ogs_nas_plmn_id->mnc1 = plmn_id->mnc1; - ogs_nas_plmn_id->mnc2 = plmn_id->mnc2; - ogs_nas_plmn_id->mnc3 = plmn_id->mnc3; - } - return ogs_nas_plmn_id; -} -void *ogs_nas_to_plmn_id( - ogs_plmn_id_t *plmn_id, ogs_nas_plmn_id_t *ogs_nas_plmn_id) -{ - memcpy(plmn_id, ogs_nas_plmn_id, OGS_PLMN_ID_LEN); - if (plmn_id->mnc1 != 0xf) { - plmn_id->mnc1 = ogs_nas_plmn_id->mnc1; - plmn_id->mnc2 = ogs_nas_plmn_id->mnc2; - plmn_id->mnc3 = ogs_nas_plmn_id->mnc3; - } - return plmn_id; -} - -char *ogs_serving_network_name_from_plmn_id(ogs_plmn_id_t *plmn_id) -{ - ogs_assert(plmn_id); - return ogs_msprintf("5G:mnc%03d.mcc%03d.3gppnetwork.org", - ogs_plmn_id_mnc(plmn_id), ogs_plmn_id_mcc(plmn_id)); -} - -char *ogs_plmn_id_mcc_string(ogs_plmn_id_t *plmn_id) -{ - ogs_assert(plmn_id); - return ogs_msprintf("%03d", ogs_plmn_id_mcc(plmn_id)); -} - -char *ogs_plmn_id_mnc_string(ogs_plmn_id_t *plmn_id) -{ - ogs_assert(plmn_id); - if (ogs_plmn_id_mnc_len(plmn_id) == 2) - return ogs_msprintf("%02d", ogs_plmn_id_mnc(plmn_id)); - else - return ogs_msprintf("%03d", ogs_plmn_id_mnc(plmn_id)); -} - -char *ogs_plmn_id_to_string(ogs_plmn_id_t *plmn_id, char *buf) -{ - ogs_assert(plmn_id); - ogs_assert(buf); - - if (ogs_plmn_id_mnc_len(plmn_id) == 2) - ogs_snprintf(buf, OGS_PLMNIDSTRLEN, "%03d%02d", - ogs_plmn_id_mcc(plmn_id), ogs_plmn_id_mnc(plmn_id)); - else - ogs_snprintf(buf, OGS_PLMNIDSTRLEN, "%03d%03d", - ogs_plmn_id_mcc(plmn_id), ogs_plmn_id_mnc(plmn_id)); - - return buf; -} - -uint32_t ogs_amf_id_hexdump(ogs_amf_id_t *amf_id) -{ - uint32_t hex; - - ogs_assert(amf_id); - - memcpy(&hex, amf_id, sizeof(ogs_amf_id_t)); - hex = be32toh(hex) >> 8; - - return hex; -} - -ogs_amf_id_t *ogs_amf_id_from_string(ogs_amf_id_t *amf_id, const char *hex) -{ - char hexbufsizeof(ogs_amf_id_t); - - ogs_assert(amf_id); - ogs_assert(hex); - - OGS_HEX(hex, strlen(hex), hexbuf); - - amf_id->region = hexbuf0; - amf_id->set1 = hexbuf1; - amf_id->set2 = (hexbuf2 & 0xc0) >> 6; - amf_id->pointer = hexbuf2 & 0x3f; - - return amf_id; -} - -#define OGS_AMFIDSTRLEN (sizeof(ogs_amf_id_t)*2+1) -char *ogs_amf_id_to_string(ogs_amf_id_t *amf_id) -{ - char *str = NULL; - ogs_assert(amf_id); - - str = ogs_calloc(1, OGS_AMFIDSTRLEN); - ogs_expect_or_return_val(str, NULL); - - ogs_hex_to_ascii(amf_id, sizeof(ogs_amf_id_t), str, OGS_AMFIDSTRLEN); - - return str; -} - -uint8_t ogs_amf_region_id(ogs_amf_id_t *amf_id) -{ - ogs_assert(amf_id); - return amf_id->region; -} -uint16_t ogs_amf_set_id(ogs_amf_id_t *amf_id) -{ - ogs_assert(amf_id); - return (amf_id->set1 << 2) + amf_id->set2; -} -uint8_t ogs_amf_pointer(ogs_amf_id_t *amf_id) -{ - ogs_assert(amf_id); - return amf_id->pointer; -} - -ogs_amf_id_t *ogs_amf_id_build(ogs_amf_id_t *amf_id, - uint8_t region, uint16_t set, uint8_t pointer) -{ - amf_id->region = region; - amf_id->set1 = set >> 2; - amf_id->set2 = set & 0x3; - amf_id->pointer = pointer; - - return amf_id; -} - -char *ogs_supi_from_suci(char *suci) -{ -#define MAX_SUCI_TOKEN 16 - char *arrayMAX_SUCI_TOKEN; - char *p, *tmp; - int i; - char *supi = NULL; - - ogs_assert(suci); - tmp = ogs_strdup(suci); - ogs_expect_or_return_val(tmp, NULL); - - p = tmp; - i = 0; - while((arrayi++ = strsep(&p, "-"))) { - /* Empty Body */ - } - - SWITCH(array0) - CASE("suci") - SWITCH(array1) - CASE("0") /* SUPI format : IMSI */ - if (array2 && array3 && array7) - supi = ogs_msprintf("imsi-%s%s%s", - array2, array3, array7); - - break; - DEFAULT - ogs_error("Not implemented %s", array1); - break; - END - break; - DEFAULT - ogs_error("Not implemented %s", array0); - break; - END - - ogs_free(tmp); - return supi; -} - -char *ogs_id_get_type(char *str) -{ - char *token, *p, *tmp; - char *type = NULL; - - ogs_assert(str); - tmp = ogs_strdup(str); - ogs_expect_or_return_val(tmp, NULL); - - p = tmp; - token = strsep(&p, "-"); - ogs_assert(token); - type = ogs_strdup(token); - ogs_expect_or_return_val(type, NULL); - - ogs_free(tmp); - return type; -} - -char *ogs_id_get_value(char *str) -{ - char *token, *p, *tmp; - char *ueid = NULL; - - ogs_assert(str); - tmp = ogs_strdup(str); - ogs_expect_or_return_val(tmp, NULL); - - p = tmp; - token = strsep(&p, "-"); - ogs_assert(token); - token = strsep(&p, "-"); - ogs_assert(token); - ueid = ogs_strdup(token); - ogs_expect_or_return_val(ueid, NULL); - - ogs_free(tmp); - return ueid; -} - -char *ogs_s_nssai_sd_to_string(ogs_uint24_t sd) -{ - char *string = NULL; - - if (sd.v == OGS_S_NSSAI_NO_SD_VALUE) - return NULL; - - string = ogs_uint24_to_0string(sd); - ogs_expect(string); - - return string; -} - -ogs_uint24_t ogs_s_nssai_sd_from_string(const char *hex) -{ - ogs_uint24_t sd; - - sd.v = OGS_S_NSSAI_NO_SD_VALUE; - if (hex == NULL) - return sd; - - return ogs_uint24_from_string((char *)hex); -} - -int ogs_fqdn_build(char *dst, char *src, int length) -{ - int i = 0, j = 0; - - for (i = 0, j = 0; i < length; i++, j++) { - if (srci == '.') { - dsti-j = j; - j = -1; - } else { - dsti+1 = srci; - } - } - dsti-j = j; - - return length+1; -} - -int ogs_fqdn_parse(char *dst, char *src, int length) -{ - int i = 0, j = 0; - uint8_t len = 0; - - while (i+1 < length) { - len = srci++; - if ((j + len + 1) > length) { - ogs_error("Invalid FQDN encodinglen:%d + 1 > length%d", - len, length); - ogs_log_hexdump(OGS_LOG_ERROR, (unsigned char *)src, length); - return 0; - } - memcpy(&dstj, &srci, len); - - i += len; - j += len; - - if (i+1 < length) - dstj++ = '.'; - else - dstj = 0; - } - - return j; -} - -/* 8.13 Protocol Configuration Options (PCO) - * 10.5.6.3 Protocol configuration options in 3GPP TS 24.008 */ -int ogs_pco_parse(ogs_pco_t *pco, unsigned char *data, int data_len) -{ - ogs_pco_t *source = (ogs_pco_t *)data; - int size = 0; - int i = 0; - - ogs_assert(pco); - ogs_assert(data); - ogs_assert(data_len); - - memset(pco, 0, sizeof(ogs_pco_t)); - - pco->ext = source->ext; - pco->configuration_protocol = source->configuration_protocol; - size++; - - while(size < data_len && i < OGS_MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID) { - ogs_pco_id_t *id = &pco->idsi; - ogs_assert(size + sizeof(id->id) <= data_len); - memcpy(&id->id, data + size, sizeof(id->id)); - id->id = be16toh(id->id); - size += sizeof(id->id); - - ogs_assert(size + sizeof(id->len) <= data_len); - memcpy(&id->len, data + size, sizeof(id->len)); - size += sizeof(id->len); - - id->data = data + size; - size += id->len; - - i++; - } - pco->num_of_id = i; - ogs_assert(size == data_len); - - return size; -} -int ogs_pco_build(unsigned char *data, int data_len, ogs_pco_t *pco) -{ - ogs_pco_t target; - int size = 0; - int i = 0; - - ogs_assert(pco); - ogs_assert(data); - ogs_assert(data_len); - - memcpy(&target, pco, sizeof(ogs_pco_t)); - - ogs_assert(size + 1 <= data_len); - memcpy(data + size, &target, 1); - size += 1; - - ogs_assert(target.num_of_id <= OGS_MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID); - for (i = 0; i < target.num_of_id; i++) { - ogs_pco_id_t *id = &target.idsi; - - ogs_assert(size + sizeof(id->id) <= data_len); - id->id = htobe16(id->id); - memcpy(data + size, &id->id, sizeof(id->id)); - size += sizeof(id->id); - - ogs_assert(size + sizeof(id->len) <= data_len); - memcpy(data + size, &id->len, sizeof(id->len)); - size += sizeof(id->len); - - ogs_assert(size + id->len <= data_len); - memcpy(data + size, id->data, id->len); - size += id->len; - } - - return size; -} - -int ogs_ip_to_sockaddr(ogs_ip_t *ip, uint16_t port, ogs_sockaddr_t **list) -{ - ogs_sockaddr_t *addr = NULL, *addr6 = NULL; - - ogs_assert(ip); - ogs_assert(list); - - addr = ogs_calloc(1, sizeof(ogs_sockaddr_t)); - if (!addr) { - ogs_error("ogs_calloc() failed"); - return OGS_ERROR; - } - addr->ogs_sa_family = AF_INET; - addr->ogs_sin_port = htobe16(port); - - addr6 = ogs_calloc(1, sizeof(ogs_sockaddr_t)); - if (!addr6) { - ogs_error("ogs_calloc() failed"); - ogs_free(addr); - return OGS_ERROR; - } - addr6->ogs_sa_family = AF_INET6; - addr6->ogs_sin_port = htobe16(port); - - if (ip->ipv4 && ip->ipv6) { - addr->next = addr6; - - addr->sin.sin_addr.s_addr = ip->addr; - memcpy(addr6->sin6.sin6_addr.s6_addr, ip->addr6, OGS_IPV6_LEN); - - *list = addr; - } else if (ip->ipv4) { - addr->sin.sin_addr.s_addr = ip->addr; - ogs_free(addr6); - - *list = addr; - } else if (ip->ipv6) { - memcpy(addr6->sin6.sin6_addr.s6_addr, ip->addr6, OGS_IPV6_LEN); - ogs_free(addr); - - *list = addr6; - } else { - ogs_error("No IPv4 and IPv6"); - ogs_free(addr); - ogs_free(addr6); - return OGS_ERROR; - } - - return OGS_OK; -} - -int ogs_sockaddr_to_ip( - ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, ogs_ip_t *ip) -{ - ogs_expect_or_return_val(ip, OGS_ERROR); - ogs_expect_or_return_val(addr || addr6, OGS_ERROR); - - memset(ip, 0, sizeof(ogs_ip_t)); - - if (addr && addr6) { - ip->ipv4 = 1; - ip->ipv6 = 1; - ip->len = OGS_IPV4V6_LEN; - ip->addr = addr->sin.sin_addr.s_addr; - memcpy(ip->addr6, addr6->sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); - } else if (addr) { - ip->ipv4 = 1; - ip->len = OGS_IPV4_LEN; - ip->addr = addr->sin.sin_addr.s_addr; - } else if (addr6) { - ip->ipv6 = 1; - ip->len = OGS_IPV6_LEN; - memcpy(ip->addr6, addr6->sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); - } else - ogs_assert_if_reached(); - - return OGS_OK; -} - -char *ogs_ipv4_to_string(uint32_t addr) -{ - char *buf = NULL; - - buf = ogs_calloc(1, OGS_ADDRSTRLEN); - ogs_expect_or_return_val(buf, NULL); - - return (char*)OGS_INET_NTOP(&addr, buf); -} - -char *ogs_ipv6addr_to_string(uint8_t *addr6) -{ - char *buf = NULL; - ogs_assert(addr6); - - buf = ogs_calloc(1, OGS_ADDRSTRLEN); - ogs_expect_or_return_val(buf, NULL); - - return (char *)OGS_INET6_NTOP(addr6, buf); -} - -char *ogs_ipv6prefix_to_string(uint8_t *addr6, uint8_t prefixlen) -{ - char *buf = NULL; - uint8_t tmpOGS_IPV6_LEN; - ogs_assert(addr6); - - memset(tmp, 0, OGS_IPV6_LEN); - memcpy(tmp, addr6, prefixlen >> 3); - - buf = ogs_calloc(1, OGS_ADDRSTRLEN); - ogs_expect_or_return_val(buf, NULL); - - if (OGS_INET6_NTOP(tmp, buf) == NULL) { - ogs_fatal("Invalid IPv6 address"); - ogs_log_hexdump(OGS_LOG_FATAL, addr6, OGS_IPV6_LEN); - ogs_assert_if_reached(); - } - return ogs_mstrcatf(buf, "/%d", prefixlen); -} - -int ogs_ipv4_from_string(uint32_t *addr, char *string) -{ - int rv; - ogs_sockaddr_t tmp; - - ogs_assert(addr); - ogs_assert(string); - - rv = ogs_inet_pton(AF_INET, string, &tmp); - if (rv != OGS_OK) { - ogs_error("Invalid IPv4 string = %s", string); - return OGS_ERROR; - } - - *addr = tmp.sin.sin_addr.s_addr; - - return OGS_OK; -} - -int ogs_ipv6addr_from_string(uint8_t *addr6, char *string) -{ - int rv; - ogs_sockaddr_t tmp; - - ogs_assert(addr6); - ogs_assert(string); - - rv = ogs_inet_pton(AF_INET6, string, &tmp); - if (rv != OGS_OK) { - ogs_error("Invalid IPv6 string = %s", string); - return OGS_ERROR; - } - - memcpy(addr6, tmp.sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); - - return OGS_OK; -} - -int ogs_ipv6prefix_from_string(uint8_t *addr6, uint8_t *prefixlen, char *string) -{ - int rv; - ogs_sockaddr_t tmp; - char *v = NULL, *pv = NULL, *ipstr = NULL, *mask_or_numbits = NULL; - - ogs_assert(addr6); - ogs_assert(prefixlen); - ogs_assert(string); - pv = v = ogs_strdup(string); - ogs_expect_or_return_val(v, OGS_ERROR); - - ipstr = strsep(&v, "/"); - if (ipstr) - mask_or_numbits = v; - - if (!ipstr || !mask_or_numbits) { - ogs_error("Invalid IPv6 Prefix string = %s", v); - ogs_free(v); - return OGS_ERROR; - } - - rv = ogs_inet_pton(AF_INET6, ipstr, &tmp); - ogs_expect_or_return_val(rv == OGS_OK, rv); - - memcpy(addr6, tmp.sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); - *prefixlen = atoi(mask_or_numbits); - - ogs_free(pv); - return OGS_OK; -} - -int ogs_sockaddr_to_user_plane_ip_resource_info( - ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, - ogs_user_plane_ip_resource_info_t *info) -{ - ogs_assert(addr || addr6); - ogs_assert(info); - - if (addr) { - info->v4 = 1; - info->addr = addr->sin.sin_addr.s_addr; - } - if (addr6) { - info->v6 = 1; - memcpy(info->addr6, addr6->sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); - } - - return OGS_OK; -} - -int ogs_user_plane_ip_resource_info_to_sockaddr( - ogs_user_plane_ip_resource_info_t *info, - ogs_sockaddr_t **addr, ogs_sockaddr_t **addr6) -{ - ogs_assert(addr && addr6); - ogs_assert(info); - - *addr = NULL; - *addr6 = NULL; - - if (info->v4) { - *addr = ogs_calloc(1, sizeof(**addr)); - ogs_assert(*addr); - (*addr)->sin.sin_addr.s_addr = info->addr; - (*addr)->ogs_sa_family = AF_INET; - } - - if (info->v6) { - *addr6 = ogs_calloc(1, sizeof(**addr6)); - ogs_assert(*addr6); - memcpy((*addr6)->sin6.sin6_addr.s6_addr, info->addr6, OGS_IPV6_LEN); - (*addr6)->ogs_sa_family = AF_INET6; - } - - return OGS_OK; -} - -ogs_slice_data_t *ogs_slice_find_by_s_nssai( - ogs_slice_data_t *slice_data, int num_of_slice_data, - ogs_s_nssai_t *s_nssai) -{ - int i; - - ogs_assert(slice_data); - ogs_assert(num_of_slice_data); - ogs_assert(s_nssai); - - /* Compare S-NSSAI */ - for (i = 0; i < num_of_slice_data; i++) { - if (s_nssai->sst == slice_datai.s_nssai.sst && - s_nssai->sd.v == slice_datai.s_nssai.sd.v) { - return slice_data + i; - } - } - - return NULL; -} - -void ogs_subscription_data_free(ogs_subscription_data_t *subscription_data) -{ - int i, j; - - ogs_assert(subscription_data); - - for (i = 0; i < subscription_data->num_of_slice; i++) { - ogs_slice_data_t *slice_data = &subscription_data->slicei; - - for (j = 0; j < slice_data->num_of_session; j++) { - if (slice_data->sessionj.name) - ogs_free(slice_data->sessionj.name); - } - - slice_data->num_of_session = 0; - } - - subscription_data->num_of_slice = 0; - - subscription_data->num_of_msisdn = 0; -} - -void ogs_session_data_free(ogs_session_data_t *session_data) -{ - int i; - - ogs_assert(session_data); - - if (session_data->session.name) - ogs_free(session_data->session.name); - - for (i = 0; i < session_data->num_of_pcc_rule; i++) - OGS_PCC_RULE_FREE(&session_data->pcc_rulei); -} - -void ogs_ims_data_free(ogs_ims_data_t *ims_data) -{ - int i, j, k; - - ogs_assert(ims_data); - - for (i = 0; i < ims_data->num_of_media_component; i++) { - ogs_media_component_t *media_component = &ims_data->media_componenti; - - for (j = 0; j < media_component->num_of_sub; j++) { - ogs_media_sub_component_t *sub = &media_component->subj; - - for (k = 0; k < sub->num_of_flow; k++) { - ogs_flow_t *flow = &sub->flowk; - - if (flow->description) { - ogs_free(flow->description); - } else - ogs_assert_if_reached(); - } - } - } -} - -static int flow_rx_to_gx(ogs_flow_t *rx_flow, ogs_flow_t *gx_flow) -{ - int len; - char *from_str, *to_str; - - ogs_assert(rx_flow); - ogs_assert(gx_flow); - - if (!strncmp(rx_flow->description, - "permit out", strlen("permit out"))) { - gx_flow->direction = OGS_FLOW_DOWNLINK_ONLY; - gx_flow->description = ogs_strdup(rx_flow->description); - ogs_assert(gx_flow->description); - - } else if (!strncmp(rx_flow->description, - "permit in", strlen("permit in"))) { - gx_flow->direction = OGS_FLOW_UPLINK_ONLY; - - /* 'permit in' should be changed - * 'permit out' in Gx Diameter */ - len = strlen(rx_flow->description)+2; - gx_flow->description = ogs_calloc(1, len); - ogs_assert(gx_flow->description); - strcpy(gx_flow->description, "permit out"); - from_str = strstr(&rx_flow->descriptionstrlen("permit in"), "from"); - ogs_assert(from_str); - to_str = strstr(&rx_flow->descriptionstrlen("permit in"), "to"); - ogs_assert(to_str); - strncat(gx_flow->description, - &rx_flow->descriptionstrlen("permit in"), - strlen(rx_flow->description) - - strlen("permit in") - strlen(from_str)); - strcat(gx_flow->description, "from"); - strcat(gx_flow->description, &to_strstrlen("to")); - strcat(gx_flow->description, " to"); - strncat(gx_flow->description, &from_strstrlen("from"), - strlen(from_str) - strlen(to_str) - strlen("from") - 1); - ogs_assert(len == strlen(gx_flow->description)+1); - } else { - ogs_error("Invalid Flow Descripton : %s", rx_flow->description); - return OGS_ERROR; - } - - return OGS_OK; -} - -int ogs_pcc_rule_num_of_flow_equal_to_media( - ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component) -{ - int rv; - int i, j, k; - int matched = 0; - int new = 0; - - ogs_assert(pcc_rule); - ogs_assert(media_component); - - for (i = 0; i < media_component->num_of_sub; i++) { - ogs_media_sub_component_t *sub = &media_component->subi; - - for (j = 0; j < sub->num_of_flow; j++) { - new++; - } - } - - if (new == 0) { - /* No new flow in Media-Component */ - return pcc_rule->num_of_flow; - } - - for (i = 0; i < media_component->num_of_sub; i++) { - ogs_media_sub_component_t *sub = &media_component->subi; - - for (j = 0; j < sub->num_of_flow && - j < OGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT; j++) { - ogs_flow_t gx_flow; - ogs_flow_t *rx_flow = &sub->flowj; - - rv = flow_rx_to_gx(rx_flow, &gx_flow); - if (rv != OGS_OK) { - ogs_error("flow reformatting error"); - return OGS_ERROR; - } - - for (k = 0; k < pcc_rule->num_of_flow; k++) { - if (gx_flow.direction == pcc_rule->flowk.direction && - !strcmp(gx_flow.description, - pcc_rule->flowk.description)) { - matched++; - break; - } - } - - OGS_FLOW_FREE(&gx_flow); - } - } - - return matched; -} - -int ogs_pcc_rule_install_flow_from_media( - ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component) -{ - int rv; - int i, j; - - ogs_assert(pcc_rule); - ogs_assert(media_component); - - /* Remove Flow from PCC Rule */ - for (i = 0; i < pcc_rule->num_of_flow; i++) { - OGS_FLOW_FREE(&pcc_rule->flowi); - } - pcc_rule->num_of_flow = 0; - - for (i = 0; i < media_component->num_of_sub; i++) { - ogs_media_sub_component_t *sub = &media_component->subi; - - /* Copy Flow to PCC Rule */ - for (j = 0; j < sub->num_of_flow && - j < OGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT; j++) { - ogs_flow_t *rx_flow = NULL; - ogs_flow_t *gx_flow = NULL; - - if (pcc_rule->num_of_flow < OGS_MAX_NUM_OF_FLOW_IN_PCC_RULE) { - rx_flow = &sub->flowj; - gx_flow = &pcc_rule->flowpcc_rule->num_of_flow; - - rv = flow_rx_to_gx(rx_flow, gx_flow); - if (rv != OGS_OK) { - ogs_error("flow reformatting error"); - return OGS_ERROR; - } - - pcc_rule->num_of_flow++; - } else { - ogs_error("Overflow: Number of Flow"); - return OGS_ERROR; - } - } - } - - return OGS_OK; -} - -int ogs_pcc_rule_update_qos_from_media( - ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component) -{ - int rv; - int i, j; - - ogs_assert(pcc_rule); - ogs_assert(media_component); - - pcc_rule->qos.mbr.downlink = 0; - pcc_rule->qos.mbr.uplink = 0; - pcc_rule->qos.gbr.downlink = 0; - pcc_rule->qos.gbr.uplink = 0; - - for (i = 0; i < media_component->num_of_sub; i++) { - ogs_media_sub_component_t *sub = &media_component->subi; - - for (j = 0; j < sub->num_of_flow && - j < OGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT; j++) { - ogs_flow_t gx_flow; - ogs_flow_t *rx_flow = &sub->flowj; - - rv = flow_rx_to_gx(rx_flow, &gx_flow); - if (rv != OGS_OK) { - ogs_error("flow reformatting error"); - return OGS_ERROR; - } - - if (gx_flow.direction == OGS_FLOW_DOWNLINK_ONLY) { - if (sub->flow_usage == OGS_FLOW_USAGE_RTCP) { - if (media_component->rr_bandwidth && - media_component->rs_bandwidth) { - pcc_rule->qos.mbr.downlink += - (media_component->rr_bandwidth + - media_component->rs_bandwidth); - } else if (media_component->max_requested_bandwidth_dl) { - if (media_component->rr_bandwidth && - !media_component->rs_bandwidth) { - pcc_rule->qos.mbr.downlink += - ogs_max(0.05 * - media_component->max_requested_bandwidth_dl, - media_component->rr_bandwidth); - } - if (!media_component->rr_bandwidth && - media_component->rs_bandwidth) { - pcc_rule->qos.mbr.downlink += - ogs_max(0.05 * - media_component->max_requested_bandwidth_dl, - media_component->rs_bandwidth); - } - if (!media_component->rr_bandwidth && - !media_component->rs_bandwidth) { - pcc_rule->qos.mbr.downlink += - 0.05 * - media_component->max_requested_bandwidth_dl; - } - } - } else { - if (gx_flow.description) { - pcc_rule->qos.mbr.downlink += - media_component->max_requested_bandwidth_dl; - pcc_rule->qos.gbr.downlink += - media_component->min_requested_bandwidth_dl; - } - } - } else if (gx_flow.direction == OGS_FLOW_UPLINK_ONLY) { - if (sub->flow_usage == OGS_FLOW_USAGE_RTCP) { - if (media_component->rr_bandwidth && - media_component->rs_bandwidth) { - pcc_rule->qos.mbr.uplink += - (media_component->rr_bandwidth + - media_component->rs_bandwidth); - } else if (media_component->max_requested_bandwidth_ul) { - if (media_component->rr_bandwidth && - !media_component->rs_bandwidth) { - pcc_rule->qos.mbr.uplink += - ogs_max(0.05 * - media_component->max_requested_bandwidth_ul, - media_component->rr_bandwidth); - } - if (!media_component->rr_bandwidth && - media_component->rs_bandwidth) { - pcc_rule->qos.mbr.uplink += - ogs_max(0.05 * - media_component->max_requested_bandwidth_ul, - media_component->rs_bandwidth); - } - if (!media_component->rr_bandwidth && - !media_component->rs_bandwidth) { - pcc_rule->qos.mbr.uplink += - 0.05 * - media_component->max_requested_bandwidth_ul; - } - } - } else { - if (gx_flow.description) { - pcc_rule->qos.mbr.uplink += - media_component->max_requested_bandwidth_ul; - pcc_rule->qos.gbr.uplink += - media_component->min_requested_bandwidth_ul; - } - } - } else - ogs_assert_if_reached(); - - OGS_FLOW_FREE(&gx_flow); - } - } - - if (pcc_rule->qos.mbr.downlink == 0) { - pcc_rule->qos.mbr.downlink += - media_component->max_requested_bandwidth_dl; - pcc_rule->qos.mbr.downlink += - (media_component->rr_bandwidth + media_component->rs_bandwidth); - } - - if (pcc_rule->qos.mbr.uplink == 0) { - pcc_rule->qos.mbr.uplink += - media_component->max_requested_bandwidth_ul; - pcc_rule->qos.mbr.uplink += - (media_component->rr_bandwidth + media_component->rs_bandwidth); - } - - if (pcc_rule->qos.gbr.downlink == 0) - pcc_rule->qos.gbr.downlink = pcc_rule->qos.mbr.downlink; - if (pcc_rule->qos.gbr.uplink == 0) - pcc_rule->qos.gbr.uplink = pcc_rule->qos.mbr.uplink; - - return OGS_OK; -}
View file
open5gs_2.4.9.tar.xz/lib/core/ogs-3gpp-types.h
Deleted
@@ -1,781 +0,0 @@ -/* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#if !defined(OGS_CORE_INSIDE) && !defined(OGS_CORE_COMPILATION) -#error "This header cannot be included directly." -#endif - -#ifndef OGS_3GPP_TYPES_H -#define OGS_3GPP_TYPES_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define OGS_MAX_NUM_OF_SESS 4 /* Num of APN(Session) per UE */ -#define OGS_MAX_NUM_OF_BEARER 4 /* Num of Bearer per Session */ -#define OGS_BEARER_PER_UE 8 /* Num of Bearer per UE */ -#define OGS_MAX_NUM_OF_PACKET_BUFFER 64 /* Num of PacketBuffer per UE */ - -/* Num of NF Service per NF Instance */ -#define OGS_MAX_NUM_OF_NF_SERVICE 16 - -/* - * The array of TLV messages is limited to 8. - * So, Flow(PDI.SDF_Filter) in PDR is limited to 8. - * - * However, the number of flow in bearer context seems to need more than 16. - * - * Therefore, the maximum number of flows of messages is defined as 8, - * and the maximum number of flows stored by the context is 16. - */ -#define OGS_MAX_NUM_OF_FLOW_IN_PDR 8 -#define OGS_MAX_NUM_OF_FLOW_IN_GTP OGS_MAX_NUM_OF_FLOW_IN_PDR -#define OGS_MAX_NUM_OF_FLOW_IN_NAS OGS_MAX_NUM_OF_FLOW_IN_PDR -#define OGS_MAX_NUM_OF_FLOW_IN_PCC_RULE OGS_MAX_NUM_OF_FLOW_IN_PDR -#define OGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT OGS_MAX_NUM_OF_FLOW_IN_PDR -#define OGS_MAX_NUM_OF_FLOW_IN_BEARER 16 - -#define OGS_MAX_NUM_OF_GTPU_RESOURCE 4 - -#define OGS_MAX_SDU_LEN 8192 -#define OGS_MAX_PKT_LEN 2048 -#define OGS_PLMN_ID_LEN 3 -#define OGS_MAX_PLMN_ID_BCD_LEN 6 - -#define OGS_CHRGCHARS_LEN 2 - -#define OGS_BCD_TO_BUFFER_LEN(x) (((x)+1)/2) -#define OGS_MAX_IMSI_BCD_LEN 15 -#define OGS_MAX_IMSI_LEN \ - OGS_BCD_TO_BUFFER_LEN(OGS_MAX_IMSI_BCD_LEN) - -#define OGS_MAX_IMEISV_BCD_LEN 16 -#define OGS_MAX_IMEISV_LEN \ - OGS_BCD_TO_BUFFER_LEN(OGS_MAX_IMEISV_BCD_LEN) - -#define OGS_MAX_MSISDN_BCD_LEN 15 -#define OGS_MAX_MSISDN_LEN \ - OGS_BCD_TO_BUFFER_LEN(OGS_MAX_MSISDN_BCD_LEN) - -#define OGS_MAX_NUM_OF_CELL_ID 16 -#define OGS_MAX_NUM_OF_ENB_ID 16 -#define OGS_MAX_NUM_OF_DNN 16 -#define OGS_MAX_NUM_OF_APN OGS_MAX_NUM_OF_DNN -#define OGS_MAX_NUM_OF_HOSTNAME 16 -#define OGS_MAX_DNN_LEN 100 -#define OGS_MAX_APN_LEN OGS_MAX_DNN_LEN -#define OGS_MAX_PCO_LEN 251 -#define OGS_MAX_FQDN_LEN 256 - -#define OGS_MAX_NUM_OF_SERVED_TAI 16 -#define OGS_MAX_NUM_OF_ALGORITHM 8 - -#define OGS_MAX_NUM_OF_BPLMN 6 - -#define OGS_NEXT_ID(__id, __min, __max) \ - ((__id) = ((__id) == (__max) ? (__min) : ((__id) + 1))) -#define OGS_COMPARE_ID(__id1, __id2, __max) \ - ((__id2) > (__id1) ? ((__id2) - (__id1) < ((__max)-1) ? -1 : 1) : \ - (__id1) > (__id2) ? ((__id1) - (__id2) < ((__max)-1) ? 1 : -1) : 0) - -#define OGS_TIME_TO_BCD(x) \ - (((((x) % 10) << 4) & 0xf0) | (((x) / 10) & 0x0f)) - -#define OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED 0 -#define OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED 0 - -#define OGS_ACCESS_TYPE_3GPP 1 -#define OGS_ACCESS_TYPE_NON_3GPP 2 -#define OGS_ACCESS_TYPE_BOTH_3GPP_AND_NON_3GPP 3 - -#define OGS_MAX_QOS_FLOW_ID 63 - -#define OGS_DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS 30 - -/************************************ - * PLMN_ID Structure */ -#define OGS_MAX_NUM_OF_PLMN 6 -typedef struct ogs_plmn_id_s { -ED2(uint8_t mcc2:4;, - uint8_t mcc1:4;) -ED2(uint8_t mnc1:4;, - uint8_t mcc3:4;) -ED2(uint8_t mnc3:4;, - uint8_t mnc2:4;) -} __attribute__ ((packed)) ogs_plmn_id_t; - -uint32_t ogs_plmn_id_hexdump(void *plmn_id); - -uint16_t ogs_plmn_id_mcc(ogs_plmn_id_t *plmn_id); -uint16_t ogs_plmn_id_mnc(ogs_plmn_id_t *plmn_id); -uint16_t ogs_plmn_id_mnc_len(ogs_plmn_id_t *plmn_id); - -void *ogs_plmn_id_build(ogs_plmn_id_t *plmn_id, - uint16_t mcc, uint16_t mnc, uint16_t mnc_len); - -char *ogs_serving_network_name_from_plmn_id(ogs_plmn_id_t *plmn_id); -char *ogs_plmn_id_mcc_string(ogs_plmn_id_t *plmn_id); -char *ogs_plmn_id_mnc_string(ogs_plmn_id_t *plmn_id); - -#define OGS_PLMNIDSTRLEN (sizeof(ogs_plmn_id_t)*2+1) -char *ogs_plmn_id_to_string(ogs_plmn_id_t *plmn_id, char *buf); - -/************************* - * NAS PLMN_ID Structure */ -typedef struct ogs_nas_plmn_id_s { -ED2(uint8_t mcc2:4;, - uint8_t mcc1:4;) -ED2(uint8_t mnc3:4;, - uint8_t mcc3:4;) -ED2(uint8_t mnc2:4;, - uint8_t mnc1:4;) -} __attribute__ ((packed)) ogs_nas_plmn_id_t; - -void *ogs_nas_from_plmn_id( - ogs_nas_plmn_id_t *ogs_nas_plmn_id, ogs_plmn_id_t *plmn_id); -void *ogs_nas_to_plmn_id( - ogs_plmn_id_t *plmn_id, ogs_nas_plmn_id_t *ogs_nas_plmn_id); - -/************************************ - * AMF_ID Structure */ -typedef struct ogs_amf_id_s { - uint8_t region; - uint8_t set1; -ED2(uint8_t set2:2;, - uint8_t pointer:6;) -} __attribute__ ((packed)) ogs_amf_id_t; - -typedef struct ogs_guami_s { - ogs_plmn_id_t plmn_id; - ogs_amf_id_t amf_id; -} ogs_guami_t; - -uint32_t ogs_amf_id_hexdump(ogs_amf_id_t *amf_id); - -ogs_amf_id_t *ogs_amf_id_from_string(ogs_amf_id_t *amf_id, const char *hex); -char *ogs_amf_id_to_string(ogs_amf_id_t *amf_id); - -uint8_t ogs_amf_region_id(ogs_amf_id_t *amf_id); -uint16_t ogs_amf_set_id(ogs_amf_id_t *amf_id); -uint8_t ogs_amf_pointer(ogs_amf_id_t *amf_id); - -ogs_amf_id_t *ogs_amf_id_build(ogs_amf_id_t *amf_id, - uint8_t region, uint16_t set, uint8_t pointer); - -/************************************ - * SUPI/SUCI */ -char *ogs_supi_from_suci(char *suci); - -/************************************ - * SUPI/GPSI */ -#define OGS_ID_SUPI_TYPE_IMSI "imsi" -#define OGS_ID_GPSI_TYPE_MSISDN "msisdn" -char *ogs_id_get_type(char *str); -char *ogs_id_get_value(char *str); - -/************************************ - * TAI Structure */ -#define OGS_MAX_NUM_OF_TAI 16 -typedef struct ogs_eps_tai_s { - ogs_plmn_id_t plmn_id; - uint16_t tac; -} __attribute__ ((packed)) ogs_eps_tai_t; - -typedef struct ogs_5gs_tai_s { - ogs_plmn_id_t plmn_id; - ogs_uint24_t tac; -} __attribute__ ((packed)) ogs_5gs_tai_t; - -typedef struct ogs_e_cgi_s { - ogs_plmn_id_t plmn_id; - uint32_t cell_id; /* 28 bit */ -} __attribute__ ((packed)) ogs_e_cgi_t; - -typedef struct ogs_nr_cgi_s { - ogs_plmn_id_t plmn_id; - uint64_t cell_id; /* 36 bit */ -} __attribute__ ((packed)) ogs_nr_cgi_t; - -/************************************ - * S-NSSAI Structure */ -#define OGS_MAX_NUM_OF_SLICE 8 -#define OGS_S_NSSAI_NO_SD_VALUE 0xffffff -typedef struct ogs_s_nssai_s { - uint8_t sst; - ogs_uint24_t sd; -} __attribute__ ((packed)) ogs_s_nssai_t; - -char *ogs_s_nssai_sd_to_string(ogs_uint24_t sd); -ogs_uint24_t ogs_s_nssai_sd_from_string(const char *hex); - -/************************************************** - * Common Structure - * S1AP : 9.2.2.1 Transport Layer Address, See 36.414 - * GTP : 8.22 Fully Qualified TEID (F-TEID) */ -#define OGS_IPV4_LEN 4 -#define OGS_IPV6_LEN 16 -#define OGS_IPV6_DEFAULT_PREFIX_LEN 64 -#define OGS_IPV6_128_PREFIX_LEN 128 -#define OGS_IPV4V6_LEN 20 -typedef struct ogs_ip_s { - uint32_t addr; - uint8_t addr6OGS_IPV6_LEN; - uint32_t len; -ED3(uint8_t ipv4:1;, - uint8_t ipv6:1;, - uint8_t reserved:6;) -} ogs_ip_t; - -int ogs_ip_to_sockaddr(ogs_ip_t *ip, uint16_t port, ogs_sockaddr_t **list); -int ogs_sockaddr_to_ip( - ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, ogs_ip_t *ip); - -char *ogs_ipv4_to_string(uint32_t addr); -char *ogs_ipv6addr_to_string(uint8_t *addr6); -char *ogs_ipv6prefix_to_string(uint8_t *addr6, uint8_t prefixlen); -int ogs_ipv4_from_string(uint32_t *addr, char *string); -int ogs_ipv6addr_from_string(uint8_t *addr6, char *string); -int ogs_ipv6prefix_from_string( - uint8_t *addr6, uint8_t *prefixlen, char *string); - -/************************************************** - * GTPv1-C: TS 29.060 7.7.27 End User Address (EUA) */ -#define OGS_PDP_EUA_ORG_ETSI 0 -#define OGS_PDP_EUA_ORG_IETF 1 -#define OGS_PDP_EUA_ETSI_PPP 1 -#define OGS_PDP_EUA_IETF_IPV4 0x21 -#define OGS_PDP_EUA_IETF_IPV6 0x57 -#define OGS_PDP_EUA_IETF_IPV4V6 0x8D -typedef struct ogs_eua_s { -ED2(uint8_t spare:4;, - uint8_t organization:4;) - uint8_t type; - union { - /* PDU_SESSION_TYPE_IPV4 */ - uint32_t addr; - - /* PDU_SESSION_TYPE_IPV6 */ - uint8_t addr6OGS_IPV6_LEN; - - /* PDU_SESSION_TYPE_IPV4V6 */ - struct { - uint32_t addr; - uint8_t addr6OGS_IPV6_LEN; - } __attribute__ ((packed)) both; - }; -} __attribute__ ((packed)) ogs_eua_t; - -/************************************************** - * GTPv2-C: TS 29.274 8.14 PDN Address Allocation (PAA) */ -#define OGS_PAA_IPV4_LEN 5 -#define OGS_PAA_IPV6_LEN 18 -#define OGS_PAA_IPV4V6_LEN 22 -typedef struct ogs_paa_s { -ED2(uint8_t spare:5;, -/* 8.34 PDN Type */ -#define OGS_PDU_SESSION_TYPE_IS_VALID(x) \ - ((x) == OGS_PDU_SESSION_TYPE_IPV4 || \ - (x) == OGS_PDU_SESSION_TYPE_IPV6 || \ - (x) == OGS_PDU_SESSION_TYPE_IPV4V6) \ - - uint8_t session_type:3;) - union { - /* PDU_SESSION_TYPE_IPV4 */ - uint32_t addr; - - /* PDU_SESSION_TYPE_IPV6 */ - struct { - /* the IPv6 Prefix Length */ - uint8_t len; - /* IPv6 Prefix and Interface Identifier */ - uint8_t addr6OGS_IPV6_LEN; - }; - - /* PDU_SESSION_TYPE_IPV4V6 */ - struct { - struct { - /* the IPv6 Prefix Length */ - uint8_t len; - /* IPv6 Prefix and Interface Identifier */ - uint8_t addr6OGS_IPV6_LEN; - }; - uint32_t addr; - } __attribute__ ((packed)) both; - }; -} __attribute__ ((packed)) ogs_paa_t; - -#define MAX_BIT_RATE 10000000000UL - -typedef struct ogs_bitrate_s { - uint64_t downlink; /* bits per seconds */ - uint64_t uplink; /* bits per seconds */ -} ogs_bitrate_t; - -/********************************** - * QoS Structure */ -typedef struct ogs_qos_s { -#define OGS_QOS_INDEX_1 1 -#define OGS_QOS_INDEX_2 2 -#define OGS_QOS_INDEX_5 5 - uint8_t index; - - struct { - /* Values 1 to 8 should only be assigned for services that are - * authorized to receive prioritized treatment within an operator domain. - * Values 9 to 15 may be assigned to resources that are authorized - * by the home network and thus applicable when a UE is roaming. */ - uint8_t priority_level; -/* - * Ch 7.3.40 Allocation-Retenion-Proirty in TS 29.272 V15.9.0 - * - * If the Pre-emption-Capability AVP is not present in the - * Allocation-Retention-Priority AVP, the default value shall be - * PRE-EMPTION_CAPABILITY_DISABLED (1). - * - * If the Pre-emption-Vulnerability AVP is not present in the - * Allocation-Retention-Priority AVP, the default value shall be - * PRE-EMPTION_VULNERABILITY_ENABLED (0). - * - * However, to easily set up VoLTE service, - * enable Pre-emption Capability/Vulnerablility - * in Default Bearer - */ -#define OGS_EPC_PRE_EMPTION_DISABLED 1 -#define OGS_EPC_PRE_EMPTION_ENABLED 0 - -#define OGS_5GC_PRE_EMPTION_DISABLED 1 -#define OGS_5GC_PRE_EMPTION_ENABLED 2 - uint8_t pre_emption_capability; - uint8_t pre_emption_vulnerability; - } arp; - - ogs_bitrate_t mbr; /* Maxmimum Bit Rate (MBR) */ - ogs_bitrate_t gbr; /* Guaranteed Bit Rate (GBR) */ -} ogs_qos_t; - -/********************************** - * Flow Structure */ -#define OGS_FLOW_DOWNLINK_ONLY 1 -#define OGS_FLOW_UPLINK_ONLY 2 -typedef struct ogs_flow_s { - uint8_t direction; - char *description; -} ogs_flow_t; - -#define OGS_FLOW_FREE(__fLOW) \ - do { \ - if ((__fLOW)->description) { \ - ogs_free((__fLOW)->description); \ - } \ - else \ - ogs_assert_if_reached(); \ - } while(0) - -/********************************** - * PCC Rule Structure */ -typedef struct ogs_pcc_rule_s { -#define OGS_PCC_RULE_TYPE_INSTALL 1 -#define OGS_PCC_RULE_TYPE_REMOVE 2 - uint8_t type; - - char *id; /* 5GC */ - char *name; /* EPC */ - - ogs_flow_t flowOGS_MAX_NUM_OF_FLOW_IN_PCC_RULE; - int num_of_flow; - - int flow_status; - uint32_t precedence; - - ogs_qos_t qos; -} ogs_pcc_rule_t; - -#define OGS_STORE_PCC_RULE(__dST, __sRC) \ - do { \ - int __iNDEX; \ - ogs_assert((__sRC)); \ - ogs_assert((__dST)); \ - OGS_PCC_RULE_FREE(__dST); \ - (__dST)->type = (__sRC)->type; \ - if ((__sRC)->name) { \ - (__dST)->name = ogs_strdup((__sRC)->name); \ - ogs_assert((__dST)->name); \ - } \ - if ((__sRC)->id) { \ - (__dST)->id = ogs_strdup((__sRC)->id); \ - ogs_assert((__dST)->id); \ - } \ - for (__iNDEX = 0; __iNDEX < (__sRC)->num_of_flow; __iNDEX++) { \ - (__dST)->flow__iNDEX.direction = \ - (__sRC)->flow__iNDEX.direction; \ - (__dST)->flow__iNDEX.description = \ - ogs_strdup((__sRC)->flow__iNDEX.description); \ - ogs_assert((__dST)->flow__iNDEX.description); \ - } \ - (__dST)->num_of_flow = (__sRC)->num_of_flow; \ - (__dST)->flow_status = (__sRC)->flow_status; \ - (__dST)->precedence = (__sRC)->precedence; \ - memcpy(&(__dST)->qos, &(__sRC)->qos, sizeof(ogs_qos_t)); \ - } while(0) - -#define OGS_PCC_RULE_FREE(__pCCrULE) \ - do { \ - int __pCCrULE_iNDEX; \ - ogs_assert((__pCCrULE)); \ - if ((__pCCrULE)->id) \ - ogs_free((__pCCrULE)->id); \ - if ((__pCCrULE)->name) \ - ogs_free((__pCCrULE)->name); \ - for (__pCCrULE_iNDEX = 0; \ - __pCCrULE_iNDEX < (__pCCrULE)->num_of_flow; __pCCrULE_iNDEX++) { \ - OGS_FLOW_FREE(&((__pCCrULE)->flow__pCCrULE_iNDEX)); \ - } \ - (__pCCrULE)->num_of_flow = 0; \ - } while(0) - -/********************************** - * PDN Structure */ -typedef struct ogs_session_s { - char *name; - - uint32_t context_identifier; /* EPC */ - bool default_dnn_indicator; /* 5GC */ - - uint8_t charging_characteristicsOGS_CHRGCHARS_LEN; - bool charging_characteristics_presence; - -#define OGS_PDU_SESSION_TYPE_IPV4 1 -#define OGS_PDU_SESSION_TYPE_IPV6 2 -#define OGS_PDU_SESSION_TYPE_IPV4V6 3 -#define OGS_PDU_SESSION_TYPE_UNSTRUCTURED 4 -#define OGS_PDU_SESSION_TYPE_ETHERNET 5 - -#define OGS_PDU_SESSION_TYPE_TO_DIAMETER(x) ((x)-1) -#define OGS_PDU_SESSION_TYPE_FROM_DIAMETER(x) ((x)+1) - uint8_t session_type; - -#define OGS_SSC_MODE_1 1 -#define OGS_SSC_MODE_2 2 -#define OGS_SSC_MODE_3 3 - uint8_t ssc_mode; - - ogs_qos_t qos; - ogs_bitrate_t ambr; /* APN-AMBR */ - - ogs_paa_t paa; - ogs_ip_t ue_ip; - ogs_ip_t smf_ip; -} ogs_session_t; - -int ogs_fqdn_build(char *dst, char *src, int len); -int ogs_fqdn_parse(char *dst, char *src, int len); - -/************************************************** - * Protocol Configuration Options Structure - * 8.13 Protocol Configuration Options (PCO) - * 10.5.6.3 Protocol configuration options in 3GPP TS 24.008 - * RFC 3232 103 - * RFC 1661 102 */ -#define OGS_PCO_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE 0 - -#define OGS_PCO_ID_INTERNET_PROTOCOL_CONTROL_PROTOCOL 0x8021 -#define OGS_PCO_ID_PASSWORD_AUTHENTICATION_PROTOCOL 0xc023 -#define OGS_PCO_ID_CHALLENGE_HANDSHAKE_AUTHENTICATION_PROTOCOL 0xc223 -#define OGS_PCO_ID_P_CSCF_IPV6_ADDRESS_REQUEST 0x0001 -#define OGS_PCO_ID_DNS_SERVER_IPV6_ADDRESS_REQUEST 0x0003 -#define OGS_PCO_ID_MS_SUPPORTS_BCM 0x0005 -#define OGS_PCO_ID_IP_ADDRESS_ALLOCATION_VIA_NAS_SIGNALLING 0x000a -#define OGS_PCO_ID_P_CSCF_IPV4_ADDRESS_REQUEST 0x000c -#define OGS_PCO_ID_DNS_SERVER_IPV4_ADDRESS_REQUEST 0x000d -#define OGS_PCO_ID_IPV4_LINK_MTU_REQUEST 0x0010 -#define OGS_PCO_ID_MS_SUPPORT_LOCAL_ADDR_TFT_INDICATOR 0x0011 -#define OGS_PCO_ID_P_CSCF_RE_SELECTION_SUPPORT 0x0012 - -enum ogs_pco_ipcp_options { - OGS_IPCP_OPT_IPADDR = 3, - OGS_IPCP_OPT_PRIMARY_DNS = 129, - OGS_IPCP_OPT_SECONDARY_DNS = 131, -}; - -typedef struct ogs_pco_ipcp_options_s { - uint8_t type; - uint8_t len; - uint32_t addr; -} __attribute__ ((packed)) ogs_pco_ipcp_options_t; - -#define OGS_PCO_MAX_NUM_OF_IPCP_OPTIONS 4 -typedef struct ogs_pco_ipcp_s { - uint8_t code; - uint8_t identifier; - uint16_t len; - ogs_pco_ipcp_options_t optionsOGS_PCO_MAX_NUM_OF_IPCP_OPTIONS; -} __attribute__ ((packed)) ogs_pco_ipcp_t; - -typedef struct ogs_pco_pap_s { - uint8_t code; - uint8_t identifier; - uint16_t len; - uint8_t welcome_len; - char welcome255; -} __attribute__ ((packed)) ogs_pco_pap_t; - -typedef struct ogs_pco_chap_s { - uint8_t code; - uint8_t identifier; - uint16_t len; -} __attribute__ ((packed)) ogs_pco_chap_t; - -typedef struct ogs_pco_id_s { - uint16_t id; - uint8_t len; - void *data; -} ogs_pco_id_t; - -#define OGS_MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID 16 -typedef struct ogs_pco_s { -ED3(uint8_t ext:1;, - uint8_t spare:4;, - uint8_t configuration_protocol:3;) - uint8_t num_of_id; - ogs_pco_id_t idsOGS_MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID; -} ogs_pco_t; - -int ogs_pco_parse(ogs_pco_t *pco, unsigned char *data, int data_len); -int ogs_pco_build(unsigned char *data, int data_len, ogs_pco_t *pco); - -/* - * PFCP Specification - * - * TS29.244, Ch 8.2.82 User Plane IP Resource Information - * - * The following flags are coded within Octet 5: - * - Bit 1 – V4: If this bit is set to "1", then the IPv4 address field - * shall be present, otherwise the IPv4 address field shall not be present. - * - Bit 2 – V6: If this bit is set to "1", then the IPv6 address field - * shall be present, otherwise the IPv6 address field shall not be present. - * - Bit 3-5 – TEID Range Indication (TEIDRI): the value of this field - * indicates the number of bits in the most significant octet of a TEID - * that are used to partition the TEID range, - * e.g. if this field is set to "4", then the first 4 bits in the TEID - * are used to partition the TEID range. - * - Bit 6 – Associated Network Instance (ASSONI): if this bit is set to "1", - * then the Network Instance field shall be present, otherwise the Network - * Instance field shall not be present. - * - Bit 7 – Associated Source Interface (ASSOSI): if this bit is set to "1", - * then the Source Interface field shall be present, - * otherwise the Source Interface field shall not be present. - * - Bit 8: Spare, for future use and set to 0. - * - * At least one of the V4 and V6 flags shall be set to "1", - * and both may be set to "1". - * - * If both the ASSONI and ASSOSI flags are set to "0", this shall indicate - * that the User Plane IP Resource Information provided can be used - * by CP function for any Network Instance and any Source Interface - * of GTP-U user plane in the UP function. Octet 6 (TEID Range) shall be - * present if the TEID Range Indication is not set to zero and - * shall contain a value of the bits which are used to partition the TEID range. - * E.g. if the TEID Range Indication is set to "4", then Octet 6 shall be - * one of values between 0 and 15. When TEID Range Indication is set to zero, - * the Octet 6 shall not be present, the TEID is not partitioned, - * i.e. all TEID values are available for use by the CP function. - * - * Octets "m to (m+3)" and/or "p to (p+15)" (IPv4 address / IPv6 address fields) - * , if present, shall contain the respective IP address values. - * - * Octets "k to l", if present, shall contain a Network Instance value - * as encoded in octet "5 to n+4" of the Figure 8.2.4-1 in clause 8.2.4, - * identifying a Network Instance with which the IP address or TEID Range - * is associated. - * - * Octet r, if present, shall contain a Source Interface value as encoded - * in octet 5 of the Figure 8.2.2-1 in clause 8.2.2, - * identifying the Source Interface with which the IP address or TEID Range - * is associated. - */ - -/* Flags(1) + TEID Range(1) + IPV4(4) + IPV6(16) + Source Interface(1) = 23 */ -#define OGS_MAX_USER_PLANE_IP_RESOURCE_INFO_LEN \ - (23 + (OGS_MAX_APN_LEN+1)) -typedef struct ogs_user_plane_ip_resource_info_s { - union { - struct { -ED6(uint8_t spare:1;, - uint8_t assosi:1;, - uint8_t assoni:1;, - uint8_t teidri:3;, - uint8_t v6:1;, - uint8_t v4:1;) - }; - uint8_t flags; - }; - - /* - * OGS_PFCP-GTPU-TEID = INDEX | TEID_RANGE - * INDEX = OGS_PFCP-GTPU-TEID & ~TEID_RANGE - */ -#define OGS_PFCP_GTPU_TEID_TO_INDEX(__tEID, __iND, __rANGE) \ - (__tEID & ~(__rANGE << (32 - __iND))) -#define OGS_PFCP_GTPU_INDEX_TO_TEID(__iNDEX, __iND, __rANGE) \ - (__iNDEX | (__rANGE << (32 - __iND))) - uint8_t teid_range; - uint32_t addr; - uint8_t addr6OGS_IPV6_LEN; - char network_instanceOGS_MAX_APN_LEN+1; - uint8_t source_interface; -} __attribute__ ((packed)) ogs_user_plane_ip_resource_info_t; - -int ogs_sockaddr_to_user_plane_ip_resource_info( - ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, - ogs_user_plane_ip_resource_info_t *info); -int ogs_user_plane_ip_resource_info_to_sockaddr( - ogs_user_plane_ip_resource_info_t *info, - ogs_sockaddr_t **addr, ogs_sockaddr_t **addr6); - -typedef struct ogs_slice_data_s { - ogs_s_nssai_t s_nssai; - bool default_indicator; - - uint32_t context_identifier; /* EPC for checking default APN */ - - int num_of_session; - ogs_session_t sessionOGS_MAX_NUM_OF_SESS; -} ogs_slice_data_t; - -ogs_slice_data_t *ogs_slice_find_by_s_nssai( - ogs_slice_data_t *slice_data, int num_of_slice_data, - ogs_s_nssai_t *s_nssai); - -typedef struct ogs_subscription_data_s { -#define OGS_ACCESS_RESTRICTION_UTRAN_NOT_ALLOWED (1) -#define OGS_ACCESS_RESTRICTION_GERAN_NOT_ALLOWED (1<<1) -#define OGS_ACCESS_RESTRICTION_GAN_NOT_ALLOWED (1<<2) -#define OGS_ACCESS_RESTRICTION_I_HSPA_EVOLUTION_NOT_ALLOWED (1<<3) -#define OGS_ACCESS_RESTRICTION_WB_E_UTRAN_NOT_ALLOWED (1<<4) -#define OGS_ACCESS_RESTRICTION_HO_TO_NON_3GPP_ACCESS_NOT_ALLOWED (1<<5) -#define OGS_ACCESS_RESTRICTION_NB_IOT_NOT_ALLOWED (1<<6) - uint32_t access_restriction_data; -#define OGS_SUBSCRIBER_STATUS_SERVICE_GRANTED 0 -#define OGS_SUBSCRIBER_STATUS_OPERATOR_DETERMINED_BARRING 1 - uint32_t subscriber_status; -#define OGS_NETWORK_ACCESS_MODE_PACKET_AND_CIRCUIT 0 -#define OGS_NETWORK_ACCESS_MODE_RESERVED 1 -#define OGS_NETWORK_ACCESS_MODE_ONLY_PACKET 2 - uint32_t network_access_mode; - - ogs_bitrate_t ambr; /* UE-AMBR */ - -#define OGS_RAU_TAU_DEFAULT_TIME (12*60) /* 12 min */ - uint32_t subscribed_rau_tau_timer; /* unit : seconds */ - - int num_of_slice; - ogs_slice_data_t sliceOGS_MAX_NUM_OF_SLICE; - -#define OGS_MAX_NUM_OF_MSISDN 2 - int num_of_msisdn; - struct { - uint8_t bufOGS_MAX_MSISDN_LEN; - int len; - char bcdOGS_MAX_MSISDN_BCD_LEN+1; - } msisdnOGS_MAX_NUM_OF_MSISDN; -} ogs_subscription_data_t; - -void ogs_subscription_data_free(ogs_subscription_data_t *subscription_data); - -typedef struct ogs_session_data_s { - ogs_session_t session; -#define OGS_MAX_NUM_OF_PCC_RULE 8 /* Num of PCC Rule */ - ogs_pcc_rule_t pcc_ruleOGS_MAX_NUM_OF_PCC_RULE; - int num_of_pcc_rule; -} ogs_session_data_t; - -void ogs_session_data_free(ogs_session_data_t *session_data); - -typedef struct ogs_media_sub_component_s { - uint32_t flow_number; -/* - * TS29.214 - * 5.3.12 Flow-Usage AVP - * NO_INFORMATION(0) - * RTCP(1) - * AF_SIGNALLING(2) - * - * TS29.514 - * 5.6.3.14 Enumeration: FlowUsage - * NO_INFO : 1 - * RTCP : 2 - * AF_SIGNALLING : 3 - * - * EPC and 5GC have different values for FlowUsage - * At this point, we will use the 5GC value. - */ -#define OGS_FLOW_USAGE_NO_INFO 1 -#define OGS_FLOW_USAGE_RTCP 2 -#define OGS_FLOW_USAGE_AF_SIGNALLING 3 - uint32_t flow_usage; - ogs_flow_t flowOGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT; - int num_of_flow; -} ogs_media_sub_component_t; - -typedef struct ogs_media_component_s { - uint32_t media_component_number; - uint32_t media_type; - - uint64_t max_requested_bandwidth_dl; - uint64_t max_requested_bandwidth_ul; - uint64_t min_requested_bandwidth_dl; - uint64_t min_requested_bandwidth_ul; - uint64_t rr_bandwidth; - uint64_t rs_bandwidth; - - int flow_status; - -#define OGS_MAX_NUM_OF_MEDIA_SUB_COMPONENT 8 - ogs_media_sub_component_t subOGS_MAX_NUM_OF_MEDIA_SUB_COMPONENT; - int num_of_sub; -} ogs_media_component_t; - -typedef struct ogs_ims_data_s { - int num_of_msisdn; - struct { - uint8_t bufOGS_MAX_MSISDN_LEN; - int len; - char bcdOGS_MAX_MSISDN_BCD_LEN+1; - } msisdnOGS_MAX_NUM_OF_MSISDN; - -#define OGS_MAX_NUM_OF_MEDIA_COMPONENT 16 - ogs_media_component_t media_componentOGS_MAX_NUM_OF_MEDIA_COMPONENT; - int num_of_media_component; -} ogs_ims_data_t; - -void ogs_ims_data_free(ogs_ims_data_t *ims_data); - -int ogs_pcc_rule_num_of_flow_equal_to_media( - ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component); -int ogs_pcc_rule_install_flow_from_media( - ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component); -int ogs_pcc_rule_update_qos_from_media( - ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component); - -#ifdef __cplusplus -} -#endif - -#endif /* OGS_3GPP_TYPES_H */
View file
open5gs_2.4.9.tar.xz/src/amf/nf-sm.c
Deleted
@@ -1,467 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void amf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - amf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - amf_nf_state_initial, amf_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void amf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - amf_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 amf_nf_state_initial(ogs_fsm_t *s, amf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - amf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - amf_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - amf_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - amf_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - amf_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &amf_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &amf_nf_state_registered); - } -} - -void amf_nf_state_final(ogs_fsm_t *s, amf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - amf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void amf_nf_state_will_register(ogs_fsm_t *s, amf_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); - - amf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, amf_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case AMF_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - amf_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &amf_nf_state_registered); - } else { - ogs_error("%s HTTP Response Status Code %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &amf_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case AMF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AMF_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", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, amf_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - amf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("Unknown event %s", amf_event_get_name(e)); - break; - } -} - -void amf_nf_state_registered(ogs_fsm_t *s, amf_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); - - amf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - 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_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_AUSF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_UDM)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_PCF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_SMF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_NSSF)); - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->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, amf_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case AMF_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.component0) - 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", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &amf_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case AMF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AMF_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_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case AMF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &amf_nf_state_will_register); - break; - - case AMF_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &amf_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - amf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - amf_event_get_name(e)); - break; - } -} - -void amf_nf_state_de_registered(ogs_fsm_t *s, amf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - amf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - amf_event_get_name(e)); - break; - } -} - -void amf_nf_state_exception(ogs_fsm_t *s, amf_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); - - amf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - 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_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case AMF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AMF_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", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &amf_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - amf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case AMF_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - amf_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.tar.xz/src/ausf/nf-sm.c
Deleted
@@ -1,447 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void ausf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - ausf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - ausf_nf_state_initial, ausf_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void ausf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - ausf_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 ausf_nf_state_initial(ogs_fsm_t *s, ausf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - ausf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - ausf_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - ausf_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - ausf_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - ausf_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &ausf_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &ausf_nf_state_registered); - } -} - -void ausf_nf_state_final(ogs_fsm_t *s, ausf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - ausf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void ausf_nf_state_will_register(ogs_fsm_t *s, ausf_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); - - ausf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, ausf_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case AUSF_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - ausf_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &ausf_nf_state_registered); - } else { - ogs_error("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &ausf_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case AUSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AUSF_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", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, ausf_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - ausf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("Unknown event %s", ausf_event_get_name(e)); - break; - } -} - -void ausf_nf_state_registered(ogs_fsm_t *s, ausf_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); - - ausf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - 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_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_UDM)); - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->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, ausf_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case AUSF_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.component0) - 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", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &ausf_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case AUSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AUSF_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_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case AUSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &ausf_nf_state_will_register); - break; - - case AUSF_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &ausf_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - ausf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - ausf_event_get_name(e)); - break; - } -} - -void ausf_nf_state_de_registered(ogs_fsm_t *s, ausf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - ausf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - ausf_event_get_name(e)); - break; - } -} - -void ausf_nf_state_exception(ogs_fsm_t *s, ausf_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); - - ausf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - 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_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case AUSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AUSF_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", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &ausf_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - ausf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case AUSF_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - ausf_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.tar.xz/src/ausf/nnrf-build.c
Deleted
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *ausf_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -}
View file
open5gs_2.4.9.tar.xz/src/ausf/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef AUSF_NNRF_BUILD_H -#define AUSF_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *ausf_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* AUSF_NNRF_BUILD_H */
View file
open5gs_2.4.9.tar.xz/src/ausf/timer.c
Deleted
@@ -1,116 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "context.h" - -const char *ausf_timer_get_name(ausf_timer_e id) -{ - switch (id) { - case AUSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "AUSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case AUSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "AUSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case AUSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "AUSF_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case AUSF_TIMER_NF_INSTANCE_VALIDITY: - return "AUSF_TIMER_NF_INSTANCE_VALIDITY"; - case AUSF_TIMER_SUBSCRIPTION_VALIDITY: - return "AUSF_TIMER_SUBSCRIPTION_VALIDITY"; - case AUSF_TIMER_SBI_CLIENT_WAIT: - return "AUSF_TIMER_SBI_CLIENT_WAIT"; - default: - break; - } - - return "UNKNOWN_TIMER"; -} - -static void sbi_timer_send_event(int timer_id, void *data) -{ - int rv; - ausf_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case AUSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case AUSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case AUSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case AUSF_TIMER_NF_INSTANCE_VALIDITY: - case AUSF_TIMER_SUBSCRIPTION_VALIDITY: - e = ausf_event_new(AUSF_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - case AUSF_TIMER_SBI_CLIENT_WAIT: - e = ausf_event_new(AUSF_EVT_SBI_TIMER); - if (!e) { - ogs_sbi_xact_t *sbi_xact = data; - ogs_assert(sbi_xact); - - ogs_error("sbi_timer_send_event() failed"); - ogs_sbi_xact_remove(sbi_xact); - return; - } - 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_error("ogs_queue_push() failed %d in %s", - (int)rv, ausf_timer_get_name(e->timer_id)); - ausf_event_free(e); - } -} - -void ausf_timer_nf_instance_registration_interval(void *data) -{ - sbi_timer_send_event(AUSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void ausf_timer_nf_instance_heartbeat_interval(void *data) -{ - sbi_timer_send_event(AUSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void ausf_timer_nf_instance_no_heartbeat(void *data) -{ - sbi_timer_send_event(AUSF_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void ausf_timer_nf_instance_validity(void *data) -{ - sbi_timer_send_event(AUSF_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void ausf_timer_subscription_validity(void *data) -{ - sbi_timer_send_event(AUSF_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void ausf_timer_sbi_client_wait_expire(void *data) -{ - sbi_timer_send_event(AUSF_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.tar.xz/src/ausf/timer.h
Deleted
@@ -1,57 +0,0 @@ -/* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef AUSF_TIMER_H -#define AUSF_TIMER_H - -#include "ogs-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* forward declaration */ -typedef enum { - AUSF_TIMER_BASE = 0, - - AUSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - AUSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - AUSF_TIMER_NF_INSTANCE_NO_HEARTBEAT, - AUSF_TIMER_NF_INSTANCE_VALIDITY, - AUSF_TIMER_SUBSCRIPTION_VALIDITY, - AUSF_TIMER_SBI_CLIENT_WAIT, - - MAX_NUM_OF_AUSF_TIMER, - -} ausf_timer_e; - -const char *ausf_timer_get_name(ausf_timer_e id); - -void ausf_timer_nf_instance_registration_interval(void *data); -void ausf_timer_nf_instance_heartbeat_interval(void *data); -void ausf_timer_nf_instance_no_heartbeat(void *data); -void ausf_timer_nf_instance_validity(void *data); -void ausf_timer_subscription_validity(void *data); -void ausf_timer_sbi_client_wait_expire(void *data); - -#ifdef __cplusplus -} -#endif - -#endif /* AUSF_TIMER_H */
View file
open5gs_2.4.9.tar.xz/src/bsf/nf-sm.c
Deleted
@@ -1,442 +0,0 @@ -/* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void bsf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - bsf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - bsf_nf_state_initial, bsf_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void bsf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - bsf_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 bsf_nf_state_initial(ogs_fsm_t *s, bsf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - bsf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - bsf_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - bsf_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - bsf_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - bsf_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &bsf_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &bsf_nf_state_registered); - } -} - -void bsf_nf_state_final(ogs_fsm_t *s, bsf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - bsf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void bsf_nf_state_will_register(ogs_fsm_t *s, bsf_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); - - bsf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, bsf_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case BSF_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - bsf_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &bsf_nf_state_registered); - } else { - ogs_error("%s HTTP Response Status Code %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &bsf_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case BSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case BSF_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", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, bsf_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - bsf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s Unknown event %s", - ogs_sbi_self()->nf_instance->id, bsf_event_get_name(e)); - break; - } -} - -void bsf_nf_state_registered(ogs_fsm_t *s, bsf_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); - - bsf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - 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)); - } - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->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, bsf_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case BSF_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.component0) - 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", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &bsf_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case BSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case BSF_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_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case BSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &bsf_nf_state_will_register); - break; - - case BSF_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &bsf_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - bsf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - bsf_event_get_name(e)); - break; - } -} - -void bsf_nf_state_de_registered(ogs_fsm_t *s, bsf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - bsf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - bsf_event_get_name(e)); - break; - } -} - -void bsf_nf_state_exception(ogs_fsm_t *s, bsf_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); - - bsf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - 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_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case BSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case BSF_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", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &bsf_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - bsf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case BSF_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - bsf_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.tar.xz/src/bsf/nnrf-build.c
Deleted
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *bsf_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -}
View file
open5gs_2.4.9.tar.xz/src/bsf/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef BSF_NNRF_BUILD_H -#define BSF_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *bsf_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* BSF_NNRF_BUILD_H */
View file
open5gs_2.4.9.tar.xz/src/bsf/timer.c
Deleted
@@ -1,118 +0,0 @@ -/* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "timer.h" -#include "event.h" -#include "context.h" - -const char *bsf_timer_get_name(bsf_timer_e id) -{ - switch (id) { - case BSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "BSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case BSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "BSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case BSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "BSF_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case BSF_TIMER_NF_INSTANCE_VALIDITY: - return "BSF_TIMER_NF_INSTANCE_VALIDITY"; - case BSF_TIMER_SUBSCRIPTION_VALIDITY: - return "BSF_TIMER_SUBSCRIPTION_VALIDITY"; - case BSF_TIMER_SBI_CLIENT_WAIT: - return "BSF_TIMER_SBI_CLIENT_WAIT"; - default: - break; - } - - return "UNKNOWN_TIMER"; -} - -static void timer_send_event(int timer_id, void *data) -{ - int rv; - bsf_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case BSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case BSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case BSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case BSF_TIMER_NF_INSTANCE_VALIDITY: - case BSF_TIMER_SUBSCRIPTION_VALIDITY: - e = bsf_event_new(BSF_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - case BSF_TIMER_SBI_CLIENT_WAIT: - e = bsf_event_new(BSF_EVT_SBI_TIMER); - if (!e) { - ogs_sbi_xact_t *sbi_xact = data; - ogs_assert(sbi_xact); - - ogs_error("timer_send_event() failed"); - ogs_sbi_xact_remove(sbi_xact); - return; - } - 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_error("ogs_queue_push() failed %d in %s", - (int)rv, bsf_timer_get_name(e->timer_id)); - bsf_event_free(e); - } -} - -void bsf_timer_nf_instance_registration_interval(void *data) -{ - timer_send_event(BSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void bsf_timer_nf_instance_heartbeat_interval(void *data) -{ - timer_send_event(BSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void bsf_timer_nf_instance_no_heartbeat(void *data) -{ - timer_send_event(BSF_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void bsf_timer_nf_instance_validity(void *data) -{ - timer_send_event(BSF_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void bsf_timer_subscription_validity(void *data) -{ - timer_send_event(BSF_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void bsf_timer_sbi_client_wait_expire(void *data) -{ - timer_send_event(BSF_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.tar.xz/src/bsf/timer.h
Deleted
@@ -1,57 +0,0 @@ -/* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef BSF_TIMER_H -#define BSF_TIMER_H - -#include "ogs-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* forward declaration */ -typedef enum { - BSF_TIMER_BASE = 0, - - BSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - BSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - BSF_TIMER_NF_INSTANCE_NO_HEARTBEAT, - BSF_TIMER_NF_INSTANCE_VALIDITY, - BSF_TIMER_SUBSCRIPTION_VALIDITY, - BSF_TIMER_SBI_CLIENT_WAIT, - - MAX_NUM_OF_BSF_TIMER, - -} bsf_timer_e; - -const char *bsf_timer_get_name(bsf_timer_e id); - -void bsf_timer_nf_instance_registration_interval(void *data); -void bsf_timer_nf_instance_heartbeat_interval(void *data); -void bsf_timer_nf_instance_no_heartbeat(void *data); -void bsf_timer_nf_instance_validity(void *data); -void bsf_timer_subscription_validity(void *data); -void bsf_timer_sbi_client_wait_expire(void *data); - -#ifdef __cplusplus -} -#endif - -#endif /* BSF_TIMER_H */
View file
open5gs_2.4.9.tar.xz/src/nssf/nf-sm.c
Deleted
@@ -1,441 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void nssf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - nssf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - nssf_nf_state_initial, nssf_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void nssf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - nssf_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 nssf_nf_state_initial(ogs_fsm_t *s, nssf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - nssf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - nssf_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - nssf_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - nssf_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - nssf_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &nssf_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &nssf_nf_state_registered); - } -} - -void nssf_nf_state_final(ogs_fsm_t *s, nssf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - nssf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void nssf_nf_state_will_register(ogs_fsm_t *s, nssf_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); - - nssf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, nssf_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case NSSF_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - nssf_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &nssf_nf_state_registered); - } else { - ogs_error("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &nssf_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case NSSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case NSSF_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", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, nssf_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - nssf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("Unknown event %s", nssf_event_get_name(e)); - break; - } -} - -void nssf_nf_state_registered(ogs_fsm_t *s, nssf_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); - - nssf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - 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)); - } - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->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, nssf_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case NSSF_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.component0) - 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", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &nssf_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case NSSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case NSSF_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_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case NSSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &nssf_nf_state_will_register); - break; - - case NSSF_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &nssf_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - nssf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - nssf_event_get_name(e)); - break; - } -} - -void nssf_nf_state_de_registered(ogs_fsm_t *s, nssf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - nssf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - nssf_event_get_name(e)); - break; - } -} - -void nssf_nf_state_exception(ogs_fsm_t *s, nssf_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); - - nssf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - 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_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case NSSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case NSSF_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", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &nssf_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - nssf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case NSSF_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - nssf_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.tar.xz/src/nssf/nnrf-build.c
Deleted
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *nssf_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -}
View file
open5gs_2.4.9.tar.xz/src/nssf/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef NSSF_NNRF_BUILD_H -#define NSSF_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *nssf_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* NSSF_NNRF_BUILD_H */
View file
open5gs_2.4.9.tar.xz/src/nssf/nnrf-handler.c
Deleted
@@ -1,249 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void nssf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void nssf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->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_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - 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, - nssf_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 nssf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - nssf_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - nf_instance->reference_count++; - - OGS_FSM_TRAN(&nf_instance->sm, nssf_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - NSSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - NSSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - NSSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -}
View file
open5gs_2.4.9.tar.xz/src/nssf/nnrf-handler.h
Deleted
@@ -1,41 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef NSSF_NNRF_HANDLER_H -#define NSSF_NNRF_HANDLER_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void nssf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void nssf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool nssf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - -#ifdef __cplusplus -} -#endif - -#endif /* NSSF_NNRF_HANDLER_H */
View file
open5gs_2.4.9.tar.xz/src/nssf/timer.c
Deleted
@@ -1,101 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "context.h" - -const char *nssf_timer_get_name(nssf_timer_e id) -{ - switch (id) { - case NSSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "NSSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case NSSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "NSSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case NSSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "NSSF_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case NSSF_TIMER_NF_INSTANCE_VALIDITY: - return "NSSF_TIMER_NF_INSTANCE_VALIDITY"; - case NSSF_TIMER_SUBSCRIPTION_VALIDITY: - return "NSSF_TIMER_SUBSCRIPTION_VALIDITY"; - default: - break; - } - - return "UNKNOWN_TIMER"; -} - -static void sbi_timer_send_event(int timer_id, void *data) -{ - int rv; - nssf_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case NSSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case NSSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case NSSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case NSSF_TIMER_NF_INSTANCE_VALIDITY: - case NSSF_TIMER_SUBSCRIPTION_VALIDITY: - e = nssf_event_new(NSSF_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_error("ogs_queue_push() failed %d in %s", - (int)rv, nssf_timer_get_name(e->timer_id)); - nssf_event_free(e); - } -} - -void nssf_timer_nf_instance_registration_interval(void *data) -{ - sbi_timer_send_event(NSSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void nssf_timer_nf_instance_heartbeat_interval(void *data) -{ - sbi_timer_send_event(NSSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void nssf_timer_nf_instance_no_heartbeat(void *data) -{ - sbi_timer_send_event(NSSF_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void nssf_timer_nf_instance_validity(void *data) -{ - sbi_timer_send_event(NSSF_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void nssf_timer_subscription_validity(void *data) -{ - sbi_timer_send_event(NSSF_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void nssf_timer_sbi_client_wait_expire(void *data) -{ - sbi_timer_send_event(NSSF_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.tar.xz/src/nssf/timer.h
Deleted
@@ -1,57 +0,0 @@ -/* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef NSSF_TIMER_H -#define NSSF_TIMER_H - -#include "ogs-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* forward declaration */ -typedef enum { - NSSF_TIMER_BASE = 0, - - NSSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - NSSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - NSSF_TIMER_NF_INSTANCE_NO_HEARTBEAT, - NSSF_TIMER_NF_INSTANCE_VALIDITY, - NSSF_TIMER_SUBSCRIPTION_VALIDITY, - NSSF_TIMER_SBI_CLIENT_WAIT, - - MAX_NUM_OF_NSSF_TIMER, - -} nssf_timer_e; - -const char *nssf_timer_get_name(nssf_timer_e id); - -void nssf_timer_nf_instance_registration_interval(void *data); -void nssf_timer_nf_instance_heartbeat_interval(void *data); -void nssf_timer_nf_instance_no_heartbeat(void *data); -void nssf_timer_nf_instance_validity(void *data); -void nssf_timer_subscription_validity(void *data); -void nssf_timer_sbi_client_wait_expire(void *data); - -#ifdef __cplusplus -} -#endif - -#endif /* NSSF_TIMER_H */
View file
open5gs_2.4.9.tar.xz/src/pcf/nf-sm.c
Deleted
@@ -1,453 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#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); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - pcf_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - pcf_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - pcf_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - pcf_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &pcf_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &pcf_nf_state_registered); - } -} - -void pcf_nf_state_final(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_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -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); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, pcf_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - 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.component0) - 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", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &pcf_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->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", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, pcf_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->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); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - 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_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_BSF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_UDR)); - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->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_assert(true == - 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.component0) - 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", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &pcf_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->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_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case PCF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &pcf_nf_state_will_register); - break; - - case PCF_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(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:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - pcf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - 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); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - 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); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - 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_NRF(nf_instance)) { - 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", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &pcf_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - pcf_timer_get_name(e->timer_id), e->timer_id); - } - 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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - pcf_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.tar.xz/src/pcf/nnrf-build.c
Deleted
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *pcf_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -}
View file
open5gs_2.4.9.tar.xz/src/pcf/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef PCF_NNRF_BUILD_H -#define PCF_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *pcf_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* PCF_NNRF_BUILD_H */
View file
open5gs_2.4.9.tar.xz/src/pcf/timer.c
Deleted
@@ -1,116 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#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: - e = pcf_event_new(PCF_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - case PCF_TIMER_SBI_CLIENT_WAIT: - e = pcf_event_new(PCF_EVT_SBI_TIMER); - if (!e) { - ogs_sbi_xact_t *sbi_xact = data; - ogs_assert(sbi_xact); - - ogs_error("sbi_timer_send_event() failed"); - ogs_sbi_xact_remove(sbi_xact); - return; - } - 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_error("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); -}
View file
open5gs_2.4.9.tar.xz/src/pcf/timer.h
Deleted
@@ -1,57 +0,0 @@ -/* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#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 */
View file
open5gs_2.4.9.tar.xz/src/scp/nf-sm.c
Deleted
@@ -1,483 +0,0 @@ -/* - * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void scp_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - scp_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - scp_nf_state_initial, scp_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void scp_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - scp_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 scp_nf_state_initial(ogs_fsm_t *s, scp_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - scp_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - scp_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - scp_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - scp_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - scp_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &scp_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &scp_nf_state_registered); - } -} - -void scp_nf_state_final(ogs_fsm_t *s, scp_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - scp_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void scp_nf_state_will_register(ogs_fsm_t *s, scp_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); - - scp_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, scp_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case SCP_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - scp_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &scp_nf_state_registered); - } else { - ogs_error("%s HTTP Response Status Code %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &scp_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case SCP_EVT_SBI_TIMER: - switch(e->timer_id) { - case SCP_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", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, scp_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - scp_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s Unknown event %s", - ogs_sbi_self()->nf_instance->id, scp_event_get_name(e)); - break; - } -} - -void scp_nf_state_registered(ogs_fsm_t *s, scp_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); - - scp_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - 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_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_AMF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_AUSF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_BSF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_NSSF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_PCF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_SMF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_UDM)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_UDR)); - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->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, scp_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case SCP_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.component0) - 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", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &scp_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case SCP_EVT_SBI_TIMER: - switch(e->timer_id) { - case SCP_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_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case SCP_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &scp_nf_state_will_register); - break; - - case SCP_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &scp_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - scp_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - scp_event_get_name(e)); - break; - } -} - -void scp_nf_state_de_registered(ogs_fsm_t *s, scp_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - scp_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - scp_event_get_name(e)); - break; - } -} - -void scp_nf_state_exception(ogs_fsm_t *s, scp_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); - - scp_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - 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_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case SCP_EVT_SBI_TIMER: - switch(e->timer_id) { - case SCP_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", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &scp_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - scp_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case SCP_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - scp_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.tar.xz/src/scp/nnrf-build.c
Deleted
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *scp_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -}
View file
open5gs_2.4.9.tar.xz/src/scp/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef SCP_NNRF_BUILD_H -#define SCP_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *scp_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* SCP_NNRF_BUILD_H */
View file
open5gs_2.4.9.tar.xz/src/scp/timer.c
Deleted
@@ -1,118 +0,0 @@ -/* - * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "timer.h" -#include "event.h" -#include "context.h" - -const char *scp_timer_get_name(scp_timer_e id) -{ - switch (id) { - case SCP_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "SCP_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case SCP_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "SCP_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case SCP_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "SCP_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case SCP_TIMER_NF_INSTANCE_VALIDITY: - return "SCP_TIMER_NF_INSTANCE_VALIDITY"; - case SCP_TIMER_SUBSCRIPTION_VALIDITY: - return "SCP_TIMER_SUBSCRIPTION_VALIDITY"; - case SCP_TIMER_SBI_CLIENT_WAIT: - return "SCP_TIMER_SBI_CLIENT_WAIT"; - default: - break; - } - - return "UNKNOWN_TIMER"; -} - -static void timer_send_event(int timer_id, void *data) -{ - int rv; - scp_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case SCP_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case SCP_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case SCP_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case SCP_TIMER_NF_INSTANCE_VALIDITY: - case SCP_TIMER_SUBSCRIPTION_VALIDITY: - e = scp_event_new(SCP_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - case SCP_TIMER_SBI_CLIENT_WAIT: - e = scp_event_new(SCP_EVT_SBI_TIMER); - if (!e) { - ogs_sbi_xact_t *sbi_xact = data; - ogs_assert(sbi_xact); - - ogs_error("timer_send_event() failed"); - ogs_sbi_xact_remove(sbi_xact); - return; - } - 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, scp_timer_get_name(e->timer_id)); - scp_event_free(e); - } -} - -void scp_timer_nf_instance_registration_interval(void *data) -{ - timer_send_event(SCP_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void scp_timer_nf_instance_heartbeat_interval(void *data) -{ - timer_send_event(SCP_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void scp_timer_nf_instance_no_heartbeat(void *data) -{ - timer_send_event(SCP_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void scp_timer_nf_instance_validity(void *data) -{ - timer_send_event(SCP_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void scp_timer_subscription_validity(void *data) -{ - timer_send_event(SCP_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void scp_timer_sbi_client_wait_expire(void *data) -{ - timer_send_event(SCP_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.tar.xz/src/scp/timer.h
Deleted
@@ -1,57 +0,0 @@ -/* - * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef SCP_TIMER_H -#define SCP_TIMER_H - -#include "ogs-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* forward declaration */ -typedef enum { - SCP_TIMER_BASE = 0, - - SCP_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - SCP_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - SCP_TIMER_NF_INSTANCE_NO_HEARTBEAT, - SCP_TIMER_NF_INSTANCE_VALIDITY, - SCP_TIMER_SUBSCRIPTION_VALIDITY, - SCP_TIMER_SBI_CLIENT_WAIT, - - MAX_NUM_OF_SCP_TIMER, - -} scp_timer_e; - -const char *scp_timer_get_name(scp_timer_e id); - -void scp_timer_nf_instance_registration_interval(void *data); -void scp_timer_nf_instance_heartbeat_interval(void *data); -void scp_timer_nf_instance_no_heartbeat(void *data); -void scp_timer_nf_instance_validity(void *data); -void scp_timer_subscription_validity(void *data); -void scp_timer_sbi_client_wait_expire(void *data); - -#ifdef __cplusplus -} -#endif - -#endif /* SCP_TIMER_H */
View file
open5gs_2.4.9.tar.xz/src/smf/nf-sm.c
Deleted
@@ -1,462 +0,0 @@ -/* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void smf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - smf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - smf_nf_state_initial, smf_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void smf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - smf_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 smf_nf_state_initial(ogs_fsm_t *s, smf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - smf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - smf_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - smf_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - smf_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - smf_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &smf_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &smf_nf_state_registered); - } -} - -void smf_nf_state_final(ogs_fsm_t *s, smf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - smf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void smf_nf_state_will_register(ogs_fsm_t *s, smf_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); - - smf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, smf_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case SMF_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - smf_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &smf_nf_state_registered); - } else { - ogs_error("%s HTTP Response Status Code %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &smf_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case SMF_EVT_SBI_TIMER: - switch(e->timer_id) { - case SMF_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", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, smf_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - smf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s Unknown event %s", - ogs_sbi_self()->nf_instance->id, smf_event_get_name(e)); - break; - } -} - -void smf_nf_state_registered(ogs_fsm_t *s, smf_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); - - smf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - 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_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_AMF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_UDM)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_PCF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_UPF)); - } - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->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, smf_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case SMF_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.component0) - 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", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &smf_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case SMF_EVT_SBI_TIMER: - switch(e->timer_id) { - case SMF_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_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case SMF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &smf_nf_state_will_register); - break; - - case SMF_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &smf_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - smf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - smf_event_get_name(e)); - break; - } -} - -void smf_nf_state_de_registered(ogs_fsm_t *s, smf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - smf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - smf_event_get_name(e)); - break; - } -} - -void smf_nf_state_exception(ogs_fsm_t *s, smf_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); - - smf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - 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_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case SMF_EVT_SBI_TIMER: - switch(e->timer_id) { - case SMF_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", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &smf_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - smf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case SMF_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - smf_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.tar.xz/src/smf/nnrf-build.c
Deleted
@@ -1,293 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *smf_nnrf_nfm_build_register(void) -{ - int i, j; - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_nf_info_t *nf_info = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - OpenAPI_list_t *SmfInfoList = NULL; - OpenAPI_map_t *SmfInfoMap = NULL; - OpenAPI_smf_info_t *SmfInfo = NULL; - int SmfInfoMapKey; - - OpenAPI_list_t *sNssaiSmfInfoList = NULL; - OpenAPI_snssai_smf_info_item_t *sNssaiSmfInfoItem = NULL; - OpenAPI_snssai_t *sNssai = NULL; - OpenAPI_list_t *DnnSmfInfoList = NULL; - OpenAPI_dnn_smf_info_item_t *DnnSmfInfoItem = NULL; - - OpenAPI_list_t *TaiList = NULL; - OpenAPI_tai_t *TaiItem = NULL; - OpenAPI_list_t *TaiRangeList = NULL; - OpenAPI_tai_range_t *TaiRangeItem = NULL; - OpenAPI_list_t *TacRangeList = NULL; - OpenAPI_tac_range_t *TacRangeItem = NULL; - - OpenAPI_lnode_t *node = NULL, *node2 = NULL, *node3 = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - SmfInfoList = OpenAPI_list_create(); - ogs_assert(SmfInfoList); - - SmfInfoMapKey = 0; - - ogs_list_for_each(&nf_instance->nf_info_list, nf_info) { - if (nf_info->nf_type != OpenAPI_nf_type_SMF) { - ogs_fatal("Not implemented NF-type%s", - OpenAPI_nf_type_ToString(nf_info->nf_type)); - ogs_assert_if_reached(); - } - - if (nf_info->smf.num_of_slice == 0) { - ogs_fatal("CHECK CONFIGURATION: No S-NSSAI"); - ogs_assert_if_reached(); - } - - SmfInfo = ogs_calloc(1, sizeof(*SmfInfo)); - ogs_expect_or_return_val(SmfInfo, NULL); - - sNssaiSmfInfoList = OpenAPI_list_create(); - ogs_assert(sNssaiSmfInfoList); - - for (i = 0; i < nf_info->smf.num_of_slice; i++) { - DnnSmfInfoList = OpenAPI_list_create(); - ogs_assert(DnnSmfInfoList); - - for (j = 0; j < nf_info->smf.slicei.num_of_dnn; j++) { - DnnSmfInfoItem = ogs_calloc(1, sizeof(*DnnSmfInfoItem)); - ogs_expect_or_return_val(DnnSmfInfoItem, NULL); - DnnSmfInfoItem->dnn = nf_info->smf.slicei.dnnj; - - OpenAPI_list_add(DnnSmfInfoList, DnnSmfInfoItem); - } - - if (!DnnSmfInfoList->count) { - OpenAPI_list_free(DnnSmfInfoList); - - ogs_error("CHECK CONFIGURATION: No DNN"); - ogs_expect_or_return_val(0, NULL); - } - - sNssaiSmfInfoItem = ogs_calloc(1, sizeof(*sNssaiSmfInfoItem)); - ogs_expect_or_return_val(sNssaiSmfInfoItem, NULL); - - sNssaiSmfInfoItem->dnn_smf_info_list = DnnSmfInfoList; - - sNssaiSmfInfoItem->s_nssai = sNssai = - ogs_calloc(1, sizeof(*sNssai)); - ogs_expect_or_return_val(sNssai, NULL); - sNssai->sst = nf_info->smf.slicei.s_nssai.sst; - sNssai->sd = - ogs_s_nssai_sd_to_string(nf_info->smf.slicei.s_nssai.sd); - - OpenAPI_list_add(sNssaiSmfInfoList, sNssaiSmfInfoItem); - } - - if (sNssaiSmfInfoList->count) - SmfInfo->s_nssai_smf_info_list = sNssaiSmfInfoList; - else - OpenAPI_list_free(sNssaiSmfInfoList); - - TaiList = OpenAPI_list_create(); - ogs_assert(TaiList); - - for (i = 0; i < nf_info->smf.num_of_nr_tai; i++) { - TaiItem = ogs_calloc(1, sizeof(*TaiItem)); - ogs_expect_or_return_val(TaiItem, NULL); - TaiItem->plmn_id = ogs_sbi_build_plmn_id( - &nf_info->smf.nr_taii.plmn_id); - ogs_expect_or_return_val(TaiItem->plmn_id, NULL); - TaiItem->tac = ogs_uint24_to_0string(nf_info->smf.nr_taii.tac); - ogs_expect_or_return_val(TaiItem->tac, NULL); - - OpenAPI_list_add(TaiList, TaiItem); - } - - if (TaiList->count) - SmfInfo->tai_list = TaiList; - else - OpenAPI_list_free(TaiList); - - TaiRangeList = OpenAPI_list_create(); - ogs_assert(TaiRangeList); - - for (i = 0; i < nf_info->smf.num_of_nr_tai_range; i++) { - TacRangeList = OpenAPI_list_create(); - ogs_assert(TacRangeList); - - for (j = 0; - j < nf_info->smf.nr_tai_rangei.num_of_tac_range; j++) { - TacRangeItem = ogs_calloc(1, sizeof(*TacRangeItem)); - ogs_expect_or_return_val(TacRangeItem, NULL); - - TacRangeItem->start = ogs_uint24_to_0string( - nf_info->smf.nr_tai_rangei.startj); - ogs_expect_or_return_val(TacRangeItem->start, NULL); - TacRangeItem->end = - ogs_uint24_to_0string(nf_info->smf.nr_tai_rangei.endj); - ogs_expect_or_return_val(TacRangeItem->end, NULL); - - OpenAPI_list_add(TacRangeList, TacRangeItem); - } - - if (!TacRangeList->count) { - OpenAPI_list_free(TacRangeList); - - ogs_error("CHECK CONFIGURATION: No Start/End in TacRange"); - ogs_expect_or_return_val(0, NULL); - } - - TaiRangeItem = ogs_calloc(1, sizeof(*TaiRangeItem)); - ogs_expect_or_return_val(TaiRangeItem, NULL); - - TaiRangeItem->plmn_id = ogs_sbi_build_plmn_id( - &nf_info->smf.nr_tai_rangei.plmn_id); - ogs_expect_or_return_val(TaiRangeItem->plmn_id, NULL); - - TaiRangeItem->tac_range_list = TacRangeList; - - OpenAPI_list_add(TaiRangeList, TaiRangeItem); - } - - if (TaiRangeList->count) - SmfInfo->tai_range_list = TaiRangeList; - else - OpenAPI_list_free(TaiRangeList); - - SmfInfoMap = OpenAPI_map_create( - ogs_msprintf("%d", ++SmfInfoMapKey), SmfInfo); - ogs_assert(SmfInfoMap); - - OpenAPI_list_add(SmfInfoList, SmfInfoMap); - } - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - if (SmfInfoList->count == 1) { - NFProfile->smf_info = SmfInfo; - } else if (SmfInfoList->count > 1) { - NFProfile->smf_info_list = SmfInfoList; - } - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - OpenAPI_list_for_each(SmfInfoList, node) { - SmfInfoMap = node->data; - if (SmfInfoMap) { - SmfInfo = SmfInfoMap->value; - if (SmfInfo) { - sNssaiSmfInfoList = SmfInfo->s_nssai_smf_info_list; - OpenAPI_list_for_each(sNssaiSmfInfoList, node2) { - sNssaiSmfInfoItem = node2->data; - ogs_assert(sNssaiSmfInfoItem); - - DnnSmfInfoList = sNssaiSmfInfoItem->dnn_smf_info_list; - OpenAPI_list_for_each(DnnSmfInfoList, node3) { - DnnSmfInfoItem = node3->data; - ogs_assert(DnnSmfInfoItem); - ogs_free(DnnSmfInfoItem); - } - OpenAPI_list_free(DnnSmfInfoList); - - sNssai = sNssaiSmfInfoItem->s_nssai; - if (sNssai) { - if (sNssai->sd) - ogs_free(sNssai->sd); - ogs_free(sNssai); - } - - ogs_free(sNssaiSmfInfoItem); - } - OpenAPI_list_free(sNssaiSmfInfoList); - - TaiList = SmfInfo->tai_list; - OpenAPI_list_for_each(TaiList, node2) { - TaiItem = node2->data; - ogs_assert(TaiItem); - if (TaiItem->plmn_id) - ogs_sbi_free_plmn_id(TaiItem->plmn_id); - if (TaiItem->tac) - ogs_free(TaiItem->tac); - ogs_free(TaiItem); - } - OpenAPI_list_free(TaiList); - - TaiRangeList = SmfInfo->tai_range_list; - OpenAPI_list_for_each(TaiRangeList, node2) { - TaiRangeItem = node2->data; - ogs_assert(TaiRangeItem); - - if (TaiRangeItem->plmn_id) - ogs_sbi_free_plmn_id(TaiRangeItem->plmn_id); - - TacRangeList = TaiRangeItem->tac_range_list; - OpenAPI_list_for_each(TacRangeList, node3) { - TacRangeItem = node3->data; - ogs_assert(TacRangeItem); - if (TacRangeItem->start) - ogs_free(TacRangeItem->start); - if (TacRangeItem->end) - ogs_free(TacRangeItem->end); - - ogs_free(TacRangeItem); - } - OpenAPI_list_free(TacRangeList); - - ogs_free(TaiRangeItem); - } - OpenAPI_list_free(TaiRangeList); - - ogs_free(SmfInfo); - } - if (SmfInfoMap->key) - ogs_free(SmfInfoMap->key); - ogs_free(SmfInfoMap); - } - } - OpenAPI_list_free(SmfInfoList); - - return request; -}
View file
open5gs_2.4.9.tar.xz/src/smf/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef SMF_NNRF_BUILD_H -#define SMF_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *smf_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* SMF_NNRF_BUILD_H */
View file
open5gs_2.4.9.tar.xz/src/udm/nf-sm.c
Deleted
@@ -1,447 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void udm_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - udm_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - udm_nf_state_initial, udm_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void udm_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - udm_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 udm_nf_state_initial(ogs_fsm_t *s, udm_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - udm_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - udm_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - udm_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - udm_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - udm_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &udm_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &udm_nf_state_registered); - } -} - -void udm_nf_state_final(ogs_fsm_t *s, udm_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - udm_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void udm_nf_state_will_register(ogs_fsm_t *s, udm_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); - - udm_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, udm_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case UDM_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - udm_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &udm_nf_state_registered); - } else { - ogs_error("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &udm_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case UDM_EVT_SBI_TIMER: - switch(e->timer_id) { - case UDM_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", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, udm_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - udm_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("Unknown event %s", udm_event_get_name(e)); - break; - } -} - -void udm_nf_state_registered(ogs_fsm_t *s, udm_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); - - udm_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - 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_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_UDR)); - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->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, udm_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case UDM_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.component0) - 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", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &udm_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case UDM_EVT_SBI_TIMER: - switch(e->timer_id) { - case UDM_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_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case UDM_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &udm_nf_state_will_register); - break; - - case UDM_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &udm_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udm_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udm_event_get_name(e)); - break; - } -} - -void udm_nf_state_de_registered(ogs_fsm_t *s, udm_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - udm_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udm_event_get_name(e)); - break; - } -} - -void udm_nf_state_exception(ogs_fsm_t *s, udm_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); - - udm_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - 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_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case UDM_EVT_SBI_TIMER: - switch(e->timer_id) { - case UDM_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", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &udm_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udm_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case UDM_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udm_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.tar.xz/src/udm/nnrf-build.c
Deleted
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *udm_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -}
View file
open5gs_2.4.9.tar.xz/src/udm/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef UDM_NNRF_BUILD_H -#define UDM_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *udm_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* UDM_NNRF_BUILD_H */
View file
open5gs_2.4.9.tar.xz/src/udm/timer.c
Deleted
@@ -1,116 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "context.h" - -const char *udm_timer_get_name(udm_timer_e id) -{ - switch (id) { - case UDM_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "UDM_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case UDM_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "UDM_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case UDM_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "UDM_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case UDM_TIMER_NF_INSTANCE_VALIDITY: - return "UDM_TIMER_NF_INSTANCE_VALIDITY"; - case UDM_TIMER_SUBSCRIPTION_VALIDITY: - return "UDM_TIMER_SUBSCRIPTION_VALIDITY"; - case UDM_TIMER_SBI_CLIENT_WAIT: - return "UDM_TIMER_SBI_CLIENT_WAIT"; - default: - break; - } - - return "UNKNOWN_TIMER"; -} - -static void sbi_timer_send_event(int timer_id, void *data) -{ - int rv; - udm_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case UDM_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case UDM_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case UDM_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case UDM_TIMER_NF_INSTANCE_VALIDITY: - case UDM_TIMER_SUBSCRIPTION_VALIDITY: - e = udm_event_new(UDM_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - case UDM_TIMER_SBI_CLIENT_WAIT: - e = udm_event_new(UDM_EVT_SBI_TIMER); - if (!e) { - ogs_sbi_xact_t *sbi_xact = data; - ogs_assert(sbi_xact); - - ogs_error("sbi_timer_send_event() failed"); - ogs_sbi_xact_remove(sbi_xact); - return; - } - 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_error("ogs_queue_push() failed %d in %s", - (int)rv, udm_timer_get_name(e->timer_id)); - udm_event_free(e); - } -} - -void udm_timer_nf_instance_registration_interval(void *data) -{ - sbi_timer_send_event(UDM_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void udm_timer_nf_instance_heartbeat_interval(void *data) -{ - sbi_timer_send_event(UDM_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void udm_timer_nf_instance_no_heartbeat(void *data) -{ - sbi_timer_send_event(UDM_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void udm_timer_nf_instance_validity(void *data) -{ - sbi_timer_send_event(UDM_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void udm_timer_subscription_validity(void *data) -{ - sbi_timer_send_event(UDM_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void udm_timer_sbi_client_wait_expire(void *data) -{ - sbi_timer_send_event(UDM_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.tar.xz/src/udm/timer.h
Deleted
@@ -1,57 +0,0 @@ -/* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef UDM_TIMER_H -#define UDM_TIMER_H - -#include "ogs-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* forward declaration */ -typedef enum { - UDM_TIMER_BASE = 0, - - UDM_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - UDM_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - UDM_TIMER_NF_INSTANCE_NO_HEARTBEAT, - UDM_TIMER_NF_INSTANCE_VALIDITY, - UDM_TIMER_SUBSCRIPTION_VALIDITY, - UDM_TIMER_SBI_CLIENT_WAIT, - - MAX_NUM_OF_UDM_TIMER, - -} udm_timer_e; - -const char *udm_timer_get_name(udm_timer_e id); - -void udm_timer_nf_instance_registration_interval(void *data); -void udm_timer_nf_instance_heartbeat_interval(void *data); -void udm_timer_nf_instance_no_heartbeat(void *data); -void udm_timer_nf_instance_validity(void *data); -void udm_timer_subscription_validity(void *data); -void udm_timer_sbi_client_wait_expire(void *data); - -#ifdef __cplusplus -} -#endif - -#endif /* UDM_TIMER_H */
View file
open5gs_2.4.9.tar.xz/src/udr/nf-sm.c
Deleted
@@ -1,441 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void udr_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - udr_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - udr_nf_state_initial, udr_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void udr_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - udr_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 udr_nf_state_initial(ogs_fsm_t *s, udr_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - udr_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - udr_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - udr_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - udr_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - udr_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &udr_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &udr_nf_state_registered); - } -} - -void udr_nf_state_final(ogs_fsm_t *s, udr_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - udr_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void udr_nf_state_will_register(ogs_fsm_t *s, udr_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); - - udr_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, udr_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case UDR_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - udr_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &udr_nf_state_registered); - } else { - ogs_error("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &udr_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case UDR_EVT_SBI_TIMER: - switch(e->timer_id) { - case UDR_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", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, udr_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - udr_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("Unknown event %s", udr_event_get_name(e)); - break; - } -} - -void udr_nf_state_registered(ogs_fsm_t *s, udr_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); - - udr_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - 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)); - } - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->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, udr_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case UDR_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.component0) - 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", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &udr_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case UDR_EVT_SBI_TIMER: - switch(e->timer_id) { - case UDR_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_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case UDR_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &udr_nf_state_will_register); - break; - - case UDR_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &udr_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udr_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udr_event_get_name(e)); - break; - } -} - -void udr_nf_state_de_registered(ogs_fsm_t *s, udr_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - udr_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udr_event_get_name(e)); - break; - } -} - -void udr_nf_state_exception(ogs_fsm_t *s, udr_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); - - udr_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - 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_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case UDR_EVT_SBI_TIMER: - switch(e->timer_id) { - case UDR_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", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &udr_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udr_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case UDR_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udr_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.tar.xz/src/udr/nnrf-build.c
Deleted
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *udr_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -}
View file
open5gs_2.4.9.tar.xz/src/udr/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef UDR_NNRF_BUILD_H -#define UDR_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *udr_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* UDR_NNRF_BUILD_H */
View file
open5gs_2.4.9.tar.xz/src/udr/nnrf-handler.c
Deleted
@@ -1,250 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void udr_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void udr_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->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_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - 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, - udr_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 udr_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - udr_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - nf_instance->reference_count++; - - OGS_FSM_TRAN(&nf_instance->sm, udr_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - UDR_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - UDR_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - UDR_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - 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_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -}
View file
open5gs_2.4.9.tar.xz/src/udr/nnrf-handler.h
Deleted
@@ -1,41 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef UDR_NNRF_HANDLER_H -#define UDR_NNRF_HANDLER_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void udr_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void udr_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool udr_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - -#ifdef __cplusplus -} -#endif - -#endif /* UDR_NNRF_HANDLER_H */
View file
open5gs_2.4.9.tar.xz/src/udr/timer.c
Deleted
@@ -1,101 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "context.h" - -const char *udr_timer_get_name(udr_timer_e id) -{ - switch (id) { - case UDR_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "UDR_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case UDR_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "UDR_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case UDR_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "UDR_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case UDR_TIMER_NF_INSTANCE_VALIDITY: - return "UDR_TIMER_NF_INSTANCE_VALIDITY"; - case UDR_TIMER_SUBSCRIPTION_VALIDITY: - return "UDR_TIMER_SUBSCRIPTION_VALIDITY"; - default: - break; - } - - return "UNKNOWN_TIMER"; -} - -static void sbi_timer_send_event(int timer_id, void *data) -{ - int rv; - udr_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case UDR_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case UDR_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case UDR_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case UDR_TIMER_NF_INSTANCE_VALIDITY: - case UDR_TIMER_SUBSCRIPTION_VALIDITY: - e = udr_event_new(UDR_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_error("ogs_queue_push() failed %d in %s", - (int)rv, udr_timer_get_name(e->timer_id)); - udr_event_free(e); - } -} - -void udr_timer_nf_instance_registration_interval(void *data) -{ - sbi_timer_send_event(UDR_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void udr_timer_nf_instance_heartbeat_interval(void *data) -{ - sbi_timer_send_event(UDR_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void udr_timer_nf_instance_no_heartbeat(void *data) -{ - sbi_timer_send_event(UDR_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void udr_timer_nf_instance_validity(void *data) -{ - sbi_timer_send_event(UDR_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void udr_timer_subscription_validity(void *data) -{ - sbi_timer_send_event(UDR_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void udr_timer_sbi_client_wait_expire(void *data) -{ - sbi_timer_send_event(UDR_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.tar.xz/src/udr/timer.h
Deleted
@@ -1,57 +0,0 @@ -/* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef UDR_TIMER_H -#define UDR_TIMER_H - -#include "ogs-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* forward declaration */ -typedef enum { - UDR_TIMER_BASE = 0, - - UDR_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - UDR_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - UDR_TIMER_NF_INSTANCE_NO_HEARTBEAT, - UDR_TIMER_NF_INSTANCE_VALIDITY, - UDR_TIMER_SUBSCRIPTION_VALIDITY, - UDR_TIMER_SBI_CLIENT_WAIT, - - MAX_NUM_OF_UDR_TIMER, - -} udr_timer_e; - -const char *udr_timer_get_name(udr_timer_e id); - -void udr_timer_nf_instance_registration_interval(void *data); -void udr_timer_nf_instance_heartbeat_interval(void *data); -void udr_timer_nf_instance_no_heartbeat(void *data); -void udr_timer_nf_instance_validity(void *data); -void udr_timer_subscription_validity(void *data); -void udr_timer_sbi_client_wait_expire(void *data); - -#ifdef __cplusplus -} -#endif - -#endif /* UDR_TIMER_H */
View file
open5gs_2.4.9.tar.xz/tests/af/nf-sm.c
Deleted
@@ -1,448 +0,0 @@ -/* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void af_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - af_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - af_nf_state_initial, af_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void af_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - af_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 af_nf_state_initial(ogs_fsm_t *s, af_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - af_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - af_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - af_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - af_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - af_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &af_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &af_nf_state_registered); - } -} - -void af_nf_state_final(ogs_fsm_t *s, af_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - af_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void af_nf_state_will_register(ogs_fsm_t *s, af_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); - - af_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == af_nnrf_nfm_send_nf_register(nf_instance)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case AF_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - af_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &af_nf_state_registered); - } else { - ogs_error("%s HTTP Response Status Code %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &af_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case AF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AF_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", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == af_nnrf_nfm_send_nf_register(nf_instance)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - af_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s Unknown event %s", - ogs_sbi_self()->nf_instance->id, af_event_get_name(e)); - break; - } -} - -void af_nf_state_registered(ogs_fsm_t *s, af_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); - - af_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - 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_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_BSF)); - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->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, af_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case AF_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.component0) - 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", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &af_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case AF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AF_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_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case AF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &af_nf_state_will_register); - break; - - case AF_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &af_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - af_timer_get_name(e->timer_id), e->timer_id); - break; - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - af_event_get_name(e)); - break; - } -} - -void af_nf_state_de_registered(ogs_fsm_t *s, af_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - af_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - af_event_get_name(e)); - break; - } -} - -void af_nf_state_exception(ogs_fsm_t *s, af_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); - - af_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - 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_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case AF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AF_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", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &af_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - af_timer_get_name(e->timer_id), e->timer_id); - break; - } - break; - - case AF_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.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - af_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.tar.xz/tests/af/nnrf-build.c
Deleted
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *af_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -}
View file
open5gs_2.4.9.tar.xz/tests/af/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef AF_NNRF_BUILD_H -#define AF_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *af_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* AF_NNRF_BUILD_H */
View file
open5gs_2.4.9.tar.xz/tests/af/timer.c
Deleted
@@ -1,116 +0,0 @@ -/* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "context.h" - -const char *af_timer_get_name(af_timer_e id) -{ - switch (id) { - case AF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "AF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case AF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "AF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case AF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "AF_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case AF_TIMER_NF_INSTANCE_VALIDITY: - return "AF_TIMER_NF_INSTANCE_VALIDITY"; - case AF_TIMER_SUBSCRIPTION_VALIDITY: - return "AF_TIMER_SUBSCRIPTION_VALIDITY"; - case AF_TIMER_SBI_CLIENT_WAIT: - return "AF_TIMER_SBI_CLIENT_WAIT"; - default: - break; - } - - return "UNKNOWN_TIMER"; -} - -static void timer_send_event(int timer_id, void *data) -{ - int rv; - af_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case AF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case AF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case AF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case AF_TIMER_NF_INSTANCE_VALIDITY: - case AF_TIMER_SUBSCRIPTION_VALIDITY: - e = af_event_new(AF_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - case AF_TIMER_SBI_CLIENT_WAIT: - e = af_event_new(AF_EVT_SBI_TIMER); - if (!e) { - ogs_sbi_xact_t *sbi_xact = data; - ogs_assert(sbi_xact); - - ogs_error("timer_send_event() failed"); - ogs_sbi_xact_remove(sbi_xact); - return; - } - 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_error("ogs_queue_push() failed %d in %s", - (int)rv, af_timer_get_name(e->timer_id)); - af_event_free(e); - } -} - -void af_timer_nf_instance_registration_interval(void *data) -{ - timer_send_event(AF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void af_timer_nf_instance_heartbeat_interval(void *data) -{ - timer_send_event(AF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void af_timer_nf_instance_no_heartbeat(void *data) -{ - timer_send_event(AF_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void af_timer_nf_instance_validity(void *data) -{ - timer_send_event(AF_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void af_timer_subscription_validity(void *data) -{ - timer_send_event(AF_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void af_timer_sbi_client_wait_expire(void *data) -{ - timer_send_event(AF_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.tar.xz/tests/af/timer.h
Deleted
@@ -1,57 +0,0 @@ -/* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#ifndef AF_TIMER_H -#define AF_TIMER_H - -#include "ogs-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* forward declaration */ -typedef enum { - AF_TIMER_BASE = 0, - - AF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - AF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - AF_TIMER_NF_INSTANCE_NO_HEARTBEAT, - AF_TIMER_NF_INSTANCE_VALIDITY, - AF_TIMER_SUBSCRIPTION_VALIDITY, - AF_TIMER_SBI_CLIENT_WAIT, - - MAX_NUM_OF_AF_TIMER, - -} af_timer_e; - -const char *af_timer_get_name(af_timer_e id); - -void af_timer_nf_instance_registration_interval(void *data); -void af_timer_nf_instance_heartbeat_interval(void *data); -void af_timer_nf_instance_no_heartbeat(void *data); -void af_timer_nf_instance_validity(void *data); -void af_timer_subscription_validity(void *data); -void af_timer_sbi_client_wait_expire(void *data); - -#ifdef __cplusplus -} -#endif - -#endif /* AF_TIMER_H */
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.