Compare commits

...

152 Commits
v2.7.0 ... main

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Example config, to have no timestamps on stderr:
```
logger:
  default:
    timestamp: false
  file:
    path: /var/log/open5gs/smf.log
    timestamp: true
```
2024-04-18 21:08:35 +09:00
Sukchan Lee f960047ccb [SMF/UPF] Follow-up on Pull #3137 (Issues #2975) 2024-04-14 09:19:07 +09:00
Sukchan Lee a6830b30a0 [SMF/UPF] Changes subnet configuration (#2975)
The way subnet is set up has changed as shown below.

```
<OLD Format>
smf:
  session:
    - subnet: 10.45.0.1/16

<NEW Format>
smf:
  session:
    - subnet: 10.45.0.0/16
      gateway: 10.45.0.1
```

For more information, please refer to Pull Request #2975.
2024-04-13 19:31:19 +09:00
Sukchan Lee 2b6369e9d9 [SMF] crash when malformed NAS message (#3132)
A malformed PDU Session Modification Request is sent from UE
after Registration Complete.

```
Crash 1:
04/12 15:00:44.031: [amf] INFO: [imsi-999700000000001:1:11][0:0:NULL] /nsmf-pdusession/v1/sm-contexts/{smContextRef}/modify (../src/amf/nsmf-handler.c:837)
04/12 15:00:46.569: [nas] FATAL: ogs_nas_parse_qos_flow_descriptions: Assertion `descriptions->length' failed. (../lib/nas/5gs/types.c:486)
04/12 15:00:46.569: [core] FATAL: backtrace() returned 11 addresses (../lib/core/ogs-abort.c:37)
../src/smf/../../lib/nas/5gs/libogsnas-5gs.so.2(ogs_nas_parse_qos_flow_descriptions+0x162) [0x7e6e7a5a4e5d]
../src/smf/open5gs-smfd(+0x8c6ec) [0x5dd6c333d6ec]
../src/smf/open5gs-smfd(+0x2d69b) [0x5dd6c32de69b]
../src/smf/../../lib/core/libogscore.so.2(ogs_fsm_dispatch+0x119) [0x7e6e7b216c0c]
../src/smf/open5gs-smfd(+0x288b3) [0x5dd6c32d98b3]
../src/smf/../../lib/core/libogscore.so.2(ogs_fsm_dispatch+0x119) [0x7e6e7b216c0c]
../src/smf/open5gs-smfd(+0xf2d8) [0x5dd6c32c02d8]
../src/smf/../../lib/core/libogscore.so.2(+0x1197a) [0x7e6e7b20797a]
/lib/x86_64-linux-gnu/libc.so.6(+0x94ac3) [0x7e6e7a094ac3]
/lib/x86_64-linux-gnu/libc.so.6(+0x126850) [0x7e6e7a126850]
04/12 15:00:46.613: [app] ERROR: Signal-NUM[17] received (Child status change) (../src/main.c:81)
04/12 15:00:46.613: [sbi] WARNING: [92] HTTP/2 stream 19 was not closed cleanly before end of the underlying stream (../lib/sbi/client.c:626)
04/12 15:00:46.613: [scp] WARNING: response_handler() failed [-1] (../src/scp/sbi-path.c:539)
04/12 15:00:46.613: [amf] ERROR: [1:0] No SmContextUpdateError [500] (../src/amf/nsmf-handler.c:866)
04/12 15:00:46.613: [amf] ERROR: AMF_SESS_CLEAR (../src/amf/amf-sm.c:484)
04/12 15:00:46.613: [amf] INFO: [Removed] Number of AMF-Sessions is now 0 (../src/amf/context.c:2551)
04/12 15:00:50.596: [nrf] WARNING: [c466ec64-f8fe-41ee-a888-194dc4363612] No heartbeat (../src/nrf/nrf-sm.c:260)
04/12 15:00:50.596: [nrf] INFO: [c466ec64-f8fe-41ee-a888-194dc4363612] NF de-registered (../src/nrf/nf-sm.c:205)
04/12 15:00:50.596: [sbi] INFO: [c466ec64-f8fe-41ee-a888-194dc4363612:1] NF removed (../lib/sbi/nnrf-handler.c:750)
04/12 15:00:50.596: [sbi] INFO: [c466ec64-f8fe-41ee-a888-194dc4363612:1] NF removed (../lib/sbi/nnrf-handler.c:750)
04/12 15:00:55.094: [pfcp] WARNING: [10] LOCAL  No Reponse. Give up! for step 1 type 1 peer [127.0.0.4]:8805 (../lib/pfcp/xact.c:599)
04/12 15:00:55.094: [upf] WARNING: No Heartbeat from SMF [127.0.0.4]:8805 (../src/upf/pfcp-sm.c:329)
04/12 15:00:55.094: [upf] INFO: PFCP de-associated [127.0.0.4]:8805 (../src/upf/pfcp-sm.c:199)
04/12 15:01:02.599: [pfcp] WARNING: [11] LOCAL  No Reponse. Give up! for step 1 type 5 peer [127.0.0.4]:8805 (../lib/pfcp/xact.c:599)
04/12 15:01:06.098: [upf] WARNING: Retry to association with peer [127.0.0.4]:8805 failed (../src/upf/pfcp-sm.c:107)

Crash 2:
04/12 15:16:39.748: [amf] INFO: [imsi-999700000000001:1:11][0:0:NULL] /nsmf-pdusession/v1/sm-contexts/{smContextRef}/modify (../src/amf/nsmf-handler.c:837)
04/12 15:16:42.155: [nas] FATAL: ogs_nas_parse_qos_rules: Assertion `size+sizeof(rule->flow.flags) <= length' failed. (../lib/nas/5gs/types.c:961)
04/12 15:16:42.155: [core] FATAL: backtrace() returned 11 addresses (../lib/core/ogs-abort.c:37)
../src/smf/../../lib/nas/5gs/libogsnas-5gs.so.2(ogs_nas_parse_qos_rules+0x12d1) [0x7d1affbd2d72]
../src/smf/open5gs-smfd(+0x8b446) [0x629a57861446]
../src/smf/open5gs-smfd(+0x2d69b) [0x629a5780369b]
../src/smf/../../lib/core/libogscore.so.2(ogs_fsm_dispatch+0x119) [0x7d1affd05c0c]
../src/smf/open5gs-smfd(+0x288b3) [0x629a577fe8b3]
../src/smf/../../lib/core/libogscore.so.2(ogs_fsm_dispatch+0x119) [0x7d1affd05c0c]
../src/smf/open5gs-smfd(+0xf2d8) [0x629a577e52d8]
../src/smf/../../lib/core/libogscore.so.2(+0x1197a) [0x7d1affcf697a]
/lib/x86_64-linux-gnu/libc.so.6(+0x94ac3) [0x7d1afea94ac3]
/lib/x86_64-linux-gnu/libc.so.6(+0x126850) [0x7d1afeb26850]
04/12 15:16:42.199: [sbi] WARNING: [92] HTTP/2 stream 13 was not closed cleanly before end of the underlying stream (../lib/sbi/client.c:626)
04/12 15:16:42.199: [scp] WARNING: response_handler() failed [-1] (../src/scp/sbi-path.c:539)
04/12 15:16:42.199: [app] ERROR: Signal-NUM[17] received (Child status change) (../src/main.c:81)
04/12 15:16:42.200: [amf] ERROR: [1:0] No SmContextUpdateError [500] (../src/amf/nsmf-handler.c:866)
04/12 15:16:42.200: [amf] ERROR: AMF_SESS_CLEAR (../src/amf/amf-sm.c:484)
04/12 15:16:42.200: [amf] INFO: [Removed] Number of AMF-Sessions is now 0 (../src/amf/context.c:2551)
04/12 15:16:49.858: [nrf] WARNING: [23f1aee2-f901-41ee-a488-85a58e1e3420] No heartbeat (../src/nrf/nrf-sm.c:260)
04/12 15:16:49.858: [nrf] INFO: [23f1aee2-f901-41ee-a488-85a58e1e3420] NF de-registered (../src/nrf/nf-sm.c:205)
04/12 15:16:49.859: [sbi] INFO: [23f1aee2-f901-41ee-a488-85a58e1e3420:1] NF removed (../lib/sbi/nnrf-handler.c:750)
04/12 15:16:49.859: [sbi] INFO: [23f1aee2-f901-41ee-a488-85a58e1e3420:1] NF removed (../lib/sbi/nnrf-handler.c:750)
04/12 15:16:59.364: [pfcp] WARNING: [5] LOCAL  No Reponse. Give up! for step 1 type 1 peer [127.0.0.4]:8805 (../lib/pfcp/xact.c:599)
04/12 15:16:59.364: [upf] WARNING: No Heartbeat from SMF [127.0.0.4]:8805 (../src/upf/pfcp-sm.c:329)
04/12 15:16:59.364: [upf] INFO: PFCP de-associated [127.0.0.4]:8805 (../src/upf/pfcp-sm.c:199)
```

So, I've fixed it.
2024-04-13 15:03:09 +09:00
Sukchan Lee 3cfa8ba301 [AMF/MME] NAS message in an invaild state (#3131)
In InitialUEMessage, send a NAS message with a message type
other than Registration Request, Deregistration Request, or Service Request,
the following messages from UE will not be accepted.

We found this issue in not only the initial state but multiple states.
We believe if an attacker has the ability to inject a NAS message to the core,
it can perform a DoS attack on the victim UE.

So, I've fixed that The MME/AMF deletes MME_UE_S1AP_ID/AMF_UE_NGAP_ID,
and will not accept any following messages from the UE.
2024-04-13 13:25:09 +09:00
Sukchan Lee cd76dc641d [SEC] Crash and Protocol Violations
The AMF will crash on the following locations when it receives a sequence
of NAS messages from a UE.

- ogs_nas_encrypt: Assertion `pkbuf->len' failed. (../lib/nas/common/security.c:86)
- gmm_state_authentication: Assertion `r != OGS_ERROR' failed. (../src/amf/gmm-sm.c:1561)

Besides the crashes found above, an incorrect protocol transition
is identified in Open5GS. Without any Registration/Attach Request message,
when the Identity Response message sent, the Core Network responds
with an Authentication Request message. According to the standard,
only the Registration/Attach Request message can start a state transition
from the 5GMM/EMM-DEREGISTERED state to the 5GMM/EMM-COMMON-PROCEDURE-INITIATED.

So I've modified the relevant code to address these issues.
2024-04-09 16:23:49 +09:00
Sukchan Lee 09410eba08 Revert "udpate it"
This reverts commit 6814de5c57.
2024-04-09 11:20:16 +09:00
Sukchan Lee 6814de5c57 udpate it 2024-04-09 11:18:57 +09:00
Pau Espin 34b930b4e5 RFC: [HSS] Initial global metrics 2024-04-09 08:35:46 +09:00
Sukchan Lee 3b820b1dbe Revert "RFC: [HSS] Initial global metrics"
This reverts commit 253b09f589.
2024-04-09 08:35:15 +09:00
Sukchan Lee 01ef8ea6f2 Revert "[HSS] Initial Diameter S6a and Cx metrics"
This reverts commit d3a779e715.
2024-04-09 08:35:09 +09:00
Pau Espin d3a779e715 [HSS] Initial Diameter S6a and Cx metrics 2024-04-09 07:14:49 +09:00
Pau Espin 253b09f589 RFC: [HSS] Initial global metrics 2024-04-09 07:14:49 +09:00
Pau Espin cfd4f28f8a cosmetic: Fix trailing whitespace 2024-04-09 07:13:51 +09:00
Pau Espin b30604b289 [SMF] Initial implementation of Final-Unit-Indication
Only "Terminate" action is implemented so far, and it will be used
regardless of the action provided by the OCS.
2024-04-09 07:13:33 +09:00
Sukchan Lee bbdfca29bf [SGWC] Fixed crashing when Create Bearer Response occurs after Delete Bearer Response (#3109)
If a Create Bearer Response occurs after a Delete Bearer Response,
SGW-C crashes.

The execution is stopped by the following ASSERT
because it tries to access the UL Tunnel
deleted by the Delete Bearer Response.

```
03/28 17:28:41.229: [gtp] DEBUG: [7] LOCAL Find GTPv2 peer [172.22.0.9]:2123 (../lib/gtp/xact.c:949)
03/28 17:28:41.229: [gtp] DEBUG: [7] LOCAL Receive peer [172.22.0.9]:2123 (../lib/gtp/xact.c:966)
03/28 17:28:41.229: [gtp] DEBUG: [7] LOCAL UPD RX-96 peer [172.22.0.9]:2123 (../lib/gtp/xact.c:448)
03/28 17:28:41.229: [sgwc] DEBUG: Create Bearer Response (../src/sgwc/s11-handler.c:707)
03/28 17:28:41.229: [gtp] DEBUG: [7] LOCAL Commit peer [172.22.0.9]:2123 (../lib/gtp/xact.c:629)
03/28 17:28:41.230: [gtp] DEBUG: [7] LOCAL Delete peer [172.22.0.9]:2123 (../lib/gtp/xact.c:1149)
03/28 17:28:41.230: [sgwc] FATAL: sgwc_s11_handle_create_bearer_response: Assertion `ul_tunnel' failed. (../src/sgwc/s11-handler.c:802)
03/28 17:28:41.231: [core] FATAL: backtrace() returned 8 addresses (../lib/core/ogs-abort.c:37)
./open5gs-sgwcd(+0x189b7) [0x5b3c92cf09b7]
./open5gs-sgwcd(+0x13c6d) [0x5b3c92cebc6d]
/open5gs/install/lib/x86_64-linux-gnu/libogscore.so.2(ogs_fsm_dispatch+0x113) [0x70600ed63402]
./open5gs-sgwcd(+0x629d) [0x5b3c92cde29d]
/open5gs/install/lib/x86_64-linux-gnu/libogscore.so.2(+0x11754) [0x70600ed54754]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x8609) [0x70600ecfc609]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x43) [0x70600ec21353]
```

To solve this problem, I have modified to handle the exception appropriately,
display the error situation in the Cause of the Create Bearer Response,
and proceed with the execution.
2024-04-07 22:51:46 +09:00
Pau Espin e078b33f0c [SMF] Fix Volume/Time Threshold conversion Gy->PFCP
AS shown in 3GPP TS 29.244 C.2.1.1 diagram, the meaning of Threshold
value is different in Diameter Gy and in PFCP interfaces.
In Diameter Gy the value sets the trigger for the "remaining credit",
while in PFCP the value sets the trigger for the "used credit".

ThresholdPFCP = Quota - ThresholdGy
2024-04-07 08:51:24 +09:00
Sukchan Lee 8484a5af60 [GTP] Incorrect destination TEID=0 (#3043)
If eg. PCRF or AAA diameter link is not yet ready (eg. PCRF crashed),
and a client sends a CreateSessionRequest announcing its ow F-TEID,
then open5gs-smfd answers with Create Session Response Cause=
"Remote peer not responding", but it is not setting the received F-TEID
in the header of the response, instead it sends with TEI=0.

As a result, the peer cannot match the CreateSessionResponse,
and needs to rely on its own timeout timer to figure out
that specific request failed.

To address this issue, I modified the GTP Response message to check
the Sender F-TEID and send it accordingly, setting the destination TEID
to the value of the Sender F-TEID.

I've made this modification only for SMF, but MME and SGW-C have not done so;
if you need to, you can work from the examples in SMF.

Similarly, the same situation can happen with PFCP. If anyone needs to do this
in the future, I think you can work on it this way.
2024-04-06 16:39:32 +09:00
Pau Espin 990bfe96a8 [SMF] Gy: Check Multiple-Services-Credit-Control Result-Code in CCA-I
This is the continuation of commit
12158eebb8, which only checked the code in
CCA[Update], but not in CCA[Initial].

The handling in CCA[Initial] is a bit more complex since depending on
the outcome, we may end up with a Result-Code != SUCCESS in MSCC but the
session may still be created at the OCS because the message Result-Code
= SUCCESS. In that scenario, we want to abort setting up the PDN session
but we still need to make sure we terminate the Gy session that was just
created.
2024-04-05 21:35:36 +09:00
gstaa eb2b19b39c
Include cause in HTTP response ProblemDetails (#3051)
Cause is set according to particular NF standard.

Additionally:
- OGS_SBI_HTTP_STATUS_MEHTOD_NOT_ALLOWED typo fixed.
- [PCF] Fixed SM Policy establishment error handling
2024-04-04 23:29:20 +09:00
Pau Espin 3ee4bb7d3c pfcp: Fix missing fields in ogs_pfcp_build_update_urr()
Flag bitmask check elements are reordered to follow same order as
IEs in 3GPP TS 29.244 7.5.4.4 "Update URR".
2024-04-04 23:23:32 +09:00
Pau Espin 74fcd9b9c6 cosmetic: upf: Add missing lines between functions 2024-04-04 23:23:32 +09:00
Sukchan Lee da5d424ed9 [MME] Incorrect behavior of SGsAP+Dedicated-Bearer (#3072)
First of all, it crashes when creating a Dedicated Bearer
on the default Session that is created for the first time.
This behavior should be possible, so the related ASSERT is removed.

Next, the InitialContextRequest is modified
during the Attach Request to include the first Bearer.

Finally, there was an issue where trying to create a Dedicated Bearer
with SGsAP enabled resulted in an InitialContextSetupRequest message
with a PTI of zero. This is because MME initializes the PTI to 0
upon receiving the Create Bearer Request while processing SGsAP.

All of these issues has been fixed.
2024-04-01 22:13:36 +09:00
Sukchan Lee d32cc14a71 [DBI] mongoc version not checked correctly #3086
checks mongoc version with

which can unexpectedly return false in case of mongoc versions such as 2.3.4.

So, I've fixed it as below.
2024-03-31 20:41:50 +09:00
Sukchan Lee e8a3b76af3 [SMF] Crash SMF when no GTP-C config (#3094)
When GTP-C secition of smf.yaml is deleted as follows to run smf as 5G,
it crashed.

```diff
--- smf.yaml.orig       2024-03-26 14:13:12.000000000 +0900
+++ smf.yaml    2024-03-26 14:29:40.701508424 +0900
@@ -23,9 +23,6 @@
     client:
       upf:
         - address: 127.0.0.7
-  gtpc:
-    server:
-      - address: 127.0.0.4
   gtpu:
     server:
       - address: 127.0.0.4
@@ -47,7 +44,7 @@
 #    - ::1
 #  ctf:
 #    enabled: auto   # auto(default)|yes|no
-  freeDiameter: /root/open5gs/install/etc/freeDiameter/smf.conf
+#  freeDiameter: /root/open5gs/install/etc/freeDiameter/smf.conf

 ################################################################################
 # SMF Info
Open5GS daemon v2.7.0-119-g581d255

03/26 14:39:42.844: [app] INFO: Configuration: 'install/etc/open5gs/smf.yaml' (../lib/app/ogs-init.c:130)
03/26 14:39:42.845: [app] INFO: File Logging: '/root/open5gs/install/var/log/open5gs/smf.log' (../lib/app/ogs-init.c:133)
03/26 14:39:42.913: [metrics] INFO: metrics_server() [http://127.0.0.4]:9090 (../lib/metrics/prometheus/context.c:299)
03/26 14:39:42.913: [smf] WARNING: No diameter configuration (../src/smf/fd-path.c:30)
03/26 14:39:42.913: [smf] FATAL: smf_gtp_open: Assertion `ogs_gtp_self()->gtpc_sock || ogs_gtp_self()->gtpc_sock6' failed. (../src/smf/gtp-path.c:253)
03/26 14:39:42.913: [core] FATAL: backtrace() returned 8 addresses (../lib/core/ogs-abort.c:37)
./install/bin/open5gs-smfd(+0x391ab) [0x55d28319b1ab]
./install/bin/open5gs-smfd(+0x10046) [0x55d283172046]
./install/bin/open5gs-smfd(+0xf3de) [0x55d2831713de]
./install/bin/open5gs-smfd(+0xfcf9) [0x55d283171cf9]
/lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f0a145f9d90]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f0a145f9e40]
./install/bin/open5gs-smfd(+0xf305) [0x55d283171305]
Aborted (core dumped)
```

So, Fixed to run SMF with GTP-C disabled for 5G.
2024-03-31 20:25:25 +09:00
Oliver Smith be7d08bffc logrotate: fix reload failures
Do not attempt to run "systemctl reload" on the open5gs services, unless
they are running. This fixes the logrotate service failing on this
postrotate script, if units are not running or not installed.
2024-03-27 20:37:36 +09:00
Sukchan Lee 581d255c53 Revert "[GTP/PFCP]] incorrect dst TEI=0/SEID=0 (#3043)"
This reverts commit a667525041.
2024-03-26 08:04:26 +09:00
Sukchan Lee 390a9dd637 [MME] incorrect behavior of the SGsAP
1. According to ETSI TS 129 118 4.1, if the Network Access Mode (NAM) is set
   to "Packet only," no SGs association should be established.

2. If the NAM is set to "Packet and Circuit," and the SGs association is
   rejected by the CS core, this rejection should only impact
   the SGs association itself and not result in a UE attach rejection
   for a UE with a valid HSS account.
2024-03-24 20:31:56 +09:00
Sukchan Lee 7c14073533 [UDM] Added validation for pubkey
a cryptographic vulnerability in the SUCI decryption routines
of Open5GS 5G—specifically Profile B, which uses P-256 (secp256r1)
for its elliptic curve routines.

If a mobile device user passes a public key within its SUCI
that does not correspond to a valid point on the P-256 elliptic curve,
the Open5GS UDM will not check the point
before running elliptic curve operations with it and returning a response
to the mobile device user.

If the public key is not checked to be a valid point, an attacker can leverage
this behavior to extract the Profile B private key from the UDM,
as has been done in other domains
(https://owasp.org/www-pdf-archive/Practical_Invalid_Curve_Attacks_on_TLS-ECDH_-_Juraj_Somorovsky.pdf).

Note that Profile A is not similarly vulnerable to this, as it is impossible
to construct an invalid point on a curve25519 elliptic curve.

There was some work that went into developing a practical proof of concept
of this kind of attack against free5gc last year; it can be found here:

https://www.gsma.com/security/wp-content/uploads/2023/10/0073-invalid_curve.pdf

And here is the free5gc security advisory:

https://github.com/advisories/GHSA-cqvv-r3g3-26rf

To mitigate this issue in Open5GS, the public key of the UE must be validated
by the UDM prior to use. Adding a validation function such as the following
should work:

I designed this code based on information from https://crypto.stackexchange.com/questions/90151/verify-that-a-point-belongs-to-secp256r1.
2024-03-24 14:09:10 +09:00
Sukchan Lee cf4ad1f248 [PFCP] Session removal while waiting PFCP reply (#3040)
'node_timeout' and some other functions can remove a smf_sess_t
while that session is still waiting for a PFCP reply
and has an active PFCP xact.

In this case, xact->data points to the deleted session
and xact's timeout function (sess_5gc_timeout for example)
eventually refers to this already freed session.

This fix prevents duplicate deletes from occurring by checking to see
if the session context has already been deleted when the timeout occurs.

Additionally, it moves session deletions out of timer callbacks into
state machine by reselect_upf().

Due to the way 'ogs_timer_mgr_expire' calls timer callbacks,
one must not stop or expire timers from within a timer callback.

And now one must not remove sessions from within a timer callback.
2024-03-24 09:50:23 +09:00
Sukchan Lee a667525041 [GTP/PFCP]] incorrect dst TEI=0/SEID=0 (#3043)
If eg. PCRF or AAA diameter link is not yet ready (eg. PCRF crashed), and
a client sends a CreateSessionRequest announcing its ow F-TEID,
then open5gs-smfd answers with Create Session Response Cause=
"Remote peer not responding", but it is not setting the received F-TEID
in the header of the response, instead it sends with TEI=0.

As a result, the peer cannot match the CreateSessionResponse, and needs
to rely on its own timeout timer to figure out that specific request failed.

This also happens in PFCP, so to solve this problem, I added teid/seid_presence
to the interface that sends the error message as shown below.

void ogs_gtp2_send_error_message(ogs_gtp_xact_t *xact,
        int teid_presence, uint32_t teid, uint8_t type, uint8_t cause_value);
void ogs_pfcp_send_error_message(
    ogs_pfcp_xact_t *xact, int seid_presence, uint64_t seid, uint8_t type,
    uint8_t cause_value, uint16_t offending_ie_value);
2024-03-23 10:06:16 +09:00
Sukchan Lee 1dc4300203 [AMF] ran_ue can be NULL in IMPLICIT Dereg (#2999)
When we try to send an SBI message to SMF to release a session,
sometimes ran_ue is NULL. This happens when the Mobile Reachable Timer expires
and Implicit Deregistration is triggered.

To account for this case, we added the `ran_ue` parameter to the SBI interface
and made it work even if it is NULL.
2024-03-22 06:51:09 +09:00
Pau Espin 3b5e851f5d [SMF] Gy: Remove 3GPP-RAT-Type AVP from Multiple-Services-Credit-Control AVP
This AVP is optional and was added in later releases of the 3GPP TS
32.299 spec. For instance, it shows up in Release 16 (V16.2.0), but
doesn't show up in Release 12 (V12.7.0).

Some OCS, like PortaOne OCS, implement older versions of the release
(V12.14.0), and hence fail when receiving the 3GPP-RAT-Type inside
Multiple-Services-Credit-Control AVP.
Since nowadays we also send the 3GPP-RAT-Type in PS-Information AVP,
which has been specified for longer time (it already shows up in
V12.7.0), drop it from Multiple-Services-Credit-Control to have greater
compatibility with other vendors.
2024-03-21 07:14:06 +09:00
Pau Espin d0b31177cc [SMF] Gy: Include 3GPP-RAT-Type AVP in PS-Information AVP
The AVP is optional, but used by some OCS vendors like PortaOne OCS make
use of it.
2024-03-21 07:14:06 +09:00
Pau Espin 6420e80fe6 [SMF] Gy: Split PS-Information AVP creation into its own function
Makes the already long function easier to follow, since there's one
level less of encapsulation inside it.
2024-03-21 07:14:06 +09:00
Pau Espin ca5a29dbe3 [SMF] Gy: Use correct QoS AVP descriptor from Gy instead of Gx one 2024-03-21 07:13:55 +09:00
Pau Espin 12158eebb8 [SMF] Gy: Check Multiple-Services-Credit-Control Result-Code 2024-03-21 07:13:44 +09:00
Matej Gradišar e1820e4e54
UE context transfer (#3052)
* [SBI] Handle and store AMF info

* [SBI] Add "target GUAMI" discovery option

* [SBI] Handle UeContextTransfer request and response messages

* [AMF] Handle NF discovery from AMF to AMF

* [AMF] Add UE Context Transfer Request/Response from AMF to AMF

* [SCP] Handle UeContextTransfer

* Follow-up on #3052

* [AMF] force authentication after 'Ue context transfer' for now

* [AMF] force authentication after 'Ue context transfer' for now

---------

Co-authored-by: Sukchan Lee <acetcom@gmail.com>
2024-03-21 07:07:25 +09:00
Pau Espin ea122da9fc [SMF] Allow Gy CCA event to contain NULL gtp_xact
This happens for instance when the session is terminated due to a
rejection coming from the OCS, hence no originating GTP xact producing
the tear down.
2024-03-20 07:03:18 +09:00
Pau Espin 32a275b9a8 [SMF] smf_gy_send_ccr: Allow NULL xact
The xact may well be NULL, eg. when tearin down the session
(send_ccr_termination_req_gx_gy_s6b()) because OCS rejected an update:
Hence there's no GTP xact originating the tear down, aka e->gtp-xact
passed to the function is NULL.

smf_gx_send_ccr() is already handling this case properly, contrary to smf_gf_send_ccr().
2024-03-20 07:03:18 +09:00
Pau Espin 10a0647f09 [SMF] Gy: Tear down session when CCR-Update is rejected by OCS 2024-03-20 07:03:18 +09:00
Bostjan Meglic f66c65b9cf [SBI] Fix handling "dnn" URL parameter
Split handling discovery and other URL parameters into 2 distinct sets,
to prevent bugs with overlaps.
2024-03-18 17:59:57 +09:00
Sukchan Lee 4ee3ea08c4 Add special sponsors mobi 2024-03-18 06:49:28 +09:00
Sukchan Lee 7063d853e7 [SBI] Preamble parsing issues in MIME (#3058)
When building the MIME Multipart Media Encapsulation format
within an SBI message in the NF of a third-party product,
Open5GS does not parse properly if it contains a Preamble CRLF.

For example,

```
    TCP/HTTP2
    Stream: Data, Stream ID: 1, Length 841
    MIME Multipart Media Encapsulation, Type: multipart/related, Boundary: "gc0pJq08jU534c"
--->Preamble: 0d0a
    First boundary: --gc0pJq08jU534c\r\n
    Encapsulated multipart part: (application/json)
    Boundary: \r\n--gc0pJq08jU534c\r\n
    Encapsulated multipart part: (application/vnd.3gpp.5gnas)
    Boundary: \r\n--gc0pJq08jU534c\r\n
    Encapsulated multipart part: (application/vnd.3gpp.ngap)
    Last Boundary: \r\n--gc0pJq08jU534c--\r\n
```
2024-03-17 10:36:29 +09:00
Sukchan Lee a1a0a8c0a6 [MME] Race condition between S1AP and S6A
Assume the UE has Attached, the session has been created,
and is in the IDLE state with the UEContextRelease process.

This could result in the following call flow.

1. TAU request without Integrity Protected
2. Authentication request/response
3. Security-mode command/complete

MME can be performed simultaneously by the HSS(S6A) and UE(S1AP).

Update-Location-Request
Service request
Service reject
Delete Session Request
Delete Session Response
Update-Location-Answer
UEContextReleaseCommand for Service reject
TAU reject
UEContextReleaseCommand for TAU reject
UEContextReleaseComplete
UEContextReleaseComplete

MME crashes when UE sends a service request(S1AP) during ULR/ULA(S6A) with HSS,
which has been fixed.
2024-03-16 23:08:07 +09:00
Pau Espin a1bd80515b [MME] Assign valid PTI to sess created by mobility from 2G
Transaction Identity doesn't map 1-to-1 with Procedure Transaction
Identity: The value ranges change, and PTI cannot use value 0 8which
means unused).
Hence, for now let's simply set the PTI to a valid default value instead
of asserting during mme_sess_add:
Assertion `pti != OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED'

Related: https://github.com/open5gs/open5gs/issues/3020
2024-03-09 06:03:43 +09:00
Pau Espin b31fc343d1 cosmetic: Document spec references for unassigned identity values 2024-03-08 21:51:36 +09:00
mitmitmitm a2b0284172 [SMF] Don't FSM_TRAN smf-sm into incorrect state 2024-03-08 21:14:07 +09:00
Pau Espin 054323ba8d [mme] cosmetic: Document spec references stating NSAPI=EBI 2024-03-08 06:46:31 +09:00
Sukchan Lee 322719f3e7 [SEC] Vulnerabilities have been resolved (#2945)
Reachable assertion in amf_ue_set_suci

Location: src/amf/context.c:1968

```
void amf_ue_set_suci(amf_ue_t *amf_ue,
        ogs_nas_5gs_mobile_identity_t *mobile_identity)
{
    amf_ue_t *old_amf_ue = NULL;
    amf_sess_t *old_sess = NULL;
    char *suci = NULL;

    ogs_assert(amf_ue);
    ogs_assert(mobile_identity);

    suci = ogs_nas_5gs_suci_from_mobile_identity(mobile_identity);
    ogs_assert(suci);
```

Exploitable by: Base Station
Severity: denial of service
2024-03-06 07:20:50 +09:00
Sukchan Lee 199f4c7add [AMF] Fixed crash in no context setup (#2999)
Remove ogs_assert((__sESS)->gsm_message.n1buf) from AMF_SESS_STORE_5GSM_MESSAGE
because N1 buffer can become NULL during PDU session release.
2024-03-04 21:03:07 +09:00
Sukchan Lee 152b4400f8 Fixed docs for changing WebUI port 3000 => 9999 2024-03-02 16:57:45 +09:00
Sukchan Lee 2ceca49161 [MME/AMF] Fixed crash following Handover Request (#3014)
1. HandoverRequired
2. HandoverRequest
3. HandoverFailure
4. UEContextReleaseCommand
5. HandoverPreparationFailure

If UEContextReleaseComplete is not received,
the Source-UE will have the Target-UE.

6. HandoverRequired

There may be cases where the Source UE has a Target UE
from a previous HandoverRequired process. In this case,
it is recommended to force the deletion of the Target UE information
when receiving a new HandoverRequired.

7. HandoverRequest
8. HandoverFailure
9. UEContextReleaseCommand
10. UEContextReleaseComplete
11. HandoverPreparationFailure

... Crashed ...
2024-02-29 23:02:38 +09:00
Matej Gradisar 24b9150c15 [SMF] Check config file for overlapping UE subnets for subnets with no DNN 2024-02-28 12:06:02 +00:00
Sukchan Lee 4d7f2fb661 [SMF] Memory leak in Handling APCO IE (#3010) 2024-02-28 20:51:20 +09:00
Pau Espin 32de75b1a5 [SMF] Setup Gy session when creating UE session over S2b interface
So far the Gy session creation triggered by S2b interface (ePDG) was not
implemented. Fix it.
2024-02-28 11:42:33 +00:00
Pau Espin 4aaac999f7 [SMF] Handle APCO IE in S2b GTPv2C CreateSessionRequest/Response
This IE is used by UEs registering through S2b interface (ePDG) to
obtain DNS and P-CSCF server address information.
2024-02-28 11:40:31 +00:00
Sukchan Lee 0dd2ad6557 [MME] Added log messages to find memory problem 2024-02-27 21:16:50 +09:00
Sukchan Lee 9a515e9b1d [GTP-U] Fixed a stack overflow bug (#3003) 2024-02-23 19:59:04 +00:00
Sukchan Lee 41d8934677 [SMF] Added Bi-Directional Flow (#2909)
For bi-directions, the rules are created in the same form as for downlink
as shown below, so to apply them for uplink, we need to swap the rules
according to the interface.

RX : permit out from <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> to <UE_IP> <UE_PORT>
GX : permit out from <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> to <UE_IP> <UE_PORT>
PFCP : permit out from <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> to <UE_IP> <UE_PORT>
RULE : Source <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> Destination <UE_IP> <UE_PORT>
TFT : Local <UE_IP> <UE_PORT> REMOTE <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT>

RX : permit in from <UE_IP> <UE_PORT> to <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT>
GX : permit out from <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> to <UE_IP> <UE_PORT>
PFCP : permit out from <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> to <UE_IP> <UE_PORT>
RULE : Source <UE_IP> <UE_PORT> Destination <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT>
TFT : Local <UE_IP> <UE_PORT> REMOTE <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT>
2024-02-17 20:43:15 +01:00
Sukchan Lee 843c4950ac [ASN1C] Fixed asn1c library on 32bit (#2934)
APER encoding fails when using the asn_uint642INTEGER function on a 32-bit machine as shown below.

```C
   asn_uint642INTEGER(AMF_UE_NGAP_ID, 0xffffffff);
   ...
   aper_encode_to_buffer(...)
```

INTEGER APER encode/decode functions seem to be operating internally with long variables instead of intmax_t.
That is probably the reason of the failure.

@v0-e fixed this issues in the mouse07410/asn1c pull request.
https://github.com/mouse07410/asn1c/pull/176
https://github.com/mouse07410/asn1c/pull/177
2024-02-12 14:00:06 +09:00
Sukchan Lee 94bd68aa7b [MME] Follow-up on #2916
When there is no MME-UE Context, going to cleanup without setting
s6a_message could cause a segmentation fault.

We fixed the problem by moving the location of setting s6a_message
to before cleanup.
2024-02-08 18:46:45 +09:00
Sukchan Lee 290df460ef Added UPF performance test with NextEPC 2024-02-05 06:29:36 +09:00
Sukchan Lee 82398811db [UPF] Report after Session was Deleted (#2936)
The UPF is sending Session Report Request after the Session was Deleted,
when the Gy interface is active.

UPF is sending PFCP session report request after the session has been deleted
when the Gy interface is active. This is because some of the timers related to
the report are not deleted when the session is deleted.

We have fixed it to delete all the timers in the session
when the SESSION is deleted.
2024-02-04 09:32:33 +09:00
Sukchan Lee 8762425fbc [AMF] Fixed sm_context_ref failed (#2603, #2917) 2024-02-03 16:59:47 +09:00
Sukchan Lee 7e8f145973 Rollback Pull Request (#1911)
Problems with Purge-UE-Request/Answer can occur in the following situations

1. Attach Request
2. Authentication request
3. Authentication reject
4. UEContextReleaseCommand
5. UEContextReleaseComplete
6. Purge-UE-Request
7. Attach Request
8. Purge-UE-Answer
9. (UE Context Remove)

To resolve this issue, we have changed to delete the UE-Context
via mme_ue_remove() immediately upon receiving UEContextReleaseComplete()
without calling mme_s6a_send_pur().
2024-02-03 16:18:26 +09:00
Sukchan Lee d1d3ec6fcb [SEC] Several vulnerabilities have been resolved.
1. Reachable assertion in ogs_nas_5gmm_decode

Location: lib/nas/5gs/decoder.c:4445

```c
int ogs_nas_5gmm_decode(ogs_nas_5gs_message_t *message, ogs_pkbuf_t *pkbuf)
{
    int size = 0;
    int decoded = 0;

    ogs_assert(pkbuf);
    ogs_assert(pkbuf->data);
    ogs_assert(pkbuf->len);
```

When a NAS payload is received over `src/amf/context.c:1675`NGAP that has no data, the ogs_assert(pkbuf->len) assertion will be triggered.

2.Reachable assertion in ogs_nas_emm_decode

```
int ogs_nas_emm_decode(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
{
    int size = 0;
    int decoded = 0;

    ogs_assert(pkbuf);
    ogs_assert(pkbuf->data);
    ogs_assert(pkbuf->len);
```

Nearly identical to (1), but for LTE.

3. Reachable assertion in nas_eps_send_emm_to_esm

```
int nas_eps_send_emm_to_esm(mme_ue_t *mme_ue,
        ogs_nas_esm_message_container_t *esm_message_container)
{
    int rv;
    ogs_pkbuf_t *esmbuf = NULL;

    if (!mme_ue_cycle(mme_ue)) {
        ogs_error("UE(mme-ue) context has already been removed");
        return OGS_NOTFOUND;
    }

    ogs_assert(esm_message_container);
    ogs_assert(esm_message_container->length);
```

The ESM message payload may be 0-length, as the length is determined by a field in the NAS payload (which can be chosen arbitrarily by an attacker). This leads to the length assertion above being triggered.

5. Reachable assertion and incorrect hash calculation in ogs_kdf_hash_mme

```
void ogs_kdf_hash_mme(const uint8_t *message, uint8_t message_len, uint8_t *hash_mme)
{
    uint8_t key[32];
    uint8_t output[OGS_SHA256_DIGEST_SIZE];

    ogs_assert(message);
    ogs_assert(message_len);
    ogs_assert(hash_mme);

    memset(key, 0, 32);
    ogs_hmac_sha256(key, 32, message, message_len,
            output, OGS_SHA256_DIGEST_SIZE);

    memcpy(hash_mme, output+24, OGS_HASH_MME_LEN);
}
```

When handling NAS attach requests or TAU requests, the ogs_kdf_hash_mme function is passed the NAS payload. However, the length field is represented as an unsigned 8-bit integer, which the passed length of the packet may overflow. This leads to the passed value being truncated.

When the passed value is a multiple of 256, the above assertion (ogs_assert(message_len)) is triggered. Otherwise, the hash is computed on only the first n bits of the message (where n = actual_message_len % 256).
2024-02-03 10:41:12 +09:00
Sukchan Lee be12610fb6 [AMF/MME] No STATE Change for the EMM/GMM-STATUS 2024-02-03 10:16:16 +09:00
Sukchan Lee 47419be650 [AMF/SMF] Resolved the Issue of Session Release Based on the Order of N1/N2 Messages (#2917)
There is an issue with SESSION RELEASE not working properly
depending on the PDU session release complete order
in the PDUSessionResourceReleaseResponse.

If the AMF receives PDUSessionResourceReleaseResponse
followed by PDU session release complete, it works correctly.

However, if it receives PDU session release complete
followed by PDUSessionResourceReleaseResponse, it does not work correctly
and sends an Error Indication to the UE/gNB.

To fix this issue, we added pdu_session_release_complete_received and
pdu_session_resource_release_response_received to the content
so that CLEAR_SM_CONTEXT_REF() is executed when both are received.
2024-02-03 09:42:09 +09:00
Sukchan Lee 3f0979dab2 [MME] Fixes crash in building s1ap message
Because a race condition can occur between S6A Diameter and S1AP message,
the following error handling code has been added.

1. InitialUEMessage + Attach Request + PDN Connectivity request
2. Authentication-Information-Request/Authentication-Information-Answer
3. Authentication Request/Response
4. Security-mode command/complete
5. Update-Location-Request/Update-Location-Answer
6. Detach request/accept

In the ULR/ULA process in step 6, the PDN Connectivity request is
pushed to the queue as an ESM_MESSAGE because the NAS-Type is still
an Attach Request.

See the code below in 'mme-s6a-handler.c' for where the queue is pushed.

  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) {
      r = nas_eps_send_tau_accept(mme_ue,
              S1AP_ProcedureCode_id_InitialContextSetup);
      ogs_expect(r == OGS_OK);
      ogs_assert(r != OGS_ERROR);
  } else {
      ogs_error("Invalid Type[%d]", mme_ue->nas_eps.type);
      return OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED;
  }

If you perform step 7 Detach request/accept here,
the NAS-Type becomes Detach Request and the EMM state changes
to emm_state_de_registered().

Since the PDN, which is an ESM message that was previously queued,
should not be processed in de_registered, the message is ignored
through error handling below.

Otherwise, MME will crash because there is no active bearer
in the initial_context_setup_request build process.

See the code below in 's1ap-build.c' for where the crash occurs.
  ogs_list_for_each(&mme_ue->sess_list, sess) {
      ogs_list_for_each(&sess->bearer_list, bearer) {
          ...
          if (mme_ue->nas_eps.type == MME_EPS_TYPE_ATTACH_REQUEST) {
          } else if (OGS_FSM_CHECK(&bearer->sm, esm_state_inactive)) {
              ogs_warn("No active EPS bearer [%d]", bearer->ebi);
              ogs_warn("    IMSI[%s] NAS-EPS Type[%d] "
                      "ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]",
                      mme_ue->imsi_bcd, mme_ue->nas_eps.type,
                      enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id);
              continue;
          }
          ...
      }
  }
2024-02-02 21:17:41 +09:00
Sukchan Lee 93110d011e [GTP-U] Fixed ogs_pfcp_find_gtpu_resource()(#2923)
As mentioned in the sgwu.yaml configuration file, it is possible to configure multiple addresses with different source_interface values for the gtpu interface.

Following the this section, I defined two addresses, one with source_interface set to 0 and another with source_interface set to 1. My expectation was to see different addresses for the two PDRs in the Session Establishment Response message during session establishment. However, both addresses were the same, and it was the address I had set for source_interface = 0.

When I looked into the code, I found the reason for the issue. In the lib/pfcp/context.c file, on line 1185, the function that determines the address is called as follows:

...
        } else {
            ogs_gtpu_resource_t *resource = NULL;
            resource = ogs_pfcp_find_gtpu_resource(
                    &ogs_gtp_self()->gtpu_resource_list,
                    pdr->dnn, OGS_PFCP_INTERFACE_ACCESS);
            if (resource) {
...
In the last parameter of this function, a constant value, OGS_PFCP_INTERFACE_ACCESS, is used. This causes every PDR with any source_interface to be considered as "access," and the value 0 is used for its interface.

I replaced the value with pdr->src_if, and the bug was resolved.
2024-01-30 22:39:34 +09:00
Pau Espin 88a77f7bc5 [SMF,MME] Gn: Set Maximum SDU Size QoS field to 1500
Before this patch, it was set as 0, which is Reserved in Network to MS
direction.
2024-01-27 07:11:44 +09:00
Pau Espin a613be8c4c [SMF,MME] Gn: Set Delivery of erroneous SDUs QoS field to No
Before this patch, it was set as 0, which is Reserved in Network to MS
direction.
2024-01-27 07:11:44 +09:00
Pau Espin d95c82b21c [SMF,MME] Gn: Set Delivery order QoS field to No
Before this patch, it was set as 0, which is Reserved in Network to MS
direction.
2024-01-27 07:11:44 +09:00
Pau Espin a5feccf4c8 [SMF] Fix fixed-0 IPCP identifier in PCO ack 2024-01-27 07:10:55 +09:00
Sukchan Lee 3886891833 [MME] Crash due to a race condition
A race condition can occur in the following situations.
In conclusion, we can use this situation to determine
whether or not the UE Context has been removed and avoiding a crash.

For example, suppose a UE Context is removed in the followings.

1. Attach Request
2. Authentication-Information-Request
3. Authentication-Information-Answer
4. Authentication Request
5. Authentication Response(MAC Failed)
6. Authentication Reject
7. UEContextReleaseCommand
8. UEContextReleaseComplete

The MME then sends a Purge-UE-request to the HSS and deletes
the UE context as soon as it receives a Purge-UE-Answer.

Suppose an Attach Request is received from the same UE
between Purge-UE-Request/Answer, then the MME and HSS start
the Authentication-Information-Request/Answer process.

This can lead to the following situations.

1. Purge-UE-Request
2. Attach Request
3. Authentication-Information-Request
4. Purge-UE-Answer
5. [UE Context Removed]
6. Authentication-Information-Answer

Since the UE Context has already been deleted
when the Authentication-Information-Answer is received,
it cannot be processed properly.

Therefore, mme_ue_cycle() is used to check
whether the UE Context has been deleted and
decide whether to process or
ignore the Authentication-Information-Answer as shown below.
2024-01-25 23:27:34 +09:00
Pau Espin 609c234f0b Document Gy interface spec reference 2024-01-25 07:05:33 +09:00
Pau Espin 64598fab2e Document Gx interface spec references 2024-01-25 07:05:33 +09:00
Pau Espin 29ea85ca4c cosmetic: pcrf/pcrf-gx-path.c: Fix trailing whitespace 2024-01-25 07:05:33 +09:00
Bostjan Meglic dcdfc970ce initialize variables before using them 2024-01-22 17:34:59 +09:00
Bostjan Meglic a3afc4764c memset input/output structure inside the function
Instead of checking if caller memset'ted the structure to zero, memset
it inside the function regardless.
There is no added benefit of a memset() + memcmp() to check if caller
cleared the structure used for outputing data from the database.
2024-01-22 17:34:59 +09:00
Bostjan Meglic e650b66305 fix mismatch of parameters between prototype and declaration 2024-01-22 17:34:59 +09:00
jmasterfunk84 2583fd3c08 Introduce ability for multiple SDM_Subscriptions 2024-01-21 13:16:21 +09:00
Sukchan Lee b94173ab41 [AMF/MME] Fixed M-TMSI pool release (#2307)
M-TMSI pool release was incorrectly modified and has now been corrected.
2024-01-21 11:58:43 +09:00
Gaber Stare d7b896affb [SMF] Build URR at bearer modification 2024-01-20 08:20:24 +09:00
Sukchan Lee 97e1b1bd30 [PFCP] Fixed incorrect TLV names (#2887)
Fixed standards documentation that described incorrect TLV names.
2024-01-19 23:40:20 +09:00
Pau Espin 60691b02d2 [MME] Gn: Introduce initial support for 2G->4G cell reselection
In an Inter-RAT setup a UE could perform a TAU coming from a 2G/3G network.
In that case the UE/MS is unknown to the MME and it should request the
SGSN context (MM, PDP) from the old SGSN. This is done through the following
GTPv1C message exchange on the Gn interface of SGSN and MME:
SGSN <- MME: SGSN Context Request
SGSN -> MME: SGSN Context Response
SGSN <- MME: SGSN Context Acknowledge

Diagram with full set of steps can be found at 3GPP TS 23.401 D.3.6.

This commit doesn't aim to be a complete implementation of the mentioned
procedure, since it's quite a complex one, with lots of fields and logic
required. This so far only implements in general the minimally
successful case by filling as much as possible the required set of
fields.
This will allow for a base onto which do incremental improvements and
fixes while testing against UEs and SGSNs (such as osmo-sgsn, which
doesn't yet support this procedure but will potentially earn it soon).

The reverse direction, aka UE issuing cell reselection 4G->2G was
already implemented (same as here, initial non-complete implementation)
in open5gs-mmed in commit 3d693da73e.

Related: https://osmocom.org/issues/6294
2024-01-17 23:05:19 +09:00
Sukchan Lee 4088cdf17d [MME] Hangs on an invalid S1AP message
Within the PathSwitchRequest packet,
the E-RABToBeSwitchedDLList has two bearers.

If the E-RAB-ID of both bearers is 5, the MME's list memory is destroyed
and the MME crashes. To fix this issue, we modified the code so that
the MME can work correctly with invalid S1AP messages.
2024-01-17 20:17:55 +09:00
Pau Espin 52be56b839 [MME] Match any SGSN in same RAI if none with specific RAI+CI found
This will be useful for other procedures where only the RAI is known,
but not the specific CI. This is the case of idle mobility from Gb or Iu
to EUTRAN, where MME needs to request contexts based on the RAI mapped
in the GUTI obtained from the UE during TAU.
This also makes the config more resilient in RIM scenario, where an SGSN
can be picked now even if CI doesn't match, instead of failing or faling
back to the default route SGSN.
2024-01-16 06:37:29 +09:00
Pau Espin 078bfc90da [GTPv1] Introduce APIs to decode MM Context and PDP Context IEs
They will be used in a follow-up patch implementing GERAN->EUTRAN idle
mobility.
2024-01-16 06:37:10 +09:00
Pau Espin feaa86fc9c [GTPv1] Fix encoding of MM Context IE if NRSNRA bit not set
The len byte, describing the length of the field coming after it,
is always expected according to the struct definition.
2024-01-16 06:37:10 +09:00
Pau Espin afa2c2c9e0 [CRYPT] Add ogs_kdf_kasme_idle_mobility()
This function is needed by a follow-up patch implementing initial
support for GERAN->EUTRAN idle mobility.
2024-01-16 06:36:44 +09:00
Sukchan Lee b0cf9fcbe7 [AMF] Issue during Concurrent UE Registration (#2839)
While they were continuing their fuzzy testing and developing PacketRusher, an unusual issue with the AMF was observed. The problem arises when a single Ethernet frame containing three bundled SCTP chunks is sent. This behavior is reproduced with PacketRusher when attempting to concurrently register two UEs with the same MSIN.

The expected behavior is that the PDU Session Establishment Accept is sent inside a DownlinkNASTransport to RAN UE NGAP ID 1. However, it is actually sent inside an InitialContextSetupRequest to RAN UE NGAP ID 2. The MAC of this NAS message is invalid for the Security Context of RAN UE NGAP ID 2 (probably valid for RAN UE NGAP ID 1)
2024-01-13 23:16:50 +09:00
Emanuele Di Pascale 21f99ad08d MME: support for IDR EPS_USER_STATE
keep track of whether we failed to page the UE, as that is
needed to provide the correct user state to the HSS.
2024-01-13 12:00:20 +09:00
Emanuele Di Pascale 77d94c0301 lib/diameter/s6a: add EPS-User-State
and the MME-related children
2024-01-13 12:00:20 +09:00
Bostjan Meglic 84569ccbdc [SBI] Fix conversion of AMBR bitrates from string to integer
When the input string contains a number and a unit too large to be
represented by a 64-bit variable, AMF/SMF would crash due to conversion
resulting in a negative value and unable to be used in compiling NAS-PDU
container.
Now the value gets clipped at int64_t maximum value.

Failed to encode ASN-PDU [-1] (../lib/asn1c/util/message.c:42)
2024-01-10 22:45:46 +09:00
Bostjan Meglic a4babef9eb [AMF] Add initialRegistrationInd field in Amf3GppAccessRegistration request to UDM 2024-01-10 22:37:56 +09:00
herlesupreeth 48323bd299 Update VoLTE tutorials 2024-01-10 21:49:48 +09:00
Sukchan Lee be1305b903 Added SEPP debian package (#2861) 2024-01-09 22:12:16 +09:00
Pau Espin ba59c8309a cosmetic: mme: Fix trailing whitespace 2024-01-09 21:33:01 +09:00
Bostjan Meglic 21b7cd487a [DBI] Fix code indent 2024-01-09 17:50:37 +09:00
Bostjan Meglic ad216c0b77 [core] Fix a couple of warnings when using C++ compiler or more strict settings
../lib/core/ogs-list.h:62:24: warning: invalid conversion from 'void*' to 'ogs_list_t*' {aka 'ogs_list_s*'} [-fpermissive]
../lib/core/ogs-rbtree.h:79:32: warning: invalid conversion from 'const void*' to 'const ogs_rbnode_t*' {aka 'const ogs_rbnode_s*'} [-fpermissive]

[SBI] Fix compiler error - possible uninitialized variable

[SCP] Fix compiler error - Error: this condition has identical branches

In case of additional compiler warnings turned on, the compiler warns
about potentially unused variables. Fix those issues.
2024-01-09 17:50:22 +09:00
Pau Espin 7d60b13d3a lib/proto/conv: Introduce API ogs_ip_to_paa()
The counterpart API ogs_paa_to_ip() was already present, but this was
missing. It will be required in open5gs-mmed in a follow-up patch.
2024-01-06 07:44:14 +09:00
Pau Espin 4ab275ad70 Rename and move ogs_gtp2_paa_to_ip() to lib/proto/conv
Both types are defined under lib/proto/type.h, and the conversion
function is used in several different protocols, so let's better move it
to generic lib/proto/conv.h and remove the "gtp2" prefix.
2024-01-06 07:44:14 +09:00
Pau Espin b3845d5b0b [MME] Constify params in mme-context and depending APIs 2024-01-06 07:42:32 +09:00
Pau Espin 2a840297f8 cosmetic: Fix trailing whitespace 2024-01-06 07:42:32 +09:00
Pau Espin 3457435071 [MME] Fix potential null ptr dereference
The assert is checking for sess->session->name, but afterwards there's a
check to skip ses->session not being null, which means the assert can
crash while dereferencing sess->session.
2024-01-06 07:42:32 +09:00
Sukchan Lee b1515a16ff [SMF] Fixes crash when PDU session release
I've resolved an issue where sending continuous
'PDU Session Release Request' message to the same session,
when more than two sessions were created, was causing an SMF crash.

For your reference, this problem did not occur
when only one session was created.
2024-01-05 21:15:34 +09:00
Pau Espin 8f58b55e14 [MME] Fix incorrect function name printed in error line 2024-01-05 05:52:56 +09:00
Pau Espin 27d2f86103 lib/gtp/xact: Fix tx of SGSN Context Acknowledge 2024-01-04 06:57:18 +09:00
Pau Espin 389ccaed16 lib/gtp/xact: Fix rx of SGSN Context Response 2024-01-04 06:57:18 +09:00
jmasterfunk84 ad2154ac2a
[HSS] Add hss_event_init after change to event system (#2838)
* Add hss_event_init after change to event system

* also include hss_event_final
2024-01-03 21:15:16 +09:00
Pau Espin 1f8f20da34 lib/proto/types.{c,h}: Constify several parameters 2024-01-03 07:10:09 +09:00
Pau Espin 55844d1eed ogs-conv.{c,h}: Constify several parameters 2024-01-03 07:10:09 +09:00
Pau Espin 9b729b2c6f cosmetic: ogs-conv.c: Fix trailing whitespace 2024-01-03 07:10:09 +09:00
Pau Espin 7d9f6181f3 [MME] cosmetic: Fix typo in comment 2024-01-02 21:25:42 +09:00
jmasterfunk84 f0de33833b Use SUPI not SUCI in error message 2023-12-31 11:30:27 +09:00
Sergey Yarin 0b93bd2ca9 Update 01-genodebs.md
Add a Nokia pico BTS to the list of tested hardware
2023-12-29 17:55:18 +09:00
Sukchan Lee 5d26416cd5 [DOCS] 5G Roaming with Mutual TLS by @infinitydon 2023-12-28 06:58:03 +09:00
Pau Espin 6cb20185fa cosmetic: mme: emm-*.c fix trailing whitespace 2023-12-23 09:57:11 +09:00
Pau Espin 3d693da73e [MME] Gn: Introduce initial support for 4G->2G cell reselection
In an Inter-RAT setup a UE could perform a RAU coming from a 4G network.
In that case the UE/MS is unknown to the SGSN and it should request the
SGSN context (MM, PDP) from the MME. This is done through the following
GTPv1C message exchange on the Gn interface of SGSN and MME:
SGSN -> MME: SGSN Context Request
SGSN <- MME: SGSN Context Response
SGSN -> MME: SGSN Context Acknowledge

This commit doesn't aim to be a complete implementation of the mentioned
procedure, since it's quite a complex one, with lots of fields and logic
required. This so far only implements in general the minimally
successful case by filling as much as possible the required set of
fields.
This will allow for a base onto which do incremental improvements and
fixes while testing against UEs and SGSNs (such as osmo-sgsn, which
doesn't yet support this procedure but will potentially earn it soon).

This commit doesn't implement the reverse direction, aka UE issuing cell
reselection 2G->4G. Initial support for this scenario will hopefully be
added soon as a follow-up patch, similar to this one.

Related: https://osmocom.org/issues/6294
2023-12-23 09:56:55 +09:00
Sukchan Lee 080f5bfd70 [NRF] crash after sending invalid message (#2808)
NRF crash after receiving
curl --http2-prior-knowledge http://127.0.0.10:7777/nnrf-disc/v1/nf-instances?target-nf-type=AUSF&requester-plmn-list=[{"mcc":"999","mnc":"70"}]&requester-nf-type=AMF&service-names=nausf-auth&target-plmn-list=[{"mcc":"999","mnc":"70"}]
curl --http2-prior-knowledge http://127.0.0.10:7777/nnrf-disc/v1/nf-instances\?target-nf-type=AUSF\&requester-plmn-list=%5B%7B%22mcc%22%3A%22999%22%2C%22mnc%22%3A%2270%22%7D%5D\&requester-nf-type\=AMF\&service-names=nausf-auth\&target-plmn-list=%5B%7B%22mcc%22%3A%22999%22%2C%22mnc%22%3A%2210%22%7D%5D
2023-12-23 09:55:19 +09:00
Pau Espin ea7708bcfc lib/gtp: Fix xact logic for gtp1 messages with intermediate stage
As per TS 29.060:
The Initial/request message is "SGSN Context Request", sent by peer A.
Peer B sends a response message "SGSN Context Response" with same SeqNr.
Peer A sends a response message "SGSN Context Acknowledge" with same
SeqNr.
If Peer B doesn't see a "SGSN Context Acknowlegde", it should keep
retransmitting "SGSN Context Response" as usual.
2023-12-22 06:04:18 +09:00
Pau Espin 14932a7254 [MME] Split Gn local TEID generation from S11 TEID generation 2023-12-22 06:04:03 +09:00
Pau Espin 6a9c7f16c1 Revert "[MME] Gn: Introduce initial support for 4G->2G cell reselection"
This reverts commit 5a31af36e0.
2023-12-22 06:02:11 +09:00
jmasterfunk84 2390a22504 Add space to inprove readbility of error 2023-12-21 22:14:24 +09:00
Pau Espin 75f32e07de xact: Fix debug message printed when not needed 2023-12-21 22:13:45 +09:00
Pau Espin ab51ba9dd5 cosmetic: mme: Fix trailing whitespace 2023-12-21 22:12:20 +09:00
Pau Espin 5a31af36e0 [MME] Gn: Introduce initial support for 4G->2G cell reselection
In an Inter-RAT setup a UE could perform a RAU coming from a 4G network.
In that case the UE/MS is unknown to the SGSN and it should request the
SGSN context (MM, PDP) from the MME. This is done through the following
GTPv1C message exchange on the Gn interface of SGSN and MME:
SGSN -> MME: SGSN Context Request
SGSN <- MME: SGSN Context Response
SGSN -> MME: SGSN Context Acknowledge

This commit doesn't aim to be a complete implementation of the mentioned
procedure, since it's quite a complex one, with lots of fields and logic
required. This so far only implements in general the minimally
successful case by filling as much as possible the required set of
fields.
This will allow for a base onto which do incremental improvements and
fixes while testing against UEs and SGSNs (such as osmo-sgsn, which
doesn't yet support this procedure but will potentially earn it soon).

This commit doesn't implement the reverse direction, aka UE issuing cell
reselection 2G->4G. Initial support for this scenario will hopefully be
added soon as a follow-up patch, similar to this one.

Related: https://osmocom.org/issues/6294
2023-12-21 22:11:49 +09:00
Pau Espin 7728172a83 [CRYPT] Constify several input parameters
This allows easily spotting input vs output parameters, as well as
make it easier for compiler to find out bugs and optimize code.
2023-12-20 20:04:23 +09:00
Pau Espin 9349743295 lib/proto: Constify params of ogs_id_get_{type,value}() 2023-12-20 20:04:23 +09:00
Pau Espin 5061a3aec0 [MME] Store decoded PAA into session->ue_ip and session_type
This will be used by the Gn interface to obtain the UE IP and provide
it to new SGSN when transmitting SGSN Context Response.
2023-12-19 06:57:35 +09:00
Pau Espin 414f81fcd5 [MME] Store received PGW S5C IP address in mme_sess_t
This information will be required by the Gn interface in MME when
answering an SGSN with an "SGSN Context Response" message during MS cell
reselection EUTRAN->GERAN.
2023-12-19 06:57:18 +09:00
Stare Gaber 4655507a00 [AMF] Fix deregistration request De-registration type 2023-12-19 06:47:54 +09:00
Sukchan Lee 4eb4a93cbd Merge branch 'main' of https://github.com/open5gs/open5gs 2023-12-17 10:23:21 +09:00
Sukchan Lee dcaccb4105 Added open5gs-sepp in debian package 2023-12-17 10:22:39 +09:00
mitmitmitm cecb87b346 Fix small typo in ogs_pfcp_sendto 2023-12-16 18:44:36 +09:00
Pau Espin 8c01f3387d constify src param of ogs_fqdn_{build,parse}() 2023-12-13 23:02:50 +09:00
Pau Espin 3b6b8ebf4f lib/proto/types.c: Fix trailing whitespace 2023-12-13 23:02:50 +09:00
Sukchan Lee 1ba3fd3cf8
[AMF/MME] UEContextReleaseCommand after Interity Protected (#2786) (#2794)
* [AMF/MME] UEContextReleaseCommand in Integrity (#2786)

Modified not to send UEContextReleaseCommand in Integrity Unprotected
NAS message such like Registration or Service request.

* [AMF/MME] UEContextReleaseCommand after Interity Protected (#2786)

Modified not to send UEContextReleaseCommand in Integrity Unprotected
NAS message such like Registration or Service request.
2023-12-13 17:54:37 +09:00
Pau Espin b0f381416b gtp/v1: Specify 'P-TMSI Signature' as uint24_t 2023-12-12 08:14:40 +09:00
Pau Espin 204ac35a66 gtp/v1: Specify 'MS Validated' IE as uint8
This field is a fixed size 1 byte with all bits set as spare (1) and the
lsb set as 0 ("No") or 1 ("Yes").
2023-12-12 08:14:40 +09:00
Sukchan Lee 1041f37a34 [DOCS] Added UPF performance test 2023-12-09 18:29:03 +09:00
Oliver Smith 66c39f2085
[MME] [AMF] Set Daylight Saving Time (#2766)
Fix DST always being set to 0 ("No adjustment for Daylight
Saving Time").

Related: 3GPP TS 24.008 § 10.5.3.12
2023-12-06 20:24:33 +09:00
Sukchan Lee 177e561ba8
[WebUI] Fix launch problem in docker (#2767) (#2769) 2023-12-04 22:16:10 +09:00
3884 changed files with 19195 additions and 7355 deletions

View File

@ -8,6 +8,16 @@ Please follow the [documentation](https://open5gs.org/open5gs/docs/) at [open5gs
If you find Open5GS useful for work, please consider supporting this Open Source project by [Becoming a sponsor](https://github.com/sponsors/acetcom). To manage the funding transactions transparently, you can donate through [OpenCollective](https://opencollective.com/open5gs).
<p align="center">
<h3 align="center">Special Sponsor</h3>
</p>
<p align="center">
<a target="_blank" href="https://mobi.com">
<img alt="special sponsor mobi" src="https://open5gs.org/assets/img/mobi-open5GS.png" width="400">
</a>
</p>
<p align="center">
<a target="_blank" href="https://open5gs.org/#sponsors">
<img alt="sponsors" src="https://open5gs.org/assets/img/sponsors.svg">

View File

@ -109,8 +109,10 @@ smf:
server:
- address: 127.0.0.4
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -189,8 +191,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7

View File

@ -142,8 +142,10 @@ smf:
server:
- address: 127.0.0.4
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -219,8 +221,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7

View File

@ -112,8 +112,10 @@ smf:
- address: 127.0.1.4
port: 9090
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -207,8 +209,10 @@ upf:
server:
- address: 127.0.1.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.1.7

View File

@ -112,8 +112,10 @@ smf:
- address: 127.0.2.4
port: 9090
session:
- subnet: 10.46.0.1/16
- subnet: 2001:db8:babe::1/48
- subnet: 10.46.0.0/16
gateway: 10.46.0.1
- subnet: 2001:db8:babe::/48
gateway: 2001:db8:babe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -207,9 +209,11 @@ upf:
server:
- address: 127.0.2.7
session:
- subnet: 10.46.0.1/16
- subnet: 10.46.0.0/16
gateway: 10.46.0.1
dev: ogstun2
- subnet: 2001:db8:babe::1/48
- subnet: 2001:db8:babe::/48
gateway: 2001:db8:babe::1
dev: ogstun2
metrics:
server:

View File

@ -112,8 +112,10 @@ smf:
- address: 127.0.3.4
port: 9090
session:
- subnet: 10.47.0.1/16
- subnet: 2001:db8:face::1/48
- subnet: 10.47.0.0/16
gateway: 10.47.0.1
- subnet: 2001:db8:face::/48
gateway: 2001:db8:face::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -207,9 +209,11 @@ upf:
server:
- address: 127.0.3.7
session:
- subnet: 10.47.0.1/16
- subnet: 10.47.0.0/16
gateway: 10.47.0.1
dev: ogstun3
- subnet: 2001:db8:face::1/48
- subnet: 2001:db8:face::/48
gateway: 2001:db8:face::1
dev: ogstun3
metrics:
server:

View File

@ -113,8 +113,10 @@ smf:
- address: 127.0.1.4
port: 9090
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -208,8 +210,10 @@ upf:
server:
- address: 127.0.1.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.1.7

View File

@ -113,8 +113,10 @@ smf:
- address: 127.0.2.4
port: 9090
session:
- subnet: 10.46.0.1/16
- subnet: 2001:db8:babe::1/48
- subnet: 10.46.0.0/16
gateway: 10.46.0.1
- subnet: 2001:db8:babe::/48
gateway: 2001:db8:babe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -208,9 +210,11 @@ upf:
server:
- address: 127.0.2.7
session:
- subnet: 10.46.0.1/16
- subnet: 10.46.0.0/16
gateway: 10.46.0.1
dev: ogstun2
- subnet: 2001:db8:babe::1/48
- subnet: 2001:db8:babe::/48
gateway: 2001:db8:babe::1
dev: ogstun2
metrics:
server:

View File

@ -113,8 +113,10 @@ smf:
- address: 127.0.3.4
port: 9090
session:
- subnet: 10.47.0.1/16
- subnet: 2001:db8:face::1/48
- subnet: 10.47.0.0/16
gateway: 10.47.0.1
- subnet: 2001:db8:face::/48
gateway: 2001:db8:face::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -208,9 +210,11 @@ upf:
server:
- address: 127.0.3.7
session:
- subnet: 10.47.0.1/16
- subnet: 10.47.0.0/16
gateway: 10.47.0.1
dev: ogstun3
- subnet: 2001:db8:face::1/48
- subnet: 2001:db8:face::/48
gateway: 2001:db8:face::1
dev: ogstun3
metrics:
server:

View File

@ -118,8 +118,10 @@ smf:
- address: 127.0.0.4
port: 9090
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -203,8 +205,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7

View File

@ -118,8 +118,10 @@ smf:
- address: 127.0.0.4
port: 9090
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -203,8 +205,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7

View File

@ -116,8 +116,10 @@ smf:
- address: 127.0.0.4
port: 9090
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -198,8 +200,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7

View File

@ -118,8 +118,10 @@ smf:
- address: 127.0.0.4
port: 9090
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -203,8 +205,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7

View File

@ -116,8 +116,10 @@ smf:
- address: 127.0.0.4
port: 9090
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -198,8 +200,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7

View File

@ -118,8 +118,10 @@ smf:
- address: 127.0.0.4
port: 9090
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -203,8 +205,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7

View File

@ -118,8 +118,10 @@ smf:
- address: 127.0.0.4
port: 9090
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -203,8 +205,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7

View File

@ -118,8 +118,10 @@ smf:
- address: 127.0.0.4
port: 9090
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -203,8 +205,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7

View File

@ -116,8 +116,10 @@ smf:
- address: 127.0.0.4
port: 9090
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -198,8 +200,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7

View File

@ -8,7 +8,9 @@
postrotate
for i in nrfd scpd seppd pcrfd hssd ausfd udmd udrd upfd sgwcd sgwud smfd mmed amfd; do
systemctl reload open5gs-$i
if systemctl --quiet is-active open5gs-$i; then
systemctl reload open5gs-$i
fi
done
endscript
}

View File

@ -110,8 +110,10 @@ smf:
server:
- address: 127.0.0.4
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -192,8 +194,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,6 @@
logger:
file: @localstatedir@/log/open5gs/scp.log
file:
path: @localstatedir@/log/open5gs/scp.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:
@ -83,3 +84,44 @@ scp:
# client:
# nrf:
# - uri: http://127.0.0.10:7777
#
################################################################################
# HTTPS scheme with TLS
################################################################################
# o Set as default if not individually set
# default:
# tls:
# server:
# scheme: https
# private_key: @sysconfdir@/open5gs/tls/scp.key
# cert: @sysconfdir@/open5gs/tls/scp.crt
# client:
# scheme: https
# cacert: @sysconfdir@/open5gs/tls/ca.crt
# sbi:
# server:
# - address: scp.localdomain
# client:
# nrf:
# - uri: https://nrf.localdomain
#
# o Add client TLS verification
# default:
# tls:
# server:
# scheme: https
# private_key: @sysconfdir@/open5gs/tls/scp.key
# cert: @sysconfdir@/open5gs/tls/scp.crt
# verify_client: true
# verify_client_cacert: @sysconfdir@/open5gs/tls/ca.crt
# client:
# scheme: https
# cacert: @sysconfdir@/open5gs/tls/ca.crt
# client_private_key: @sysconfdir@/open5gs/tls/scp.key
# client_cert: @sysconfdir@/open5gs/tls/scp.crt
# sbi:
# server:
# - address: scp.localdomain
# client:
# nrf:
# - uri: https://nrf.localdomain

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,6 @@
logger:
file: @localstatedir@/log/open5gs/smf.log
file:
path: @localstatedir@/log/open5gs/smf.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:
@ -34,8 +35,10 @@ smf:
- address: 127.0.0.4
port: 9090
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -327,23 +330,26 @@ smf:
# o Specific DNN/APN(e.g 'ims') uses 10.46.0.1/16, 2001:db8:babe::1/48
# (If the UE has unknown DNN/APN(not internet/ims), SMF/UPF will crash.)
# session:
# - subnet: 10.45.0.1/16
# - subnet: 10.45.0.0/16
# gateway: 10.45.0.1
# dnn: internet
# - subnet: 2001:db8:cafe::1/48
# - subnet: 2001:db8:cafe::/48
# dnn: internet
# - subnet: 10.46.0.1/16
# - subnet: 10.46.0.0/16
# gateway: 10.46.0.1
# dnn: ims
# - subnet: 2001:db8:babe::1/48
# - subnet: 2001:db8:babe::/48
# dnn: ims
#
# o Pool Range
# session:
# - subnet: 10.45.0.1/16
# - subnet: 10.45.0.0/16
# gateway: 10.45.0.1
# range:
# - 10.45.0.100-10.45.0.200
# - 10.45.1.100-
# - -10.45.0.200
# - subnet: 2001:db8:cafe::1/48
# - subnet: 2001:db8:cafe::/48
# range:
# - 2001:db8:cafe:a0::0-2001:db8:cafe:b0::0
# - 2001:db8:cafe:c0::0-2001:db8:cafe:d0::0

View File

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

View File

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

View File

@ -1,5 +1,6 @@
logger:
file: @localstatedir@/log/open5gs/upf.log
file:
path: @localstatedir@/log/open5gs/upf.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:
@ -18,8 +19,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7
@ -70,14 +73,16 @@ upf:
# $ sudo ip addr add 2001:db8:babe::1/48 dev ogstun3
#
# session:
# - subnet: 10.45.0.1/16
# - subnet: 10.45.0.0/16
# gateway: 10.45.0.1
# dnn: internet
# - subnet: 2001:db8:cafe::1/48
# - subnet: 2001:db8:cafe::/48
# dnn: internet
# dev: ogstun2
# - subnet: 10.46.0.1/16
# - subnet: 10.46.0.0/16
# gateway: 10.46.0.1
# dnn: ims
# dev: ogstun3
# - subnet: 2001:db8:babe::1/48
# - subnet: 2001:db8:babe::/48
# dnn: ims
# dev: ogstun3

View File

@ -118,8 +118,10 @@ smf:
- address: 127.0.0.4
port: 9090
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -203,8 +205,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7

View File

@ -110,8 +110,10 @@ smf:
server:
- address: 127.0.0.4
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -194,8 +196,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7

View File

@ -107,8 +107,10 @@ smf:
server:
- address: 127.0.0.4
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -184,8 +186,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7

View File

@ -5,6 +5,14 @@ Name=ogstun
Address=10.45.0.1/16
Address=2001:db8:cafe::1/48
[Route]
Gateway=0.0.0.0
Destination=10.45.0.0/16
[Route]
Gateway=::
Destination=2001:db8:cafe::0/48
[Link]
MTUBytes=1400
RequiredForOnline=false

View File

@ -107,8 +107,10 @@ smf:
server:
- address: 127.0.0.4
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
@ -187,8 +189,10 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
metrics:
server:
- address: 127.0.0.7

View File

@ -110,8 +110,9 @@ smf:
server:
- address: 127.0.0.4
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
dns:
- 8.8.8.8
- 8.8.4.4
@ -193,8 +194,9 @@ upf:
server:
- address: 127.0.0.7
session:
- subnet: 10.45.0.1/16
- subnet: 2001:db8:cafe::1/48
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
metrics:
server:
- address: 127.0.0.7

30
debian/changelog vendored
View File

@ -1,3 +1,33 @@
open5gs (2.7.1) unstable; urgency=medium
* Bug Fixed
-- Sukchan Lee <acetcom@gmail.com> Fri, 19 Apr 2024 21:21:46 +0900
open5gs (2.7.1~mantic) mantic; urgency=medium
* Bug Fixed
-- Sukchan Lee <acetcom@gmail.com> Fri, 19 Apr 2024 21:18:53 +0900
open5gs (2.7.1~bionic) bionic; urgency=medium
* Bug Fixed
-- Sukchan Lee <acetcom@gmail.com> Fri, 19 Apr 2024 21:16:21 +0900
open5gs (2.7.1~jammy) jammy; urgency=medium
* Bug Fixed
-- Sukchan Lee <acetcom@gmail.com> Fri, 19 Apr 2024 21:11:30 +0900
open5gs (2.7.1~focal) focal; urgency=medium
* Bug Fixed
-- Sukchan Lee <acetcom@gmail.com> Fri, 19 Apr 2024 21:08:46 +0900
open5gs (2.7.0) unstable; urgency=medium
* 5G Roaming with SEPP

1
debian/control vendored
View File

@ -277,6 +277,7 @@ Depends: ${misc:Depends},
open5gs-pcrf (= ${binary:Version}),
open5gs-nrf (= ${binary:Version}),
open5gs-scp (= ${binary:Version}),
open5gs-sepp (= ${binary:Version}),
open5gs-ausf (= ${binary:Version}),
open5gs-udm (= ${binary:Version}),
open5gs-pcf (= ${binary:Version}),

5
debian/open5gs-sepp.install vendored Normal file
View File

@ -0,0 +1,5 @@
usr/bin/open5gs-seppd
configs/open5gs/sepp*.yaml etc/open5gs
configs/open5gs/tls/sepp*.key etc/open5gs/tls
configs/open5gs/tls/sepp*.crt etc/open5gs/tls
configs/systemd/open5gs-seppd.service lib/systemd/system

1
docker/debian/bookworm Symbolic link
View File

@ -0,0 +1 @@
latest

View File

@ -20,7 +20,7 @@ services:
depends_on:
- mongodb
ports:
- "3000:3000"
- "9999:9999"
environment:
- DB_URI=mongodb://mongodb/open5gs
- WAIT_HOSTS=mongodb:27017

1
docker/i386/debian Symbolic link
View File

@ -0,0 +1 @@
../debian

1
docker/i386/ubuntu Symbolic link
View File

@ -0,0 +1 @@
../ubuntu

1
docker/ubuntu/lunar Symbolic link
View File

@ -0,0 +1 @@
latest

1
docker/ubuntu/noble Symbolic link
View File

@ -0,0 +1 @@
latest

View File

@ -13,4 +13,4 @@ RUN chmod +x /wait
CMD /wait && npm run start
EXPOSE 3000
EXPOSE 9999

View File

@ -224,7 +224,7 @@ Okay - you have installed the software, now what to do with it? Well, there are
Out of the box, the default configurations see all of the Open5GS components fully configured for use on a single computer. They are set to communicate with each other using the local loopback address space (`127.0.0.X`). The default addresses for each of the bind interfaces for these components and functions are as follows:
```
MongoDB = 127.0.0.1 (subscriber data) - http://localhost:3000
MongoDB = 127.0.0.1 (subscriber data) - http://localhost:9999
MME-s1ap = 127.0.0.2 :36412 for S1-MME
MME-gtpc = 127.0.0.2 :2123 for S11
@ -233,7 +233,7 @@ MME-frDi = 127.0.0.2 :3868 for S6a
SGWC-gtpc = 127.0.0.3 :2123 for S11
SGWC-pfcp = 127.0.0.3 :8805 for Sxa
SMF-gtpc = 127.0.0.4 :2123 for S5c, N11
SMF-gtpc = 127.0.0.4 :2123 for S5c
SMF-gtpu = 127.0.0.4 :2152 for N4u (Sxu)
SMF-pfcp = 127.0.0.4 :8805 for N4 (Sxb)
SMF-frDi = 127.0.0.4 :3868 for Gx auth
@ -335,10 +335,29 @@ $ sudo systemctl restart open5gs-sgwud
#### Setup a 5G Core
You will need to modify your 5G AMF config to support your PLMN and TAC. The international test PLMN is 001/01, and the international private network PLMN is 999/99. You should stick to using either of these PLMNs unless you have been issued a PLMN by your national regulator. (This PLMN will need to be configured in your gNB).
You will need to modify the PLMN in your NRF and AMF config, and in case of AMF, further modify the TAC information. The international test PLMN is 001/01, and the international private network PLMN is 999/99. You should stick to using either of these PLMNs unless you have been issued a PLMN by your national regulator. (This PLMN will need to be configured in your gNB).
If you are aiming to connect an external gNB to your core, you will also need to change the NGAP bind address of the AMF **and** the GTPU bind address of the UPF. If you are running an gNB stack locally, you will not need to make these changes.
Modify [/etc/open5gs/nrf.yaml](https://github.com/{{ site.github_username }}/open5gs/blob/main/configs/open5gs/nrf.yaml.in) to set the Serving PLMN ID.
```diff
$ diff --git a/configs/open5gs/nrf.yaml.in b/configs/open5gs/nrf.yaml.in
index cd9e45feb..58e8cbbce 100644
--- a/configs/open5gs/nrf.yaml.in
+++ b/configs/open5gs/nrf.yaml.in
@@ -10,8 +10,8 @@ global:
nrf:
serving: # 5G roaming requires PLMN in NRF
- plmn_id:
- mcc: 999
- mnc: 70
+ mcc: 001
+ mnc: 01
sbi:
server:
- address: 127.0.0.10
```
Modify [/etc/open5gs/amf.yaml](https://github.com/{{ site.github_username }}/open5gs/blob/main/configs/open5gs/amf.yaml.in) to set the NGAP IP address, PLMN ID, TAC and NSSAI.
@ -404,15 +423,44 @@ index e78b018f1..35a54419e 100644
After changing config files, please restart Open5GS daemons.
```bash
$ sudo systemctl restart open5gs-nrfd
$ sudo systemctl restart open5gs-amfd
$ sudo systemctl restart open5gs-upfd
```
#### Configure logging
The Open5GS components log to `/var/log/open5gs/*.log` and to `stderr` by
default.
##### Avoid duplicate timestamps in journalctl
Open5GS adds timestamps to each log line in the log file, and on `stderr`. If
you run Open5GS with systemd and prefer looking at the logs with `journalctl`,
then each line will have two timestamps. To fix this, disable the timestamp for
`stderr` with the following configuration change:
```diff
diff --git a/configs/open5gs/mme.yaml.in b/configs/open5gs/mme.yaml.in
index 87c251b9d..599032b8a 100644
--- a/configs/open5gs/mme.yaml.in
+++ b/configs/open5gs/mme.yaml.in
@@ -1,6 +1,9 @@
logger:
+ default:
+ timestamp: false
file:
path: /var/log/open5gs/mme.log
+ timestamp: true
# level: info # fatal|error|warn|info(default)|debug|trace
global:
```
#### Register Subscriber Information
---
Connect to `http://localhost:3000` and login with **admin** account.
Connect to `http://localhost:9999` and login with **admin** account.
> Username : admin
> Password : 1423

View File

@ -110,6 +110,26 @@ $ cd ../
##### 5G Core
Modify [install/etc/open5gs/nrf.yaml](https://github.com/{{ site.github_username }}/open5gs/blob/main/configs/open5gs/nrf.yaml.in) to set the NGAP IP address, PLMN ID, TAC and NSSAI.
```diff
$ diff --git a/configs/open5gs/nrf.yaml.in b/configs/open5gs/nrf.yaml.in
index cd9e45feb..58e8cbbce 100644
--- a/configs/open5gs/nrf.yaml.in
+++ b/configs/open5gs/nrf.yaml.in
@@ -10,8 +10,8 @@ global:
nrf:
serving: # 5G roaming requires PLMN in NRF
- plmn_id:
- mcc: 999
- mnc: 70
+ mcc: 001
+ mnc: 01
sbi:
server:
- address: 127.0.0.10
```
Modify [install/etc/open5gs/amf.yaml](https://github.com/{{ site.github_username }}/open5gs/blob/main/configs/open5gs/amf.yaml.in) to set the NGAP IP address, PLMN ID, TAC and NSSAI.
```diff
@ -475,7 +495,7 @@ $ PORT=7777 npm run dev
### Register Subscriber Information
---
Connect to `http://127.0.0.1:3000` and login with **admin** account.
Connect to `http://127.0.0.1:9999` and login with **admin** account.
> Username : admin
> Password : 1423

View File

@ -48,11 +48,13 @@ If you have tested radio hardware from a vendor not listed with Open5GS, please
* Gemtek WLTGFC-101 (S/W version 2.1.1746.1116)
* Huawei BTS3900 (S/W version V100R011C10SPC230)
* Huawei BBU5900 with RRU5304W Band 7 FDD 2600Mhz 40W Version V100R016C10
* Klas VoyagerCell Duo 4GAP1000/4GAP1000X
* Nokia FW2PC BC28 Flexi Zone G2 Outdoor Micro FDD LTE 700 MHz High Power
* Nokia FWH1 B38 Flexi Zone Outdoor Micro TD LTE 2600 MHz
* Nokia FRGY Flexi BTS BBU with Nokia FRCG RRU Band 5 850Mhz FDD 40W. Version 16.1A to 19.0
* Nokia FW2FA Flexi Zone Mini-Macro Outdoor BTS, 2x20w Band 39
* Nokia FWGR Flexi Zone Mini-Macro Outdoor BTS, 2x20w Band 1
* Nokia FWHG Flexi Zone Indoor Pico BTS, 2x250 mW Band 7
* Ruckus Q710 and Q910
### 4G/5G Software Stacks + SDRs

View File

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

View File

@ -10,6 +10,175 @@ head_inline: "<style> .blue { color: blue; } </style>"
}
</style>
#### How to run wireshark from within Docker?
In the following, I will explain how to run wireshark on Ubuntu 32bit.
First, make the following modifications to get wireshark working.
```diff
$ diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 01925303b..8d5e23a4f 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -105,7 +105,7 @@ services:
volumes:
- home:/home/${USER}
- ${HOME}:/mnt
- # - /tmp/.X11-unix:/tmp/.X11-unix
+ - /tmp/.X11-unix:/tmp/.X11-unix
# - /etc/localtime:/etc/localtime:ro
# - /usr/share/zoneinfo/Europe/Helsinki:/etc/localtime:ro
hostname: open5gs-dev
$ diff --git a/docker/ubuntu/latest/dev/Dockerfile b/docker/ubuntu/latest/dev/Dockerfile
index 970dddb72..6902fc59c 100644
--- a/docker/ubuntu/latest/dev/Dockerfile
+++ b/docker/ubuntu/latest/dev/Dockerfile
@@ -23,12 +23,12 @@ RUN apt-get update && \
net-tools && \
apt-get clean
-#RUN apt-get update && \
-# apt-get install -y software-properties-common && \
-# sudo add-apt-repository ppa:wireshark-dev/stable -y && \
-# apt-get update && \
-# DEBIAN_FRONTEND=noninteractive \
-# apt-get install -y wireshark
+RUN apt-get update && \
+ apt-get install -y software-properties-common && \
+ sudo add-apt-repository ppa:wireshark-dev/stable -y && \
+ apt-get update && \
+ DEBIAN_FRONTEND=noninteractive \
+ apt-get install -y wireshark
COPY setup.sh /root
```
It allows any program run by the docker user to communicate with X windows.
```
$ xhost +local:docker
```
And run 32bit ubuntu like below.
```
$ cd docker
$ DIST=i386/ubuntu docker compose run dev
```
#### What to do if a FATAL occurs?
You may occasionally encounter a FATAL like the one below.
```
FATAL: s1ap_build_initial_context_setup_request: Assertion `E_RABToBeSetupListCtxtSUReq->list.count' failed. (../src/mme/s1ap-build.c:577)
01/19 22:01:49.169: [core] FATAL: backtrace() returned 10 addresses (../lib/core/ogs-abort.c:37)
./src/mme/open5gs-mmed(+0x8ef5e) [0x55f6f8a78f5e]
./src/mme/open5gs-mmed(+0x5910b) [0x55f6f8a4310b]
./src/mme/open5gs-mmed(+0xa4ea5) [0x55f6f8a8eea5]
./src/mme/open5gs-mmed(+0x88b65) [0x55f6f8a72b65]
/home/acetcom/Documents/git/open5gs/build/src/mme/../../lib/core/libogscore.so.2(ogs_fsm_dispatch+0x119) [0x7fc2362f4c2f]
./src/mme/open5gs-mmed(+0x9e99) [0x55f6f89f3e99]
/home/acetcom/Documents/git/open5gs/build/src/mme/../../lib/core/libogscore.so.2(+0x1199d) [0x7fc2362e599d]
/lib/x86_64-linux-gnu/libc.so.6(+0x94ac3) [0x7fc235a94ac3]
/lib/x86_64-linux-gnu/libc.so.6(+0x126850) [0x7fc235b26850]
[1] 41823 IOT instruction (core dumped) ./src/mme/open5gs-mmed
```
When a FATAL occurs, Open5GS automatically calls backtrace(), and from the address information it outputs, we can see in which source code this happened. Note the addresses 0x8ef5e, 0x5910b, 0xa4ea5, 0x88b65 in the output below. You can find those addresses in the following places.
```
./src/mme/open5gs-mmed(+0x8ef5e)
./src/mme/open5gs-mmed(+0x5910b)
./src/mme/open5gs-mmed(+0xa4ea5)
./src/mme/open5gs-mmed(+0x88b65)
```
And you can use the GDB tool to provide additional information. If you are in a Ubuntu environment, you can install GDB as shown below.
```
$ sudo apt install gdb
```
Then run gdb like below.
```
$ gdb ./src/mme/open5gs-mmed
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./src/mme/open5gs-mmed...
(gdb)
```
With the address 0x8ef5e, 0x5910b, 0xa4ea5, 0x88b65 that you remembered from above and the `list` command within the GDB prompt, you can find out in which source code the problem is occurring.
```
(gdb) list *0x8ef5e
0x8ef5e is in s1ap_build_initial_context_setup_request (../src/mme/s1ap-build.c:579).
574 emmbuf = NULL;
575 }
576
577 ogs_assert(E_RABToBeSetupListCtxtSUReq->list.count);
578
579 ie = CALLOC(1, sizeof(S1AP_InitialContextSetupRequestIEs_t));
580 ASN_SEQUENCE_ADD(&InitialContextSetupRequest->protocolIEs, ie);
581
582 ie->id = S1AP_ProtocolIE_ID_id_UESecurityCapabilities;
583 ie->criticality = S1AP_Criticality_reject;
(gdb) list *0x5910b
0x5910b is in nas_eps_send_attach_accept (../src/mme/nas-path.c:171).
166 * the MME shall delete the stored UE radio capability information
167 * or the UE radio capability ID, if any.
168 */
169 OGS_ASN_CLEAR_DATA(&mme_ue->ueRadioCapability);
170
171 s1apbuf = s1ap_build_initial_context_setup_request(mme_ue, emmbuf);
172 if (!s1apbuf) {
173 ogs_error("s1ap_build_initial_context_setup_request() failed");
174 return OGS_ERROR;
175 }
(gdb) list *0xa4ea5
0xa4ea5 is in mme_s11_handle_create_session_response (../src/mme/mme-s11-handler.c:436).
431 ogs_assert(OGS_OK ==
432 sgsap_send_location_update_request(mme_ue));
433 } else {
434 ogs_assert(OGS_PDU_SESSION_TYPE_IS_VALID(
435 session->paa.session_type));
436 r = nas_eps_send_attach_accept(mme_ue);
437 ogs_expect(r == OGS_OK);
438 ogs_assert(r != OGS_ERROR);
439 }
440
(gdb) list *0x88b65
0x88b65 is in mme_state_operational (../src/mme/mme-sm.c:552).
547 break;
548 case OGS_GTP2_CREATE_SESSION_RESPONSE_TYPE:
549 if (!gtp_message.h.teid_presence) ogs_error("No TEID");
550 mme_s11_handle_create_session_response(
551 xact, mme_ue, &gtp_message.create_session_response);
552 break;
553 case OGS_GTP2_MODIFY_BEARER_RESPONSE_TYPE:
554 if (!gtp_message.h.teid_presence) ogs_error("No TEID");
555 mme_s11_handle_modify_bearer_response(
556 xact, mme_ue, &gtp_message.modify_bearer_response);
(gdb)
```
Reporting this information to a github issue or discussion will help others troubleshoot the issue.
#### MME sends Attach reject(EMM-Cause:15) with Diameter error(Result-Code:3002)
If you see the Attach reject(EMM-Cause:15] with Diameter error(Result-Code:3002), it means that HSS is not running.
@ -316,7 +485,8 @@ index a70143f08..e0dba560c 100644
+++ b/configs/open5gs/amf.yaml.in
@@ -1,6 +1,6 @@
logger:
file: @localstatedir@/log/open5gs/amf.log
file:
path: @localstatedir@/log/open5gs/amf.log
-# level: info # fatal|error|warn|info(default)|debug|trace
+ level: debug

View File

@ -229,7 +229,7 @@ K : 82E9053A1882085FF2C020359938DAE9
OPc : BFD5771AAF4F6728E9BC6EF2C2533BDB
```
Connect to `http://localhost:3000` and login with **admin** account.
Connect to `http://localhost:9999` and login with **admin** account.
> Username : admin
> Password : 1423
@ -334,7 +334,7 @@ Change back to the srsRAN source directory and copy the main config example as w
```bash
$ cp srsenb/enb.conf.example srsenb/enb.conf
$ cp srsenb/rr.conf.example srsenb/rr.conf
$ cp srsenb/drb.conf.example srsenb/drb.conf
$ cp srsenb/rb.conf.example srsenb/rb.conf
$ cp srsenb/sib.conf.example srsenb/sib.conf
```

View File

@ -457,7 +457,7 @@ $ mysql
```
$ cd ~ && git clone https://github.com/herlesupreeth/Kamailio_IMS_Config
$ cd Kamailio_IMS_Config
$ cd Kamailio_IMS_Config && git checkout 5.3
$ cp -r kamailio_icscf /etc
$ cp -r kamailio_pcscf /etc
$ cp -r kamailio_scscf /etc

View File

@ -5,63 +5,56 @@ head_inline: "<style> .blue { color: blue; } </style>"
Setup description:
- MCC: 001, MNC: 01
- Docker-compose
- Docker + Docker Compose
- VM/Physical machine running Ubuntu 20.04 or 22.04
- srsENB + USRP B210 or a commercial eNB
- Sysmocom USIM - sysmoUSIM-SJS1
- UE: Mi 9 Pro 5G. Other UE are being tested.
- UE: Mi 9 Pro 5G, Oneplus 5, iPhone X and above, Nokia 5.3. Other UE are being tested.
{: .blue}
#### 0. Introduction
This tutorial introduces an install-and-run lab for Open5GS + Kamailio IMS
VoLTE study, a follow-up project of [Open5GS Tutorial: VoLTE Setup with Kamailio IMS and Open5GS](https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/).
This tutorial introduces an install-and-run setup for Open5GS + Kamailio IMS VoLTE study.
The main purpose is to save researchers' and students' time to debug for a
minimum-viable environment before actual study can be proceeded.
**Important notice before you start**
1. Java 7 is downloaded from an alternative location. You have to agree with
Oracle's term of service and have an Oracle account, to legally use Java SDK
7u80. By using this repo, I assume you have the legal right to use it and
hold no liability.
You have to prepare IMSI, Ki, OP/OPc, SQN of your SIM cards.
The main purpose is to save researchers' and students' time to debug for a minimum-viable environment before actual study can be proceeded.
#### 1. Prepare SIM cards for VoLTE
1. Wrong KIC / KID / KIK bricks your SIM card.
Program IMSI, Ki, OP/OPc, SQN for the SIM cards you plan to use.
If VoLTE is not enabled on your Android phone then please refer to the instructions mentioned here: [VoLTE settings overriding](https://github.com/herlesupreeth/CoIMS_Wiki/blob/master/README.md).
{: .notice--info}
1. Using wrong KIC / KID / KIK bricks your SIM card and is irrecoverable
2. Use MCC = 001, MNC = 01 for a test network, unless you know your MCC/MNC is supported by Android Carrier Privileges.
{: .notice--warning}
Refer to: https://github.com/herlesupreeth/CoIMS_Wiki/blob/master/README.md
* gp --key-enc <KIC1> --key-mac <KID1> --key-dek <KIK1> -lvi
* gp --key-enc <KIC1> --key-mac <KID1> --key-dek <KIK1> --unlock
* gp --install applet.cap
* gp -a 00A4040009A00000015141434C0000 -a 80E2900033F031E22FE11E4F06FFFFFFFFFFFFC114E46872F28B350B7E1F140DE535C2A8D5804F0BE3E30DD00101DB080000000000000001
* gp --acr-list-aram
#### 2. Build Open5GS, Kamailio docker images
#### 2. Build Open5GS, Kamailio with docker-compose
* Mandatory requirements:
* [docker-ce](https://docs.docker.com/install/linux/docker-ce/ubuntu) - Version 22.0.5 or above
* [docker compose](https://docs.docker.com/compose) - Version 2.14 or above
Mandatory requirements:
* [docker-ce](https://docs.docker.com/install/linux/docker-ce/ubuntu)
* [docker-compose](https://docs.docker.com/compose)
Install docker-compose and make sure it works before going forward.
Clone the repository and build base docker images of open5gs and Kamailio:
Clone repository and build base docker image of open5gs and kamailio:
```
# Build docker images for open5gs EPC/5GC components
git clone https://github.com/herlesupreeth/docker_open5gs
cd docker_open5gs/base
docker build --no-cache --force-rm -t docker_open5gs .
# Build docker images for kamailio IMS components
cd ../ims_base
docker build --no-cache --force-rm -t docker_kamailio .
# Build docker images for additional components
cd ..
docker compose -f 4g-volte-deploy.yaml build
```
#### 3. Configuring your setup
`.env` is the only file most of them need to edit as per their deployment needs
`.env` is the only file most of them need to edit as per your deployment needs
{: .notice--warning}
Edit only the following parameters in `.env` as per your setup
@ -69,15 +62,15 @@ Edit only the following parameters in `.env` as per your setup
```
MCC
MNC
TEST_NETWORK --> Change this only if it clashes with the internal network at your home/office
DOCKER_HOST_IP --> This is the IP address of the host running your docker setup
SGWU_ADVERTISE_IP --> Change this to value of DOCKER_HOST_IP set above only if eNB is not running the same docker network/host
DOCKER_HOST_IP --> This is the IP address of the host running (EPC+IMS)
SGWU_ADVERTISE_IP --> Change this to value of DOCKER_HOST_IP
UE_IPV4_INTERNET --> Change this to your desired (Not conflicted) UE network ip range for internet APN
UE_IPV4_IMS --> Change this to your desired (Not conflicted) UE network ip range for ims APN
```
If eNB is NOT running in the same docker network/host as the host running the dockerized Core + IMS then follow the below additional steps
Under `mme` section in docker-compose file (`docker-compose.yaml`, `nsa-deploy.yaml`), uncomment the following part
Under **mme** section in docker compose file (**4g-volte-deploy.yaml**), uncomment the following part
```
...
# ports:
@ -85,8 +78,7 @@ Under `mme` section in docker-compose file (`docker-compose.yaml`, `nsa-deploy.y
...
```
Under `sgwu` section in docker-compose file (`docker-compose.yaml`, `nsa-deploy.yaml`), uncomment the following part
Then, uncomment the following part under **sgwu** section
```
...
# ports:
@ -94,57 +86,96 @@ Under `sgwu` section in docker-compose file (`docker-compose.yaml`, `nsa-deploy.
...
```
#### 4. Building 4G/5G Core + IMS related components images
#### 4. Deploying 4G/5G Core + IMS related components images
```
cd docker_open5gs
source .env
docker-compose -f deploy-all.yaml build --no-cache
docker-compose -f deploy-all.yaml up
sudo ufw disable
sudo sysctl -w net.ipv4.ip_forward=1
docker compose -f 4g-volte-deploy.yaml up
```
#### 5. (Optional) Run srsENB in a separate container
I use srsENB and USRP B210 in the lab. Sometimes you may want to restart
srsENB while keeping the core network running. It is thus recommended to run
srsENB separately.
Sometimes you may want to restart srsENB while keeping the core network running. It is thus recommended to run srsENB separately.
In order to run srsENB in a separate host, clone the docker_open5gs repository as mentioned above and build srsENB docker images.
```
# Build docker images for srsRAN_4G eNB
cd ../srslte
docker build --no-cache --force-rm -t docker_srslte .
```
And, edit only the following parameters in **.env** as per your setup
```
MCC
MNC
DOCKER_HOST_IP --> This is the IP address of the host running eNB
MME_IP --> Change this to IP address of host running (EPC+IMS)
SRS_ENB_IP --> Change this to the IP address of the host running eNB
```
Replace the following part in the docker compose file (**srsenb.yaml**)
```
networks:
default:
ipv4_address: ${SRS_ENB_IP}
networks:
default:
external:
name: docker_open5gs_default
```
with
```
network_mode: host
```
```
cd docker_open5gs
source .env
docker-compose -f srsenb.yaml build --no-cache
docker-compose -f srsenb.yaml up
sudo cpupower frequency-set -g performance
docker compose -f srsenb.yaml up -d && docker container attach srsenb
```
#### 6. Configuration and register two UE
#### 6. Configuration and provisioning of SIM information in HSS and HLR
If there is a need to change the Core Network component configuration files
found under their respective folder, make sure to re-compile images using
`docker-compose build` again.
If there is a need to change the Core Network component configuration, then corresponding configuration files can be found under their respective folders.
{: .notice--warning}
Open (http://<DOCKER_HOST_IP>:3000) in a web browser, where <DOCKER_HOST_IP> is
the IP of the machine/VM running the open5gs containers. Login with following
credentials
- Provision SIM details in open5gs HSS
Open (http://<DOCKER_HOST_IP>:9999) in a web browser, where <DOCKER_HOST_IP> is the IP of the machine/VM running the open5gs containers. Login with following credentials
```
Username : admin
Password : 1423
```
Follow the instructions in [VoLTE Setup](https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/):
- Step 18, set IMSI, Ki, OP, SQN and APN of your SIM cards.
**Important!** Set the type of both APN to IPv4. Kamailio does not support VoLTE over
IPv6 at the moment. (See the screenshot below.)
- Step 20, add IMS subscriptions to FHoSS.
Add users with their corresponding IMSI, Ki, OP/OPc value and APN settings. The APN settings should look like below:
<pre>
APN Configuration:
---------------------------------------------------------------------------------------------------------------------
| APN | Type | QCI | ARP | Capability | Vulnerablility | MBR DL/UL(Kbps) | GBR DL/UL(Kbps) | PGW IP |
---------------------------------------------------------------------------------------------------------------------
| internet | IPv4 | 9 | 8 | Disabled | Disabled | unlimited/unlimited | | |
---------------------------------------------------------------------------------------------------------------------
| ims | IPv4 | 5 | 1 | Disabled | Disabled | 3850/1530 | | |
| | | 1 | 2 | Enabled | Enabled | 128/128 | 128/128 | |
| | | 2 | 4 | Enabled | Enabled | 128/128 | 128/128 | |
---------------------------------------------------------------------------------------------------------------------
</pre>
**Important!** Set the type of both APN to IPv4. Kamailio does not support VoLTE over IPv6 at the moment. (See the screenshot below)
![Set both type to IPv4 only](https://raw.githubusercontent.com/miaoski/docker_open5gs/gh-pages/screenshots/subscriber-type-ipv4.png)
For already running systems, copy SQN from Open5GS and type it in FHoSS. You
can type SQN in decimal. FHoSS will automagically convert it to hex.
- Provision IMSI and MSISDN in osmohlr to allow [SMS over SGs](https://github.com/herlesupreeth/docker_open5gs#provisioning-of-imsi-and-msisdn-with-osmohlr-as-follows)
Pay special attention to copy/paste. You might have leading or trailing spaces
in FHoSS, resulting in failed connections!
- Provision SIM information in pyHSS [IMS](https://github.com/herlesupreeth/docker_open5gs#provisioning-of-sim-information-in-pyhss-is-as-follows)
#### 7. Debugging with Wireshark
@ -152,15 +183,13 @@ Thanks to Open5GS, the topology is super similar to [SAE on Wikipedia](https://e
![Network topology of Open5GS + IMS](https://raw.githubusercontent.com/miaoski/docker_open5gs/master/network-topology.png)
**APN**
On your cellphone, there should be *internet* and *ims*.
<img src="https://raw.githubusercontent.com/miaoski/docker_open5gs/gh-pages/screenshots/apn-on-cellphone.jpg" width="320" />
CoIMS should look like the one below. If you don't know what CoIMS is, please
refer to step 23 of VoLTE Setup.
If CoIMS is used to force enable VoLTE on the Android device, it should look like in the screenshot below:
<img src="https://raw.githubusercontent.com/miaoski/docker_open5gs/gh-pages/screenshots/coims.jpg" width="320" />
@ -173,13 +202,11 @@ When DNS is not properly set, you may end up with 478 Unresolvable destination (
![478 unresolvable destination](https://raw.githubusercontent.com/miaoski/docker_open5gs/gh-pages/screenshots/478-unresolvable-destination.png)
If the port if not open, or DNS is not properly configured, the phone cannot
reach P-CSCF and fails.
If the port if not open, or DNS is not properly configured, the phone cannot reach P-CSCF and fails.
![RST at port 5060](https://raw.githubusercontent.com/miaoski/docker_open5gs/gh-pages/screenshots/RST-5060.png)
If there is an NAT between PGW and P-CSCF, IPsec-NAT would not work, and the
PCAP looks like the one below. N.B. that you need to run P-CSCF as root, in
If there is an NAT between PGW and P-CSCF, IPsec-NAT would not work, and the PCAP looks like the one below. Note that you need to run P-CSCF as root, in
order to add xfrm state and policy.
![401 Unauthorized](https://raw.githubusercontent.com/miaoski/docker_open5gs/gh-pages/screenshots/401-unauthorized.png)
@ -193,17 +220,12 @@ Herle Supreeth has shared PCAP files of successful calls, including
- [Non-IPSec UE to IPSec UE calling]({{ site.url }}{{ site.baseurl }}/assets/pcapng/nonipsec_to_ipsec_call.pcapng)
- [IPSec UE to Non-IPSec UE calling]({{ site.url }}{{ site.baseurl }}/assets/pcapng/ipsec_to_nonipsec_call.pcapng)
The successful calls were made with a commercial eNB (in his case a Casa
smallcell), while srsENB the ACK takes a very long time to reach the UE,
resulting in disconnected calls.
**UE registration**
![UE registration with IPSec](https://raw.githubusercontent.com/miaoski/docker_open5gs/gh-pages/screenshots/ue-ipsec.png)
From the screenshot, we see a UE that supports IPSec got a response from
S-CSCF, indicating that ipsec-3gpp is supported, protocol is ESP (ethernet
proto 50, IPSec). Client port (port-c) is 5100 and server port (port-s) 6100.
From the screenshot, we see a UE that supports IPSec got a response from S-CSCF, indicating that ipsec-3gpp is supported, protocol is ESP (ethernet proto 50, IPSec). Client port (port-c) is 5100 and server port (port-s) 6100.
Refer to [IMS/SIP - Basic Procedures](https://www.sharetechnote.com/html/IMS_SIP_Procedure_Reg_Auth_IPSec.html) if you want to know more.
Also, notice that packets after 401 Unauthorized are transmitted over ESP.
@ -216,8 +238,7 @@ If a UE does not support IPSec, you don't see the "security-server", as shown be
![ipsec to ipsec call](https://raw.githubusercontent.com/miaoski/docker_open5gs/gh-pages/screenshots/ipsec-to-ipsec%20calls.png)
The Wireshark above shows that after several IPSec (ESP) packets, S-CSCF is
sending a SIP INVITE for UE 03 to UE 04. To be more precise,
The Wireshark above shows that after several IPSec (ESP) packets, S-CSCF is sending a SIP INVITE for UE 03 to UE 04. To be more precise,
```
Request-Line: INVITE sip:0398765432100;phone-context=0498765432100@0498765432100;user=phone SIP/2.0

View File

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

View File

@ -18,9 +18,9 @@ head_inline: "<style> ul { padding-bottom: 1em; } </style>"
- [Dockerized VoLTE Setup](tutorial/03-VoLTE-dockerized)
- [Roaming](tutorial/05-roaming)
- Inside Source Code
- [UPF Code Explanation](https://medium.com/@aditya.koranga/open5gs-upf-code-explanation-with-flow-c-79c50f253dd1)
- [SMF Code Explanation](https://medium.com/@aditya.koranga/open5gs-smf-code-explanation-with-flow-charts-a3b3cd38c991)
- In the lab
- [A Demonstration of 30 Gbps Load Testing for Accelerated UPF with Open5gs](https://nextepc.com/technology)
- [Measurement of UPF Performance](https://github.com/s5uishida/simple_measurement_of_upf_performance)
- Troubleshooting
- [Simple Issues](troubleshoot/01-simple-issues)
@ -38,12 +38,17 @@ head_inline: "<style> ul { padding-bottom: 1em; } </style>"
- Hardware Specific Notes
- [eNodeBs/gNodeBs tested on Open5GS](hardware/01-genodebs)
- Inside Source Code
- [UPF Code Explanation](https://medium.com/@aditya.koranga/open5gs-upf-code-explanation-with-flow-c-79c50f253dd1)
- [SMF Code Explanation](https://medium.com/@aditya.koranga/open5gs-smf-code-explanation-with-flow-charts-a3b3cd38c991)
- @infinitydon
- [Open5GS on Amazon Elastic Kubernetes Service](https://aws.amazon.com/blogs/opensource/open-source-mobile-core-network-implementation-on-amazon-elastic-kubernetes-service/)
- [Kubernetes Open5GS Deployment](https://dev.to/infinitydon/virtual-4g-simulation-using-kubernetes-and-gns3-3b7k?fbclid=IwAR1p99h13a-mCfejanbBQe0H0-jp5grXkn5mWf1WrTHf47UtegB2-UHGGZQ)
- [5G Core SBI mTLS Using External Certificate PKI](https://futuredon.medium.com/5g-core-sbi-mtls-using-external-certificate-pki-4ffc02ac7728)
- [5G Frame Routing](https://futuredon.medium.com/5g-frame-routing-6e34d8587123)
- [5G SCTP LoadBalancer Using LoxiLB](https://futuredon.medium.com/5g-sctp-loadbalancer-using-loxilb-b525198a9103)([Video Link](https://youtu.be/k3ICc7MXcC8))
- [5G Roaming With Mutual TLS](https://futuredon.medium.com/5g-roaming-with-mutual-tls-1468d109129c)
- @nickvsnetworking
- [My first 5G Core : Open5GS and UERANSIM](http://nickvsnetworking.com/my-first-5g-core-open5gs-and-ueransim/)

View File

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

View File

@ -0,0 +1,15 @@
---
title: "v2.7.1 - Bug Fixed"
date: 2024-04-19 21:23:00 +0900
categories:
- Release
tags:
- News
- Release
head_inline: "<style> ul { padding-bottom: 1em; } .blue { color: blue; }</style>"
---
See [Release Note](https://github.com/open5gs/open5gs/releases/tag/v2.7.1)
Download -- [v2.7.1.tar.gz](https://github.com/open5gs/open5gs/archive/v2.7.1.tar.gz)
{: .notice--info}

View File

@ -36,10 +36,15 @@ typedef struct ogs_app_context_s {
const char *db_uri;
struct {
ogs_log_ts_e timestamp;
} logger_default;
struct {
const char *file;
const char *level;
const char *domain;
ogs_log_ts_e timestamp;
} logger;
ogs_queue_t *queue;

View File

@ -114,6 +114,9 @@ int ogs_app_initialize(
ogs_app()->logger.domain, ogs_app()->logger.level);
if (rv != OGS_OK) return rv;
ogs_log_set_timestamp(ogs_app()->logger_default.timestamp,
ogs_app()->logger.timestamp);
/**************************************************************************
* Stage 5 : Setup Database Module
*/
@ -197,7 +200,7 @@ static int read_config(void)
break;
case YAML_SCANNER_ERROR:
if (parser.context)
ogs_error("Scanner error - %s at line %zu, column %zu"
ogs_error("Scanner error - %s at line %zu, column %zu "
"%s at line %zu, column %zu", parser.context,
parser.context_mark.line+1,
parser.context_mark.column+1,
@ -210,7 +213,7 @@ static int read_config(void)
break;
case YAML_PARSER_ERROR:
if (parser.context)
ogs_error("Parser error - %s at line %zu, column %zu"
ogs_error("Parser error - %s at line %zu, column %zu "
"%s at line %zu, column %zu", parser.context,
parser.context_mark.line+1,
parser.context_mark.column+1,
@ -254,6 +257,57 @@ static int context_validation(void)
return OGS_OK;
}
static void parse_config_logger_file(ogs_yaml_iter_t *logger_iter,
const char *logger_key)
{
ogs_yaml_iter_t iter;
/* Legacy format:
* logger:
* file: /var/log/open5gs/mme.log */
if (!strcmp(logger_key, "file") && ogs_yaml_iter_has_value(logger_iter)) {
ogs_app()->logger.file = ogs_yaml_iter_value(logger_iter);
ogs_warn("Please change the configuration file as below.");
ogs_log_print(OGS_LOG_WARN, "\n<OLD Format>\n");
ogs_log_print(OGS_LOG_WARN, "logger:\n");
ogs_log_print(OGS_LOG_WARN, " file: %s\n", ogs_app()->logger.file);
ogs_log_print(OGS_LOG_WARN, "\n<NEW Format>\n");
ogs_log_print(OGS_LOG_WARN, "logger:\n");
ogs_log_print(OGS_LOG_WARN, " file:\n");
ogs_log_print(OGS_LOG_WARN, " path: %s\n", ogs_app()->logger.file);
ogs_log_print(OGS_LOG_WARN, "\n\n\n");
return;
}
/* Current format:
* logger:
* default:
* timestamp: false
* file:
* path: /var/log/open5gs/mme.log
* timestamp: true */
ogs_yaml_iter_recurse(logger_iter, &iter);
while (ogs_yaml_iter_next(&iter)) {
const char *key = ogs_yaml_iter_key(&iter);
ogs_assert(key);
if (!strcmp(key, "timestamp")) {
ogs_log_ts_e ts = ogs_yaml_iter_bool(&iter)
? OGS_LOG_TS_ENABLED
: OGS_LOG_TS_DISABLED;
if (!strcmp(logger_key, "default")) {
ogs_app()->logger_default.timestamp = ts;
} else if (!strcmp(logger_key, "file")) {
ogs_app()->logger.timestamp = ts;
}
} else if (!strcmp(key, "path")) {
if (!strcmp(logger_key, "file")) {
ogs_app()->logger.file = ogs_yaml_iter_value(&iter);
}
}
}
}
static int parse_config(void)
{
int rv;
@ -278,9 +332,8 @@ static int parse_config(void)
while (ogs_yaml_iter_next(&logger_iter)) {
const char *logger_key = ogs_yaml_iter_key(&logger_iter);
ogs_assert(logger_key);
if (!strcmp(logger_key, "file")) {
ogs_app()->logger.file = ogs_yaml_iter_value(&logger_iter);
} else if (!strcmp(logger_key, "level")) {
parse_config_logger_file(&logger_iter, logger_key);
if (!strcmp(logger_key, "level")) {
ogs_app()->logger.level =
ogs_yaml_iter_value(&logger_iter);
} else if (!strcmp(logger_key, "domain")) {

View File

@ -178,6 +178,34 @@ const char *ogs_yaml_iter_value(ogs_yaml_iter_t *iter)
return NULL;
}
int ogs_yaml_iter_has_value(ogs_yaml_iter_t *iter)
{
ogs_assert(iter);
ogs_assert(iter->document);
ogs_assert(iter->node);
if (iter->node->type == YAML_SCALAR_NODE) {
return 1;
} else if (iter->node->type == YAML_MAPPING_NODE) {
yaml_node_t *node = NULL;
ogs_assert(iter->pair);
node = yaml_document_get_node(iter->document, iter->pair->value);
ogs_assert(node);
return node->type == YAML_SCALAR_NODE;
} else if (iter->node->type == YAML_SEQUENCE_NODE) {
yaml_node_t *node = NULL;
ogs_assert(iter->item);
node = yaml_document_get_node(iter->document, *iter->item);
ogs_assert(node);
return node->type == YAML_SCALAR_NODE;
}
ogs_assert_if_reached();
return 0;
}
int ogs_yaml_iter_bool(ogs_yaml_iter_t *iter)
{
const char *v = ogs_yaml_iter_value(iter);

View File

@ -59,6 +59,7 @@ void ogs_yaml_iter_recurse(ogs_yaml_iter_t *parent, ogs_yaml_iter_t *iter);
int ogs_yaml_iter_type(ogs_yaml_iter_t *iter);
const char *ogs_yaml_iter_key(ogs_yaml_iter_t *iter);
const char *ogs_yaml_iter_value(ogs_yaml_iter_t *iter);
int ogs_yaml_iter_has_value(ogs_yaml_iter_t *iter);
int ogs_yaml_iter_bool(ogs_yaml_iter_t *iter);
#ifdef __cplusplus

View File

@ -18,6 +18,7 @@ asn_TYPE_operation_t asn_OP_ANY = {
0,
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare,
OCTET_STRING_copy,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber,
OCTET_STRING_encode_der,
@ -33,9 +34,11 @@ asn_TYPE_operation_t asn_OP_ANY = {
0,
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
OCTET_STRING_decode_jer_hex,
ANY_encode_jer,
#else
0,
0,
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
#if !defined(ASN_DISABLE_OER_SUPPORT)
0,

View File

@ -29,6 +29,7 @@ extern asn_OCTET_STRING_specifics_t asn_SPC_ANY_specs;
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define ANY_compare OCTET_STRING_compare
#define ANY_copy OCTET_STRING_copy
#define ANY_constraint asn_generic_no_constraint
@ -43,6 +44,7 @@ xer_type_encoder_f ANY_encode_xer;
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
jer_type_decoder_f ANY_decode_jer;
jer_type_encoder_f ANY_encode_jer;
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */

View File

@ -24,6 +24,7 @@ asn_TYPE_operation_t asn_OP_BIT_STRING = {
0,
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
BIT_STRING_compare,
BIT_STRING_copy,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
@ -39,9 +40,11 @@ asn_TYPE_operation_t asn_OP_BIT_STRING = {
0,
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
OCTET_STRING_decode_jer_hex,
BIT_STRING_encode_jer,
#else
0,
0,
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
#if !defined(ASN_DISABLE_OER_SUPPORT)
BIT_STRING_decode_oer,
@ -211,3 +214,37 @@ BIT_STRING_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
return 1;
}
}
int
BIT_STRING_copy(const asn_TYPE_descriptor_t *td, void **aptr,
const void *bptr) {
const asn_OCTET_STRING_specifics_t *specs = td->specifics;
BIT_STRING_t *a = (BIT_STRING_t *)*aptr;
const BIT_STRING_t *b = (const BIT_STRING_t *)bptr;
if(!b) {
if(a) {
FREEMEM(a->buf);
FREEMEM(a);
*aptr = 0;
}
return 0;
}
if(!a) {
a = *aptr = CALLOC(1, specs->struct_size);
if(!a) return -1;
}
uint8_t* buf = MALLOC(b->size + 1);
if(!buf) return -1;
memcpy(buf, b->buf, b->size);
buf[b->size] = 0;
FREEMEM(a->buf);
a->buf = buf;
a->size = b->size;
a->bits_unused = b->bits_unused;
return 0;
}

View File

@ -31,6 +31,7 @@ asn_struct_print_f BIT_STRING_print; /* Human-readable output */
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f BIT_STRING_compare;
asn_struct_copy_f BIT_STRING_copy;
asn_constr_check_f BIT_STRING_constraint;
@ -45,6 +46,7 @@ xer_type_encoder_f BIT_STRING_encode_xer;
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
#define BIT_STRING_decode_jer OCTET_STRING_decode_jer_binary
jer_type_encoder_f BIT_STRING_encode_jer;
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */

View File

@ -0,0 +1,92 @@
/*-
* Copyright (c) 2003, 2005, 2006 Lev Walkin <vlm@lionet.info>.
* All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#include <asn_internal.h>
#include <ENUMERATED.h>
/*
* ENUMERATED basic type description.
*/
static const ber_tlv_tag_t asn_DEF_ENUMERATED_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (10 << 2))
};
asn_TYPE_operation_t asn_OP_ENUMERATED = {
ASN__PRIMITIVE_TYPE_free,
#if !defined(ASN_DISABLE_PRINT_SUPPORT)
INTEGER_print, /* Implemented in terms of INTEGER */
#else
0,
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
INTEGER_compare, /* Implemented in terms of INTEGER */
INTEGER_copy, /* Implemented in terms of INTEGER */
#if !defined(ASN_DISABLE_BER_SUPPORT)
ber_decode_primitive,
INTEGER_encode_der, /* Implemented in terms of INTEGER */
#else
0,
0,
#endif /* !defined(ASN_DISABLE_BER_SUPPORT) */
#if !defined(ASN_DISABLE_XER_SUPPORT)
INTEGER_decode_xer, /* This is temporary! */
INTEGER_encode_xer,
#else
0,
0,
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
ENUMERATED_decode_jer,
INTEGER_encode_jer,
#else
0,
0,
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
#if !defined(ASN_DISABLE_OER_SUPPORT)
ENUMERATED_decode_oer,
ENUMERATED_encode_oer,
#else
0,
0,
#endif /* !defined(ASN_DISABLE_OER_SUPPORT) */
#if !defined(ASN_DISABLE_UPER_SUPPORT)
ENUMERATED_decode_uper, /* Unaligned PER decoder */
ENUMERATED_encode_uper, /* Unaligned PER encoder */
#else
0,
0,
#endif /* !defined(ASN_DISABLE_UPER_SUPPORT) */
#if !defined(ASN_DISABLE_APER_SUPPORT)
ENUMERATED_decode_aper, /* Aligned PER decoder */
ENUMERATED_encode_aper, /* Aligned PER encoder */
#else
0,
0,
#endif /* !defined(ASN_DISABLE_APER_SUPPORT) */
#if !defined(ASN_DISABLE_RFILL_SUPPORT)
ENUMERATED_random_fill,
#else
0,
#endif /* !defined(ASN_DISABLE_RFILL_SUPPORT) */
0 /* Use generic outmost tag fetcher */
};
asn_TYPE_descriptor_t asn_DEF_ENUMERATED = {
"ENUMERATED",
"ENUMERATED",
&asn_OP_ENUMERATED,
asn_DEF_ENUMERATED_tags,
sizeof(asn_DEF_ENUMERATED_tags) / sizeof(asn_DEF_ENUMERATED_tags[0]),
asn_DEF_ENUMERATED_tags, /* Same as above */
sizeof(asn_DEF_ENUMERATED_tags) / sizeof(asn_DEF_ENUMERATED_tags[0]),
{
#if !defined(ASN_DISABLE_OER_SUPPORT)
0,
#endif /* !defined(ASN_DISABLE_OER_SUPPORT) */
#if !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT)
0,
#endif /* !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT) */
asn_generic_no_constraint
},
0, 0, /* No members */
0 /* No specifics */
};

View File

@ -0,0 +1,67 @@
/*-
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef _ENUMERATED_H_
#define _ENUMERATED_H_
#include <INTEGER.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef INTEGER_t ENUMERATED_t; /* Implemented via INTEGER */
extern asn_TYPE_descriptor_t asn_DEF_ENUMERATED;
extern asn_TYPE_operation_t asn_OP_ENUMERATED;
#define ENUMERATED_free ASN__PRIMITIVE_TYPE_free
#if !defined(ASN_DISABLE_PRINT_SUPPORT)
#define ENUMERATED_print INTEGER_print
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define ENUMERATED_compare INTEGER_compare
#define ENUMERATED_copy INTEGER_copy
#define ENUMERATED_constraint asn_generic_no_constraint
#if !defined(ASN_DISABLE_BER_SUPPORT)
#define ENUMERATED_decode_ber ber_decode_primitive
#define ENUMERATED_encode_der INTEGER_encode_der
#endif /* !defined(ASN_DISABLE_BER_SUPPORT) */
#if !defined(ASN_DISABLE_XER_SUPPORT)
#define ENUMERATED_decode_xer INTEGER_decode_xer
#define ENUMERATED_encode_xer INTEGER_encode_xer
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
jer_type_decoder_f ENUMERATED_decode_jer;
#define ENUMERATED_encode_jer INTEGER_encode_jer
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
#if !defined(ASN_DISABLE_OER_SUPPORT)
oer_type_decoder_f ENUMERATED_decode_oer;
oer_type_encoder_f ENUMERATED_encode_oer;
#endif /* !defined(ASN_DISABLE_OER_SUPPORT) */
#if !defined(ASN_DISABLE_UPER_SUPPORT)
per_type_decoder_f ENUMERATED_decode_uper;
per_type_encoder_f ENUMERATED_encode_uper;
#endif /* !defined(ASN_DISABLE_UPER_SUPPORT) */
#if !defined(ASN_DISABLE_APER_SUPPORT)
per_type_decoder_f ENUMERATED_decode_aper;
per_type_encoder_f ENUMERATED_encode_aper;
#endif /* !defined(ASN_DISABLE_APER_SUPPORT) */
#if !defined(ASN_DISABLE_RFILL_SUPPORT)
#define ENUMERATED_random_fill INTEGER_random_fill
#endif /* !defined(ASN_DISABLE_RFILL_SUPPORT) */
#ifdef __cplusplus
}
#endif
#endif /* _ENUMERATED_H_ */

View File

@ -0,0 +1,43 @@
/*
* Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
* All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#include <asn_internal.h>
#include <ENUMERATED.h>
#include <NativeEnumerated.h>
asn_dec_rval_t
ENUMERATED_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
asn_dec_rval_t rval;
ENUMERATED_t *st = (ENUMERATED_t *)*sptr;
long value;
void *vptr = &value;
if(!st) {
st = (ENUMERATED_t *)(*sptr = CALLOC(1, sizeof(*st)));
if(!st) ASN__DECODE_FAILED;
}
rval = NativeEnumerated_decode_aper(opt_codec_ctx, td, constraints,
(void **)&vptr, pd);
if(rval.code == RC_OK)
if(asn_long2INTEGER(st, value))
rval.code = RC_FAIL;
return rval;
}
asn_enc_rval_t
ENUMERATED_encode_aper(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, asn_per_outp_t *po) {
const ENUMERATED_t *st = (const ENUMERATED_t *)sptr;
long value;
if(asn_INTEGER2long(st, &value))
ASN__ENCODE_FAILED;
return NativeEnumerated_encode_aper(td, constraints, &value, po);
}

View File

@ -20,6 +20,7 @@ asn_TYPE_operation_t asn_OP_GraphicString = {
0,
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare,
OCTET_STRING_copy,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der,
@ -35,9 +36,11 @@ asn_TYPE_operation_t asn_OP_GraphicString = {
0,
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
OCTET_STRING_decode_jer_hex,
OCTET_STRING_encode_jer, /* Can't expect it to be ASCII/UTF8 */
#else
0,
0,
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
#if !defined(ASN_DISABLE_OER_SUPPORT)
OCTET_STRING_decode_oer,

View File

@ -23,6 +23,7 @@ extern asn_TYPE_operation_t asn_OP_GraphicString;
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define GraphicString_compare OCTET_STRING_compare
#define GraphicString_copy OCTET_STRING_copy
#define GraphicString_constraint asn_generic_unknown_constraint
@ -37,6 +38,7 @@ extern asn_TYPE_operation_t asn_OP_GraphicString;
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
#define GraphicString_decode_jer OCTET_STRING_decode_jer
#define GraphicString_encode_jer OCTET_STRING_encode_jer
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */

View File

@ -22,6 +22,7 @@ asn_TYPE_operation_t asn_OP_INTEGER = {
0,
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
INTEGER_compare,
INTEGER_copy,
#if !defined(ASN_DISABLE_BER_SUPPORT)
ber_decode_primitive,
INTEGER_encode_der,
@ -37,9 +38,11 @@ asn_TYPE_operation_t asn_OP_INTEGER = {
0,
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
INTEGER_decode_jer,
INTEGER_encode_jer,
#else
0,
0,
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
#if !defined(ASN_DISABLE_OER_SUPPORT)
INTEGER_decode_oer, /* OER decoder */
@ -411,6 +414,33 @@ asn_ulong2INTEGER(INTEGER_t *st, unsigned long value) {
return asn_imax2INTEGER(st, value);
}
int asn_INTEGER2int64(const INTEGER_t *st, int64_t *value) {
intmax_t v;
if(asn_INTEGER2imax(st, &v) == 0) {
if(v < INT64_MIN || v > INT64_MAX) {
errno = ERANGE;
return -1;
}
*value = v;
return 0;
} else {
return -1;
}
}
int asn_INTEGER2uint64(const INTEGER_t *st, uint64_t *value) {
uintmax_t v;
if(asn_INTEGER2umax(st, &v) == 0) {
if(v > UINT64_MAX) {
errno = ERANGE;
return -1;
}
*value = v;
return 0;
} else {
return -1;
}
}
int
asn_uint642INTEGER(INTEGER_t *st, uint64_t value) {
@ -736,3 +766,40 @@ INTEGER_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
}
}
int
INTEGER_copy(const asn_TYPE_descriptor_t *td, void **aptr,
const void *bptr) {
(void)td;
INTEGER_t *a = *aptr;
const INTEGER_t *b = bptr;
if(!b) {
if(a) {
FREEMEM(a->buf);
FREEMEM(a);
*aptr = 0;
}
return 0;
}
if(!a) {
a = *aptr = CALLOC(1, sizeof(*a));
if(!a) return -1;
}
if(b->size) {
uint8_t* buf = MALLOC(b->size);
if(!buf) return -1;
memcpy(buf, b->buf, b->size);
FREEMEM(a->buf);
a->buf = buf;
a->size = b->size;
} else {
FREEMEM(a->buf);
a->buf = 0;
a->size = 0;
}
return 0;
}

View File

@ -47,6 +47,7 @@ asn_struct_print_f INTEGER_print;
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f INTEGER_compare;
asn_struct_copy_f INTEGER_copy;
#define INTEGER_constraint asn_generic_no_constraint
@ -61,6 +62,7 @@ xer_type_encoder_f INTEGER_encode_xer;
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
jer_type_decoder_f INTEGER_decode_jer;
jer_type_encoder_f INTEGER_encode_jer;
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
@ -106,6 +108,8 @@ int asn_INTEGER2long(const INTEGER_t *i, long *l);
int asn_INTEGER2ulong(const INTEGER_t *i, unsigned long *l);
int asn_long2INTEGER(INTEGER_t *i, long l);
int asn_ulong2INTEGER(INTEGER_t *i, unsigned long l);
int asn_INTEGER2int64(const INTEGER_t *i, int64_t *l);
int asn_INTEGER2uint64(const INTEGER_t *i, uint64_t *l);
int asn_int642INTEGER(INTEGER_t *i, int64_t l);
int asn_uint642INTEGER(INTEGER_t *i, uint64_t l);

View File

@ -57,7 +57,7 @@ INTEGER_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
int max_range_bytes = (ct->range_bits >> 3) +
(((ct->range_bits % 8) > 0) ? 1 : 0);
int length = 0, i;
long value = 0;
intmax_t value = 0;
for (i = 1; ; i++) {
int upper = 1 << i;
@ -79,18 +79,18 @@ INTEGER_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
int buf = per_get_few_bits(pd, 8);
if (buf < 0)
ASN__DECODE_FAILED;
value += (((long)buf) << (8 * length));
value += (((intmax_t)buf) << (8 * length));
}
value += ct->lower_bound;
if((specs && specs->field_unsigned)
? asn_uint642INTEGER(st, (unsigned long)value)
: asn_int642INTEGER(st, value))
? asn_umax2INTEGER(st, (uintmax_t)value)
: asn_imax2INTEGER(st, value))
ASN__DECODE_FAILED;
ASN_DEBUG("Got value %ld + low %lld",
value, (long long int)ct->lower_bound);
value, (intmax_t)ct->lower_bound);
} else {
long value = 0;
intmax_t value = 0;
if (ct->range_bits < 8) {
value = per_get_few_bits(pd, ct->range_bits);
if(value < 0) ASN__DECODE_STARVED;
@ -108,11 +108,11 @@ INTEGER_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
}
value += ct->lower_bound;
if((specs && specs->field_unsigned)
? asn_ulong2INTEGER(st, value)
: asn_long2INTEGER(st, value))
? asn_umax2INTEGER(st, (uintmax_t)value)
: asn_imax2INTEGER(st, value))
ASN__DECODE_FAILED;
ASN_DEBUG("Got value %ld + low %lld",
value, (long long int)ct->lower_bound);
value, (intmax_t)ct->lower_bound);
}
return rval;
} else {
@ -167,7 +167,7 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
const uint8_t *buf;
const uint8_t *end;
const asn_per_constraint_t *ct;
long value = 0;
intmax_t value = 0;
if(!st || st->size == 0) ASN__ENCODE_FAILED;
@ -179,26 +179,26 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
if(ct) {
int inext = 0;
if(specs && specs->field_unsigned) {
unsigned long uval;
if(asn_INTEGER2ulong(st, &uval))
uintmax_t uval;
if(asn_INTEGER2umax(st, &uval))
ASN__ENCODE_FAILED;
/* Check proper range */
if(ct->flags & APC_SEMI_CONSTRAINED) {
if(uval < (unsigned long)ct->lower_bound)
if(uval < (uintmax_t)ct->lower_bound)
inext = 1;
} else if(ct->range_bits >= 0) {
if(uval < (unsigned long)ct->lower_bound
|| uval > (unsigned long)ct->upper_bound)
if(uval < (uintmax_t)ct->lower_bound
|| uval > (uintmax_t)ct->upper_bound)
inext = 1;
}
ASN_DEBUG("Value %lu (%02x/%zu) lb %lld ub %lld %s",
uval, st->buf[0], st->size,
(long long int)ct->lower_bound,
(long long int)ct->upper_bound,
(intmax_t)ct->lower_bound,
(intmax_t)ct->upper_bound,
inext ? "ext" : "fix");
value = uval;
} else {
if(asn_INTEGER2long(st, &value)) ASN__ENCODE_FAILED;
if(asn_INTEGER2imax(st, &value)) ASN__ENCODE_FAILED;
/* Check proper range */
if(ct->flags & APC_SEMI_CONSTRAINED) {
if(value < ct->lower_bound)
@ -210,8 +210,8 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
}
ASN_DEBUG("Value %lu (%02x/%zu) lb %lld ub %lld %s",
value, st->buf[0], st->size,
(long long int)ct->lower_bound,
(long long int)ct->upper_bound,
(intmax_t)ct->lower_bound,
(intmax_t)ct->upper_bound,
inext ? "ext" : "fix");
}
if(ct->flags & APC_EXTENSIBLE) {
@ -225,11 +225,11 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
/* X.691, #12.2.2 */
if(ct && ct->range_bits >= 0) {
unsigned long v;
uintmax_t v;
/* #10.5.6 */
ASN_DEBUG("Encoding integer %ld (%lld) with range %d bits",
value, (long long int)(value - ct->lower_bound),
value, (intmax_t)(value - ct->lower_bound),
ct->range_bits);
v = value - ct->lower_bound;
@ -287,7 +287,7 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
}
if(ct && ct->lower_bound) {
ASN_DEBUG("Adjust lower bound to %lld", (long long int)ct->lower_bound);
ASN_DEBUG("Adjust lower bound to %lld", (intmax_t)ct->lower_bound);
/* TODO: adjust lower bound */
ASN__ENCODE_FAILED;
}

View File

@ -19,6 +19,7 @@ asn_TYPE_operation_t asn_OP_NULL = {
0,
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
NULL_compare,
NULL_copy,
#if !defined(ASN_DISABLE_BER_SUPPORT)
NULL_decode_ber,
NULL_encode_der, /* Special handling of DER encoding */
@ -34,9 +35,11 @@ asn_TYPE_operation_t asn_OP_NULL = {
0,
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
NULL_decode_jer,
NULL_encode_jer,
#else
0,
0,
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
#if !defined(ASN_DISABLE_OER_SUPPORT)
NULL_decode_oer,
@ -111,3 +114,15 @@ NULL_compare(const asn_TYPE_descriptor_t *td, const void *a, const void *b) {
(void)b;
return 0;
}
int
NULL_copy(const asn_TYPE_descriptor_t *td, void **a, const void *b) {
(void)td;
if(b && !*a) {
*a = CALLOC(1, sizeof(NULL_t));
if (!*a) return -1;
}
return 0;
}

View File

@ -27,6 +27,7 @@ asn_struct_print_f NULL_print;
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f NULL_compare;
asn_struct_copy_f NULL_copy;
#define NULL_constraint asn_generic_no_constraint
@ -41,6 +42,7 @@ xer_type_encoder_f NULL_encode_xer;
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
jer_type_decoder_f NULL_decode_jer;
jer_type_encoder_f NULL_encode_jer;
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */

View File

@ -26,6 +26,7 @@ asn_TYPE_operation_t asn_OP_NativeEnumerated = {
0,
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
NativeInteger_compare,
NativeInteger_copy,
#if !defined(ASN_DISABLE_BER_SUPPORT)
NativeInteger_decode_ber,
NativeInteger_encode_der,
@ -41,9 +42,11 @@ asn_TYPE_operation_t asn_OP_NativeEnumerated = {
0,
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
NativeEnumerated_decode_jer,
NativeEnumerated_encode_jer,
#else
0,
0,
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
#if !defined(ASN_DISABLE_OER_SUPPORT)
NativeEnumerated_decode_oer,

View File

@ -13,6 +13,7 @@
#define _NativeEnumerated_H_
#include <NativeInteger.h>
#include <ENUMERATED.h>
#ifdef __cplusplus
extern "C" {
@ -28,6 +29,7 @@ extern asn_TYPE_operation_t asn_OP_NativeEnumerated;
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define NativeEnumerated_compare NativeInteger_compare
#define NativeEnumerated_copy NativeInteger_copy
#define NativeEnumerated_constraint asn_generic_no_constraint
@ -42,6 +44,7 @@ xer_type_encoder_f NativeEnumerated_encode_xer;
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
jer_type_decoder_f NativeEnumerated_decode_jer;
jer_type_encoder_f NativeEnumerated_encode_jer;
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */

View File

@ -64,7 +64,7 @@ NativeEnumerated_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
*/
/* XXX handle indefinite index length > 64k */
value = aper_get_nsnnwn(pd, 65537);
value = aper_get_nsnnwn(pd);
if(value < 0) ASN__DECODE_STARVED;
value += specs->extension - 1;
//if(value >= specs->map_count)
@ -148,9 +148,7 @@ NativeEnumerated_encode_aper(const asn_TYPE_descriptor_t *td,
ASN_DEBUG("value = %ld, ext = %d, inext = %d, res = %ld",
value, specs->extension, inext,
value - (inext ? (specs->extension - 1) : 0));
if(aper_put_nsnnwn(po,
ct->upper_bound - ct->lower_bound + 1,
value - (inext ? (specs->extension - 1) : 0)))
if(aper_put_nsnnwn(po, value - (inext ? (specs->extension - 1) : 0)))
ASN__ENCODE_FAILED;
ASN__ENCODED_OK(er);

View File

@ -27,6 +27,7 @@ asn_TYPE_operation_t asn_OP_NativeInteger = {
0,
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
NativeInteger_compare,
NativeInteger_copy,
#if !defined(ASN_DISABLE_BER_SUPPORT)
NativeInteger_decode_ber,
NativeInteger_encode_der,
@ -42,9 +43,11 @@ asn_TYPE_operation_t asn_OP_NativeInteger = {
0,
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
NativeInteger_decode_jer,
NativeInteger_encode_jer,
#else
0,
0,
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
#if !defined(ASN_DISABLE_OER_SUPPORT)
NativeInteger_decode_oer, /* OER decoder */
@ -150,3 +153,30 @@ NativeInteger_compare(const asn_TYPE_descriptor_t *td, const void *aptr, const v
return 1;
}
}
int
NativeInteger_copy(const asn_TYPE_descriptor_t *td, void **aptr, const void *bptr) {
unsigned long *a = *aptr;
const unsigned long *b = bptr;
(void)td;
/* Check if source has data */
if(!b) {
/* Clear destination */
if(a) {
FREEMEM(a);
*aptr = 0;
}
return 0;
}
if(!a) {
a = *aptr = MALLOC(sizeof(*a));
if(!a) return -1;
}
*a = *b;
return 0;
}

View File

@ -29,6 +29,7 @@ asn_struct_print_f NativeInteger_print;
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f NativeInteger_compare;
asn_struct_copy_f NativeInteger_copy;
#define NativeInteger_constraint asn_generic_no_constraint
@ -43,6 +44,7 @@ xer_type_encoder_f NativeInteger_encode_xer;
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
jer_type_decoder_f NativeInteger_decode_jer;
jer_type_encoder_f NativeInteger_encode_jer;
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */

View File

@ -63,8 +63,10 @@ NativeInteger_random_fill(const asn_TYPE_descriptor_t *td, void **sptr,
0, sizeof(variants) / sizeof(variants[0]) - 1)];
}
if(!constraints) constraints = &td->encoding_constraints;
#if !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT)
if(!constraints || !constraints->per_constraints)
constraints = &td->encoding_constraints;
const asn_per_constraints_t *ct;
ct = constraints ? constraints->per_constraints : 0;
@ -74,6 +76,8 @@ NativeInteger_random_fill(const asn_TYPE_descriptor_t *td, void **sptr,
ct->value.upper_bound);
}
}
#else
if(!constraints) constraints = &td->encoding_constraints;
#endif /* !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT) */
}

View File

@ -24,6 +24,7 @@ asn_TYPE_operation_t asn_OP_OBJECT_IDENTIFIER = {
0,
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare, /* Implemented in terms of a string comparison */
OCTET_STRING_copy, /* Implemented in terms of a string copy */
#if !defined(ASN_DISABLE_BER_SUPPORT)
ber_decode_primitive,
der_encode_primitive,
@ -39,9 +40,11 @@ asn_TYPE_operation_t asn_OP_OBJECT_IDENTIFIER = {
0,
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
OBJECT_IDENTIFIER_decode_jer,
OBJECT_IDENTIFIER_encode_jer,
#else
0,
0,
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
#if !defined(ASN_DISABLE_OER_SUPPORT)
OBJECT_IDENTIFIER_decode_oer,

View File

@ -32,6 +32,7 @@ asn_struct_print_f OBJECT_IDENTIFIER_print;
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define OBJECT_IDENTIFIER_compare OCTET_STRING_compare
#define OBJECT_IDENTIFIER_copy OCTET_STRING_copy
asn_constr_check_f OBJECT_IDENTIFIER_constraint;
@ -46,6 +47,7 @@ xer_type_encoder_f OBJECT_IDENTIFIER_encode_xer;
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
jer_type_decoder_f OBJECT_IDENTIFIER_decode_jer;
jer_type_encoder_f OBJECT_IDENTIFIER_encode_jer;
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */

View File

@ -26,6 +26,7 @@ asn_TYPE_operation_t asn_OP_OCTET_STRING = {
0,
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare,
OCTET_STRING_copy,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber,
OCTET_STRING_encode_der,
@ -41,9 +42,11 @@ asn_TYPE_operation_t asn_OP_OCTET_STRING = {
0,
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
OCTET_STRING_decode_jer_hex,
OCTET_STRING_encode_jer,
#else
0,
0,
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
#if !defined(ASN_DISABLE_OER_SUPPORT)
OCTET_STRING_decode_oer,
@ -247,6 +250,43 @@ OCTET_STRING_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
}
int
OCTET_STRING_copy(const asn_TYPE_descriptor_t *td, void **aptr,
const void *bptr) {
const asn_OCTET_STRING_specifics_t *specs =
td->specifics ? (const asn_OCTET_STRING_specifics_t *)td->specifics
: &asn_SPC_OCTET_STRING_specs;
OCTET_STRING_t *a = *aptr;
const OCTET_STRING_t *b = bptr;
if(!b) {
if(a) {
FREEMEM(a->buf);
a->buf = 0;
a->size = 0;
FREEMEM(a);
}
*aptr = 0;
return 0;
}
if(!a) {
a = *aptr = (OCTET_STRING_t *)CALLOC(1, specs->struct_size);
if(!a) return -1;
}
void *buf = MALLOC(b->size + 1);
if(!buf) return -1;
memcpy(buf, b->buf, b->size);
((uint8_t *)buf)[b->size] = '\0';
FREEMEM(a->buf);
a->buf = (uint8_t *)buf;
a->size = b->size;
return 0;
}
#if !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT)
int
OCTET_STRING_per_get_characters(asn_per_data_t *po, uint8_t *buf,

View File

@ -29,6 +29,7 @@ asn_struct_print_f OCTET_STRING_print_utf8;
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f OCTET_STRING_compare;
asn_struct_copy_f OCTET_STRING_copy;
#define OCTET_STRING_constraint asn_generic_no_constraint
@ -46,6 +47,8 @@ xer_type_encoder_f OCTET_STRING_encode_xer_utf8;
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
jer_type_decoder_f OCTET_STRING_decode_jer_hex; /* Hexadecimal */
jer_type_decoder_f OCTET_STRING_decode_jer_utf8; /* ASCII/UTF-8 */
jer_type_encoder_f OCTET_STRING_encode_jer;
jer_type_encoder_f OCTET_STRING_encode_jer_utf8;
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */

View File

@ -179,7 +179,6 @@ OCTET_STRING_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
raw_len = aper_get_length(pd, csiz->lower_bound, csiz->upper_bound,
csiz->effective_bits, &repeat);
if(raw_len < 0) RETURN(RC_WMORE);
raw_len += csiz->lower_bound;
ASN_DEBUG("Got PER length eb %ld, len %ld, %s (%s)",
(long)csiz->effective_bits, (long)raw_len,

View File

@ -14,6 +14,7 @@ asn_TYPE_operation_t asn_OP_OPEN_TYPE = {
0,
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OPEN_TYPE_compare,
OPEN_TYPE_copy,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OPEN_TYPE_decode_ber,
OPEN_TYPE_encode_der,
@ -29,9 +30,11 @@ asn_TYPE_operation_t asn_OP_OPEN_TYPE = {
0,
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
OPEN_TYPE_decode_jer,
OPEN_TYPE_encode_jer,
#else
0,
0,
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
#if !defined(ASN_DISABLE_OER_SUPPORT)
OPEN_TYPE_decode_oer,

View File

@ -33,6 +33,7 @@ extern "C" {
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define OPEN_TYPE_compare CHOICE_compare
#define OPEN_TYPE_copy CHOICE_copy
#define OPEN_TYPE_constraint CHOICE_constraint
@ -59,6 +60,13 @@ asn_dec_rval_t OPEN_TYPE_xer_get(
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
asn_dec_rval_t OPEN_TYPE_jer_get(
const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *parent_type,
void *parent_structure,
const asn_TYPE_member_t *element,
const void *ptr, size_t size);
#define OPEN_TYPE_decode_jer NULL
#define OPEN_TYPE_encode_jer CHOICE_encode_jer
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
@ -70,7 +78,10 @@ asn_dec_rval_t OPEN_TYPE_oer_get(
asn_TYPE_member_t *element, const void *ptr,
size_t size);
#define OPEN_TYPE_decode_oer NULL
#define OPEN_TYPE_encode_oer CHOICE_encode_oer
asn_enc_rval_t OPEN_TYPE_encode_oer(
const asn_TYPE_descriptor_t *type_descriptor,
const asn_oer_constraints_t *constraints, const void *struct_ptr,
asn_app_consume_bytes_f *consume_bytes_cb, void *app_key);
#endif /* !defined(ASN_DISABLE_OER_SUPPORT) */
#if !defined(ASN_DISABLE_UPER_SUPPORT)

View File

@ -53,7 +53,8 @@ OPEN_TYPE_aper_get(const asn_codec_ctx_t *opt_codec_ctx,
(char *)*memb_ptr2
+ elm->type->elements[selected.presence_index - 1].memb_offset;
rv = aper_open_type_get(opt_codec_ctx, selected.type_descriptor, NULL,
rv = aper_open_type_get(opt_codec_ctx, selected.type_descriptor,
elm->type->elements[selected.presence_index - 1].encoding_constraints.per_constraints,
&inner_value, pd);
switch(rv.code) {
case RC_OK:
@ -110,7 +111,7 @@ OPEN_TYPE_encode_aper(const asn_TYPE_descriptor_t *td,
memb_ptr = (const char *)sptr + elm->memb_offset;
}
if(aper_open_type_put(elm->type, NULL, memb_ptr, po) < 0) {
if(aper_open_type_put(elm->type, elm->encoding_constraints.per_constraints, memb_ptr, po) < 0) {
ASN__ENCODE_FAILED;
}

View File

@ -20,6 +20,7 @@ asn_TYPE_operation_t asn_OP_ObjectDescriptor = {
0,
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare,
OCTET_STRING_copy,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der,
@ -35,9 +36,11 @@ asn_TYPE_operation_t asn_OP_ObjectDescriptor = {
0,
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
OCTET_STRING_decode_jer_utf8,
OCTET_STRING_encode_jer_utf8,
#else
0,
0,
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
#if !defined(ASN_DISABLE_OER_SUPPORT)
0,

View File

@ -35,6 +35,7 @@ extern asn_TYPE_operation_t asn_OP_ObjectDescriptor;
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
#define ObjectDescriptor_decode_jer OCTET_STRING_decode_jer_utf8
#define ObjectDescriptor_encode_jer OCTET_STRING_encode_jer_utf8
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */

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