Compare commits

...

82 Commits

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
3819 changed files with 14089 additions and 6445 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:

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
docker/debian/bookworm Symbolic link
View File

@ -0,0 +1 @@
latest

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

@ -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
@ -428,11 +428,39 @@ $ 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

@ -495,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

@ -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,62 @@ 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.
@ -429,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

@ -147,7 +147,7 @@ If there is a need to change the Core Network component configuration, then corr
- Provision SIM details in open5gs HSS
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
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

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,6 +38,10 @@ 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)
@ -69,7 +73,6 @@ head_inline: "<style> ul { padding-bottom: 1em; } </style>"
- [VPP-UPF with DPDK](https://github.com/s5uishida/open5gs_5gc_ueransim_vpp_upf_dpdk_sample_config)
- [UERANSIM with eUPF(eBPF/XDP UPF)](https://github.com/s5uishida/open5gs_5gc_ueransim_eupf_sample_config)
- [srsRAN with eUPF(eBPF/XDP UPF)](https://github.com/s5uishida/open5gs_epc_srsran_eupf_sample_config)
- [Measurement of UPF Performance](https://github.com/s5uishida/simple_measurement_of_upf_performance)
- @gradiant helm charts
- [Open5GS EPC and SRS LTE in kubernetes](https://gradiant.github.io/openverso-charts/open5gs-srslte.html)

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
*/
@ -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) */

View File

@ -57,6 +57,7 @@ asn_TYPE_operation_t asn_OP_PrintableString = {
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,
@ -72,9 +73,11 @@ asn_TYPE_operation_t asn_OP_PrintableString = {
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)
OCTET_STRING_decode_oer,

View File

@ -23,6 +23,7 @@ extern asn_TYPE_operation_t asn_OP_PrintableString;
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define PrintableString_compare OCTET_STRING_compare
#define PrintableString_copy OCTET_STRING_copy
asn_constr_check_f PrintableString_constraint;
@ -37,6 +38,7 @@ asn_constr_check_f PrintableString_constraint;
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
#define PrintableString_decode_jer OCTET_STRING_decode_jer_utf8
#define PrintableString_encode_jer OCTET_STRING_encode_jer_utf8
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */

View File

@ -21,6 +21,7 @@ asn_TYPE_operation_t asn_OP_UTF8String = {
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,
@ -36,9 +37,11 @@ asn_TYPE_operation_t asn_OP_UTF8String = {
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)
OCTET_STRING_decode_oer,

View File

@ -23,6 +23,7 @@ asn_struct_print_f UTF8String_print;
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define UTF8String_compare OCTET_STRING_compare
#define UTF8String_copy OCTET_STRING_copy
asn_constr_check_f UTF8String_constraint;
@ -37,6 +38,7 @@ asn_constr_check_f UTF8String_constraint;
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
#define UTF8String_decode_jer OCTET_STRING_decode_jer_utf8
#define UTF8String_encode_jer OCTET_STRING_encode_jer_utf8
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */

View File

@ -27,6 +27,7 @@ asn_TYPE_operation_t asn_OP_VisibleString = {
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,
@ -42,9 +43,11 @@ asn_TYPE_operation_t asn_OP_VisibleString = {
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)
OCTET_STRING_decode_oer,

View File

@ -23,6 +23,7 @@ extern asn_TYPE_operation_t asn_OP_VisibleString;
#endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define VisibleString_compare OCTET_STRING_compare
#define VisibleString_copy OCTET_STRING_copy
asn_constr_check_f VisibleString_constraint;
@ -37,6 +38,7 @@ asn_constr_check_f VisibleString_constraint;
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
#define VisibleString_decode_jer OCTET_STRING_decode_jer_hex
#define VisibleString_encode_jer OCTET_STRING_encode_jer
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */

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