Compare commits

...

37 Commits

Author SHA1 Message Date
Pau Espin c6c73c1f70 MME: Gn: Fill PDP Context requested from SGSN with IP allocated by SMF
IP assigned from SMF: session->paa
Static IP read from the Subscriber DB: session->ue_ip

When passing the PDP context information to the SGSN, we actually wanna
provide it with the IP address currently in use.
2024-05-22 07:14:53 +09:00
Pau Espin f401e7df14 Revert "[MME] Fixed ttcn3-mme-test-ogs (#2806) (#315)"
This reverts commit 87d9cdf569.
2024-05-22 07:14:53 +09:00
Sukchan Lee 87d9cdf569 [MME] Fixed ttcn3-mme-test-ogs (#2806) (#315)
Try to fix the following error

"MME_Tests.ttcn:955 : no SGSN Context Response from MME"
      MME_Tests.ttcn:1572 MME_Tests control part
      MME_Tests.ttcn:1457 TC_ue_cell_reselect_eutran_to_geran testcase
2024-05-21 21:06:17 +09:00
Sukchan Lee 02d302b15a [SEC] Fix Assertion ogs_pfcp_parse_volume (#3207) 2024-05-18 21:37:28 +09:00
Sukchan Lee 15ff23de75 [SEC] Fix Assertion ogs_pfcp_parse_sdf_filter (#3207) 2024-05-18 21:37:28 +09:00
Sukchan Lee b1bf2b10e2 [SEC] Fix Assertion ogs_pfcp_f_seid_to_ip (#3207) 2024-05-18 21:37:28 +09:00
Sukchan Lee bd4d925f0f [SEC] Fix Assertion ogs_pfcp_parse_user_plane_ip_resource_info() (#3207) 2024-05-18 21:37:28 +09:00
Sukchan Lee 5f425445a8 [SEC] Fix Assertion ogs_gtp2_parse_uli (#3209) 2024-05-18 21:37:28 +09:00
Sukchan Lee 05deed616c [SEC] fix Assertion `0 < ogs_fadn_parse` (#3207) 2024-05-18 21:37:28 +09:00
Sukchan Lee 4599b273fa [MME] Problem keep changing PDN-Type (#3209)
If the UE continuously attempts to Attach while changing PDN Type,
it will cause the wrong IP to be assigned.
(e.g PDU-Type : IPv4v6 -> IPv4 -> IPv4v6)

This is because we use two variables at the same time,
one to read and store the Static IP from the Subscriber DB and
one to store the IP assigned from SMF, called session->paa.

When the UE attaches with PDN-Type set to IPv4v6,
MME saves the allocated IP in session->paa.

However, MME thinks it has been assigned a static IP based on the information
in session->paa, so changing the PDN-Type may result in the wrong IP
being assigned.

To solve this problem, I separated the variable(session->paa) that stores
the allocated IP received from SMF and the variable(session->ue_ip) that stores
the Static IP read from the Subscriber DB.

Therefore, the information read from the Subscriber DB
(session->session_type and session->ue_ip) should not be modified.
2024-05-18 14:01:00 +09:00
Sukchan Lee bba0ebe6a4 [SEC] crash for IMSI/MSISDN/IMEI overflow (#3207)
When using ogs_buffer_to_bcd(), an overflow occurs if the input buffer length
is larger than the output bcd size, causing a crash.

We adjusted the size of the input buffer length using ogs_min as follows.
```
    sgwc_ue->imsi_len = ogs_min(imsi_len, OGS_MAX_IMSI_LEN);
    memcpy(sgwc_ue->imsi, imsi, sgwc_ue->imsi_len);
    ogs_buffer_to_bcd(sgwc_ue->imsi, sgwc_ue->imsi_len, sgwc_ue->imsi_bcd);
```
2024-05-17 20:25:49 +09:00
Sukchan Lee 80ab4c4a1b [NF] Move ogs_log_config_domain() location (#3210)
When we run the test, for example,
./tests/registration/registration simple-init,
wee get an INFO message like the one below.

```
05/17 14:24:03.933: [sbi] INFO: NF EndPoint(addr) setup [127.0.0.200:7777] (../lib/sbi/context.c:474)
```

When we run the code in Open5GS, the log level initially defaults to INFO.

However, for test code, we change the log level to ERROR
by automatically inserting the -e error option into argv.

The reason for this is to prevent WARNING and INFO messages
from appearing when the test code is run.

However, the log level to ERROR is changed at the bottom of
the initialize routine, which caused the above message
to be printed during testing.

To prevent this from being printed, I modified the code
to change that log level to ERROR a little earlier.
2024-05-17 14:54:32 +09:00
Sukchan Lee 95de14c72b [SBI] SearchResult.validityPeriod 3600->30s (#3210)
The validity time for NF Instances obtained through NF Discovery was
not properly implemented. Since the validity was 3600 seconds(1 hour),
which caused 5G Core to not work properly after 3600 seconds(1 hour).

There was an issue where an NF Instance should be deleted
when its validity time expired, but it was not working correctly
due to incorrect use of reference count.

Therefore, I have modified the Validity of NF Instances obtained
through NF Discovery to work properly.

I also changed the default value of valdityPeriod to 30 seconds.
2024-05-17 14:54:32 +09:00
Sukchan Lee 7a9fea8aec [SBI] Re-factor NF Instance Context (#3093)
Fixed not using Reference Count for adding/deleting NF Instances.

Up until now, NF Instances have been managed by referencing the Reference Count.

Initially, when an NF Instance is added, the Reference Count is incremented and
when it is deleted, the Reference Count is decremented.

If a UE discovers another NF Instance through the NF Discovery function,
the Reference Count is incremented. And if a UE de-registers,
the Reference Count of the discovered NF is decremented.

However, there's a problem with this approach.

When other NF is de-registered,
there is no guarantee that it will be 100% notified.

For example, if a UDM is de-registered, but an SCP is de-registered before it,
the AMF will not be notified that the UDM has been de-registered.

In situations where this is not clear, Reference Count cannot be used.

Therefore, we have modified it to not use the Reference Count method.

Also, when a UE connects, it is modified to always search
whether an NF Instance exists by NF Instance ID whenever it is discovered.

To do this, we modified lib/sbi/path.c as shown below.

```diff
@@ -281,13 +281,15 @@ int ogs_sbi_discover_and_send(ogs_sbi_xact_t *xact)
     }

     /* Target NF-Instance */
-    nf_instance = sbi_object->service_type_array[service_type].nf_instance;
+    nf_instance = ogs_sbi_nf_instance_find(
+            sbi_object->service_type_array[service_type].nf_instance_id);
     if (!nf_instance) {
         nf_instance = ogs_sbi_nf_instance_find_by_discovery_param(
                         target_nf_type, requester_nf_type, discovery_option);
-        if (nf_instance)
-            OGS_SBI_SETUP_NF_INSTANCE(
-                    sbi_object->service_type_array[service_type], nf_instance);
+        if (nf_instance) {
+            OGS_SBI_SETUP_NF_INSTANCE_ID(
+                    sbi_object->service_type_array[service_type], nf_instance->id);
+        }
     }
```
2024-05-12 10:24:15 +09:00
Sukchan Lee 9d8d560be7 [DOCKER] Change UID from 1000 to 2000
The ubuntu docker image defaults to UID 1000 as the ubuntu username,
so change the UID of the open5gs default user acetcom to 2000.
2024-05-11 16:26:04 +09:00
Daniel Willmann eb28c514ea [MME] s11: Allow CreateSessionResponse with no S5c TEID IE
The TEID is already known (provided by SGSN through Gn SGSNContextResponse),
so not mandatory for it to be set.
2024-05-11 01:07:45 +02:00
Pau Espin f16f6e3c6c [MME] s11: Allow CreateSessionResponse with no PAA IE
The PAA is already known (provided by SGSN through Gn SGSNContextResponse),
so not mandatory for it to be set.
2024-05-11 01:07:45 +02:00
Pau Espin 190b39a75c cosmetic: [MME] Fix wrong content in comment line 2024-05-11 01:07:45 +02:00
Sukchan Lee 87b4e4535c [SEC] Stack overflow in PCRF/PCF (#3157)
The indexes rx_message.ims_data.num_of_media_component and media_component->num_of_sub can overflow.

```
static int pcrf_rx_aar_cb( struct msg **msg, struct avp *avp,
        struct session *sess, void *opaque, enum disp_action *act)
..
        /* Gwt Specific-Action */
        case OGS_DIAM_RX_AVP_CODE_SPECIFIC_ACTION:
            break;
        /* Gwt Media-Component-Description */
        case OGS_DIAM_RX_AVP_CODE_MEDIA_COMPONENT_DESCRIPTION:
            media_component = &rx_message.ims_data.
                    media_component[rx_message.ims_data.num_of_media_component];

            ret = fd_msg_browse(avpch1, MSG_BRW_FIRST_CHILD, &avpch2, NULL);
            ogs_assert(ret == 0);
            while (avpch2) {
                ret = fd_msg_avp_hdr(avpch2, &hdr);
..
                }

                fd_msg_browse(avpch2, MSG_BRW_NEXT, &avpch2, NULL);
            }

            rx_message.ims_data.num_of_media_component++;
            break;
        default:
            ogs_warn("Not supported(%d)", hdr->avp_code);
            break;
        }
..
}
```
2024-05-01 16:52:10 +09:00
Sukchan Lee b57722178a [SEC] Heap overflow in open5gs-mmed/s1ap (#3153)
Assert shall be triggered if the mme_enb_t object is corrupted.

```
$ gdb -q -p `pidof open5gs-mmed`
..
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
0x0000ffff90deb46c in __GI___sigtimedwait (set=set@entry=0xfffffe63be68, info=info@entry=0xfffffe63bda8, timeout=timeout@entry=0x0) at ../sysdeps/unix/sysv/linux/sigtimedwait.c:61
61      ../sysdeps/unix/sysv/linux/sigtimedwait.c: No such file or directory.
Breakpoint 1 at 0xaaaabef69250: file ../src/mme/s1ap-handler.c, line 199.
[Switching to Thread 0xffff1efdef00 (LWP 20348)]

Thread 38 "open5gs-mmed" hit Breakpoint 1, s1ap_handle_s1_setup_request (enb=0xffff9029b5a0, message=0xffff1efdc498) at ../src/mme/s1ap-handler.c:199
warning: Source file is more recent than executable.
199         if (maximum_number_of_enbs_is_reached()) {
(gdb) p enb.supported_ta_list
$1 = {{plmn_id = {mcc1 = 0 '\000', mcc2 = 0 '\000', mcc3 = 1 '\001', mnc1 = 15 '\017', mnc2 = 0 '\000', mnc3 = 1 '\001'}, tac = 1} <repeats 256 times>}
(gdb) p enb
$2 = (mme_enb_t *) 0xffff9029b5a0
(gdb) p *enb
$3 = {lnode = {prev = 0x0, next = 0x0}, sm = {init = 0xaaaabef66540 <s1ap_state_initial>, fini = 0xaaaabef66640 <s1ap_state_final>, state = 0xaaaabef66730 <s1ap_state_operational>}, enb_id = 1, plmn_id = {
    mcc1 = 1 '\001', mcc2 = 2 '\002', mcc3 = 3 '\003', mnc1 = 15 '\017', mnc2 = 4 '\004', mnc3 = 5 '\005'}, sctp = {type = 1, sock = 0xfffedc000bd0, addr = 0xfffedc000e70, poll = {read = 0xffff9032a0f0,
      write = 0x0}, write_queue = {prev = 0x0, next = 0x0}}, state = {s1_setup_success = false}, max_num_of_ostreams = 30, ostream_id = 0, num_of_supported_ta_list = 258, supported_ta_list = {{plmn_id = {
        mcc1 = 0 '\000', mcc2 = 0 '\000', mcc3 = 1 '\001', mnc1 = 15 '\017', mnc2 = 0 '\000', mnc3 = 1 '\001'}, tac = 1} <repeats 256 times>}, s1_reset_ack = 0x10f100000110f100, enb_ue_list = {prev = 0x1,
    next = 0x0}}
pwndbg> vmmap enb
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
             Start                End Perm     Size Offset File
    0xffff8edd4000     0xffff8ede4000 ---p    10000      0 [anon_ffff8edd4]
►   0xffff8ede4000     0xffff90650000 rw-p  186c000      0 [anon_ffff8ede4] +0x1517010
    0xffff90650000     0xffff90659000 r-xp     9000      0 /usr/lib/aarch64-linux-gnu/libffi.so.8.1.0
```

The value s1_reset_ack = 0x10f100000110f100 shall contain a function pointer, but has been corrupted.

The following patch will abort the process:

```diff
$ diff --git a/src/mme/s1ap-handler.c b/src/mme/s1ap-handler.c
index dff401ded..55a1f7e1b 100644
--- a/src/mme/s1ap-handler.c
+++ b/src/mme/s1ap-handler.c
@@ -178,6 +178,7 @@ void s1ap_handle_s1_setup_request(mme_enb_t *enb, ogs_s1ap_message_t *message)
                 SupportedTAs_Item->broadcastPLMNs.list.array[j];
             ogs_assert(pLMNidentity);

+           ogs_assert(enb->num_of_supported_ta_list < OGS_ARRAY_SIZE(enb->supported_ta_list));
             memcpy(&enb->supported_ta_list[enb->num_of_supported_ta_list].tac,
                     tAC->buf, sizeof(uint16_t));
             enb->supported_ta_list[enb->num_of_supported_ta_list].tac =
@@ -310,6 +311,7 @@ void s1ap_handle_enb_configuration_update(
                     SupportedTAs_Item->broadcastPLMNs.list.array[j];
                 ogs_assert(pLMNidentity);

+               ogs_assert(enb->num_of_supported_ta_list < OGS_ARRAY_SIZE(enb->supported_ta_list));
                 memcpy(&enb->supported_ta_list[
                         enb->num_of_supported_ta_list].tac,
                         tAC->buf, sizeof(uint16_t));
```
2024-05-01 16:25:33 +09:00
Sukchan Lee 7ea82cb87b [SEC] Heap overflow in open5gs-mmed/s6a (#3156)
An assert shall be triggered.

The vulnerable code path is in src/mme/mme-fd-path.c:

```
/* s6a process Subscription-Data from avp */
static int mme_s6a_subscription_data_from_avp(struct avp *avp,
    ogs_subscription_data_t *subscription_data,
    mme_ue_t *mme_ue, uint32_t *subdatamask)
{
...
    /* AVP: 'MSISDN'( 701 )
     * The MSISDN AVP is of type OctetString. This AVP contains an MSISDN,
     * in international number format as described in ITU-T Rec E.164 [8],
     * encoded as a TBCD-string, i.e. digits from 0 through 9 are encoded
     * 0000 to 1001; 1111 is used as a filler when there is an odd number
     * of digits; bits 8 to 5 of octet n encode digit 2n; bits 4 to 1 of
     * octet n encode digit 2(n-1)+1.
     * Reference: 3GPP TS 29.329
     */
    ret = fd_avp_search_avp(avp, ogs_diam_s6a_msisdn, &avpch1);
    ogs_assert(ret == 0);
    if (avpch1) {
        ret = fd_msg_avp_hdr(avpch1, &hdr);
        ogs_assert(ret == 0);
        if (hdr->avp_value->os.data && hdr->avp_value->os.len) {
            mme_ue->msisdn_len = hdr->avp_value->os.len;                /* 1 */
            memcpy(mme_ue->msisdn, hdr->avp_value->os.data,
                    ogs_min(mme_ue->msisdn_len, OGS_MAX_MSISDN_LEN));   /* 2 */
            ogs_buffer_to_bcd(mme_ue->msisdn,
                    mme_ue->msisdn_len, mme_ue->msisdn_bcd);            /* 3 */
            *subdatamask = (*subdatamask | OGS_DIAM_S6A_SUBDATA_MSISDN);
        }
    }
```
2024-05-01 14:51:11 +09:00
Sukchan Lee e89aa79efe [SEC] Stack overflow in open5gs-hssd/s6a (#3155)
An assert shall be triggered if a stack corruption occurs.

The vulnerable code path is in src/hss/hss-s6a-path.c:

```
static int hss_ogs_diam_s6a_air_cb( struct msg **msg, struct avp *avp,
        struct session *session, void *opaque, enum disp_action *act)
{
..
    ogs_plmn_id_t visited_plmn_id;
..
    ret = fd_msg_search_avp(qry, ogs_diam_visited_plmn_id, &avp);
    ogs_assert(ret == 0);
    ret = fd_msg_avp_hdr(avp, &hdr);
    ogs_assert(ret == 0);
    memcpy(&visited_plmn_id, hdr->avp_value->os.data, hdr->avp_value->os.len);
```
2024-04-30 22:25:52 +09:00
Sukchan Lee 048a74005b [SEC] Heap overflow in parse PLMN-ID (#3154)
An assert shall be triggered if sepp_node is corrupted.

```
pwndbg> p *sepp_node
$5 = {
  lnode = {
    prev = 0x0,
    next = 0xaaaac920c638
  },
  receiver = 0xaaaac9230990 "sepp2.localdomain",
  negotiated_security_scheme = OpenAPI_security_capability_TLS,
  target_apiroot_supported = true,
  plmn_id = {{
      mcc1 = 6 '\006',
      mcc2 = 6 '\006',
      mcc3 = 6 '\006',
      mnc1 = 6 '\006',
      mnc2 = 6 '\006',
      mnc3 = 6 '\006'
    } <repeats 12 times>},
  num_of_plmn_id = 6710887,
  target_plmn_id_presence = false,
  target_plmn_id = {
    mcc1 = 0 '\000',
    mcc2 = 0 '\000',
    mcc3 = 0 '\000',
    mnc1 = 0 '\000',
    mnc2 = 0 '\000',
    mnc3 = 0 '\000'
  },
  supported_features = 1,
  sm = {
    init = 0xaaaaada181fc <sepp_handshake_state_initial>,
    fini = 0xaaaaada18390 <sepp_handshake_state_final>,
    state = 0xaaaaada194b4 <sepp_handshake_state_established>
  },
  t_establish_interval = 0xffffa7d6c4e0,
  client = 0xaaaac91af010,
  n32f = {
    client = 0xaaaac91af090
  }
}
pwndbg> p/x sepp_node.num_of_plmn_id
$6 = 0x666667
```
2024-04-30 22:10:45 +09:00
Sukchan Lee f6c0ded7b4 [NSSF] Added POST nnrf-nfm/nf-status-notify
When NSSF was first implemented, nf-status-notify was not required.

This is because there was no need to be notified
if other NFs were registered or de-registered in the NRF.

However, this situation changed with the addition of SEPP.

NSSFs can be notified whenever a SEPP registers or de-registers an NRF.

Therefore, we added nf-status-notify,
which was not implemented when the NSSF was originally created.
2024-04-30 21:35:42 +09:00
Sukchan Lee 819861be2f [DOCS] Update Helm Chars Links (#3173) 2024-04-27 09:18:11 +09:00
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
189 changed files with 2664 additions and 1102 deletions

View File

@ -2,51 +2,51 @@ name: Meson Continuous Integration
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
macos-latest: # macos-latest:
name: Build and Test on MacOS Latest # name: Build and Test on MacOS Latest
runs-on: macos-latest # runs-on: macos-latest
steps: # steps:
# - name: Install MongoDB with Package Manager ## - name: Install MongoDB with Package Manager
## run: |
## brew tap mongodb/brew
## brew install mongodb-community
## brew services start mongodb-community
# - name: Create the TUN device with the interface name `ogstun`.
# run: | # run: |
# brew tap mongodb/brew # sudo ifconfig lo0 alias 127.0.0.2 netmask 255.255.255.255
# brew install mongodb-community # sudo ifconfig lo0 alias 127.0.0.3 netmask 255.255.255.255
# brew services start mongodb-community # sudo ifconfig lo0 alias 127.0.0.4 netmask 255.255.255.255
- name: Create the TUN device with the interface name `ogstun`. # sudo ifconfig lo0 alias 127.0.0.5 netmask 255.255.255.255
run: | # sudo ifconfig lo0 alias 127.0.0.5 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.2 netmask 255.255.255.255 # sudo ifconfig lo0 alias 127.0.0.6 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.3 netmask 255.255.255.255 # sudo ifconfig lo0 alias 127.0.0.7 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.4 netmask 255.255.255.255 # sudo ifconfig lo0 alias 127.0.0.8 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.5 netmask 255.255.255.255 # sudo ifconfig lo0 alias 127.0.0.9 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.5 netmask 255.255.255.255 # sudo ifconfig lo0 alias 127.0.0.10 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.6 netmask 255.255.255.255 # sudo ifconfig lo0 alias 127.0.0.11 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.7 netmask 255.255.255.255 # sudo ifconfig lo0 alias 127.0.0.12 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.8 netmask 255.255.255.255 # sudo ifconfig lo0 alias 127.0.0.13 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.9 netmask 255.255.255.255 # sudo ifconfig lo0 alias 127.0.0.14 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.10 netmask 255.255.255.255 # sudo ifconfig lo0 alias 127.0.0.15 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.11 netmask 255.255.255.255 # sudo ifconfig lo0 alias 127.0.0.16 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.12 netmask 255.255.255.255 # sudo ifconfig lo0 alias 127.0.0.17 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.13 netmask 255.255.255.255 # sudo ifconfig lo0 alias 127.0.0.18 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.14 netmask 255.255.255.255 # sudo ifconfig lo0 alias 127.0.0.19 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.15 netmask 255.255.255.255 # sudo ifconfig lo0 alias 127.0.0.20 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.16 netmask 255.255.255.255 # sudo ifconfig lo0 alias 127.0.1.10 netmask 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.17 netmask 255.255.255.255 # - name: Install the dependencies for building the source code.
sudo ifconfig lo0 alias 127.0.0.18 netmask 255.255.255.255 # run: brew install mongo-c-driver libidn libmicrohttpd nghttp2 bison libusrsctp libtins talloc meson
sudo ifconfig lo0 alias 127.0.0.19 netmask 255.255.255.255 # - name: Check out repository code
sudo ifconfig lo0 alias 127.0.0.20 netmask 255.255.255.255 # uses: actions/checkout@main
sudo ifconfig lo0 alias 127.0.1.10 netmask 255.255.255.255 # - name: Setup Meson Build
- name: Install the dependencies for building the source code. # run: PATH="/usr/local/opt/bison/bin:$PATH" PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig:$PKG_CONFIG_PATH" meson setup build
run: brew install mongo-c-driver libidn libmicrohttpd nghttp2 bison libusrsctp libtins talloc meson # env:
- name: Check out repository code # CC: gcc
uses: actions/checkout@main # - name : Build Open5GS
- name: Setup Meson Build # run: ninja -C build
run: PATH="/usr/local/opt/bison/bin:$PATH" PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig:$PKG_CONFIG_PATH" meson setup build # - name: Test Open5GS
env: # run: sudo meson test -C build -v crypt unit
CC: gcc #
- name : Build Open5GS
run: ninja -C build
- name: Test Open5GS
run: sudo meson test -C build -v crypt unit
ubuntu-latest: ubuntu-latest:
name: Build and Test on Ubuntu Latest name: Build and Test on Ubuntu Latest
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,6 +5,14 @@ Name=ogstun
Address=10.45.0.1/16 Address=10.45.0.1/16
Address=2001:db8:cafe::1/48 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] [Link]
MTUBytes=1400 MTUBytes=1400
RequiredForOnline=false RequiredForOnline=false

View File

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

View File

@ -110,8 +110,9 @@ smf:
server: server:
- address: 127.0.0.4 - address: 127.0.0.4
session: session:
- subnet: 10.45.0.1/16 - subnet: 10.45.0.0/16
- subnet: 2001:db8:cafe::1/48 gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
dns: dns:
- 8.8.8.8 - 8.8.8.8
- 8.8.4.4 - 8.8.4.4
@ -193,8 +194,9 @@ upf:
server: server:
- address: 127.0.0.7 - address: 127.0.0.7
session: session:
- subnet: 10.45.0.1/16 - subnet: 10.45.0.0/16
- subnet: 2001:db8:cafe::1/48 gateway: 10.45.0.1
- subnet: 2001:db8:cafe::/48
metrics: metrics:
server: server:
- address: 127.0.0.7 - 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 open5gs (2.7.0) unstable; urgency=medium
* 5G Roaming with SEPP * 5G Roaming with SEPP

View File

@ -13,7 +13,7 @@ RUN apk update && \
sudo sudo
ARG username=acetcom ARG username=acetcom
RUN adduser -u 1000 acetcom -D && \ RUN adduser -u 2000 acetcom -D && \
echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} && \ echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} && \
chmod 0440 /etc/sudoers.d/${username} chmod 0440 /etc/sudoers.d/${username}

View File

@ -27,7 +27,7 @@ RUN apt-get update && \
COPY setup.sh /root COPY setup.sh /root
ARG username=acetcom ARG username=acetcom
RUN useradd -m --uid=1000 ${username} && \ RUN useradd -m --uid=2000 ${username} && \
echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} && \ echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} && \
chmod 0440 /etc/sudoers.d/${username} chmod 0440 /etc/sudoers.d/${username}

View File

@ -16,7 +16,7 @@ RUN dnf -y install \
COPY setup.sh /root COPY setup.sh /root
ARG username=acetcom ARG username=acetcom
RUN useradd -m --uid=1000 ${username} && \ RUN useradd -m --uid=2000 ${username} && \
echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} && \ echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} && \
chmod 0440 /etc/sudoers.d/${username} chmod 0440 /etc/sudoers.d/${username}

View File

@ -33,7 +33,7 @@ RUN apt-get update && \
COPY setup.sh /root COPY setup.sh /root
ARG username=acetcom ARG username=acetcom
RUN useradd -m --uid=1000 ${username} && \ RUN useradd -m --uid=2000 ${username} && \
echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} && \ echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} && \
chmod 0440 /etc/sudoers.d/${username} chmod 0440 /etc/sudoers.d/${username}

View File

@ -428,6 +428,34 @@ $ sudo systemctl restart open5gs-amfd
$ sudo systemctl restart open5gs-upfd $ 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 #### Register Subscriber Information
--- ---

View File

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

View File

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

View File

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

View File

@ -75,8 +75,10 @@ head_inline: "<style> ul { padding-bottom: 1em; } </style>"
- [srsRAN with eUPF(eBPF/XDP UPF)](https://github.com/s5uishida/open5gs_epc_srsran_eupf_sample_config) - [srsRAN with eUPF(eBPF/XDP UPF)](https://github.com/s5uishida/open5gs_epc_srsran_eupf_sample_config)
- @gradiant helm charts - @gradiant helm charts
- [Open5GS EPC and SRS LTE in kubernetes](https://gradiant.github.io/openverso-charts/open5gs-srslte.html) - [Open5GS and srsRAN-5G in kubernetes](https://gradiant.github.io/5g-charts/open5gs-srsran-5g-zmq.html)
- [Open5GS NGC and UERANSIM in kubernetes](https://gradiant.github.io/openverso-charts/open5gs-ueransim-gnb.html) - [Open5GS and srsLTE in kubernetes](https://gradiant.github.io/5g-charts/open5gs-srslte.html)
- [Open5GS NGC and OpenAirInterface GNB with ettus USRP in kubernetes](https://gradiant.github.io/openverso-charts/open5gs-oaignb.html) - [Open5GS and UERANSIM](https://gradiant.github.io/5g-charts/open5gs-ueransim-gnb.html)
- [Open5GS EPC and SRS ENB with ettus USRP in kubernetes](https://gradiant.github.io/openverso-charts/open5gs-srsenb.html) - [Open5GS and PacketRusher](https://gradiant.github.io/5g-charts/open5gs-packetrusher.html)
- [Open5GS with Service Communication Proxy in kubernetes](https://gradiant.github.io/openverso-charts/open5gs-scp.html) - [Open5GS and OAI-GNB](https://gradiant.github.io/5g-charts/open5gs-oaignb.html)
- [Open5GS and srsenb](https://gradiant.github.io/5g-charts/open5gs-srsenb.html)
- [Open5GS with SCP(Service Communication Proxy](https://gradiant.github.io/5g-charts/open5gs-scp.html)

View File

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

@ -408,8 +408,8 @@ static int local_conf_prepare(void)
* Heartbeat Interval(e.g: 10 seconds) + No Heartbeat Margin(1 second) */ * Heartbeat Interval(e.g: 10 seconds) + No Heartbeat Margin(1 second) */
local_conf.time.nf_instance.no_heartbeat_margin = 1; local_conf.time.nf_instance.no_heartbeat_margin = 1;
/* 3600 seconds = 1 hour */ /* 30 seconds */
local_conf.time.nf_instance.validity_duration = 3600; local_conf.time.nf_instance.validity_duration = 30;
/* 86400 seconds = 1 day */ /* 86400 seconds = 1 day */
local_conf.time.subscription.validity_duration = 86400; local_conf.time.subscription.validity_duration = 86400;

View File

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

View File

@ -114,6 +114,9 @@ int ogs_app_initialize(
ogs_app()->logger.domain, ogs_app()->logger.level); ogs_app()->logger.domain, ogs_app()->logger.level);
if (rv != OGS_OK) return rv; if (rv != OGS_OK) return rv;
ogs_log_set_timestamp(ogs_app()->logger_default.timestamp,
ogs_app()->logger.timestamp);
/************************************************************************** /**************************************************************************
* Stage 5 : Setup Database Module * Stage 5 : Setup Database Module
*/ */
@ -254,6 +257,57 @@ static int context_validation(void)
return OGS_OK; 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) static int parse_config(void)
{ {
int rv; int rv;
@ -278,9 +332,8 @@ static int parse_config(void)
while (ogs_yaml_iter_next(&logger_iter)) { while (ogs_yaml_iter_next(&logger_iter)) {
const char *logger_key = ogs_yaml_iter_key(&logger_iter); const char *logger_key = ogs_yaml_iter_key(&logger_iter);
ogs_assert(logger_key); ogs_assert(logger_key);
if (!strcmp(logger_key, "file")) { parse_config_logger_file(&logger_iter, logger_key);
ogs_app()->logger.file = ogs_yaml_iter_value(&logger_iter); if (!strcmp(logger_key, "level")) {
} else if (!strcmp(logger_key, "level")) {
ogs_app()->logger.level = ogs_app()->logger.level =
ogs_yaml_iter_value(&logger_iter); ogs_yaml_iter_value(&logger_iter);
} else if (!strcmp(logger_key, "domain")) { } 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; 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) int ogs_yaml_iter_bool(ogs_yaml_iter_t *iter)
{ {
const char *v = ogs_yaml_iter_value(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); 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_key(ogs_yaml_iter_t *iter);
const char *ogs_yaml_iter_value(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); int ogs_yaml_iter_bool(ogs_yaml_iter_t *iter);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -340,6 +340,28 @@ void ogs_log_set_mask_level(const char *_mask, ogs_log_level_e level)
} }
} }
void ogs_log_set_timestamp(ogs_log_ts_e ts_default, ogs_log_ts_e ts_file)
{
ogs_log_t *log;
if (ts_default == OGS_LOG_TS_UNSET)
ts_default = OGS_LOG_TS_ENABLED;
if (ts_file == OGS_LOG_TS_UNSET)
ts_file = ts_default;
ogs_list_for_each(&log_list, log) {
switch (log->type) {
case OGS_LOG_FILE_TYPE:
log->print.timestamp = (ts_file == OGS_LOG_TS_ENABLED);
break;
default:
log->print.timestamp = (ts_default == OGS_LOG_TS_ENABLED);
break;
}
}
}
static ogs_log_level_e ogs_log_level_from_string(const char *string) static ogs_log_level_e ogs_log_level_from_string(const char *string)
{ {
ogs_log_level_e level = OGS_ERROR; ogs_log_level_e level = OGS_ERROR;

View File

@ -64,6 +64,12 @@ typedef enum {
OGS_LOG_FULL = OGS_LOG_TRACE, OGS_LOG_FULL = OGS_LOG_TRACE,
} ogs_log_level_e; } ogs_log_level_e;
typedef enum {
OGS_LOG_TS_UNSET,
OGS_LOG_TS_ENABLED,
OGS_LOG_TS_DISABLED,
} ogs_log_ts_e;
typedef struct ogs_log_s ogs_log_t; typedef struct ogs_log_s ogs_log_t;
typedef struct ogs_log_domain_s ogs_log_domain_t; typedef struct ogs_log_domain_s ogs_log_domain_t;
@ -90,6 +96,7 @@ void ogs_log_install_domain(int *domain_id,
int ogs_log_config_domain(const char *domain, const char *level); int ogs_log_config_domain(const char *domain, const char *level);
void ogs_log_set_mask_level(const char *mask, ogs_log_level_e level); void ogs_log_set_mask_level(const char *mask, ogs_log_level_e level);
void ogs_log_set_timestamp(ogs_log_ts_e ts_default, ogs_log_ts_e ts_file);
void ogs_log_vprintf(ogs_log_level_e level, int id, void ogs_log_vprintf(ogs_log_level_e level, int id,
ogs_err_t err, const char *file, int line, const char *func, ogs_err_t err, const char *file, int line, const char *func,

View File

@ -629,7 +629,11 @@ int16_t ogs_gtp2_parse_uli(ogs_gtp2_uli_t *uli, ogs_tlv_octet_t *octet)
size++; size++;
if (uli->flags.cgi) { if (uli->flags.cgi) {
ogs_assert(size + sizeof(uli->cgi) <= octet->len); if (size + sizeof(uli->cgi) > octet->len) {
ogs_error("size[%d]+sizeof(uli->cgi)[%d] > IE Length[%d]",
size, (int)sizeof(uli->cgi), octet->len);
return 0;
}
memcpy(&uli->cgi, memcpy(&uli->cgi,
(unsigned char *)octet->data + size, sizeof(uli->cgi)); (unsigned char *)octet->data + size, sizeof(uli->cgi));
uli->cgi.lac = be16toh(uli->cgi.lac); uli->cgi.lac = be16toh(uli->cgi.lac);
@ -637,7 +641,11 @@ int16_t ogs_gtp2_parse_uli(ogs_gtp2_uli_t *uli, ogs_tlv_octet_t *octet)
size += sizeof(uli->cgi); size += sizeof(uli->cgi);
} }
if (uli->flags.sai) { if (uli->flags.sai) {
ogs_assert(size + sizeof(uli->sai) <= octet->len); if (size + sizeof(uli->sai) > octet->len) {
ogs_error("size[%d]+sizeof(uli->sai)[%d] > IE Length[%d]",
size, (int)sizeof(uli->sai), octet->len);
return 0;
}
memcpy(&uli->sai, memcpy(&uli->sai,
(unsigned char *)octet->data + size, sizeof(uli->sai)); (unsigned char *)octet->data + size, sizeof(uli->sai));
uli->sai.lac = be16toh(uli->sai.lac); uli->sai.lac = be16toh(uli->sai.lac);
@ -645,7 +653,11 @@ int16_t ogs_gtp2_parse_uli(ogs_gtp2_uli_t *uli, ogs_tlv_octet_t *octet)
size += sizeof(uli->sai); size += sizeof(uli->sai);
} }
if (uli->flags.rai) { if (uli->flags.rai) {
ogs_assert(size + sizeof(uli->rai) <= octet->len); if (size + sizeof(uli->rai) > octet->len) {
ogs_error("size[%d]+sizeof(uli->lai)[%d] > IE Length[%d]",
size, (int)sizeof(uli->lai), octet->len);
return 0;
}
memcpy(&uli->rai, memcpy(&uli->rai,
(unsigned char *)octet->data + size, sizeof(uli->rai)); (unsigned char *)octet->data + size, sizeof(uli->rai));
uli->rai.lac = be16toh(uli->rai.lac); uli->rai.lac = be16toh(uli->rai.lac);
@ -653,28 +665,44 @@ int16_t ogs_gtp2_parse_uli(ogs_gtp2_uli_t *uli, ogs_tlv_octet_t *octet)
size += sizeof(uli->rai); size += sizeof(uli->rai);
} }
if (uli->flags.tai) { if (uli->flags.tai) {
ogs_assert(size + sizeof(uli->tai) <= octet->len); if (size + sizeof(uli->tai) > octet->len) {
ogs_error("size[%d]+sizeof(uli->tai)[%d] > IE Length[%d]",
size, (int)sizeof(uli->tai), octet->len);
return 0;
}
memcpy(&uli->tai, memcpy(&uli->tai,
(unsigned char *)octet->data + size, sizeof(uli->tai)); (unsigned char *)octet->data + size, sizeof(uli->tai));
uli->tai.tac = be16toh(uli->tai.tac); uli->tai.tac = be16toh(uli->tai.tac);
size += sizeof(uli->tai); size += sizeof(uli->tai);
} }
if (uli->flags.e_cgi) { if (uli->flags.e_cgi) {
ogs_assert(size + sizeof(uli->e_cgi) <= octet->len); if (size + sizeof(uli->e_cgi) > octet->len) {
ogs_error("size[%d]+sizeof(uli->e_cgi)[%d] > IE Length[%d]",
size, (int)sizeof(uli->e_cgi), octet->len);
return 0;
}
memcpy(&uli->e_cgi, memcpy(&uli->e_cgi,
(unsigned char *)octet->data + size, sizeof(uli->e_cgi)); (unsigned char *)octet->data + size, sizeof(uli->e_cgi));
uli->e_cgi.cell_id = be32toh(uli->e_cgi.cell_id); uli->e_cgi.cell_id = be32toh(uli->e_cgi.cell_id);
size += sizeof(uli->e_cgi); size += sizeof(uli->e_cgi);
} }
if (uli->flags.lai) { if (uli->flags.lai) {
ogs_assert(size + sizeof(uli->lai) <= octet->len); if (size + sizeof(uli->lai) > octet->len) {
ogs_error("size[%d]+sizeof(uli->lai)[%d] > IE Length[%d]",
size, (int)sizeof(uli->lai), octet->len);
return 0;
}
memcpy(&uli->lai, memcpy(&uli->lai,
(unsigned char *)octet->data + size, sizeof(uli->lai)); (unsigned char *)octet->data + size, sizeof(uli->lai));
uli->lai.lac = be16toh(uli->lai.lac); uli->lai.lac = be16toh(uli->lai.lac);
size += sizeof(uli->lai); size += sizeof(uli->lai);
} }
if (uli->flags.enodeb_id) { if (uli->flags.enodeb_id) {
ogs_assert(size + sizeof(uli->enodeb_id) <= octet->len); if (size + sizeof(uli->enodeb_id) > octet->len) {
ogs_error("size[%d]+sizeof(uli->enodeb_id)[%d] > IE Length[%d]",
size, (int)sizeof(uli->enodeb_id), octet->len);
return 0;
}
memcpy(&uli->enodeb_id, memcpy(&uli->enodeb_id,
(unsigned char *)octet->data + size, sizeof(uli->enodeb_id)); (unsigned char *)octet->data + size, sizeof(uli->enodeb_id));
uli->enodeb_id.enodeb_id = be16toh(uli->enodeb_id.enodeb_id); uli->enodeb_id.enodeb_id = be16toh(uli->enodeb_id.enodeb_id);
@ -684,7 +712,8 @@ int16_t ogs_gtp2_parse_uli(ogs_gtp2_uli_t *uli, ogs_tlv_octet_t *octet)
ogs_error("Extended Macro eNodeB ID in ULI not implemented! see 3GPP TS 29.274 8.21.8"); ogs_error("Extended Macro eNodeB ID in ULI not implemented! see 3GPP TS 29.274 8.21.8");
} }
ogs_assert(size == octet->len); if (size != octet->len)
ogs_error("Mismatch IE Length[%d] != Decoded[%d]", octet->len, size);
return size; return size;
} }

View File

@ -483,35 +483,59 @@ int ogs_nas_parse_qos_flow_descriptions(
ogs_assert(description); ogs_assert(description);
ogs_assert(descriptions); ogs_assert(descriptions);
ogs_assert(descriptions->length);
if (descriptions->length == 0) {
ogs_error("Length is 0");
goto cleanup;
}
if (descriptions->buffer == NULL) {
ogs_error("Buffer is NULL");
goto cleanup;
}
length = descriptions->length; length = descriptions->length;
ogs_assert(descriptions->buffer);
buffer = descriptions->buffer; buffer = descriptions->buffer;
size = 0; size = 0;
while (size < length) { while (size < length) {
memset(description, 0, sizeof(*description)); memset(description, 0, sizeof(*description));
ogs_assert(size+3 <= length); if (size+3 > length) {
ogs_error("Overflow : size[%d] length[%d]", size, length);
goto cleanup;
}
memcpy(description, buffer+size, 3); memcpy(description, buffer+size, 3);
size += 3; size += 3;
for (i = 0; i < description->num_of_parameter && for (i = 0; i < description->num_of_parameter &&
i < OGS_NAS_MAX_NUM_OF_QOS_FLOW_PARAMETER; i++) { i < OGS_NAS_MAX_NUM_OF_QOS_FLOW_PARAMETER; i++) {
ogs_assert(size+sizeof(description->param[i].identifier) <= length); if (size+sizeof(description->param[i].identifier) > length) {
ogs_error("Overflow : size[%d] length[%d]", size, length);
goto cleanup;
}
memcpy(&description->param[i].identifier, buffer+size, memcpy(&description->param[i].identifier, buffer+size,
sizeof(description->param[i].identifier)); sizeof(description->param[i].identifier));
size += sizeof(description->param[i].identifier); size += sizeof(description->param[i].identifier);
ogs_assert(size+sizeof(description->param[i].len) <= length); if (size+sizeof(description->param[i].len) > length) {
ogs_error("Overflow : size[%d] length[%d]", size, length);
goto cleanup;
}
memcpy(&description->param[i].len, buffer+size, memcpy(&description->param[i].len, buffer+size,
sizeof(description->param[i].len)); sizeof(description->param[i].len));
size += sizeof(description->param[i].len); size += sizeof(description->param[i].len);
switch(description->param[i].identifier) { switch(description->param[i].identifier) {
case OGS_NAX_QOS_FLOW_PARAMETER_ID_5QI: case OGS_NAX_QOS_FLOW_PARAMETER_ID_5QI:
ogs_assert(description->param[i].len == 1); if (description->param[i].len != 1) {
ogs_assert(size+description->param[i].len <= length); ogs_error("Invalid len[%d]", description->param[i].len);
goto cleanup;
}
if (size+description->param[i].len > length) {
ogs_error("Overflow: len[%d] length[%d]",
description->param[i].len, length);
goto cleanup;
}
memcpy(&description->param[i].qos_index, memcpy(&description->param[i].qos_index,
buffer+size, description->param[i].len); buffer+size, description->param[i].len);
size += description->param[i].len; size += description->param[i].len;
@ -521,8 +545,15 @@ int ogs_nas_parse_qos_flow_descriptions(
case OGS_NAX_QOS_FLOW_PARAMETER_ID_GFBR_DOWNLINK: case OGS_NAX_QOS_FLOW_PARAMETER_ID_GFBR_DOWNLINK:
case OGS_NAX_QOS_FLOW_PARAMETER_ID_MFBR_UPLINK: case OGS_NAX_QOS_FLOW_PARAMETER_ID_MFBR_UPLINK:
case OGS_NAX_QOS_FLOW_PARAMETER_ID_MFBR_DOWNLINK: case OGS_NAX_QOS_FLOW_PARAMETER_ID_MFBR_DOWNLINK:
ogs_assert(description->param[i].len == 3); if (description->param[i].len != 3) {
ogs_assert(size+description->param[i].len <= length); ogs_error("Invalid len[%d]", description->param[i].len);
goto cleanup;
}
if (size+description->param[i].len > length) {
ogs_error("Overflow: len[%d] length[%d]",
description->param[i].len, length);
goto cleanup;
}
memcpy(&description->param[i].br, memcpy(&description->param[i].br,
buffer+size, description->param[i].len); buffer+size, description->param[i].len);
description->param[i].br.value = description->param[i].br.value =
@ -530,15 +561,17 @@ int ogs_nas_parse_qos_flow_descriptions(
size += description->param[i].len; size += description->param[i].len;
break; break;
default: default:
ogs_fatal("Unknown qos_flow parameter identifier [%d]", ogs_error("Unknown qos_flow parameter identifier [%d]",
description->param[i].identifier); description->param[i].identifier);
ogs_assert_if_reached(); goto cleanup;
} }
} }
description++; description++;
} }
cleanup:
return (int)(description-first); return (int)(description-first);
} }
@ -777,28 +810,50 @@ int ogs_nas_parse_qos_rules(
ogs_assert(rule); ogs_assert(rule);
ogs_assert(rules); ogs_assert(rules);
ogs_assert(rules->length);
if (rules->length == 0) {
ogs_error("Length is 0");
goto cleanup;
}
if (rules->buffer == NULL) {
ogs_error("Buffer is NULL");
goto cleanup;
}
length = rules->length; length = rules->length;
ogs_assert(rules->buffer);
buffer = rules->buffer; buffer = rules->buffer;
size = 0; size = 0;
while (size < length) { while (size < length) {
memset(rule, 0, sizeof(*rule)); memset(rule, 0, sizeof(*rule));
ogs_assert(size+sizeof(rule->identifier) <= length); if (size+sizeof(rule->identifier) > length) {
ogs_error("Overflow : size[%d] length[%d]", size, length);
goto cleanup;
}
memcpy(&rule->identifier, buffer+size, sizeof(rule->identifier)); memcpy(&rule->identifier, buffer+size, sizeof(rule->identifier));
size += sizeof(rule->identifier); size += sizeof(rule->identifier);
ogs_assert(size+sizeof(rule->length) <= length); if (size+sizeof(rule->length) > length) {
ogs_error("Overflow : size[%d] length[%d]", size, length);
goto cleanup;
}
memcpy(&rule->length, buffer+size, sizeof(rule->length)); memcpy(&rule->length, buffer+size, sizeof(rule->length));
rule->length = be16toh(rule->length); rule->length = be16toh(rule->length);
size += sizeof(rule->length); size += sizeof(rule->length);
ogs_assert(size+sizeof(rule->flags) <= length); if (size+sizeof(rule->flags) > length) {
ogs_error("Overflow : size[%d] length[%d]", size, length);
goto cleanup;
}
memcpy(&rule->flags, buffer+size, sizeof(rule->flags)); memcpy(&rule->flags, buffer+size, sizeof(rule->flags));
size += sizeof(rule->flags); size += sizeof(rule->flags);
if (rule->code == 0 || rule->code == 7) { /* Reserved */
ogs_error("Reserved Rule Code [%d]", rule->code);
goto cleanup;
}
if (rule->code == OGS_NAS_QOS_CODE_DELETE_EXISTING_QOS_RULE || if (rule->code == OGS_NAS_QOS_CODE_DELETE_EXISTING_QOS_RULE ||
rule->code == OGS_NAS_QOS_CODE_MODIFY_EXISTING_QOS_RULE_WITHOUT_MODIFYING_PACKET_FILTERS) { rule->code == OGS_NAS_QOS_CODE_MODIFY_EXISTING_QOS_RULE_WITHOUT_MODIFYING_PACKET_FILTERS) {
if (rule->num_of_packet_filter != 0) { if (rule->num_of_packet_filter != 0) {
@ -806,12 +861,16 @@ int ogs_nas_parse_qos_rules(
"and number of packet filter[%d]", "and number of packet filter[%d]",
rule->code, rule->num_of_packet_filter); rule->code, rule->num_of_packet_filter);
rule->num_of_packet_filter = 0; rule->num_of_packet_filter = 0;
goto cleanup;
} }
} }
for (i = 0; i < rule->num_of_packet_filter && for (i = 0; i < rule->num_of_packet_filter &&
i < OGS_MAX_NUM_OF_FLOW_IN_GTP; i++) { i < OGS_MAX_NUM_OF_FLOW_IN_GTP; i++) {
ogs_assert(size+sizeof(rule->pf[i].flags) <= length); if (size+sizeof(rule->pf[i].flags) > length) {
ogs_error("Overflow : size[%d] length[%d]", size, length);
goto cleanup;
}
memcpy(&rule->pf[i].flags, buffer+size, sizeof(rule->pf[i].flags)); memcpy(&rule->pf[i].flags, buffer+size, sizeof(rule->pf[i].flags));
size += sizeof(rule->pf[i].flags); size += sizeof(rule->pf[i].flags);
@ -819,24 +878,35 @@ int ogs_nas_parse_qos_rules(
OGS_NAS_QOS_CODE_MODIFY_EXISTING_QOS_RULE_AND_DELETE_PACKET_FILTERS) OGS_NAS_QOS_CODE_MODIFY_EXISTING_QOS_RULE_AND_DELETE_PACKET_FILTERS)
continue; continue;
ogs_assert(size+sizeof(rule->pf[i].content.length) <= length); if (size+sizeof(rule->pf[i].content.length) > length) {
ogs_error("Overflow : size[%d] length[%d]", size, length);
goto cleanup;
}
memcpy(&rule->pf[i].content.length, buffer+size, memcpy(&rule->pf[i].content.length, buffer+size,
sizeof(rule->pf[i].content.length)); sizeof(rule->pf[i].content.length));
size += sizeof(rule->pf[i].content.length); size += sizeof(rule->pf[i].content.length);
j = 0; len = 0; j = 0; len = 0;
while(len < rule->pf[i].content.length) { while(len < rule->pf[i].content.length) {
ogs_assert(size+len+ if (size+len+
sizeof(rule->pf[i].content.component[j].type) <= length); sizeof(rule->pf[i].content.component[j].type) > length) {
ogs_error("Overflow : size[%d] len[%d] length[%d]",
size, len, length);
goto cleanup;
}
memcpy(&rule->pf[i].content.component[j].type, memcpy(&rule->pf[i].content.component[j].type,
buffer+size+len, buffer+size+len,
sizeof(rule->pf[i].content.component[j].type)); sizeof(rule->pf[i].content.component[j].type));
len += sizeof(rule->pf[i].content.component[j].type); len += sizeof(rule->pf[i].content.component[j].type);
switch(rule->pf[i].content.component[j].type) { switch(rule->pf[i].content.component[j].type) {
case OGS_PACKET_FILTER_PROTOCOL_IDENTIFIER_NEXT_HEADER_TYPE: case OGS_PACKET_FILTER_PROTOCOL_IDENTIFIER_NEXT_HEADER_TYPE:
ogs_assert(size+len+ if (size+len+
sizeof(rule->pf[i].content.component[j].proto) <= sizeof(rule->pf[i].content.component[j].proto) >
length); length) {
ogs_error("Overflow : size[%d] len[%d] length[%d]",
size, len, length);
goto cleanup;
}
memcpy(&rule->pf[i].content.component[j].proto, memcpy(&rule->pf[i].content.component[j].proto,
buffer+size+len, buffer+size+len,
sizeof(rule->pf[i].content.component[j].proto)); sizeof(rule->pf[i].content.component[j].proto));
@ -844,17 +914,25 @@ int ogs_nas_parse_qos_rules(
break; break;
case OGS_PACKET_FILTER_IPV4_REMOTE_ADDRESS_TYPE: case OGS_PACKET_FILTER_IPV4_REMOTE_ADDRESS_TYPE:
case OGS_PACKET_FILTER_IPV4_LOCAL_ADDRESS_TYPE: case OGS_PACKET_FILTER_IPV4_LOCAL_ADDRESS_TYPE:
ogs_assert(size+len+ if (size+len+
sizeof(rule->pf[i].content.component[j].ipv4.addr) <= sizeof(rule->pf[i].content.component[j].ipv4.addr) >
length); length) {
ogs_error("Overflow : size[%d] len[%d] length[%d]",
size, len, length);
goto cleanup;
}
memcpy(&rule->pf[i].content.component[j].ipv4.addr, memcpy(&rule->pf[i].content.component[j].ipv4.addr,
buffer+size+len, buffer+size+len,
sizeof(rule->pf[i].content.component[j].ipv4.addr)); sizeof(rule->pf[i].content.component[j].ipv4.addr));
len += sizeof(rule->pf[i].content.component[j].ipv4.addr); len += sizeof(rule->pf[i].content.component[j].ipv4.addr);
ogs_assert(size+len+ if (size+len+
sizeof(rule->pf[i].content.component[j].ipv4.mask) <= sizeof(rule->pf[i].content.component[j].ipv4.mask) >
length); length) {
ogs_error("Overflow : size[%d] len[%d] length[%d]",
size, len, length);
goto cleanup;
}
memcpy(&rule->pf[i].content.component[j].ipv4.mask, memcpy(&rule->pf[i].content.component[j].ipv4.mask,
buffer+size+len, buffer+size+len,
sizeof(rule->pf[i].content.component[j].ipv4.mask)); sizeof(rule->pf[i].content.component[j].ipv4.mask));
@ -862,18 +940,26 @@ int ogs_nas_parse_qos_rules(
break; break;
case OGS_PACKET_FILTER_IPV6_LOCAL_ADDRESS_PREFIX_LENGTH_TYPE: case OGS_PACKET_FILTER_IPV6_LOCAL_ADDRESS_PREFIX_LENGTH_TYPE:
case OGS_PACKET_FILTER_IPV6_REMOTE_ADDRESS_PREFIX_LENGTH_TYPE: case OGS_PACKET_FILTER_IPV6_REMOTE_ADDRESS_PREFIX_LENGTH_TYPE:
ogs_assert(size+len+ if (size+len+
sizeof(rule->pf[i].content.component[j].ipv6.addr) <= sizeof(rule->pf[i].content.component[j].ipv6.addr) >
length); length) {
ogs_error("Overflow : size[%d] len[%d] length[%d]",
size, len, length);
goto cleanup;
}
memcpy(&rule->pf[i].content.component[j].ipv6.addr, memcpy(&rule->pf[i].content.component[j].ipv6.addr,
buffer+size+len, buffer+size+len,
sizeof(rule->pf[i].content.component[j].ipv6.addr)); sizeof(rule->pf[i].content.component[j].ipv6.addr));
len += sizeof(rule->pf[i].content.component[j].ipv6.addr); len += sizeof(rule->pf[i].content.component[j].ipv6.addr);
ogs_assert(size+len+ if (size+len+
sizeof( sizeof(
rule->pf[i].content.component[j].ipv6.prefixlen) <= rule->pf[i].content.component[j].ipv6.prefixlen) >
length); length) {
ogs_error("Overflow : size[%d] len[%d] length[%d]",
size, len, length);
goto cleanup;
}
memcpy(&rule->pf[i].content.component[j].ipv6.prefixlen, memcpy(&rule->pf[i].content.component[j].ipv6.prefixlen,
buffer+size+len, buffer+size+len,
sizeof( sizeof(
@ -883,10 +969,14 @@ int ogs_nas_parse_qos_rules(
break; break;
case OGS_PACKET_FILTER_IPV6_LOCAL_ADDRESS_TYPE: case OGS_PACKET_FILTER_IPV6_LOCAL_ADDRESS_TYPE:
case OGS_PACKET_FILTER_IPV6_REMOTE_ADDRESS_TYPE: case OGS_PACKET_FILTER_IPV6_REMOTE_ADDRESS_TYPE:
ogs_assert(size+len+ if (size+len+
sizeof( sizeof(
rule->pf[i].content.component[j].ipv6_mask.addr) <= rule->pf[i].content.component[j].ipv6_mask.addr) >
length); length) {
ogs_error("Overflow : size[%d] len[%d] length[%d]",
size, len, length);
goto cleanup;
}
memcpy(&rule->pf[i].content.component[j].ipv6_mask.addr, memcpy(&rule->pf[i].content.component[j].ipv6_mask.addr,
buffer+size+len, buffer+size+len,
sizeof( sizeof(
@ -894,10 +984,14 @@ int ogs_nas_parse_qos_rules(
len += sizeof( len += sizeof(
rule->pf[i].content.component[j].ipv6_mask.addr); rule->pf[i].content.component[j].ipv6_mask.addr);
ogs_assert(size+len+ if (size+len+
sizeof( sizeof(
rule->pf[i].content.component[j].ipv6_mask.mask) <= rule->pf[i].content.component[j].ipv6_mask.mask) >
length); length) {
ogs_error("Overflow : size[%d] len[%d] length[%d]",
size, len, length);
goto cleanup;
}
memcpy(&rule->pf[i].content.component[j].ipv6_mask.mask, memcpy(&rule->pf[i].content.component[j].ipv6_mask.mask,
buffer+size+len, buffer+size+len,
sizeof( sizeof(
@ -907,9 +1001,13 @@ int ogs_nas_parse_qos_rules(
break; break;
case OGS_PACKET_FILTER_SINGLE_LOCAL_PORT_TYPE: case OGS_PACKET_FILTER_SINGLE_LOCAL_PORT_TYPE:
case OGS_PACKET_FILTER_SINGLE_REMOTE_PORT_TYPE: case OGS_PACKET_FILTER_SINGLE_REMOTE_PORT_TYPE:
ogs_assert(size+len+ if (size+len+
sizeof(rule->pf[i].content.component[j].port.low) <= sizeof(rule->pf[i].content.component[j].port.low) >
length); length) {
ogs_error("Overflow : size[%d] len[%d] length[%d]",
size, len, length);
goto cleanup;
}
memcpy(&rule->pf[i].content.component[j].port.low, memcpy(&rule->pf[i].content.component[j].port.low,
buffer+size+len, buffer+size+len,
sizeof(rule->pf[i].content.component[j].port.low)); sizeof(rule->pf[i].content.component[j].port.low));
@ -919,9 +1017,13 @@ int ogs_nas_parse_qos_rules(
break; break;
case OGS_PACKET_FILTER_LOCAL_PORT_RANGE_TYPE: case OGS_PACKET_FILTER_LOCAL_PORT_RANGE_TYPE:
case OGS_PACKET_FILTER_REMOTE_PORT_RANGE_TYPE: case OGS_PACKET_FILTER_REMOTE_PORT_RANGE_TYPE:
ogs_assert(size+len+ if (size+len+
sizeof(rule->pf[i].content.component[j].port.low) <= sizeof(rule->pf[i].content.component[j].port.low) >
length); length) {
ogs_error("Overflow : size[%d] len[%d] length[%d]",
size, len, length);
goto cleanup;
}
memcpy(&rule->pf[i].content.component[j].port.low, memcpy(&rule->pf[i].content.component[j].port.low,
buffer+size+len, buffer+size+len,
sizeof(rule->pf[i].content.component[j].port.low)); sizeof(rule->pf[i].content.component[j].port.low));
@ -929,9 +1031,13 @@ int ogs_nas_parse_qos_rules(
be16toh(rule->pf[i].content.component[j].port.low); be16toh(rule->pf[i].content.component[j].port.low);
len += sizeof(rule->pf[i].content.component[j].port.low); len += sizeof(rule->pf[i].content.component[j].port.low);
ogs_assert(size+len+ if (size+len+
sizeof(rule->pf[i].content.component[j].port.high) <= sizeof(rule->pf[i].content.component[j].port.high) >
length); length) {
ogs_error("Overflow : size[%d] len[%d] length[%d]",
size, len, length);
goto cleanup;
}
memcpy(&rule->pf[i].content.component[j].port.high, memcpy(&rule->pf[i].content.component[j].port.high,
buffer+size+len, buffer+size+len,
sizeof(rule->pf[i].content.component[j].port.high)); sizeof(rule->pf[i].content.component[j].port.high));
@ -942,7 +1048,7 @@ int ogs_nas_parse_qos_rules(
default: default:
ogs_error("Unknown Packet Filter Type(%d)", ogs_error("Unknown Packet Filter Type(%d)",
rule->pf[i].content.component[j].type); rule->pf[i].content.component[j].type);
return -1; goto cleanup;
} }
j++; j++;
} }
@ -954,11 +1060,17 @@ int ogs_nas_parse_qos_rules(
rule->code != OGS_NAS_QOS_CODE_MODIFY_EXISTING_QOS_RULE_AND_DELETE_PACKET_FILTERS && rule->code != OGS_NAS_QOS_CODE_MODIFY_EXISTING_QOS_RULE_AND_DELETE_PACKET_FILTERS &&
rule->code != OGS_NAS_QOS_CODE_MODIFY_EXISTING_QOS_RULE_WITHOUT_MODIFYING_PACKET_FILTERS) { rule->code != OGS_NAS_QOS_CODE_MODIFY_EXISTING_QOS_RULE_WITHOUT_MODIFYING_PACKET_FILTERS) {
ogs_assert(size+sizeof(rule->precedence) <= length); if (size+sizeof(rule->precedence) > length) {
ogs_error("Overflow : size[%d] length[%d]", size, length);
goto cleanup;
}
memcpy(&rule->precedence, buffer+size, sizeof(rule->precedence)); memcpy(&rule->precedence, buffer+size, sizeof(rule->precedence));
size += sizeof(rule->precedence); size += sizeof(rule->precedence);
ogs_assert(size+sizeof(rule->flow.flags) <= length); if (size+sizeof(rule->flow.flags) > length) {
ogs_error("Overflow : size[%d] length[%d]", size, length);
goto cleanup;
}
memcpy(&rule->flow.flags, buffer+size, sizeof(rule->flow.flags)); memcpy(&rule->flow.flags, buffer+size, sizeof(rule->flow.flags));
size += sizeof(rule->flow.flags); size += sizeof(rule->flow.flags);
} }
@ -966,6 +1078,8 @@ int ogs_nas_parse_qos_rules(
rule++; rule++;
} }
cleanup:
return (int)(rule-first); return (int)(rule-first);
} }

View File

@ -743,6 +743,7 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
do { do {
ogs_pfcp_subnet_t *subnet = NULL; ogs_pfcp_subnet_t *subnet = NULL;
const char *ipstr = NULL; const char *ipstr = NULL;
const char *gateway = NULL;
const char *mask_or_numbits = NULL; const char *mask_or_numbits = NULL;
const char *dnn = NULL; const char *dnn = NULL;
const char *dev = self.tun_ifname; const char *dev = self.tun_ifname;
@ -781,6 +782,8 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
mask_or_numbits = (const char *)v; mask_or_numbits = (const char *)v;
} }
} }
} else if (!strcmp(subnet_key, "gateway")) {
gateway = ogs_yaml_iter_value(&subnet_iter);
} else if (!strcmp(subnet_key, "apn") || } else if (!strcmp(subnet_key, "apn") ||
!strcmp(subnet_key, "dnn")) { !strcmp(subnet_key, "dnn")) {
dnn = ogs_yaml_iter_value(&subnet_iter); dnn = ogs_yaml_iter_value(&subnet_iter);
@ -825,7 +828,7 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
} }
subnet = ogs_pfcp_subnet_add( subnet = ogs_pfcp_subnet_add(
ipstr, mask_or_numbits, dnn, dev); ipstr, mask_or_numbits, gateway, dnn, dev);
ogs_assert(subnet); ogs_assert(subnet);
subnet->num_of_range = num; subnet->num_of_range = num;
@ -2150,7 +2153,7 @@ ogs_pfcp_dev_t *ogs_pfcp_dev_find_by_ifname(const char *ifname)
ogs_pfcp_subnet_t *ogs_pfcp_subnet_add( ogs_pfcp_subnet_t *ogs_pfcp_subnet_add(
const char *ipstr, const char *mask_or_numbits, const char *ipstr, const char *mask_or_numbits,
const char *dnn, const char *ifname) const char *gateway, const char *dnn, const char *ifname)
{ {
int rv; int rv;
ogs_pfcp_dev_t *dev = NULL; ogs_pfcp_dev_t *dev = NULL;
@ -2179,6 +2182,41 @@ ogs_pfcp_subnet_t *ogs_pfcp_subnet_add(
subnet->family = subnet->gw.family; subnet->family = subnet->gw.family;
subnet->prefixlen = atoi(mask_or_numbits); subnet->prefixlen = atoi(mask_or_numbits);
if (memcmp(subnet->gw.sub, subnet->sub.sub,
sizeof(subnet->gw.sub)) != 0) {
char *subnet_string = NULL;
if (subnet->family == AF_INET) {
subnet_string = ogs_ipv4_to_string(subnet->sub.sub[0]);
ogs_assert(subnet_string);
} else if (subnet->family == AF_INET6) {
subnet_string = ogs_ipv6addr_to_string(
(uint8_t*)&subnet->sub.sub[0]);
ogs_assert(subnet_string);
}
ogs_warn("Please change the configuration files of "
"smf.yaml and upf.yaml as below.");
ogs_log_print(OGS_LOG_WARN, "\n<OLD Format>\n");
ogs_log_print(OGS_LOG_WARN, "smf:\n");
ogs_log_print(OGS_LOG_WARN, " session:\n");
ogs_log_print(OGS_LOG_WARN, " - subnet: %s/%s\n",
ipstr, mask_or_numbits);
ogs_log_print(OGS_LOG_WARN, "\n<NEW Format>\n");
ogs_log_print(OGS_LOG_WARN, "smf:\n");
ogs_log_print(OGS_LOG_WARN, " session:\n");
ogs_log_print(OGS_LOG_WARN, " - subnet: %s/%s\n",
subnet_string ? subnet_string : "Unknown", mask_or_numbits);
ogs_log_print(OGS_LOG_WARN, " gateway: %s\n\n\n", ipstr);
ogs_free(subnet_string);
}
}
if (gateway) {
rv = ogs_ipsubnet(&subnet->gw, gateway, NULL);
ogs_assert(rv == OGS_OK);
} }
if (dnn) if (dnn)

View File

@ -491,7 +491,7 @@ ogs_pfcp_dev_t *ogs_pfcp_dev_find_by_ifname(const char *ifname);
ogs_pfcp_subnet_t *ogs_pfcp_subnet_add( ogs_pfcp_subnet_t *ogs_pfcp_subnet_add(
const char *ipstr, const char *mask_or_numbits, const char *ipstr, const char *mask_or_numbits,
const char *dnn, const char *ifname); const char *gateway, const char *dnn, const char *ifname);
ogs_pfcp_subnet_t *ogs_pfcp_subnet_next(ogs_pfcp_subnet_t *subnet); ogs_pfcp_subnet_t *ogs_pfcp_subnet_next(ogs_pfcp_subnet_t *subnet);
void ogs_pfcp_subnet_remove(ogs_pfcp_subnet_t *subnet); void ogs_pfcp_subnet_remove(ogs_pfcp_subnet_t *subnet);
void ogs_pfcp_subnet_remove_all(void); void ogs_pfcp_subnet_remove_all(void);

View File

@ -94,6 +94,7 @@ bool ogs_pfcp_cp_handle_association_setup_request(
ogs_pfcp_association_setup_request_t *req) ogs_pfcp_association_setup_request_t *req)
{ {
int i; int i;
int16_t decoded;
ogs_assert(xact); ogs_assert(xact);
ogs_assert(node); ogs_assert(node);
@ -112,8 +113,11 @@ bool ogs_pfcp_cp_handle_association_setup_request(
if (message->presence == 0) if (message->presence == 0)
break; break;
ogs_pfcp_parse_user_plane_ip_resource_info(&info, message); decoded = ogs_pfcp_parse_user_plane_ip_resource_info(&info, message);
ogs_gtpu_resource_add(&node->gtpu_resource_list, &info); if (message->len == decoded)
ogs_gtpu_resource_add(&node->gtpu_resource_list, &info);
else
ogs_error("Invalid User Plane IP Resource Info");
} }
if (req->up_function_features.presence) { if (req->up_function_features.presence) {
@ -143,6 +147,7 @@ bool ogs_pfcp_cp_handle_association_setup_response(
ogs_pfcp_association_setup_response_t *rsp) ogs_pfcp_association_setup_response_t *rsp)
{ {
int i; int i;
int16_t decoded;
ogs_assert(xact); ogs_assert(xact);
ogs_pfcp_xact_commit(xact); ogs_pfcp_xact_commit(xact);
@ -160,8 +165,11 @@ bool ogs_pfcp_cp_handle_association_setup_response(
if (message->presence == 0) if (message->presence == 0)
break; break;
ogs_pfcp_parse_user_plane_ip_resource_info(&info, message); decoded = ogs_pfcp_parse_user_plane_ip_resource_info(&info, message);
ogs_gtpu_resource_add(&node->gtpu_resource_list, &info); if (message->len == decoded)
ogs_gtpu_resource_add(&node->gtpu_resource_list, &info);
else
ogs_error("Invalid User Plane IP Resource Info");
} }
if (rsp->up_function_features.presence) { if (rsp->up_function_features.presence) {
@ -424,7 +432,10 @@ ogs_pfcp_pdr_t *ogs_pfcp_handle_create_pdr(ogs_pfcp_sess_t *sess,
len = ogs_pfcp_parse_sdf_filter( len = ogs_pfcp_parse_sdf_filter(
&sdf_filter, &message->pdi.sdf_filter[i]); &sdf_filter, &message->pdi.sdf_filter[i]);
ogs_assert(message->pdi.sdf_filter[i].len == len); if (message->pdi.sdf_filter[i].len != len) {
ogs_error("Invalid SDF Filter");
break;
}
/* Check Previous SDF Filter ID */ /* Check Previous SDF Filter ID */
if (sdf_filter.bid) { if (sdf_filter.bid) {
@ -518,12 +529,13 @@ ogs_pfcp_pdr_t *ogs_pfcp_handle_create_pdr(ogs_pfcp_sess_t *sess,
if (message->pdi.network_instance.presence) { if (message->pdi.network_instance.presence) {
char dnn[OGS_MAX_DNN_LEN+1]; char dnn[OGS_MAX_DNN_LEN+1];
ogs_assert(0 < ogs_fqdn_parse(dnn, if (ogs_fqdn_parse(dnn, message->pdi.network_instance.data,
message->pdi.network_instance.data, ogs_min(message->pdi.network_instance.len, OGS_MAX_DNN_LEN)) > 0) {
ogs_min(message->pdi.network_instance.len, OGS_MAX_DNN_LEN))); pdr->dnn = ogs_strdup(dnn);
ogs_assert(pdr->dnn);
pdr->dnn = ogs_strdup(dnn); } else {
ogs_assert(pdr->dnn); ogs_error("Invalid pdi.network_instance");
}
} }
pdr->chid = false; pdr->chid = false;
@ -765,7 +777,10 @@ ogs_pfcp_pdr_t *ogs_pfcp_handle_update_pdr(ogs_pfcp_sess_t *sess,
len = ogs_pfcp_parse_sdf_filter( len = ogs_pfcp_parse_sdf_filter(
&sdf_filter, &message->pdi.sdf_filter[i]); &sdf_filter, &message->pdi.sdf_filter[i]);
ogs_assert(message->pdi.sdf_filter[i].len == len); if (message->pdi.sdf_filter[i].len != len) {
ogs_error("Invalid SDF Filter");
break;
}
/* Check Previous SDF Filter ID */ /* Check Previous SDF Filter ID */
if (sdf_filter.bid) { if (sdf_filter.bid) {
@ -855,14 +870,16 @@ ogs_pfcp_pdr_t *ogs_pfcp_handle_update_pdr(ogs_pfcp_sess_t *sess,
if (message->pdi.network_instance.presence) { if (message->pdi.network_instance.presence) {
char dnn[OGS_MAX_DNN_LEN+1]; char dnn[OGS_MAX_DNN_LEN+1];
ogs_assert(0 < ogs_fqdn_parse(dnn, if (ogs_fqdn_parse(dnn, message->pdi.network_instance.data,
message->pdi.network_instance.data, ogs_min(message->pdi.network_instance.len,
ogs_min(message->pdi.network_instance.len, OGS_MAX_DNN_LEN))); OGS_MAX_DNN_LEN)) > 0) {
if (pdr->dnn)
if (pdr->dnn) ogs_free(pdr->dnn);
ogs_free(pdr->dnn); pdr->dnn = ogs_strdup(dnn);
pdr->dnn = ogs_strdup(dnn); ogs_assert(pdr->dnn);
ogs_assert(pdr->dnn); } else {
ogs_error("Invalid pdi.network_instance");
}
} }
if (message->pdi.local_f_teid.presence) { if (message->pdi.local_f_teid.presence) {
@ -964,13 +981,15 @@ ogs_pfcp_far_t *ogs_pfcp_handle_create_far(ogs_pfcp_sess_t *sess,
if (message->forwarding_parameters.network_instance.presence) { if (message->forwarding_parameters.network_instance.presence) {
char dnn[OGS_MAX_DNN_LEN+1]; char dnn[OGS_MAX_DNN_LEN+1];
ogs_assert(0 < ogs_fqdn_parse(dnn, if (ogs_fqdn_parse(dnn,
message->forwarding_parameters.network_instance.data, message->forwarding_parameters.network_instance.data,
ogs_min(message->forwarding_parameters.network_instance.len, ogs_min(message->forwarding_parameters.network_instance.len,
OGS_MAX_DNN_LEN))); OGS_MAX_DNN_LEN)) > 0) {
far->dnn = ogs_strdup(dnn);
far->dnn = ogs_strdup(dnn); ogs_assert(far->dnn);
ogs_assert(far->dnn); } else {
ogs_error("Invalid forwarding_parameters.network_instance");
}
} }
if (message->forwarding_parameters.outer_header_creation.presence) { if (message->forwarding_parameters.outer_header_creation.presence) {
@ -1069,15 +1088,18 @@ ogs_pfcp_far_t *ogs_pfcp_handle_update_far(ogs_pfcp_sess_t *sess,
if (message->update_forwarding_parameters.network_instance.presence) { if (message->update_forwarding_parameters.network_instance.presence) {
char dnn[OGS_MAX_DNN_LEN+1]; char dnn[OGS_MAX_DNN_LEN+1];
ogs_assert(0 < ogs_fqdn_parse(dnn, if (ogs_fqdn_parse(dnn,
message->update_forwarding_parameters.network_instance.data, message->update_forwarding_parameters.network_instance.data,
ogs_min(message->update_forwarding_parameters. ogs_min(message->update_forwarding_parameters.
network_instance.len, OGS_MAX_DNN_LEN))); network_instance.len, OGS_MAX_DNN_LEN)) > 0) {
if (far->dnn)
if (far->dnn) ogs_free(far->dnn);
ogs_free(far->dnn); far->dnn = ogs_strdup(dnn);
far->dnn = ogs_strdup(dnn); ogs_assert(far->dnn);
ogs_assert(far->dnn); } else {
ogs_error("Invalid "
"update_forwarding_parameters.network_instance");
}
} }
if (message->update_forwarding_parameters. if (message->update_forwarding_parameters.
@ -1307,6 +1329,7 @@ ogs_pfcp_urr_t *ogs_pfcp_handle_create_urr(ogs_pfcp_sess_t *sess,
ogs_pfcp_tlv_create_urr_t *message, ogs_pfcp_tlv_create_urr_t *message,
uint8_t *cause_value, uint8_t *offending_ie_value) uint8_t *cause_value, uint8_t *offending_ie_value)
{ {
int16_t decoded;
ogs_pfcp_urr_t *urr = NULL; ogs_pfcp_urr_t *urr = NULL;
ogs_assert(message); ogs_assert(message);
@ -1355,12 +1378,26 @@ ogs_pfcp_urr_t *ogs_pfcp_handle_create_urr(ogs_pfcp_sess_t *sess,
if (message->volume_threshold.presence && if (message->volume_threshold.presence &&
(urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_VOLUME)) { (urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_VOLUME)) {
ogs_pfcp_parse_volume(&urr->vol_threshold, &message->volume_threshold); decoded = ogs_pfcp_parse_volume(
&urr->vol_threshold, &message->volume_threshold);
if (message->volume_threshold.len != decoded) {
ogs_error("Invalid Volume Threshold");
*cause_value = OGS_PFCP_CAUSE_MANDATORY_IE_INCORRECT;
*offending_ie_value = OGS_PFCP_VOLUME_THRESHOLD_TYPE;
return NULL;
}
} }
if (message->volume_quota.presence && if (message->volume_quota.presence &&
(urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_VOLUME)) { (urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_VOLUME)) {
ogs_pfcp_parse_volume(&urr->vol_quota, &message->volume_quota); decoded = ogs_pfcp_parse_volume(
&urr->vol_quota, &message->volume_quota);
if (message->volume_quota.len != decoded) {
ogs_error("Invalid Volume Quota");
*cause_value = OGS_PFCP_CAUSE_MANDATORY_IE_INCORRECT;
*offending_ie_value = OGS_PFCP_VOLUME_QUOTA_TYPE;
return NULL;
}
} }
if (message->event_threshold.presence && if (message->event_threshold.presence &&
@ -1409,6 +1446,7 @@ ogs_pfcp_urr_t *ogs_pfcp_handle_update_urr(ogs_pfcp_sess_t *sess,
ogs_pfcp_tlv_update_urr_t *message, ogs_pfcp_tlv_update_urr_t *message,
uint8_t *cause_value, uint8_t *offending_ie_value) uint8_t *cause_value, uint8_t *offending_ie_value)
{ {
int16_t decoded;
ogs_pfcp_urr_t *urr = NULL; ogs_pfcp_urr_t *urr = NULL;
ogs_assert(message); ogs_assert(message);
@ -1447,12 +1485,26 @@ ogs_pfcp_urr_t *ogs_pfcp_handle_update_urr(ogs_pfcp_sess_t *sess,
if (message->volume_threshold.presence && if (message->volume_threshold.presence &&
(urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_VOLUME)) { (urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_VOLUME)) {
ogs_pfcp_parse_volume(&urr->vol_threshold, &message->volume_threshold); decoded = ogs_pfcp_parse_volume(
&urr->vol_threshold, &message->volume_threshold);
if (message->volume_threshold.len != decoded) {
ogs_error("Invalid Volume Threshold");
*cause_value = OGS_PFCP_CAUSE_MANDATORY_IE_INCORRECT;
*offending_ie_value = OGS_PFCP_VOLUME_THRESHOLD_TYPE;
return NULL;
}
} }
if (message->volume_quota.presence && if (message->volume_quota.presence &&
(urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_VOLUME)) { (urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_VOLUME)) {
ogs_pfcp_parse_volume(&urr->vol_quota, &message->volume_quota); decoded = ogs_pfcp_parse_volume(
&urr->vol_quota, &message->volume_quota);
if (message->volume_quota.len != decoded) {
ogs_error("Invalid Volume Quota");
*cause_value = OGS_PFCP_CAUSE_MANDATORY_IE_INCORRECT;
*offending_ie_value = OGS_PFCP_VOLUME_QUOTA_TYPE;
return NULL;
}
} }
if (message->event_threshold.presence && if (message->event_threshold.presence &&

View File

@ -149,14 +149,22 @@ int16_t ogs_pfcp_parse_user_plane_ip_resource_info(
size++; size++;
if (info->teidri) { if (info->teidri) {
ogs_assert(size + sizeof(info->teid_range) <= octet->len); if (size + sizeof(info->teid_range) > octet->len) {
ogs_error("size[%d]+sizeof(info->teid_range)[%d] > IE Length[%d]",
size, (int)sizeof(info->teid_range), octet->len);
return 0;
}
memcpy(&info->teid_range, (unsigned char *)octet->data + size, memcpy(&info->teid_range, (unsigned char *)octet->data + size,
sizeof(info->teid_range)); sizeof(info->teid_range));
size += sizeof(info->teid_range); size += sizeof(info->teid_range);
} }
if (info->v4) { if (info->v4) {
ogs_assert(size + sizeof(info->addr) <= octet->len); if (size + sizeof(info->addr) > octet->len) {
ogs_error("size[%d]+sizeof(info->addr)[%d] > IE Length[%d]",
size, (int)sizeof(info->addr), octet->len);
return 0;
}
memcpy(&info->addr, memcpy(&info->addr,
(unsigned char *)octet->data + size, (unsigned char *)octet->data + size,
sizeof(info->addr)); sizeof(info->addr));
@ -164,30 +172,51 @@ int16_t ogs_pfcp_parse_user_plane_ip_resource_info(
} }
if (info->v6) { if (info->v6) {
ogs_assert(size + OGS_IPV6_LEN <= octet->len); if (size + OGS_IPV6_LEN > octet->len) {
ogs_error("size[%d]+OGS_IPV6_LEN[%d] > IE Length[%d]",
size, (int)OGS_IPV6_LEN, octet->len);
return 0;
}
memcpy(&info->addr6, (unsigned char *)octet->data + size, OGS_IPV6_LEN); memcpy(&info->addr6, (unsigned char *)octet->data + size, OGS_IPV6_LEN);
size += OGS_IPV6_LEN; size += OGS_IPV6_LEN;
} }
if (info->assoni) { if (info->assoni) {
int len = octet->len - size; int len = octet->len - size;
if (info->assosi) len--; if (len <= 0) {
ogs_error("len[%d] octect->len[%d] size[%d]", len, octet->len, size);
return 0;
}
ogs_assert(0 < ogs_fqdn_parse( if (info->assosi) len--;
info->network_instance, (char *)octet->data + size, if (len <= 0) {
ogs_min(len, OGS_MAX_APN_LEN))); ogs_error("info->assosi[%d] len[%d] octect->len[%d] size[%d]",
info->assosi, len, octet->len, size);
return 0;
}
if (ogs_fqdn_parse(info->network_instance, (char *)octet->data + size,
ogs_min(len, OGS_MAX_APN_LEN)) <= 0) {
ogs_error("Invalid info->network_instance");
info->network_instance[0] = 0;
}
size += len; size += len;
} }
if (info->assosi) { if (info->assosi) {
ogs_assert(size + sizeof(info->source_interface) <= if (size + sizeof(info->source_interface) > octet->len) {
octet->len); ogs_error("size[%d]+sizeof(info->source_interface)[%d] > "
"IE Length[%d]",
size, (int)sizeof(info->source_interface), octet->len);
return 0;
}
memcpy(&info->source_interface, (unsigned char *)octet->data + size, memcpy(&info->source_interface, (unsigned char *)octet->data + size,
sizeof(info->source_interface)); sizeof(info->source_interface));
size += sizeof(info->source_interface); size += sizeof(info->source_interface);
} }
ogs_assert(size == octet->len); if (size != octet->len)
ogs_error("Mismatch IE Length[%d] != Decoded[%d]", octet->len, size);
return size; return size;
} }
@ -282,18 +311,32 @@ int16_t ogs_pfcp_parse_sdf_filter(
memset(filter, 0, sizeof(ogs_pfcp_sdf_filter_t)); memset(filter, 0, sizeof(ogs_pfcp_sdf_filter_t));
ogs_assert(size + sizeof(filter->flags) <= octet->len); if (size + sizeof(filter->flags) > octet->len) {
ogs_error("size[%d]+sizeof(filter->flags)[%d] > IE Length[%d]",
size, (int)sizeof(filter->flags), octet->len);
return 0;
}
memcpy(&filter->flags, memcpy(&filter->flags,
(unsigned char *)octet->data + size, sizeof(filter->flags)); (unsigned char *)octet->data + size, sizeof(filter->flags));
size++; size++;
ogs_assert(size + sizeof(filter->spare2) <= octet->len); if (size + sizeof(filter->spare2) > octet->len) {
ogs_error("size[%d]+sizeof(filter->spare2)[%d] > IE Length[%d]",
size, (int)sizeof(filter->spare2), octet->len);
return 0;
}
memcpy(&filter->spare2, memcpy(&filter->spare2,
(unsigned char *)octet->data + size, sizeof(filter->flags)); (unsigned char *)octet->data + size, sizeof(filter->flags));
size++; size++;
if (filter->fd) { if (filter->fd) {
ogs_assert(size + sizeof(filter->flow_description_len) <= octet->len); if (size + sizeof(filter->flow_description_len) > octet->len) {
ogs_error("size[%d]+sizeof(filter->flow_description_len)[%d] "
"> IE Length[%d]",
size, (int)sizeof(filter->flow_description_len),
octet->len);
return 0;
}
memcpy(&filter->flow_description_len, memcpy(&filter->flow_description_len,
(unsigned char *)octet->data + size, (unsigned char *)octet->data + size,
sizeof(filter->flow_description_len)); sizeof(filter->flow_description_len));
@ -305,7 +348,12 @@ int16_t ogs_pfcp_parse_sdf_filter(
} }
if (filter->ttc) { if (filter->ttc) {
ogs_assert(size + sizeof(filter->tos_traffic_class) <= octet->len); if (size + sizeof(filter->tos_traffic_class) > octet->len) {
ogs_error("size[%d]+sizeof(filter->tos_traffic_class)[%d] "
"> IE Length[%d]",
size, (int)sizeof(filter->tos_traffic_class), octet->len);
return 0;
}
memcpy(&filter->tos_traffic_class, memcpy(&filter->tos_traffic_class,
(unsigned char *)octet->data + size, (unsigned char *)octet->data + size,
sizeof(filter->tos_traffic_class)); sizeof(filter->tos_traffic_class));
@ -314,8 +362,13 @@ int16_t ogs_pfcp_parse_sdf_filter(
} }
if (filter->spi) { if (filter->spi) {
ogs_assert(size + sizeof(filter->security_parameter_index) <= if (size + sizeof(filter->security_parameter_index) > octet->len) {
octet->len); ogs_error("size[%d]+sizeof(filter->security_parameter_index)[%d] "
"> IE Length[%d]",
size, (int)sizeof(filter->security_parameter_index),
octet->len);
return 0;
}
memcpy(&filter->security_parameter_index, memcpy(&filter->security_parameter_index,
(unsigned char *)octet->data + size, (unsigned char *)octet->data + size,
sizeof(filter->security_parameter_index)); sizeof(filter->security_parameter_index));
@ -326,7 +379,11 @@ int16_t ogs_pfcp_parse_sdf_filter(
if (filter->fl) { if (filter->fl) {
int bit24_len = 3; int bit24_len = 3;
ogs_assert(size + bit24_len <= octet->len); if (size + bit24_len > octet->len) {
ogs_error("size[%d]+bit24_len[%d] > IE Length[%d]",
size, bit24_len, octet->len);
return 0;
}
memcpy(&filter->flow_label, memcpy(&filter->flow_label,
(unsigned char *)octet->data + size, bit24_len); (unsigned char *)octet->data + size, bit24_len);
filter->flow_label = be32toh(filter->flow_label); filter->flow_label = be32toh(filter->flow_label);
@ -334,14 +391,20 @@ int16_t ogs_pfcp_parse_sdf_filter(
} }
if (filter->bid) { if (filter->bid) {
ogs_assert(size + sizeof(filter->sdf_filter_id) <= octet->len); if (size + sizeof(filter->sdf_filter_id) > octet->len) {
ogs_error("size[%d]+sizeof(filter->sdf_filter_id)[%d]"
"> IE Length[%d]",
size, (int)sizeof(filter->sdf_filter_id), octet->len);
return 0;
}
memcpy(&filter->sdf_filter_id, (unsigned char *)octet->data + size, memcpy(&filter->sdf_filter_id, (unsigned char *)octet->data + size,
sizeof(filter->sdf_filter_id)); sizeof(filter->sdf_filter_id));
filter->sdf_filter_id = be32toh(filter->sdf_filter_id); filter->sdf_filter_id = be32toh(filter->sdf_filter_id);
size += sizeof(filter->sdf_filter_id); size += sizeof(filter->sdf_filter_id);
} }
ogs_assert(size == octet->len); if (size != octet->len)
ogs_error("Mismatch IE Length[%d] != Decoded[%d]", octet->len, size);
return size; return size;
} }
@ -479,25 +542,44 @@ int16_t ogs_pfcp_parse_volume(
size += sizeof(volume->flags); size += sizeof(volume->flags);
if (volume->tovol) { if (volume->tovol) {
if (size + sizeof(volume->total_volume) > octet->len) {
ogs_error("size[%d]+sizeof(volume->total_volume)[%d] "
"> IE Length[%d]",
size, (int)sizeof(volume->total_volume), octet->len);
return 0;
}
memcpy(&volume->total_volume, (unsigned char *)octet->data + size, memcpy(&volume->total_volume, (unsigned char *)octet->data + size,
sizeof(volume->total_volume)); sizeof(volume->total_volume));
volume->total_volume = be64toh(volume->total_volume); volume->total_volume = be64toh(volume->total_volume);
size += sizeof(volume->total_volume); size += sizeof(volume->total_volume);
} }
if (volume->ulvol) { if (volume->ulvol) {
if (size + sizeof(volume->uplink_volume) > octet->len) {
ogs_error("size[%d]+sizeof(volume->uplink_volume)[%d] "
"> IE Length[%d]",
size, (int)sizeof(volume->uplink_volume), octet->len);
return 0;
}
memcpy(&volume->uplink_volume, (unsigned char *)octet->data + size, memcpy(&volume->uplink_volume, (unsigned char *)octet->data + size,
sizeof(volume->uplink_volume)); sizeof(volume->uplink_volume));
volume->uplink_volume = be64toh(volume->uplink_volume); volume->uplink_volume = be64toh(volume->uplink_volume);
size += sizeof(volume->uplink_volume); size += sizeof(volume->uplink_volume);
} }
if (volume->dlvol) { if (volume->dlvol) {
if (size + sizeof(volume->downlink_volume) > octet->len) {
ogs_error("size[%d]+sizeof(volume->downlink_volume)[%d] "
"> IE Length[%d]",
size, (int)sizeof(volume->downlink_volume), octet->len);
return 0;
}
memcpy(&volume->downlink_volume, (unsigned char *)octet->data + size, memcpy(&volume->downlink_volume, (unsigned char *)octet->data + size,
sizeof(volume->downlink_volume)); sizeof(volume->downlink_volume));
volume->downlink_volume = be64toh(volume->downlink_volume); volume->downlink_volume = be64toh(volume->downlink_volume);
size += sizeof(volume->downlink_volume); size += sizeof(volume->downlink_volume);
} }
ogs_assert(size == octet->len); if (size != octet->len)
ogs_error("Mismatch IE Length[%d] != Decoded[%d]", octet->len, size);
return size; return size;
} }

View File

@ -419,8 +419,8 @@ int ogs_fqdn_parse(char *dst, const char *src, int length)
while (i+1 < length) { while (i+1 < length) {
len = src[i++]; len = src[i++];
if ((j + len + 1) > length) { if ((j + len + 1) > length) {
ogs_error("Invalid FQDN encoding[len:%d] + 1 > length[%d]", ogs_error("Invalid FQDN encoding[j:%d+len:%d] + 1 > length[%d]",
len, length); j, len, length);
ogs_log_hexdump(OGS_LOG_ERROR, (unsigned char *)src, length); ogs_log_hexdump(OGS_LOG_ERROR, (unsigned char *)src, length);
return 0; return 0;
} }

View File

@ -379,11 +379,6 @@ ED2(uint8_t spare:4;,
typedef struct ogs_paa_s { typedef struct ogs_paa_s {
ED2(uint8_t spare:5;, ED2(uint8_t spare:5;,
/* 8.34 PDN Type */ /* 8.34 PDN Type */
#define OGS_PDU_SESSION_TYPE_IS_VALID(x) \
((x) == OGS_PDU_SESSION_TYPE_IPV4 || \
(x) == OGS_PDU_SESSION_TYPE_IPV6 || \
(x) == OGS_PDU_SESSION_TYPE_IPV4V6) \
uint8_t session_type:3;) uint8_t session_type:3;)
union { union {
/* PDU_SESSION_TYPE_IPV4 */ /* PDU_SESSION_TYPE_IPV4 */

View File

@ -57,6 +57,19 @@ extern "C" {
OGS_OBJECT_REF(__pClient); \ OGS_OBJECT_REF(__pClient); \
((__cTX)->client) = (__pClient); \ ((__cTX)->client) = (__pClient); \
ogs_debug("CLIENT Ref [%d]", (__pClient)->reference_count); \ ogs_debug("CLIENT Ref [%d]", (__pClient)->reference_count); \
if ((__pClient)->fqdn) { \
ogs_info("NF EndPoint(fqdn) setup [%s:%d]", \
(__pClient)->fqdn, (__pClient)->fqdn_port); \
} \
if ((__pClient)->addr) { \
ogs_info("NF EndPoint(addr) setup [%s:%d]", \
OGS_ADDR((__pClient)->addr, buf), OGS_PORT((__pClient)->addr)); \
} \
if ((__pClient)->addr6) { \
ogs_info("NF EndPoint(addr6) setup [%s:%d]", \
OGS_ADDR((__pClient)->addr6, buf), \
OGS_PORT((__pClient)->addr6)); \
} \
} while(0) } while(0)
typedef int (*ogs_sbi_client_cb_f)( typedef int (*ogs_sbi_client_cb_f)(

View File

@ -1085,8 +1085,6 @@ ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_add(void)
ogs_assert(nf_instance); ogs_assert(nf_instance);
memset(nf_instance, 0, sizeof(ogs_sbi_nf_instance_t)); memset(nf_instance, 0, sizeof(ogs_sbi_nf_instance_t));
OGS_OBJECT_REF(nf_instance);
nf_instance->time.heartbeat_interval = nf_instance->time.heartbeat_interval =
ogs_local_conf()->time.nf_instance.heartbeat_interval; ogs_local_conf()->time.nf_instance.heartbeat_interval;
@ -1096,10 +1094,10 @@ ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_add(void)
ogs_list_add(&ogs_sbi_self()->nf_instance_list, nf_instance); ogs_list_add(&ogs_sbi_self()->nf_instance_list, nf_instance);
ogs_debug("[%s] NFInstance added with Ref [%s:%d]", ogs_debug("[%s] NFInstance added with Ref [%s]",
nf_instance->nf_type ? nf_instance->nf_type ?
OpenAPI_nf_type_ToString(nf_instance->nf_type) : "NULL", OpenAPI_nf_type_ToString(nf_instance->nf_type) : "NULL",
nf_instance->id, nf_instance->reference_count); nf_instance->id);
return nf_instance; return nf_instance;
} }
@ -1196,20 +1194,10 @@ void ogs_sbi_nf_instance_remove(ogs_sbi_nf_instance_t *nf_instance)
{ {
ogs_assert(nf_instance); ogs_assert(nf_instance);
ogs_debug("[%s] NFInstance UnRef [%s:%d]", ogs_debug("[%s] NFInstance removed [%s]",
nf_instance->nf_type ? nf_instance->nf_type ?
OpenAPI_nf_type_ToString(nf_instance->nf_type) : "NULL", OpenAPI_nf_type_ToString(nf_instance->nf_type) : "NULL",
nf_instance->id, nf_instance->reference_count); nf_instance->id);
if (OGS_OBJECT_IS_REF(nf_instance)) {
OGS_OBJECT_UNREF(nf_instance);
return;
}
ogs_debug("[%s] NFInstance removed [%s:%d]",
nf_instance->nf_type ?
OpenAPI_nf_type_ToString(nf_instance->nf_type) : "NULL",
nf_instance->id, nf_instance->reference_count);
ogs_list_remove(&ogs_sbi_self()->nf_instance_list, nf_instance); ogs_list_remove(&ogs_sbi_self()->nf_instance_list, nf_instance);
@ -2130,9 +2118,6 @@ bool ogs_sbi_discovery_param_is_matched(
if (NF_INSTANCE_EXCLUDED_FROM_DISCOVERY(nf_instance)) if (NF_INSTANCE_EXCLUDED_FROM_DISCOVERY(nf_instance))
return false; return false;
if (!OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_registered))
return false;
if (nf_instance->nf_type != target_nf_type) if (nf_instance->nf_type != target_nf_type)
return false; return false;
@ -2202,10 +2187,10 @@ void ogs_sbi_client_associate(ogs_sbi_nf_instance_t *nf_instance)
client = nf_instance_find_client(nf_instance); client = nf_instance_find_client(nf_instance);
ogs_assert(client); ogs_assert(client);
ogs_debug("[%s] NFInstance associated [%s:%d]", ogs_debug("[%s] NFInstance associated [%s]",
nf_instance->nf_type ? nf_instance->nf_type ?
OpenAPI_nf_type_ToString(nf_instance->nf_type) : "NULL", OpenAPI_nf_type_ToString(nf_instance->nf_type) : "NULL",
nf_instance->id, nf_instance->reference_count); nf_instance->id);
OGS_SBI_SETUP_CLIENT(nf_instance, client); OGS_SBI_SETUP_CLIENT(nf_instance, client);
@ -2260,30 +2245,15 @@ ogs_sbi_client_t *ogs_sbi_client_find_by_service_type(
return nf_service->client; return nf_service->client;
} }
return nf_instance->client; return NULL;
} }
void ogs_sbi_object_free(ogs_sbi_object_t *sbi_object) void ogs_sbi_object_free(ogs_sbi_object_t *sbi_object)
{ {
int i;
ogs_assert(sbi_object); ogs_assert(sbi_object);
if (ogs_list_count(&sbi_object->xact_list)) if (ogs_list_count(&sbi_object->xact_list))
ogs_error("SBI running [%d]", ogs_list_count(&sbi_object->xact_list)); ogs_error("SBI running [%d]", ogs_list_count(&sbi_object->xact_list));
for (i = 0; i < OGS_SBI_MAX_NUM_OF_SERVICE_TYPE; i++) {
ogs_sbi_nf_instance_t *nf_instance =
sbi_object->service_type_array[i].nf_instance;
if (nf_instance)
ogs_sbi_nf_instance_remove(nf_instance);
}
for (i = 0; i < OGS_SBI_MAX_NUM_OF_NF_TYPE; i++) {
ogs_sbi_nf_instance_t *nf_instance =
sbi_object->nf_type_array[i].nf_instance;
if (nf_instance)
ogs_sbi_nf_instance_remove(nf_instance);
}
} }
ogs_sbi_xact_t *ogs_sbi_xact_add( ogs_sbi_xact_t *ogs_sbi_xact_add(
@ -2493,12 +2463,26 @@ ogs_sbi_subscription_data_t *ogs_sbi_subscription_data_add(void)
return subscription_data; return subscription_data;
} }
void ogs_sbi_subscription_data_set_resource_uri(
ogs_sbi_subscription_data_t *subscription_data, char *resource_uri)
{
ogs_assert(subscription_data);
ogs_assert(resource_uri);
if (subscription_data->resource_uri)
ogs_free(subscription_data->resource_uri);
subscription_data->resource_uri = ogs_strdup(resource_uri);
ogs_assert(subscription_data->resource_uri);
}
void ogs_sbi_subscription_data_set_id( void ogs_sbi_subscription_data_set_id(
ogs_sbi_subscription_data_t *subscription_data, char *id) ogs_sbi_subscription_data_t *subscription_data, char *id)
{ {
ogs_assert(subscription_data); ogs_assert(subscription_data);
ogs_assert(id); ogs_assert(id);
if (subscription_data->id)
ogs_free(subscription_data->id);
subscription_data->id = ogs_strdup(id); subscription_data->id = ogs_strdup(id);
ogs_assert(subscription_data->id); ogs_assert(subscription_data->id);
} }
@ -2516,6 +2500,9 @@ void ogs_sbi_subscription_data_remove(
if (subscription_data->notification_uri) if (subscription_data->notification_uri)
ogs_free(subscription_data->notification_uri); ogs_free(subscription_data->notification_uri);
if (subscription_data->resource_uri)
ogs_free(subscription_data->resource_uri);
if (subscription_data->req_nf_instance_id) if (subscription_data->req_nf_instance_id)
ogs_free(subscription_data->req_nf_instance_id); ogs_free(subscription_data->req_nf_instance_id);

View File

@ -175,7 +175,6 @@ typedef struct ogs_sbi_nf_instance_s {
#define NF_INSTANCE_CLIENT(__nFInstance) \ #define NF_INSTANCE_CLIENT(__nFInstance) \
((__nFInstance) ? ((__nFInstance)->client) : NULL) ((__nFInstance) ? ((__nFInstance)->client) : NULL)
void *client; /* only used in CLIENT */ void *client; /* only used in CLIENT */
unsigned int reference_count; /* reference count for memory free */
} ogs_sbi_nf_instance_t; } ogs_sbi_nf_instance_t;
typedef enum { typedef enum {
@ -194,6 +193,16 @@ typedef struct ogs_sbi_object_s {
struct { struct {
ogs_sbi_nf_instance_t *nf_instance; ogs_sbi_nf_instance_t *nf_instance;
/*
* Search.Result stored in nf_instance->time.validity_duration;
*
* validity_timeout = nf_instance->validity->timeout =
* ogs_get_monotonic_time() + nf_instance->time.validity_duration;
*
* if no validityPeriod in SearchResult, validity_timeout is 0.
*/
ogs_time_t validity_timeout;
} nf_type_array[OGS_SBI_MAX_NUM_OF_NF_TYPE], } nf_type_array[OGS_SBI_MAX_NUM_OF_NF_TYPE],
service_type_array[OGS_SBI_MAX_NUM_OF_SERVICE_TYPE]; service_type_array[OGS_SBI_MAX_NUM_OF_SERVICE_TYPE];
@ -286,6 +295,7 @@ typedef struct ogs_sbi_subscription_data_s {
OpenAPI_nf_type_e req_nf_type; /* reqNfType */ OpenAPI_nf_type_e req_nf_type; /* reqNfType */
OpenAPI_nf_status_e nf_status; OpenAPI_nf_status_e nf_status;
char *notification_uri; char *notification_uri;
char *resource_uri;
struct { struct {
OpenAPI_nf_type_e nf_type; /* nfType */ OpenAPI_nf_type_e nf_type; /* nfType */
@ -295,7 +305,7 @@ typedef struct ogs_sbi_subscription_data_s {
uint64_t requester_features; uint64_t requester_features;
uint64_t nrf_supported_features; uint64_t nrf_supported_features;
void *client; /* only used in SERVER */ void *client;
} ogs_sbi_subscription_data_t; } ogs_sbi_subscription_data_t;
typedef struct ogs_sbi_smf_info_s { typedef struct ogs_sbi_smf_info_s {
@ -461,18 +471,47 @@ int ogs_sbi_default_client_port(OpenAPI_uri_scheme_e scheme);
#define OGS_SBI_SETUP_NF_INSTANCE(__cTX, __nFInstance) \ #define OGS_SBI_SETUP_NF_INSTANCE(__cTX, __nFInstance) \
do { \ do { \
ogs_assert(__nFInstance); \ ogs_assert(__nFInstance); \
ogs_assert((__nFInstance)->id); \
ogs_assert((__nFInstance)->t_validity); \
\ \
if ((__cTX).nf_instance) { \ if ((__cTX).nf_instance) { \
ogs_warn("NF Instance [%s] updated [%s]", \ ogs_warn("[%s] NF Instance updated [type:%s validity:%ds]", \
OpenAPI_nf_type_ToString((__nFInstance)->nf_type), \ ((__cTX).nf_instance)->id, \
(__nFInstance)->id); \ OpenAPI_nf_type_ToString(((__cTX).nf_instance)->nf_type), \
ogs_sbi_nf_instance_remove((__cTX).nf_instance); \ ((__cTX).nf_instance)->time.validity_duration); \
} \ } \
\ \
OGS_OBJECT_REF(__nFInstance); \ ((__cTX).nf_instance) = __nFInstance; \
((__cTX).nf_instance) = (__nFInstance); \ if ((__nFInstance)->time.validity_duration) { \
((__cTX).validity_timeout) = (__nFInstance)->t_validity->timeout; \
} else { \
((__cTX).validity_timeout) = 0; \
} \
ogs_info("[%s] NF Instance setup [type:%s validity:%ds]", \
(__nFInstance)->id, \
OpenAPI_nf_type_ToString((__nFInstance)->nf_type), \
(__nFInstance)->time.validity_duration); \
} while(0) } while(0)
/*
* Search.Result stored in nf_instance->time.validity_duration;
*
* validity_timeout = nf_instance->validity->timeout =
* ogs_get_monotonic_time() + nf_instance->time.validity_duration;
*
* if no validityPeriod in SearchResult, validity_timeout is 0.
*/
#define OGS_SBI_GET_NF_INSTANCE(__cTX) \
((__cTX).validity_timeout == 0 || \
(__cTX).validity_timeout > ogs_get_monotonic_time() ? \
((__cTX).nf_instance) : NULL)
#define OGS_SBI_NF_INSTANCE_VALID(__nFInstance) \
(((__nFInstance) && ((__nFInstance)->t_validity) && \
((__nFInstance)->time.validity_duration == 0 || \
(__nFInstance)->t_validity->timeout > ogs_get_monotonic_time())) ? \
true : false)
bool ogs_sbi_discovery_param_is_matched( bool ogs_sbi_discovery_param_is_matched(
ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_nf_instance_t *nf_instance,
OpenAPI_nf_type_e target_nf_type, OpenAPI_nf_type_e target_nf_type,
@ -515,6 +554,8 @@ void ogs_sbi_subscription_spec_remove(
void ogs_sbi_subscription_spec_remove_all(void); void ogs_sbi_subscription_spec_remove_all(void);
ogs_sbi_subscription_data_t *ogs_sbi_subscription_data_add(void); ogs_sbi_subscription_data_t *ogs_sbi_subscription_data_add(void);
void ogs_sbi_subscription_data_set_resource_uri(
ogs_sbi_subscription_data_t *subscription_data, char *resource_uri);
void ogs_sbi_subscription_data_set_id( void ogs_sbi_subscription_data_set_id(
ogs_sbi_subscription_data_t *subscription_data, char *id); ogs_sbi_subscription_data_t *subscription_data, char *id);
void ogs_sbi_subscription_data_remove( void ogs_sbi_subscription_data_remove(

View File

@ -32,19 +32,6 @@ void ogs_sbi_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance)
ogs_sbi_nf_state_initial, ogs_sbi_nf_state_final, &e); ogs_sbi_nf_state_initial, ogs_sbi_nf_state_final, &e);
} }
void ogs_sbi_nf_fsm_tran(ogs_sbi_nf_instance_t *nf_instance, void *state)
{
ogs_event_t e;
ogs_assert(nf_instance);
ogs_assert(OGS_FSM_STATE(&nf_instance->sm));
memset(&e, 0, sizeof(e));
e.sbi.data = nf_instance;
ogs_fsm_tran(&nf_instance->sm, state, &e);
}
void ogs_sbi_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) void ogs_sbi_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance)
{ {
ogs_event_t e; ogs_event_t e;
@ -307,7 +294,7 @@ void ogs_sbi_nf_state_registered(ogs_fsm_t *s, ogs_event_t *e)
break; break;
case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT:
ogs_error("[%s:%s] No heartbeat", ogs_error("[%s] No heartbeat [type:%s]",
NF_INSTANCE_ID(ogs_sbi_self()->nf_instance), NF_INSTANCE_ID(ogs_sbi_self()->nf_instance),
OpenAPI_nf_type_ToString( OpenAPI_nf_type_ToString(
NF_INSTANCE_TYPE(ogs_sbi_self()->nf_instance))); NF_INSTANCE_TYPE(ogs_sbi_self()->nf_instance)));
@ -318,22 +305,24 @@ void ogs_sbi_nf_state_registered(ogs_fsm_t *s, ogs_event_t *e)
ogs_assert(!NF_INSTANCE_TYPE_IS_NRF(nf_instance)); ogs_assert(!NF_INSTANCE_TYPE_IS_NRF(nf_instance));
ogs_assert(nf_instance->id); ogs_assert(nf_instance->id);
ogs_info("[%s] NF expired", nf_instance->id); ogs_info("[%s] NF expired [type:%s]",
nf_instance->id,
OpenAPI_nf_type_ToString(nf_instance->nf_type));
OGS_FSM_TRAN(s, &ogs_sbi_nf_state_de_registered); OGS_FSM_TRAN(s, &ogs_sbi_nf_state_de_registered);
break; break;
default: default:
ogs_error("[%s:%s] Unknown timer[%s:%d]", ogs_error("[%s] Unknown timer [type:%s timer:%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined", nf_instance->id ? nf_instance->id : "Undefined",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
ogs_timer_get_name(e->timer_id), e->timer_id); ogs_timer_get_name(e->timer_id), e->timer_id);
} }
break; break;
default: default:
ogs_error("[%s:%s] Unknown event %s", ogs_error("[%s] Unknown event [type:%s event:%s]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined", nf_instance->id ? nf_instance->id : "Undefined",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
ogs_event_get_name(e)); ogs_event_get_name(e));
break; break;
} }
@ -353,19 +342,20 @@ void ogs_sbi_nf_state_de_registered(ogs_fsm_t *s, ogs_event_t *e)
switch (e->id) { switch (e->id) {
case OGS_FSM_ENTRY_SIG: case OGS_FSM_ENTRY_SIG:
if (NF_INSTANCE_TYPE_IS_NRF(nf_instance)) { ogs_info("[%s] NF de-registered [type:%s]",
ogs_info("[%s] NF de-registered", nf_instance->id,
NF_INSTANCE_ID(ogs_sbi_self()->nf_instance)); OpenAPI_nf_type_ToString(nf_instance->nf_type));
} ogs_sbi_nf_fsm_fini(nf_instance);
ogs_sbi_nf_instance_remove(nf_instance);
break; break;
case OGS_FSM_EXIT_SIG: case OGS_FSM_EXIT_SIG:
break; break;
default: default:
ogs_error("[%s:%s] Unknown event %s", ogs_error("[%s] Unknown event [type:%s event:%s]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined", nf_instance->id ? nf_instance->id : "Undefined",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
ogs_event_get_name(e)); ogs_event_get_name(e));
break; break;
} }
@ -409,9 +399,9 @@ void ogs_sbi_nf_state_exception(ogs_fsm_t *s, ogs_event_t *e)
break; break;
default: default:
ogs_error("[%s:%s] Unknown timer[%s:%d]", ogs_error("[%s] Unknown timer[type:%s timer:%s:%d]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined", nf_instance->id ? nf_instance->id : "Undefined",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
ogs_timer_get_name(e->timer_id), e->timer_id); ogs_timer_get_name(e->timer_id), e->timer_id);
} }
break; break;
@ -437,9 +427,9 @@ void ogs_sbi_nf_state_exception(ogs_fsm_t *s, ogs_event_t *e)
break; break;
default: default:
ogs_error("[%s:%s] Unknown event %s", ogs_error("[%s] Unknown event [type:%s event:%s]",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->id ? nf_instance->id : "Undefined", nf_instance->id ? nf_instance->id : "Undefined",
OpenAPI_nf_type_ToString(nf_instance->nf_type),
ogs_event_get_name(e)); ogs_event_get_name(e));
break; break;
} }

View File

@ -29,7 +29,6 @@ extern "C" {
#endif #endif
void ogs_sbi_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); void ogs_sbi_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance);
void ogs_sbi_nf_fsm_tran(ogs_sbi_nf_instance_t *nf_instance, void *state);
void ogs_sbi_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); void ogs_sbi_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance);
void ogs_sbi_nf_state_initial(ogs_fsm_t *s, ogs_event_t *e); void ogs_sbi_nf_state_initial(ogs_fsm_t *s, ogs_event_t *e);

View File

@ -1712,11 +1712,7 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_status_update(
memset(&message, 0, sizeof(message)); memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PATCH; message.h.method = (char *)OGS_SBI_HTTP_METHOD_PATCH;
message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; message.h.uri = subscription_data->resource_uri;
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS;
message.h.resource.component[1] = subscription_data->id;
message.http.content_type = (char *)OGS_SBI_CONTENT_PATCH_TYPE; message.http.content_type = (char *)OGS_SBI_CONTENT_PATCH_TYPE;
@ -1771,11 +1767,7 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_status_unsubscribe(
memset(&message, 0, sizeof(message)); memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE; message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE;
message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; message.h.uri = subscription_data->resource_uri;
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] =
(char *)OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS;
message.h.resource.component[1] = subscription_data->id;
message.http.custom.callback = message.http.custom.callback =
(char *)OGS_SBI_CALLBACK_NNRF_NFMANAGEMENT_NF_STATUS_NOTIFY; (char *)OGS_SBI_CALLBACK_NNRF_NFMANAGEMENT_NF_STATUS_NOTIFY;

View File

@ -54,6 +54,15 @@ void ogs_nnrf_nfm_handle_nf_register(
OpenAPI_list_for_each(NFProfile->plmn_list, node) { OpenAPI_list_for_each(NFProfile->plmn_list, node) {
OpenAPI_plmn_id_t *PlmnId = node->data; OpenAPI_plmn_id_t *PlmnId = node->data;
if (PlmnId) { if (PlmnId) {
if (ogs_local_conf()->num_of_serving_plmn_id >=
OGS_ARRAY_SIZE(ogs_local_conf()->serving_plmn_id)) {
ogs_error("OVERFLOW NFProfile->plmn_list [%d:%d:%d]",
ogs_local_conf()->num_of_serving_plmn_id,
OGS_MAX_NUM_OF_PLMN,
(int)OGS_ARRAY_SIZE(
ogs_local_conf()->serving_plmn_id));
break;
}
ogs_sbi_parse_plmn_id( ogs_sbi_parse_plmn_id(
&ogs_local_conf()->serving_plmn_id[ &ogs_local_conf()->serving_plmn_id[
ogs_local_conf()->num_of_serving_plmn_id], PlmnId); ogs_local_conf()->num_of_serving_plmn_id], PlmnId);
@ -96,6 +105,13 @@ void ogs_nnrf_nfm_handle_nf_profile(
OpenAPI_list_for_each(NFProfile->plmn_list, node) { OpenAPI_list_for_each(NFProfile->plmn_list, node) {
OpenAPI_plmn_id_t *PlmnId = node->data; OpenAPI_plmn_id_t *PlmnId = node->data;
if (PlmnId) { if (PlmnId) {
if (nf_instance->num_of_plmn_id >=
OGS_ARRAY_SIZE(nf_instance->plmn_id)) {
ogs_error("OVERFLOW NFProfile->plmn_list [%d:%d:%d]",
nf_instance->num_of_plmn_id, OGS_MAX_NUM_OF_PLMN,
(int)OGS_ARRAY_SIZE(nf_instance->plmn_id));
break;
}
ogs_sbi_parse_plmn_id( ogs_sbi_parse_plmn_id(
&nf_instance->plmn_id[nf_instance->num_of_plmn_id], PlmnId); &nf_instance->plmn_id[nf_instance->num_of_plmn_id], PlmnId);
nf_instance->num_of_plmn_id++; nf_instance->num_of_plmn_id++;
@ -467,8 +483,12 @@ static void handle_smf_info(
TaiRangeItem = node->data; TaiRangeItem = node->data;
if (TaiRangeItem && TaiRangeItem->plmn_id && if (TaiRangeItem && TaiRangeItem->plmn_id &&
TaiRangeItem->tac_range_list) { TaiRangeItem->tac_range_list) {
ogs_assert(nf_info->smf.num_of_nr_tai_range <
OGS_MAX_NUM_OF_TAI); if (nf_info->smf.num_of_nr_tai_range >= OGS_MAX_NUM_OF_TAI) {
ogs_error("OVERFLOW TaiRangeItem [%d:%d]",
nf_info->smf.num_of_nr_tai_range, OGS_MAX_NUM_OF_TAI);
break;
}
ogs_sbi_parse_plmn_id( ogs_sbi_parse_plmn_id(
&nf_info->smf.nr_tai_range &nf_info->smf.nr_tai_range
@ -709,7 +729,13 @@ static void handle_amf_info(
TaiItem = node->data; TaiItem = node->data;
if (TaiItem && TaiItem->plmn_id && TaiItem->tac) { if (TaiItem && TaiItem->plmn_id && TaiItem->tac) {
ogs_5gs_tai_t *nr_tai = NULL; ogs_5gs_tai_t *nr_tai = NULL;
ogs_assert(nf_info->amf.num_of_nr_tai < OGS_MAX_NUM_OF_TAI);
if (nf_info->amf.num_of_nr_tai >= OGS_MAX_NUM_OF_TAI) {
ogs_error("OVERFLOW TaiItem [%d:%d]",
nf_info->amf.num_of_nr_tai, OGS_MAX_NUM_OF_TAI);
break;
}
nr_tai = &nf_info->amf.nr_tai[nf_info->amf.num_of_nr_tai]; nr_tai = &nf_info->amf.nr_tai[nf_info->amf.num_of_nr_tai];
ogs_assert(nr_tai); ogs_assert(nr_tai);
ogs_sbi_parse_plmn_id(&nr_tai->plmn_id, TaiItem->plmn_id); ogs_sbi_parse_plmn_id(&nr_tai->plmn_id, TaiItem->plmn_id);
@ -726,6 +752,12 @@ static void handle_amf_info(
ogs_assert(nf_info->amf.num_of_nr_tai_range < ogs_assert(nf_info->amf.num_of_nr_tai_range <
OGS_MAX_NUM_OF_TAI); OGS_MAX_NUM_OF_TAI);
if (nf_info->amf.num_of_nr_tai_range >= OGS_MAX_NUM_OF_TAI) {
ogs_error("OVERFLOW TaiRangeItem [%d:%d]",
nf_info->amf.num_of_nr_tai_range, OGS_MAX_NUM_OF_TAI);
break;
}
ogs_sbi_parse_plmn_id( ogs_sbi_parse_plmn_id(
&nf_info->amf.nr_tai_range &nf_info->amf.nr_tai_range
[nf_info->amf.num_of_nr_tai_range].plmn_id, [nf_info->amf.num_of_nr_tai_range].plmn_id,
@ -824,6 +856,17 @@ void ogs_nnrf_nfm_handle_nf_status_subscribe(
{ {
OpenAPI_subscription_data_t *SubscriptionData = NULL; OpenAPI_subscription_data_t *SubscriptionData = NULL;
int rv;
ogs_sbi_message_t message;
ogs_sbi_header_t header;
bool rc;
ogs_sbi_client_t *client = NULL;
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
char *fqdn = NULL;
uint16_t fqdn_port = 0;
ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
ogs_assert(recvmsg); ogs_assert(recvmsg);
ogs_assert(subscription_data); ogs_assert(subscription_data);
@ -833,45 +876,63 @@ void ogs_nnrf_nfm_handle_nf_status_subscribe(
return; return;
} }
if (recvmsg->http.location) { if (!recvmsg->http.location) {
int rv; ogs_error("No http.location");
ogs_sbi_message_t message;
ogs_sbi_header_t header;
memset(&header, 0, sizeof(header));
header.uri = recvmsg->http.location;
rv = ogs_sbi_parse_header(&message, &header);
if (rv != OGS_OK) {
ogs_error("Cannot parse http.location [%s]",
recvmsg->http.location);
return;
}
if (!message.h.resource.component[1]) {
ogs_error("No Subscription ID [%s]", recvmsg->http.location);
ogs_sbi_header_free(&header);
return;
}
ogs_sbi_subscription_data_set_id(
subscription_data, message.h.resource.component[1]);
ogs_sbi_header_free(&header);
} else if (SubscriptionData->subscription_id) {
/*
* For compatibility with v2.5.x and lower versions
*
* Deprecated : It will be removed soon.
*/
ogs_sbi_subscription_data_set_id(
subscription_data, SubscriptionData->subscription_id);
} else {
ogs_error("No Subscription ID");
return; return;
} }
memset(&header, 0, sizeof(header));
header.uri = recvmsg->http.location;
rv = ogs_sbi_parse_header(&message, &header);
if (rv != OGS_OK) {
ogs_error("Cannot parse http.location [%s]",
recvmsg->http.location);
return;
}
if (!message.h.resource.component[1]) {
ogs_error("No Subscription ID [%s]", recvmsg->http.location);
ogs_sbi_header_free(&header);
return;
}
rc = ogs_sbi_getaddr_from_uri(
&scheme, &fqdn, &fqdn_port, &addr, &addr6, header.uri);
if (rc == false || scheme == OpenAPI_uri_scheme_NULL) {
ogs_error("Invalid URI [%s]", header.uri);
ogs_sbi_header_free(&header);
return;
}
client = ogs_sbi_client_find(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_debug("%s: ogs_sbi_client_add()", OGS_FUNC);
client = ogs_sbi_client_add(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_error("%s: ogs_sbi_client_add() failed", OGS_FUNC);
ogs_sbi_header_free(&header);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
return;
}
}
OGS_SBI_SETUP_CLIENT(subscription_data, client);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
ogs_sbi_subscription_data_set_resource_uri(
subscription_data, header.uri);
ogs_sbi_subscription_data_set_id(
subscription_data, message.h.resource.component[1]);
ogs_sbi_header_free(&header);
/* SBI Features */ /* SBI Features */
if (SubscriptionData->nrf_supported_features) { if (SubscriptionData->nrf_supported_features) {
subscription_data->nrf_supported_features = subscription_data->nrf_supported_features =
@ -1026,24 +1087,23 @@ bool ogs_nnrf_nfm_handle_nf_status_notify(
nf_instance, message.h.resource.component[1]); nf_instance, message.h.resource.component[1]);
ogs_sbi_nf_fsm_init(nf_instance); ogs_sbi_nf_fsm_init(nf_instance);
ogs_info("(NRF-notify) NF registered [%s:%d]", ogs_info("[%s] (NRF-notify) NF registered", nf_instance->id);
nf_instance->id, nf_instance->reference_count);
} else { } else {
ogs_warn("[%s] (NRF-notify) NF has already been added [%s:%d]", ogs_warn("[%s] (NRF-notify) NF has already been added [type:%s]",
nf_instance->nf_type ? nf_instance->id,
OpenAPI_nf_type_ToString(nf_instance->nf_type) : "NULL", OpenAPI_nf_type_ToString(nf_instance->nf_type));
nf_instance->id, nf_instance->reference_count); if (!OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_registered)) {
ogs_error("[%s] (NRF-notify) NF invalid state [type:%s]",
ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); nf_instance->id,
ogs_sbi_nf_fsm_tran(nf_instance, ogs_sbi_nf_state_registered); OpenAPI_nf_type_ToString(nf_instance->nf_type));
}
} }
ogs_nnrf_nfm_handle_nf_profile(nf_instance, NFProfile); ogs_nnrf_nfm_handle_nf_profile(nf_instance, NFProfile);
ogs_info("[%s] (NRF-notify) NF Profile updated [%s:%d]", ogs_info("[%s] (NRF-notify) NF Profile updated [type:%s]",
nf_instance->nf_type ? nf_instance->id,
OpenAPI_nf_type_ToString(nf_instance->nf_type) : "NULL", OpenAPI_nf_type_ToString(nf_instance->nf_type));
nf_instance->id, nf_instance->reference_count);
ogs_sbi_client_associate(nf_instance); ogs_sbi_client_associate(nf_instance);
@ -1059,27 +1119,11 @@ bool ogs_nnrf_nfm_handle_nf_status_notify(
OpenAPI_notification_event_type_NF_DEREGISTERED) { OpenAPI_notification_event_type_NF_DEREGISTERED) {
nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component[1]); nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component[1]);
if (nf_instance) { if (nf_instance) {
if (OGS_OBJECT_IS_REF(nf_instance)) { ogs_info("[%s] (NRF-notify) NF_DEREGISTERED event [type:%s]",
/* There are references to other contexts. */ nf_instance->id,
ogs_warn("[%s] (NRF-notify) NF was referenced " OpenAPI_nf_type_ToString(nf_instance->nf_type));
"in other contexts [%s:%d]", ogs_sbi_nf_fsm_fini(nf_instance);
nf_instance->nf_type ? ogs_sbi_nf_instance_remove(nf_instance);
OpenAPI_nf_type_ToString(nf_instance->nf_type) :
"NULL",
nf_instance->id, nf_instance->reference_count);
ogs_assert(OGS_FSM_STATE(&nf_instance->sm));
ogs_sbi_nf_fsm_tran(
nf_instance, ogs_sbi_nf_state_de_registered);
} else {
ogs_info("[%s] (NRF-notify) NF_DEREGISTERED event [%s:%d]",
nf_instance->nf_type ?
OpenAPI_nf_type_ToString(nf_instance->nf_type) :
"NULL",
nf_instance->id, nf_instance->reference_count);
ogs_sbi_nf_fsm_fini((nf_instance));
ogs_sbi_nf_instance_remove(nf_instance);
}
} else { } else {
ogs_warn("[%s] (NRF-notify) Not found", ogs_warn("[%s] (NRF-notify) Not found",
message.h.resource.component[1]); message.h.resource.component[1]);
@ -1155,18 +1199,18 @@ void ogs_nnrf_disc_handle_nf_discover_search_result(
ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id);
ogs_sbi_nf_fsm_init(nf_instance); ogs_sbi_nf_fsm_init(nf_instance);
ogs_info("[%s] (NRF-discover) NF registered [%s:%d]", ogs_info("[%s] (NRF-discover) NF registered [type:%s]",
nf_instance->nf_type ? nf_instance->id,
OpenAPI_nf_type_ToString(nf_instance->nf_type) : "NULL", OpenAPI_nf_type_ToString(nf_instance->nf_type));
nf_instance->id, nf_instance->reference_count);
} else { } else {
ogs_warn("[%s] (NRF-discover) NF has already been added [%s:%d]", ogs_warn("[%s] (NRF-discover) NF has already been added [type:%s]",
nf_instance->nf_type ? nf_instance->id,
OpenAPI_nf_type_ToString(nf_instance->nf_type) : "NULL", OpenAPI_nf_type_ToString(nf_instance->nf_type));
nf_instance->id, nf_instance->reference_count); if (!OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_registered)) {
ogs_error("[%s] (NRF-notify) NF invalid state [type:%s]",
ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); nf_instance->id,
ogs_sbi_nf_fsm_tran(nf_instance, ogs_sbi_nf_state_registered); OpenAPI_nf_type_ToString(nf_instance->nf_type));
}
} }
if (NF_INSTANCE_ID_IS_OTHERS(nf_instance->id)) { if (NF_INSTANCE_ID_IS_OTHERS(nf_instance->id)) {
@ -1193,15 +1237,18 @@ void ogs_nnrf_disc_handle_nf_discover_search_result(
ogs_time_from_sec(nf_instance->time.validity_duration)); ogs_time_from_sec(nf_instance->time.validity_duration));
} else } else
ogs_warn("[%s] NF Instance validity-time should not 0 [%s:%d]", ogs_warn("[%s] NF Instance validity-time should not 0 "
"[type:%s]",
nf_instance->id,
nf_instance->nf_type ? nf_instance->nf_type ?
OpenAPI_nf_type_ToString(nf_instance->nf_type) : "NULL", OpenAPI_nf_type_ToString(nf_instance->nf_type) :
nf_instance->id, nf_instance->reference_count); "NULL");
ogs_info("[%s] (NF-discover) NF Profile updated [%s:%d]", ogs_info("[%s] (NF-discover) NF Profile updated "
nf_instance->nf_type ? "[type:%s validity:%ds]",
OpenAPI_nf_type_ToString(nf_instance->nf_type) : "NULL", nf_instance->id,
nf_instance->id, nf_instance->reference_count); OpenAPI_nf_type_ToString(nf_instance->nf_type),
nf_instance->time.validity_duration);
} }
} }
} }

View File

@ -208,18 +208,19 @@ static int client_discover_cb(
ogs_sbi_nf_fsm_init(nf_instance); ogs_sbi_nf_fsm_init(nf_instance);
ogs_info("[%s] (SCP-discover) NF registered [%s:%d]", ogs_info("[%s] (SCP-discover) NF registered [%s]",
nf_instance->nf_type ? nf_instance->nf_type ?
OpenAPI_nf_type_ToString(nf_instance->nf_type) : "NULL", OpenAPI_nf_type_ToString(nf_instance->nf_type) : "NULL",
nf_instance->id, nf_instance->reference_count); nf_instance->id);
} else { } else {
ogs_warn("[%s] (SCP-discover) NF has already been added [%s:%d]", ogs_warn("[%s] (SCP-discover) NF has already been added [%s]",
nf_instance->nf_type ? OpenAPI_nf_type_ToString(nf_instance->nf_type),
OpenAPI_nf_type_ToString(nf_instance->nf_type) : "NULL", nf_instance->id);
nf_instance->id, nf_instance->reference_count); if (!OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_registered)) {
ogs_error("[%s] (SCP-discover) NF invalid state [%s]",
ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); OpenAPI_nf_type_ToString(nf_instance->nf_type),
ogs_sbi_nf_fsm_tran(nf_instance, ogs_sbi_nf_state_registered); nf_instance->id);
}
} }
OGS_SBI_SETUP_NF_INSTANCE( OGS_SBI_SETUP_NF_INSTANCE(
@ -281,7 +282,8 @@ int ogs_sbi_discover_and_send(ogs_sbi_xact_t *xact)
} }
/* Target NF-Instance */ /* Target NF-Instance */
nf_instance = sbi_object->service_type_array[service_type].nf_instance; nf_instance = OGS_SBI_GET_NF_INSTANCE(
sbi_object->service_type_array[service_type]);
if (!nf_instance) { if (!nf_instance) {
nf_instance = ogs_sbi_nf_instance_find_by_discovery_param( nf_instance = ogs_sbi_nf_instance_find_by_discovery_param(
target_nf_type, requester_nf_type, discovery_option); target_nf_type, requester_nf_type, discovery_option);
@ -313,6 +315,11 @@ int ogs_sbi_discover_and_send(ogs_sbi_xact_t *xact)
ogs_free(fqdn); ogs_free(fqdn);
ogs_freeaddrinfo(addr); ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6); ogs_freeaddrinfo(addr6);
if (!client) {
ogs_fatal("No Client : [%s]", request->h.uri);
ogs_assert_if_reached();
}
} }
if (scp_client) { if (scp_client) {

View File

@ -16,7 +16,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
project('open5gs', 'c', 'cpp', project('open5gs', 'c', 'cpp',
version : '2.7.0', version : '2.7.1',
license : 'AGPL-3.0-or-later', license : 'AGPL-3.0-or-later',
meson_version : '>= 0.43.0', meson_version : '>= 0.43.0',
default_options : [ default_options : [
@ -25,7 +25,7 @@ project('open5gs', 'c', 'cpp',
], ],
) )
libogslib_version = '2.7.0' libogslib_version = '2.7.1'
prefix = get_option('prefix') prefix = get_option('prefix')
bindir = join_paths(prefix, get_option('bindir')) bindir = join_paths(prefix, get_option('bindir'))

View File

@ -1676,13 +1676,17 @@ void amf_ue_remove(amf_ue_t *amf_ue)
/* Clear SubscribedInfo */ /* Clear SubscribedInfo */
amf_clear_subscribed_info(amf_ue); amf_clear_subscribed_info(amf_ue);
if (amf_ue->policy_association_id) PCF_AM_POLICY_CLEAR(amf_ue);
ogs_free(amf_ue->policy_association_id); if (amf_ue->policy_association.client)
if (amf_ue->data_change_subscription_id) ogs_sbi_client_remove(amf_ue->policy_association.client);
ogs_free(amf_ue->data_change_subscription_id);
if (amf_ue->confirmation_url_for_5g_aka) UDM_SDM_CLEAR(amf_ue);
ogs_free(amf_ue->confirmation_url_for_5g_aka); if (amf_ue->data_change_subscription.client)
ogs_sbi_client_remove(amf_ue->data_change_subscription.client);
CLEAR_5G_AKA_CONFIRMATION(amf_ue);
if (amf_ue->confirmation_for_5g_aka.client)
ogs_sbi_client_remove(amf_ue->confirmation_for_5g_aka.client);
/* Free UeRadioCapability */ /* Free UeRadioCapability */
OGS_ASN_CLEAR_DATA(&amf_ue->ueRadioCapability); OGS_ASN_CLEAR_DATA(&amf_ue->ueRadioCapability);
@ -2249,8 +2253,10 @@ void amf_sess_remove(amf_sess_t *sess)
ogs_list_count(&sess->sbi.xact_list)); ogs_list_count(&sess->sbi.xact_list));
ogs_sbi_object_free(&sess->sbi); ogs_sbi_object_free(&sess->sbi);
if (sess->sm_context_ref) CLEAR_SESSION_CONTEXT(sess);
ogs_free(sess->sm_context_ref);
if (sess->sm_context.client)
ogs_sbi_client_remove(sess->sm_context.client);
if (sess->payload_container) if (sess->payload_container)
ogs_pkbuf_free(sess->payload_container); ogs_pkbuf_free(sess->payload_container);

View File

@ -290,13 +290,33 @@ struct amf_ue_s {
/* PCF sends the RESPONSE /* PCF sends the RESPONSE
* of [POST] /npcf-am-polocy-control/v1/policies */ * of [POST] /npcf-am-polocy-control/v1/policies */
#define PCF_AM_POLICY_ASSOCIATED(__aMF) \ #define PCF_AM_POLICY_ASSOCIATED(__aMF) \
((__aMF) && ((__aMF)->policy_association_id)) ((__aMF) && ((__aMF)->policy_association.id))
#define PCF_AM_POLICY_CLEAR(__aMF) \ #define PCF_AM_POLICY_CLEAR(__aMF) \
OGS_MEM_CLEAR((__aMF)->policy_association_id); do { \
#define PCF_AM_POLICY_STORE(__aMF, __iD) \ ogs_assert((__aMF)); \
OGS_STRING_DUP((__aMF)->policy_association_id, __iD); if ((__aMF)->policy_association.resource_uri) \
char *policy_association_id; ogs_free((__aMF)->policy_association.resource_uri); \
(__aMF)->policy_association.resource_uri = NULL; \
if ((__aMF)->policy_association.id) \
ogs_free((__aMF)->policy_association.id); \
(__aMF)->policy_association.id = NULL; \
} while(0)
#define PCF_AM_POLICY_STORE(__aMF, __rESOURCE_URI, __iD) \
do { \
ogs_assert((__aMF)); \
ogs_assert((__rESOURCE_URI)); \
ogs_assert((__iD)); \
PCF_AM_POLICY_CLEAR(__aMF); \
(__aMF)->policy_association.resource_uri = ogs_strdup(__rESOURCE_URI); \
ogs_assert((__aMF)->policy_association.resource_uri); \
(__aMF)->policy_association.id = ogs_strdup(__iD); \
ogs_assert((__aMF)->policy_association.id); \
} while(0)
struct {
char *resource_uri;
char *id;
ogs_sbi_client_t *client;
} policy_association;
/* 5GMM Capability */ /* 5GMM Capability */
struct { struct {
@ -322,7 +342,27 @@ struct amf_ue_s {
/* Security Context */ /* Security Context */
ogs_nas_ue_security_capability_t ue_security_capability; ogs_nas_ue_security_capability_t ue_security_capability;
ogs_nas_ue_network_capability_t ue_network_capability; ogs_nas_ue_network_capability_t ue_network_capability;
char *confirmation_url_for_5g_aka; #define CHECK_5G_AKA_CONFIRMATION(__aMF) \
((__aMF) && ((__aMF)->confirmation_for_5g_aka.resource_uri))
#define STORE_5G_AKA_CONFIRMATION(__aMF, __rESOURCE_URI) \
do { \
ogs_assert((__aMF)); \
CLEAR_5G_AKA_CONFIRMATION(__aMF); \
(__aMF)->confirmation_for_5g_aka.resource_uri = \
ogs_strdup(__rESOURCE_URI); \
ogs_assert((__aMF)->confirmation_for_5g_aka.resource_uri); \
} while(0)
#define CLEAR_5G_AKA_CONFIRMATION(__aMF) \
do { \
ogs_assert((__aMF)); \
if ((__aMF)->confirmation_for_5g_aka.resource_uri) \
ogs_free((__aMF)->confirmation_for_5g_aka.resource_uri); \
(__aMF)->confirmation_for_5g_aka.resource_uri = NULL; \
} while(0)
struct {
char *resource_uri;
ogs_sbi_client_t *client;
} confirmation_for_5g_aka;
uint8_t rand[OGS_RAND_LEN]; uint8_t rand[OGS_RAND_LEN];
uint8_t autn[OGS_AUTN_LEN]; uint8_t autn[OGS_AUTN_LEN];
uint8_t xres_star[OGS_MAX_RES_LEN]; uint8_t xres_star[OGS_MAX_RES_LEN];
@ -468,8 +508,34 @@ struct amf_ue_s {
/* SubscriptionId of Subscription to Data Change Notification to UDM */ /* SubscriptionId of Subscription to Data Change Notification to UDM */
#define UDM_SDM_SUBSCRIBED(__aMF) \ #define UDM_SDM_SUBSCRIBED(__aMF) \
((__aMF) && ((__aMF)->data_change_subscription_id)) ((__aMF) && ((__aMF)->data_change_subscription.id))
char *data_change_subscription_id; #define UDM_SDM_CLEAR(__aMF) \
do { \
ogs_assert((__aMF)); \
if ((__aMF)->data_change_subscription.resource_uri) \
ogs_free((__aMF)->data_change_subscription.resource_uri); \
(__aMF)->data_change_subscription.resource_uri = NULL; \
if ((__aMF)->data_change_subscription.id) \
ogs_free((__aMF)->data_change_subscription.id); \
(__aMF)->data_change_subscription.id = NULL; \
} while(0)
#define UDM_SDM_STORE(__aMF, __rESOURCE_URI, __iD) \
do { \
ogs_assert((__aMF)); \
ogs_assert((__rESOURCE_URI)); \
ogs_assert((__iD)); \
UDM_SDM_CLEAR(__aMF); \
(__aMF)->data_change_subscription.resource_uri = \
ogs_strdup(__rESOURCE_URI); \
ogs_assert((__aMF)->data_change_subscription.resource_uri); \
(__aMF)->data_change_subscription.id = ogs_strdup(__iD); \
ogs_assert((__aMF)->data_change_subscription.id); \
} while(0)
struct {
char *resource_uri;
char *id;
ogs_sbi_client_t *client;
} data_change_subscription;
struct { struct {
/* /*
@ -499,18 +565,37 @@ typedef struct amf_sess_s {
uint8_t pti; /* Procedure Trasaction Identity */ uint8_t pti; /* Procedure Trasaction Identity */
#define SESSION_CONTEXT_IN_SMF(__sESS) \ #define SESSION_CONTEXT_IN_SMF(__sESS) \
((__sESS) && (__sESS)->sm_context_ref) ((__sESS) && (__sESS)->sm_context.ref)
#define CLEAR_SM_CONTEXT_REF(__sESS) \ #define STORE_SESSION_CONTEXT(__sESS, __rESOURCE_URI, __rEF) \
do { \ do { \
ogs_assert(__sESS); \ ogs_assert(__sESS); \
ogs_assert((__sESS)->sm_context_ref); \ ogs_assert(__rESOURCE_URI); \
ogs_free((__sESS)->sm_context_ref); \ ogs_assert(__rEF); \
(__sESS)->sm_context_ref = NULL; \ CLEAR_SESSION_CONTEXT(__sESS); \
(__sESS)->sm_context.resource_uri = ogs_strdup(__rESOURCE_URI); \
ogs_assert((__sESS)->sm_context.resource_uri); \
(__sESS)->sm_context.ref = ogs_strdup(__rEF); \
ogs_assert((__sESS)->sm_context.ref); \
} while(0);
#define CLEAR_SESSION_CONTEXT(__sESS) \
do { \
ogs_assert(__sESS); \
if ((__sESS)->sm_context.ref) \
ogs_free((__sESS)->sm_context.ref); \
(__sESS)->sm_context.ref = NULL; \
if ((__sESS)->sm_context.resource_uri) \
ogs_free((__sESS)->sm_context.resource_uri); \
(__sESS)->sm_context.resource_uri = NULL; \
} while(0); } while(0);
/* SMF sends the RESPONSE /* SMF sends the RESPONSE
* of [POST] /nsmf-pdusession/v1/sm-contexts */ * of [POST] /nsmf-pdusession/v1/sm-contexts */
char *sm_context_ref; struct {
char *resource_uri;
char *ref;
ogs_sbi_client_t *client;
} sm_context;
bool pdu_session_release_complete_received; bool pdu_session_release_complete_received;
bool pdu_session_resource_release_response_received; bool pdu_session_resource_release_response_received;

View File

@ -1283,9 +1283,11 @@ int gmm_handle_ul_nas_transport(ran_ue_t *ran_ue, amf_ue_t *amf_ue,
sess->s_nssai.sd.v = selected_slice->s_nssai.sd.v; sess->s_nssai.sd.v = selected_slice->s_nssai.sd.v;
ogs_info("UE SUPI[%s] DNN[%s] S_NSSAI[SST:%d SD:0x%x] " ogs_info("UE SUPI[%s] DNN[%s] S_NSSAI[SST:%d SD:0x%x] "
"smContextRef [%s]", "smContextRef[%s] smContextResourceURI[%s]",
amf_ue->supi, sess->dnn, sess->s_nssai.sst, sess->s_nssai.sd.v, amf_ue->supi, sess->dnn, sess->s_nssai.sst, sess->s_nssai.sd.v,
sess->sm_context_ref ? sess->sm_context_ref : "NULL"); sess->sm_context.ref ? sess->sm_context.ref : "NULL",
sess->sm_context.resource_uri ?
sess->sm_context.resource_uri : "NULL");
if (!SESSION_CONTEXT_IN_SMF(sess)) { if (!SESSION_CONTEXT_IN_SMF(sess)) {
ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_instance_t *nf_instance = NULL;
@ -1303,8 +1305,8 @@ int gmm_handle_ul_nas_transport(ran_ue_t *ran_ue, amf_ue_t *amf_ue,
ogs_sbi_discovery_option_set_tai( ogs_sbi_discovery_option_set_tai(
discovery_option, &amf_ue->nr_tai); discovery_option, &amf_ue->nr_tai);
nf_instance = sess->sbi. nf_instance = OGS_SBI_GET_NF_INSTANCE(
service_type_array[service_type].nf_instance; sess->sbi.service_type_array[service_type]);
if (!nf_instance) { if (!nf_instance) {
OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_e requester_nf_type =
NF_INSTANCE_TYPE(ogs_sbi_self()->nf_instance); NF_INSTANCE_TYPE(ogs_sbi_self()->nf_instance);
@ -1315,8 +1317,8 @@ int gmm_handle_ul_nas_transport(ran_ue_t *ran_ue, amf_ue_t *amf_ue,
OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION, OGS_SBI_SERVICE_TYPE_NSMF_PDUSESSION,
requester_nf_type, requester_nf_type,
discovery_option); discovery_option);
nf_instance = sess->sbi. nf_instance = OGS_SBI_GET_NF_INSTANCE(
service_type_array[service_type].nf_instance; sess->sbi.service_type_array[service_type]);
if (!nf_instance) if (!nf_instance)
ogs_info("No SMF Instance"); ogs_info("No SMF Instance");
@ -1435,7 +1437,7 @@ int gmm_handle_ul_nas_transport(ran_ue_t *ran_ue, amf_ue_t *amf_ue,
sess->pdu_session_release_complete_received = true; sess->pdu_session_release_complete_received = true;
if (sess->pdu_session_resource_release_response_received == if (sess->pdu_session_resource_release_response_received ==
true) true)
CLEAR_SM_CONTEXT_REF(sess); CLEAR_SESSION_CONTEXT(sess);
break; break;
default: default:
break; break;
@ -1676,7 +1678,7 @@ static void amf_namf_comm_decode_ue_session_context_list(
sess = amf_sess_add(amf_ue, PduSessionContext->pdu_session_id); sess = amf_sess_add(amf_ue, PduSessionContext->pdu_session_id);
ogs_assert(sess); ogs_assert(sess);
sess->sm_context_ref = PduSessionContext->sm_context_ref; sess->sm_context.ref = PduSessionContext->sm_context_ref;
if (PduSessionContext->s_nssai) { if (PduSessionContext->s_nssai) {
memset(&sess->s_nssai, 0, sizeof(sess->s_nssai)); memset(&sess->s_nssai, 0, sizeof(sess->s_nssai));

View File

@ -274,9 +274,7 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e)
ogs_warn("[%s] Ignore SBI message", amf_ue->suci); ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
break; break;
CASE(OGS_SBI_HTTP_METHOD_DELETE) CASE(OGS_SBI_HTTP_METHOD_DELETE)
if (amf_ue->confirmation_url_for_5g_aka) CLEAR_5G_AKA_CONFIRMATION(amf_ue);
ogs_free(amf_ue->confirmation_url_for_5g_aka);
amf_ue->confirmation_url_for_5g_aka = NULL;
if (state == AMF_RELEASE_SM_CONTEXT_NO_STATE || if (state == AMF_RELEASE_SM_CONTEXT_NO_STATE ||
state == AMF_UE_INITIATED_DE_REGISTERED) { state == AMF_UE_INITIATED_DE_REGISTERED) {
@ -378,10 +376,7 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e)
*/ */
if (state == AMF_RELEASE_SM_CONTEXT_NO_STATE || if (state == AMF_RELEASE_SM_CONTEXT_NO_STATE ||
state == AMF_UE_INITIATED_DE_REGISTERED) { state == AMF_UE_INITIATED_DE_REGISTERED) {
if (amf_ue->data_change_subscription_id) { UDM_SDM_CLEAR(amf_ue);
ogs_free(amf_ue->data_change_subscription_id);
amf_ue->data_change_subscription_id = NULL;
}
r = amf_ue_sbi_discover_and_send( r = amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NUDM_UECM, NULL, OGS_SBI_SERVICE_TYPE_NUDM_UECM, NULL,
@ -447,7 +442,7 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e)
if (state == AMF_RELEASE_SM_CONTEXT_NO_STATE || if (state == AMF_RELEASE_SM_CONTEXT_NO_STATE ||
state == AMF_UE_INITIATED_DE_REGISTERED) { state == AMF_UE_INITIATED_DE_REGISTERED) {
if (amf_ue->confirmation_url_for_5g_aka) { if (CHECK_5G_AKA_CONFIRMATION(amf_ue)) {
r = amf_ue_sbi_discover_and_send( r = amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, OGS_SBI_SERVICE_TYPE_NAUSF_AUTH,
NULL, NULL,
@ -857,9 +852,7 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e)
ogs_warn("[%s] Ignore SBI message", amf_ue->suci); ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
break; break;
CASE(OGS_SBI_HTTP_METHOD_DELETE) CASE(OGS_SBI_HTTP_METHOD_DELETE)
if (amf_ue->confirmation_url_for_5g_aka) CLEAR_5G_AKA_CONFIRMATION(amf_ue);
ogs_free(amf_ue->confirmation_url_for_5g_aka);
amf_ue->confirmation_url_for_5g_aka = NULL;
if (state == AMF_RELEASE_SM_CONTEXT_NO_STATE || if (state == AMF_RELEASE_SM_CONTEXT_NO_STATE ||
state == AMF_UE_INITIATED_DE_REGISTERED) { state == AMF_UE_INITIATED_DE_REGISTERED) {
@ -967,10 +960,7 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e)
AMF_NETWORK_INITIATED_IMPLICIT_DE_REGISTERED || AMF_NETWORK_INITIATED_IMPLICIT_DE_REGISTERED ||
state == state ==
AMF_NETWORK_INITIATED_EXPLICIT_DE_REGISTERED) { AMF_NETWORK_INITIATED_EXPLICIT_DE_REGISTERED) {
if (amf_ue->data_change_subscription_id) { UDM_SDM_CLEAR(amf_ue);
ogs_free(amf_ue->data_change_subscription_id);
amf_ue->data_change_subscription_id = NULL;
}
r = amf_ue_sbi_discover_and_send( r = amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NUDM_UECM, NULL, OGS_SBI_SERVICE_TYPE_NUDM_UECM, NULL,
@ -1044,7 +1034,7 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e)
state == state ==
AMF_NETWORK_INITIATED_EXPLICIT_DE_REGISTERED) { AMF_NETWORK_INITIATED_EXPLICIT_DE_REGISTERED) {
if (amf_ue->confirmation_url_for_5g_aka) { if (amf_ue->confirmation_for_5g_aka.resource_uri) {
r = amf_ue_sbi_discover_and_send( r = amf_ue_sbi_discover_and_send(
OGS_SBI_SERVICE_TYPE_NAUSF_AUTH, OGS_SBI_SERVICE_TYPE_NAUSF_AUTH,
NULL, NULL,

View File

@ -38,6 +38,10 @@ int amf_initialize(void)
ogs_sbi_context_init(OpenAPI_nf_type_AMF); ogs_sbi_context_init(OpenAPI_nf_type_AMF);
amf_context_init(); amf_context_init();
rv = ogs_log_config_domain(
ogs_app()->logger.domain, ogs_app()->logger.level);
if (rv != OGS_OK) return rv;
rv = ogs_sbi_context_parse_config(APP_NAME, "nrf", "scp"); rv = ogs_sbi_context_parse_config(APP_NAME, "nrf", "scp");
if (rv != OGS_OK) return rv; if (rv != OGS_OK) return rv;
@ -50,10 +54,6 @@ int amf_initialize(void)
rv = amf_context_nf_info(); rv = amf_context_nf_info();
if (rv != OGS_OK) return rv; if (rv != OGS_OK) return rv;
rv = ogs_log_config_domain(
ogs_app()->logger.domain, ogs_app()->logger.level);
if (rv != OGS_OK) return rv;
ogs_metrics_context_open(ogs_metrics_self()); ogs_metrics_context_open(ogs_metrics_self());
rv = amf_sbi_open(); rv = amf_sbi_open();

View File

@ -246,7 +246,7 @@ int amf_namf_comm_handle_n1_n2_message_transfer(
amf_ue->supi, sess->psi, amf_ue->supi, sess->psi,
N1N2MessageTransferReqData-> N1N2MessageTransferReqData->
n1n2_failure_txf_notif_uri); n1n2_failure_txf_notif_uri);
return OGS_ERROR;; return OGS_ERROR;
} }
client = ogs_sbi_client_find( client = ogs_sbi_client_find(
@ -287,7 +287,7 @@ int amf_namf_comm_handle_n1_n2_message_transfer(
header.resource.component[1] = amf_ue->supi; header.resource.component[1] = amf_ue->supi;
header.resource.component[2] = header.resource.component[2] =
(char *)OGS_SBI_RESOURCE_NAME_N1_N2_MESSAGES; (char *)OGS_SBI_RESOURCE_NAME_N1_N2_MESSAGES;
header.resource.component[3] = sess->sm_context_ref; header.resource.component[3] = sess->sm_context.ref;
sendmsg.http.location = ogs_sbi_server_uri(server, &header); sendmsg.http.location = ogs_sbi_server_uri(server, &header);
@ -349,13 +349,12 @@ int amf_namf_comm_handle_n1_n2_message_transfer(
header.resource.component[1] = amf_ue->supi; header.resource.component[1] = amf_ue->supi;
header.resource.component[2] = header.resource.component[2] =
(char *)OGS_SBI_RESOURCE_NAME_N1_N2_MESSAGES; (char *)OGS_SBI_RESOURCE_NAME_N1_N2_MESSAGES;
header.resource.component[3] = sess->sm_context_ref; header.resource.component[3] = sess->sm_context.ref;
sendmsg.http.location = ogs_sbi_server_uri(server, &header); sendmsg.http.location = ogs_sbi_server_uri(server, &header);
/* Store Paging Info */ /* Store Paging Info */
AMF_SESS_STORE_PAGING_INFO( AMF_SESS_STORE_PAGING_INFO(sess, sendmsg.http.location, NULL);
sess, sendmsg.http.location, NULL);
/* Store 5GSM Message */ /* Store 5GSM Message */
AMF_SESS_STORE_5GSM_MESSAGE(sess, AMF_SESS_STORE_5GSM_MESSAGE(sess,
@ -424,13 +423,12 @@ int amf_namf_comm_handle_n1_n2_message_transfer(
header.resource.component[1] = amf_ue->supi; header.resource.component[1] = amf_ue->supi;
header.resource.component[2] = header.resource.component[2] =
(char *)OGS_SBI_RESOURCE_NAME_N1_N2_MESSAGES; (char *)OGS_SBI_RESOURCE_NAME_N1_N2_MESSAGES;
header.resource.component[3] = sess->sm_context_ref; header.resource.component[3] = sess->sm_context.ref;
sendmsg.http.location = ogs_sbi_server_uri(server, &header); sendmsg.http.location = ogs_sbi_server_uri(server, &header);
/* Store Paging Info */ /* Store Paging Info */
AMF_SESS_STORE_PAGING_INFO( AMF_SESS_STORE_PAGING_INFO(sess, sendmsg.http.location, NULL);
sess, sendmsg.http.location, NULL);
/* Store 5GSM Message */ /* Store 5GSM Message */
AMF_SESS_STORE_5GSM_MESSAGE(sess, AMF_SESS_STORE_5GSM_MESSAGE(sess,
@ -1174,7 +1172,7 @@ static OpenAPI_list_t *amf_namf_comm_encode_ue_session_context_list(amf_ue_t *am
ogs_assert(sNSSAI); ogs_assert(sNSSAI);
PduSessionContext->pdu_session_id = sess->psi; PduSessionContext->pdu_session_id = sess->psi;
PduSessionContext->sm_context_ref = sess->sm_context_ref; PduSessionContext->sm_context_ref = sess->sm_context.ref;
sNSSAI->sst = sess->s_nssai.sst; sNSSAI->sst = sess->s_nssai.sst;
sNSSAI->sd = ogs_s_nssai_sd_to_string(sess->s_nssai.sd); sNSSAI->sd = ogs_s_nssai_sd_to_string(sess->s_nssai.sd);
@ -1335,6 +1333,8 @@ int amf_namf_comm_handle_ue_context_transfer_request(
OpenAPI_ue_context_transfer_rsp_data_t UeContextTransferRspData; OpenAPI_ue_context_transfer_rsp_data_t UeContextTransferRspData;
ogs_sbi_nf_instance_t *pcf_nf_instance = NULL;
char *ue_context_id = NULL; char *ue_context_id = NULL;
char *encoded_gmm_capability = NULL; char *encoded_gmm_capability = NULL;
int status = OGS_SBI_HTTP_STATUS_OK; int status = OGS_SBI_HTTP_STATUS_OK;
@ -1418,8 +1418,14 @@ int amf_namf_comm_handle_ue_context_transfer_request(
encoded_gmm_capability = amf_namf_comm_base64_encode_5gmm_capability(amf_ue); encoded_gmm_capability = amf_namf_comm_base64_encode_5gmm_capability(amf_ue);
UeContext._5g_mm_capability = encoded_gmm_capability; UeContext._5g_mm_capability = encoded_gmm_capability;
UeContext.pcf_id = amf_ue->sbi.service_type_array[ pcf_nf_instance = OGS_SBI_GET_NF_INSTANCE(
OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL].nf_instance->id; amf_ue->sbi.service_type_array[
OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL]);
if (pcf_nf_instance) {
UeContext.pcf_id = pcf_nf_instance->id;
} else {
ogs_warn("No PCF NF Instnace");
}
/* TODO UeContext.pcfAmPolicyUri */ /* TODO UeContext.pcfAmPolicyUri */
/* TODO UeContext.pcfUePolicyUri */ /* TODO UeContext.pcfUePolicyUri */

View File

@ -87,11 +87,11 @@ ogs_sbi_request_t *amf_nausf_auth_build_authenticate_delete(
ogs_sbi_request_t *request = NULL; ogs_sbi_request_t *request = NULL;
ogs_assert(amf_ue); ogs_assert(amf_ue);
ogs_assert(amf_ue->confirmation_url_for_5g_aka); ogs_assert(amf_ue->confirmation_for_5g_aka.resource_uri);
memset(&message, 0, sizeof(message)); memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE; message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE;
message.h.uri = amf_ue->confirmation_url_for_5g_aka; message.h.uri = amf_ue->confirmation_for_5g_aka.resource_uri;
request = ogs_sbi_build_request(&message); request = ogs_sbi_build_request(&message);
ogs_expect(request); ogs_expect(request);
@ -110,11 +110,11 @@ ogs_sbi_request_t *amf_nausf_auth_build_authenticate_confirmation(
OpenAPI_confirmation_data_t *ConfirmationData = NULL; OpenAPI_confirmation_data_t *ConfirmationData = NULL;
ogs_assert(amf_ue); ogs_assert(amf_ue);
ogs_assert(amf_ue->confirmation_url_for_5g_aka); ogs_assert(amf_ue->confirmation_for_5g_aka.resource_uri);
memset(&message, 0, sizeof(message)); memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT;
message.h.uri = amf_ue->confirmation_url_for_5g_aka; message.h.uri = amf_ue->confirmation_for_5g_aka.resource_uri;
ConfirmationData = ogs_calloc(1, sizeof(*ConfirmationData)); ConfirmationData = ogs_calloc(1, sizeof(*ConfirmationData));
if (!ConfirmationData) { if (!ConfirmationData) {

View File

@ -30,9 +30,21 @@ int amf_nausf_auth_handle_authenticate(
OpenAPI_map_t *LinksValueScheme = NULL; OpenAPI_map_t *LinksValueScheme = NULL;
OpenAPI_lnode_t *node = NULL; OpenAPI_lnode_t *node = NULL;
bool rc;
ogs_sbi_client_t *client = NULL;
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
char *fqdn = NULL;
uint16_t fqdn_port = 0;
ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
ogs_assert(amf_ue); ogs_assert(amf_ue);
ogs_assert(message); ogs_assert(message);
if (!message->http.location) {
ogs_error("[%s] No http.location", amf_ue->suci);
return OGS_ERROR;
}
UeAuthenticationCtx = message->UeAuthenticationCtx; UeAuthenticationCtx = message->UeAuthenticationCtx;
if (!UeAuthenticationCtx) { if (!UeAuthenticationCtx) {
ogs_error("[%s] No UeAuthenticationCtx", amf_ue->suci); ogs_error("[%s] No UeAuthenticationCtx", amf_ue->suci);
@ -92,11 +104,36 @@ int amf_nausf_auth_handle_authenticate(
return OGS_ERROR; return OGS_ERROR;
} }
if (amf_ue->confirmation_url_for_5g_aka) rc = ogs_sbi_getaddr_from_uri(
ogs_free(amf_ue->confirmation_url_for_5g_aka); &scheme, &fqdn, &fqdn_port, &addr, &addr6, message->http.location);
amf_ue->confirmation_url_for_5g_aka = if (rc == false || scheme == OpenAPI_uri_scheme_NULL) {
ogs_strdup(LinksValueSchemeValue->href); ogs_error("[%s] Invalid URI [%s]",
ogs_assert(amf_ue->confirmation_url_for_5g_aka); amf_ue->suci, message->http.location);
return OGS_ERROR;
}
client = ogs_sbi_client_find(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_debug("[%s] ogs_sbi_client_add()", amf_ue->suci);
client = ogs_sbi_client_add(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_error("[%s] ogs_sbi_client_add() failed", amf_ue->suci);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
return OGS_ERROR;
}
}
OGS_SBI_SETUP_CLIENT(&amf_ue->confirmation_for_5g_aka, client);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
STORE_5G_AKA_CONFIRMATION(amf_ue, message->http.location);
ogs_ascii_to_hex(AV5G_AKA->rand, strlen(AV5G_AKA->rand), ogs_ascii_to_hex(AV5G_AKA->rand, strlen(AV5G_AKA->rand),
amf_ue->rand, sizeof(amf_ue->rand)); amf_ue->rand, sizeof(amf_ue->rand));

View File

@ -209,6 +209,16 @@ void ngap_handle_ng_setup_request(amf_gnb_t *gnb, ogs_ngap_message_t *message)
i++) { i++) {
NGAP_SupportedTAItem_t *SupportedTAItem = NULL; NGAP_SupportedTAItem_t *SupportedTAItem = NULL;
if (gnb->num_of_supported_ta_list >=
OGS_ARRAY_SIZE(gnb->supported_ta_list)) {
ogs_error("OVERFLOW GNB->num_of_supported_ta_list "
"[%d:%d:%d]",
gnb->num_of_supported_ta_list,
OGS_MAX_NUM_OF_SUPPORTED_TA,
(int)OGS_ARRAY_SIZE(gnb->supported_ta_list));
break;
}
SupportedTAItem = (NGAP_SupportedTAItem_t *) SupportedTAItem = (NGAP_SupportedTAItem_t *)
SupportedTAList->list.array[i]; SupportedTAList->list.array[i];
if (!SupportedTAItem) { if (!SupportedTAItem) {
@ -235,6 +245,17 @@ void ngap_handle_ng_setup_request(amf_gnb_t *gnb, ogs_ngap_message_t *message)
NGAP_BroadcastPLMNItem_t *BroadcastPLMNItem = NULL; NGAP_BroadcastPLMNItem_t *BroadcastPLMNItem = NULL;
NGAP_PLMNIdentity_t *pLMNIdentity = NULL; NGAP_PLMNIdentity_t *pLMNIdentity = NULL;
if (gnb->supported_ta_list[i].num_of_bplmn_list >=
OGS_ARRAY_SIZE(gnb->supported_ta_list[i].bplmn_list)) {
ogs_error("OVERFLOW GNB->supported_ta_list.num_of_bplmn_list "
"[%d:%d:%d]",
gnb->supported_ta_list[i].num_of_bplmn_list,
OGS_MAX_NUM_OF_BPLMN,
(int)OGS_ARRAY_SIZE(
gnb->supported_ta_list[i].bplmn_list));
break;
}
BroadcastPLMNItem = (NGAP_BroadcastPLMNItem_t *) BroadcastPLMNItem = (NGAP_BroadcastPLMNItem_t *)
SupportedTAItem->broadcastPLMNList.list.array[j]; SupportedTAItem->broadcastPLMNList.list.array[j];
if (!BroadcastPLMNItem) { if (!BroadcastPLMNItem) {
@ -268,6 +289,19 @@ void ngap_handle_ng_setup_request(amf_gnb_t *gnb, ogs_ngap_message_t *message)
NGAP_SliceSupportItem_t *SliceSupportItem = NULL; NGAP_SliceSupportItem_t *SliceSupportItem = NULL;
NGAP_S_NSSAI_t *s_NSSAI = NULL; NGAP_S_NSSAI_t *s_NSSAI = NULL;
if (gnb->supported_ta_list[i].bplmn_list[j].num_of_s_nssai >=
OGS_ARRAY_SIZE(
gnb->supported_ta_list[i].bplmn_list[j].s_nssai)) {
ogs_error("OVERFLOW GNB->supported_ta_list."
"bplmn_list.num_of_s_nssai [%d:%d:%d]",
gnb->supported_ta_list[i].bplmn_list[j].
num_of_s_nssai,
OGS_MAX_NUM_OF_SLICE_SUPPORT,
(int)OGS_ARRAY_SIZE(gnb->
supported_ta_list[i].bplmn_list[j].s_nssai));
break;
}
SliceSupportItem = (NGAP_SliceSupportItem_t *) SliceSupportItem = (NGAP_SliceSupportItem_t *)
BroadcastPLMNItem->tAISliceSupportList.list.array[k]; BroadcastPLMNItem->tAISliceSupportList.list.array[k];
if (!SliceSupportItem) { if (!SliceSupportItem) {
@ -2516,7 +2550,7 @@ void ngap_handle_pdu_session_resource_release_response(
sess->pdu_session_resource_release_response_received = true; sess->pdu_session_resource_release_response_received = true;
if (sess->pdu_session_release_complete_received == true) if (sess->pdu_session_release_complete_received == true)
CLEAR_SM_CONTEXT_REF(sess); CLEAR_SESSION_CONTEXT(sess);
} }
} }
@ -4272,6 +4306,16 @@ void ngap_handle_ran_configuration_update(
i++) { i++) {
NGAP_SupportedTAItem_t *SupportedTAItem = NULL; NGAP_SupportedTAItem_t *SupportedTAItem = NULL;
if (gnb->num_of_supported_ta_list >=
OGS_ARRAY_SIZE(gnb->supported_ta_list)) {
ogs_error("OVERFLOW GNB->num_of_supported_ta_list "
"[%d:%d:%d]",
gnb->num_of_supported_ta_list,
OGS_MAX_NUM_OF_SUPPORTED_TA,
(int)OGS_ARRAY_SIZE(gnb->supported_ta_list));
break;
}
SupportedTAItem = (NGAP_SupportedTAItem_t *) SupportedTAItem = (NGAP_SupportedTAItem_t *)
SupportedTAList->list.array[i]; SupportedTAList->list.array[i];
if (!SupportedTAItem) { if (!SupportedTAItem) {
@ -4299,6 +4343,17 @@ void ngap_handle_ran_configuration_update(
NGAP_BroadcastPLMNItem_t *BroadcastPLMNItem = NULL; NGAP_BroadcastPLMNItem_t *BroadcastPLMNItem = NULL;
NGAP_PLMNIdentity_t *pLMNIdentity = NULL; NGAP_PLMNIdentity_t *pLMNIdentity = NULL;
if (gnb->supported_ta_list[i].num_of_bplmn_list >=
OGS_ARRAY_SIZE(gnb->supported_ta_list[i].bplmn_list)) {
ogs_error("OVERFLOW GNB->supported_ta_list."
"num_of_bplm_list [%d:%d:%d]",
gnb->supported_ta_list[i].num_of_bplmn_list,
OGS_MAX_NUM_OF_BPLMN,
(int)OGS_ARRAY_SIZE(
gnb->supported_ta_list[i].bplmn_list));
break;
}
BroadcastPLMNItem = (NGAP_BroadcastPLMNItem_t *) BroadcastPLMNItem = (NGAP_BroadcastPLMNItem_t *)
SupportedTAItem->broadcastPLMNList.list.array[j]; SupportedTAItem->broadcastPLMNList.list.array[j];
if (!BroadcastPLMNItem) { if (!BroadcastPLMNItem) {
@ -4333,6 +4388,21 @@ void ngap_handle_ran_configuration_update(
NGAP_SliceSupportItem_t *SliceSupportItem = NULL; NGAP_SliceSupportItem_t *SliceSupportItem = NULL;
NGAP_S_NSSAI_t *s_NSSAI = NULL; NGAP_S_NSSAI_t *s_NSSAI = NULL;
if (gnb->supported_ta_list[i].
bplmn_list[j].num_of_s_nssai >=
OGS_ARRAY_SIZE(gnb->supported_ta_list[i].
bplmn_list[j].s_nssai)) {
ogs_error("OVERFLOW GNB->num_of_supported_ta_list."
"bplmn_list.num_of_s_nssai"
"[%d:%d:%d]",
gnb->supported_ta_list[i].bplmn_list[j].
num_of_s_nssai,
OGS_MAX_NUM_OF_SLICE_SUPPORT,
(int)OGS_ARRAY_SIZE(gnb->supported_ta_list[i].
bplmn_list[j].s_nssai));
break;
}
SliceSupportItem = (NGAP_SliceSupportItem_t *) SliceSupportItem = (NGAP_SliceSupportItem_t *)
BroadcastPLMNItem->tAISliceSupportList.list.array[k]; BroadcastPLMNItem->tAISliceSupportList.list.array[k];
if (!SliceSupportItem) { if (!SliceSupportItem) {

View File

@ -200,6 +200,7 @@ int ngap_send_to_nas(ran_ue_t *ran_ue,
default: default:
ogs_error("Not implemented(security header type:0x%x)", ogs_error("Not implemented(security header type:0x%x)",
sh->security_header_type); sh->security_header_type);
ran_ue_remove(ran_ue);
return OGS_ERROR; return OGS_ERROR;
} }
@ -207,12 +208,39 @@ int ngap_send_to_nas(ran_ue_t *ran_ue,
if (nas_5gs_security_decode(ran_ue->amf_ue, if (nas_5gs_security_decode(ran_ue->amf_ue,
security_header_type, nasbuf) != OGS_OK) { security_header_type, nasbuf) != OGS_OK) {
ogs_error("nas_eps_security_decode failed()"); ogs_error("nas_eps_security_decode failed()");
ran_ue_remove(ran_ue);
return OGS_ERROR; return OGS_ERROR;
} }
} }
h = (ogs_nas_5gmm_header_t *)nasbuf->data; h = (ogs_nas_5gmm_header_t *)nasbuf->data;
ogs_assert(h); ogs_assert(h);
if (procedureCode == NGAP_ProcedureCode_id_InitialUEMessage) {
if (h->extended_protocol_discriminator !=
OGS_NAS_EXTENDED_PROTOCOL_DISCRIMINATOR_5GMM) {
ogs_error("Invalid extended_protocol_discriminator [%d]",
h->extended_protocol_discriminator);
ogs_pkbuf_free(nasbuf);
ran_ue_remove(ran_ue);
return OGS_ERROR;
}
if (h->message_type != OGS_NAS_5GS_REGISTRATION_REQUEST &&
h->message_type != OGS_NAS_5GS_SERVICE_REQUEST &&
h->message_type != OGS_NAS_5GS_DEREGISTRATION_REQUEST_FROM_UE) {
ogs_error("Invalid 5GMM message type [%d]", h->message_type);
ogs_pkbuf_free(nasbuf);
ran_ue_remove(ran_ue);
return OGS_ERROR;
}
}
if (h->extended_protocol_discriminator == if (h->extended_protocol_discriminator ==
OGS_NAS_EXTENDED_PROTOCOL_DISCRIMINATOR_5GMM) { OGS_NAS_EXTENDED_PROTOCOL_DISCRIMINATOR_5GMM) {
e = amf_event_new(AMF_EVENT_5GMM_MESSAGE); e = amf_event_new(AMF_EVENT_5GMM_MESSAGE);
@ -247,7 +275,10 @@ int ngap_send_to_nas(ran_ue_t *ran_ue,
} else { } else {
ogs_error("Unknown NAS Protocol discriminator 0x%02x", ogs_error("Unknown NAS Protocol discriminator 0x%02x",
h->extended_protocol_discriminator); h->extended_protocol_discriminator);
ogs_pkbuf_free(nasbuf); ogs_pkbuf_free(nasbuf);
ran_ue_remove(ran_ue);
return OGS_ERROR; return OGS_ERROR;
} }
} }

View File

@ -57,7 +57,9 @@ void amf_nnrf_handle_nf_discover(
amf_sbi_select_nf(sbi_object, amf_sbi_select_nf(sbi_object,
service_type, requester_nf_type, discovery_option); service_type, requester_nf_type, discovery_option);
nf_instance = sbi_object->service_type_array[service_type].nf_instance; nf_instance = OGS_SBI_GET_NF_INSTANCE(
sbi_object->service_type_array[service_type]);
if (!nf_instance) { if (!nf_instance) {
amf_ue_t *amf_ue = NULL; amf_ue_t *amf_ue = NULL;
amf_sess_t *sess = NULL; amf_sess_t *sess = NULL;

View File

@ -221,15 +221,11 @@ ogs_sbi_request_t *amf_npcf_am_policy_control_build_delete(
ogs_assert(amf_ue); ogs_assert(amf_ue);
ogs_assert(amf_ue->supi); ogs_assert(amf_ue->supi);
ogs_assert(amf_ue->policy_association_id); ogs_assert(amf_ue->policy_association.resource_uri);
memset(&message, 0, sizeof(message)); memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE; message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE;
message.h.service.name = message.h.uri = amf_ue->policy_association.resource_uri;
(char *)OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL;
message.h.api.version = (char *)OGS_SBI_API_V1;
message.h.resource.component[0] = (char *)OGS_SBI_RESOURCE_NAME_POLICIES;
message.h.resource.component[1] = amf_ue->policy_association_id;
request = ogs_sbi_build_request(&message); request = ogs_sbi_build_request(&message);
ogs_expect(request); ogs_expect(request);

View File

@ -35,6 +35,13 @@ int amf_npcf_am_policy_control_handle_create(
ogs_sbi_message_t message; ogs_sbi_message_t message;
ogs_sbi_header_t header; ogs_sbi_header_t header;
bool rc;
ogs_sbi_client_t *client = NULL;
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
char *fqdn = NULL;
uint16_t fqdn_port = 0;
ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
if (recvmsg->res_status != OGS_SBI_HTTP_STATUS_CREATED) { if (recvmsg->res_status != OGS_SBI_HTTP_STATUS_CREATED) {
ogs_error("[%s] HTTP response error [%d]", ogs_error("[%s] HTTP response error [%d]",
amf_ue->supi, recvmsg->res_status); amf_ue->supi, recvmsg->res_status);
@ -98,12 +105,53 @@ int amf_npcf_am_policy_control_handle_create(
return OGS_ERROR; return OGS_ERROR;
} }
rc = ogs_sbi_getaddr_from_uri(
&scheme, &fqdn, &fqdn_port, &addr, &addr6, header.uri);
if (rc == false || scheme == OpenAPI_uri_scheme_NULL) {
ogs_error("[%s] Invalid URI [%s]", amf_ue->supi, header.uri);
ogs_sbi_header_free(&header);
r = nas_5gs_send_gmm_reject_from_sbi(
amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR);
ogs_expect(r == OGS_OK);
ogs_assert(r != OGS_ERROR);
return OGS_ERROR;
}
client = ogs_sbi_client_find(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_debug("[%s] ogs_sbi_client_add()", amf_ue->supi);
client = ogs_sbi_client_add(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_error("[%s] ogs_sbi_client_add() failed", amf_ue->supi);
ogs_sbi_header_free(&header);
r = nas_5gs_send_gmm_reject_from_sbi(
amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR);
ogs_expect(r == OGS_OK);
ogs_assert(r != OGS_ERROR);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
return OGS_ERROR;
}
}
OGS_SBI_SETUP_CLIENT(&amf_ue->policy_association, client);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
PCF_AM_POLICY_STORE(amf_ue, header.uri, message.h.resource.component[1]);
/* SBI Features */ /* SBI Features */
supported_features = ogs_uint64_from_string(PolicyAssociation->supp_feat); supported_features = ogs_uint64_from_string(PolicyAssociation->supp_feat);
amf_ue->am_policy_control_features &= supported_features; amf_ue->am_policy_control_features &= supported_features;
PCF_AM_POLICY_STORE(amf_ue, message.h.resource.component[1]);
OpenAPI_list_for_each(PolicyAssociation->triggers, node) { OpenAPI_list_for_each(PolicyAssociation->triggers, node) {
if (node->data) { if (node->data) {
OpenAPI_request_trigger_e trigger = (intptr_t)node->data; OpenAPI_request_trigger_e trigger = (intptr_t)node->data;

View File

@ -190,8 +190,9 @@ ogs_sbi_request_t *amf_nsmf_pdusession_build_create_sm_context(
goto end; goto end;
} }
pcf_nf_instance = amf_ue->sbi.service_type_array[ pcf_nf_instance = OGS_SBI_GET_NF_INSTANCE(
OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL].nf_instance; amf_ue->sbi.service_type_array[
OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL]);
if (!pcf_nf_instance) { if (!pcf_nf_instance) {
ogs_error("No pcf_nf_instance"); ogs_error("No pcf_nf_instance");
goto end; goto end;
@ -272,17 +273,15 @@ ogs_sbi_request_t *amf_nsmf_pdusession_build_update_sm_context(
ogs_assert(param); ogs_assert(param);
ogs_assert(sess); ogs_assert(sess);
ogs_assert(sess->sm_context_ref); ogs_assert(sess->sm_context.resource_uri);
amf_ue = sess->amf_ue; amf_ue = sess->amf_ue;
ogs_assert(amf_ue); ogs_assert(amf_ue);
memset(&message, 0, sizeof(message)); memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST; message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST;
message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION; message.h.uri = ogs_msprintf("%s/%s",
message.h.api.version = (char *)OGS_SBI_API_V1; sess->sm_context.resource_uri, OGS_SBI_RESOURCE_NAME_MODIFY);
message.h.resource.component[0] = (char *)OGS_SBI_RESOURCE_NAME_SM_CONTEXTS; ogs_assert(message.h.uri);
message.h.resource.component[1] = sess->sm_context_ref;
message.h.resource.component[2] = (char *)OGS_SBI_RESOURCE_NAME_MODIFY;
memset(&ueLocation, 0, sizeof(ueLocation)); memset(&ueLocation, 0, sizeof(ueLocation));
memset(&SmContextUpdateData, 0, sizeof(SmContextUpdateData)); memset(&SmContextUpdateData, 0, sizeof(SmContextUpdateData));
@ -377,6 +376,8 @@ ogs_sbi_request_t *amf_nsmf_pdusession_build_update_sm_context(
ogs_expect(request); ogs_expect(request);
end: end:
if (message.h.uri)
ogs_free(message.h.uri);
if (ueLocation.nr_location) { if (ueLocation.nr_location) {
if (ueLocation.nr_location->ue_location_timestamp) if (ueLocation.nr_location->ue_location_timestamp)
ogs_free(ueLocation.nr_location->ue_location_timestamp); ogs_free(ueLocation.nr_location->ue_location_timestamp);
@ -405,18 +406,15 @@ ogs_sbi_request_t *amf_nsmf_pdusession_build_release_sm_context(
OpenAPI_user_location_t ueLocation; OpenAPI_user_location_t ueLocation;
ogs_assert(sess); ogs_assert(sess);
ogs_assert(sess->sm_context_ref); ogs_assert(sess->sm_context.resource_uri);
amf_ue = sess->amf_ue; amf_ue = sess->amf_ue;
ogs_assert(amf_ue); ogs_assert(amf_ue);
memset(&message, 0, sizeof(message)); memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST; message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST;
message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION; message.h.uri = ogs_msprintf("%s/%s",
message.h.api.version = (char *)OGS_SBI_API_V1; sess->sm_context.resource_uri, OGS_SBI_RESOURCE_NAME_RELEASE);
message.h.resource.component[0] = ogs_assert(message.h.uri);
(char *)OGS_SBI_RESOURCE_NAME_SM_CONTEXTS;
message.h.resource.component[1] = sess->sm_context_ref;
message.h.resource.component[2] = (char *)OGS_SBI_RESOURCE_NAME_RELEASE;
memset(&SmContextReleaseData, 0, sizeof(SmContextReleaseData)); memset(&SmContextReleaseData, 0, sizeof(SmContextReleaseData));
@ -460,6 +458,8 @@ ogs_sbi_request_t *amf_nsmf_pdusession_build_release_sm_context(
ogs_expect(request); ogs_expect(request);
end: end:
if (message.h.uri)
ogs_free(message.h.uri);
if (ueLocation.nr_location) { if (ueLocation.nr_location) {
if (ueLocation.nr_location->ue_location_timestamp) if (ueLocation.nr_location->ue_location_timestamp)
ogs_free(ueLocation.nr_location->ue_location_timestamp); ogs_free(ueLocation.nr_location->ue_location_timestamp);

View File

@ -56,6 +56,13 @@ int amf_nsmf_pdusession_handle_create_sm_context(
ogs_sbi_message_t message; ogs_sbi_message_t message;
ogs_sbi_header_t header; ogs_sbi_header_t header;
bool rc;
ogs_sbi_client_t *client = NULL;
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
char *fqdn = NULL;
uint16_t fqdn_port = 0;
ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
if (!recvmsg->http.location) { if (!recvmsg->http.location) {
ogs_error("[%d:%d] No http.location", sess->psi, sess->pti); ogs_error("[%d:%d] No http.location", sess->psi, sess->pti);
r = nas_5gs_send_back_gsm_message(ran_ue, sess, r = nas_5gs_send_back_gsm_message(ran_ue, sess,
@ -97,6 +104,55 @@ int amf_nsmf_pdusession_handle_create_sm_context(
return OGS_ERROR; return OGS_ERROR;
} }
rc = ogs_sbi_getaddr_from_uri(
&scheme, &fqdn, &fqdn_port, &addr, &addr6, header.uri);
if (rc == false || scheme == OpenAPI_uri_scheme_NULL) {
ogs_error("[%s:%d] Invalid URI [%s]",
amf_ue->supi, sess->psi, header.uri);
ogs_sbi_header_free(&header);
r = nas_5gs_send_back_gsm_message(ran_ue, sess,
OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED,
AMF_NAS_BACKOFF_TIME);
ogs_expect(r == OGS_OK);
ogs_assert(r != OGS_ERROR);
return OGS_ERROR;
}
client = ogs_sbi_client_find(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_debug("[%s:%d] ogs_sbi_client_add()", amf_ue->supi, sess->psi);
client = ogs_sbi_client_add(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_error("[%s:%d] ogs_sbi_client_add() failed",
amf_ue->supi, sess->psi);
ogs_sbi_header_free(&header);
r = nas_5gs_send_back_gsm_message(ran_ue, sess,
OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED,
AMF_NAS_BACKOFF_TIME);
ogs_expect(r == OGS_OK);
ogs_assert(r != OGS_ERROR);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
return OGS_ERROR;
}
}
OGS_SBI_SETUP_CLIENT(&sess->sm_context, client);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
STORE_SESSION_CONTEXT(
sess, header.uri, message.h.resource.component[1]);
ogs_sbi_header_free(&header);
if (sess->pdu_session_establishment_accept) { if (sess->pdu_session_establishment_accept) {
/* /*
* [1-SERVER] /namf-comm/v1/ue-contexts/{supi}/n1-n2-messages * [1-SERVER] /namf-comm/v1/ue-contexts/{supi}/n1-n2-messages
@ -117,7 +173,6 @@ int amf_nsmf_pdusession_handle_create_sm_context(
ogs_error("[%d:%d] nas_5gs_send_to_gnb() failed", ogs_error("[%d:%d] nas_5gs_send_to_gnb() failed",
sess->psi, sess->pti); sess->psi, sess->pti);
ogs_sbi_header_free(&header);
r = nas_5gs_send_back_gsm_message(ran_ue, sess, r = nas_5gs_send_back_gsm_message(ran_ue, sess,
OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED,
AMF_NAS_BACKOFF_TIME); AMF_NAS_BACKOFF_TIME);
@ -128,13 +183,6 @@ int amf_nsmf_pdusession_handle_create_sm_context(
} }
} }
if (sess->sm_context_ref)
ogs_free(sess->sm_context_ref);
sess->sm_context_ref = ogs_strdup(message.h.resource.component[1]);
ogs_assert(sess->sm_context_ref);
ogs_sbi_header_free(&header);
} else { } else {
OpenAPI_sm_context_create_error_t *SmContextCreateError = NULL; OpenAPI_sm_context_create_error_t *SmContextCreateError = NULL;
OpenAPI_ref_to_binary_data_t *n1SmMsg = NULL; OpenAPI_ref_to_binary_data_t *n1SmMsg = NULL;

View File

@ -255,16 +255,11 @@ ogs_sbi_request_t *amf_nudm_sdm_build_subscription_delete(
ogs_assert(amf_ue); ogs_assert(amf_ue);
ogs_assert(amf_ue->supi); ogs_assert(amf_ue->supi);
ogs_assert(amf_ue->data_change_subscription_id); ogs_assert(amf_ue->data_change_subscription.resource_uri);
memset(&message, 0, sizeof(message)); memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE; message.h.method = (char *)OGS_SBI_HTTP_METHOD_DELETE;
message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NUDM_SDM; message.h.uri = amf_ue->data_change_subscription.resource_uri;
message.h.api.version = (char *)OGS_SBI_API_V2;
message.h.resource.component[0] = amf_ue->supi;
message.h.resource.component[1] =
(char *)OGS_SBI_RESOURCE_NAME_SDM_SUBSCRIPTIONS;
message.h.resource.component[2] = amf_ue->data_change_subscription_id;
request = ogs_sbi_build_request(&message); request = ogs_sbi_build_request(&message);
ogs_expect(request); ogs_expect(request);

View File

@ -246,7 +246,7 @@ int amf_nudm_sdm_handle_provisioned(
break; break;
CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA) CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA)
if (amf_ue->data_change_subscription_id) { if (UDM_SDM_SUBSCRIBED(amf_ue)) {
/* we already have a SDM subscription to UDM; continue without /* we already have a SDM subscription to UDM; continue without
* subscribing again */ * subscribing again */
r = amf_ue_sbi_discover_and_send( r = amf_ue_sbi_discover_and_send(
@ -272,6 +272,13 @@ int amf_nudm_sdm_handle_provisioned(
ogs_sbi_message_t message; ogs_sbi_message_t message;
ogs_sbi_header_t header; ogs_sbi_header_t header;
bool rc;
ogs_sbi_client_t *client = NULL;
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
char *fqdn = NULL;
uint16_t fqdn_port = 0;
ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
if (!recvmsg->http.location) { if (!recvmsg->http.location) {
ogs_error("[%s] No http.location", amf_ue->supi); ogs_error("[%s] No http.location", amf_ue->supi);
r = nas_5gs_send_gmm_reject_from_sbi( r = nas_5gs_send_gmm_reject_from_sbi(
@ -288,10 +295,12 @@ int amf_nudm_sdm_handle_provisioned(
if (rv != OGS_OK) { if (rv != OGS_OK) {
ogs_error("[%s] Cannot parse http.location [%s]", ogs_error("[%s] Cannot parse http.location [%s]",
amf_ue->supi, recvmsg->http.location); amf_ue->supi, recvmsg->http.location);
r = nas_5gs_send_gmm_reject_from_sbi( r = nas_5gs_send_gmm_reject_from_sbi(
amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR);
ogs_expect(r == OGS_OK); ogs_expect(r == OGS_OK);
ogs_assert(r != OGS_ERROR); ogs_assert(r != OGS_ERROR);
return OGS_ERROR; return OGS_ERROR;
} }
@ -304,13 +313,52 @@ int amf_nudm_sdm_handle_provisioned(
amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR);
ogs_expect(r == OGS_OK); ogs_expect(r == OGS_OK);
ogs_assert(r != OGS_ERROR); ogs_assert(r != OGS_ERROR);
return OGS_ERROR; return OGS_ERROR;
} }
if (amf_ue->data_change_subscription_id) rc = ogs_sbi_getaddr_from_uri(
ogs_free(amf_ue->data_change_subscription_id); &scheme, &fqdn, &fqdn_port, &addr, &addr6, header.uri);
amf_ue->data_change_subscription_id = if (rc == false || scheme == OpenAPI_uri_scheme_NULL) {
ogs_strdup(message.h.resource.component[2]); ogs_error("[%s] Invalid URI [%s]", amf_ue->supi, header.uri);
ogs_sbi_header_free(&header);
r = nas_5gs_send_gmm_reject_from_sbi(
amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR);
ogs_expect(r == OGS_OK);
ogs_assert(r != OGS_ERROR);
return OGS_ERROR;
}
client = ogs_sbi_client_find(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_debug("[%s] ogs_sbi_client_add()", amf_ue->supi);
client = ogs_sbi_client_add(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
ogs_error("[%s] ogs_sbi_client_add() failed", amf_ue->supi);
ogs_sbi_header_free(&header);
r = nas_5gs_send_gmm_reject_from_sbi(
amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR);
ogs_expect(r == OGS_OK);
ogs_assert(r != OGS_ERROR);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
return OGS_ERROR;
}
}
OGS_SBI_SETUP_CLIENT(&amf_ue->policy_association, client);
ogs_free(fqdn);
ogs_freeaddrinfo(addr);
ogs_freeaddrinfo(addr6);
UDM_SDM_STORE(amf_ue, header.uri, message.h.resource.component[2]);
ogs_sbi_header_free(&header); ogs_sbi_header_free(&header);

View File

@ -313,7 +313,8 @@ static int client_discover_cb(
amf_sbi_select_nf(&sess->sbi, amf_sbi_select_nf(&sess->sbi,
service_type, requester_nf_type, discovery_option); service_type, requester_nf_type, discovery_option);
if (!sess->sbi.service_type_array[service_type].nf_instance) { if (!OGS_SBI_GET_NF_INSTANCE(
sess->sbi.service_type_array[service_type])) {
ogs_error("[%s:%d] (NF discover) No [%s]", ogs_error("[%s:%d] (NF discover) No [%s]",
amf_ue->supi, sess->psi, amf_ue->supi, sess->psi,
ogs_sbi_service_type_to_name(service_type)); ogs_sbi_service_type_to_name(service_type));
@ -505,7 +506,7 @@ void amf_sbi_send_release_session(
ogs_assert(r != OGS_ERROR); ogs_assert(r != OGS_ERROR);
/* Prevent to invoke SMF for this session */ /* Prevent to invoke SMF for this session */
CLEAR_SM_CONTEXT_REF(sess); CLEAR_SESSION_CONTEXT(sess);
} }
void amf_sbi_send_release_all_sessions( void amf_sbi_send_release_all_sessions(

View File

@ -184,8 +184,9 @@ void ausf_ue_remove(ausf_ue_t *ausf_ue)
ogs_free(ausf_ue->supi); ogs_free(ausf_ue->supi);
} }
if (ausf_ue->auth_events_url) AUTH_EVENT_CLEAR(ausf_ue);
ogs_free(ausf_ue->auth_events_url); if (ausf_ue->auth_event.client)
ogs_sbi_client_remove(ausf_ue->auth_event.client);
if (ausf_ue->serving_network_name) if (ausf_ue->serving_network_name)
ogs_free(ausf_ue->serving_network_name); ogs_free(ausf_ue->serving_network_name);

View File

@ -52,7 +52,25 @@ struct ausf_ue_s {
char *serving_network_name; char *serving_network_name;
OpenAPI_auth_type_e auth_type; OpenAPI_auth_type_e auth_type;
char *auth_events_url; #define AUTH_EVENT_CLEAR(__aUSF) \
do { \
ogs_assert((__aUSF)); \
if ((__aUSF)->auth_event.resource_uri) \
ogs_free((__aUSF)->auth_event.resource_uri); \
(__aUSF)->auth_event.resource_uri = NULL; \
} while(0)
#define AUTH_EVENT_STORE(__aUSF, __rESOURCE_URI) \
do { \
ogs_assert((__aUSF)); \
ogs_assert((__rESOURCE_URI)); \
AUTH_EVENT_CLEAR(__aUSF); \
(__aUSF)->auth_event.resource_uri = ogs_strdup(__rESOURCE_URI); \
ogs_assert((__aUSF)->auth_event.resource_uri); \
} while(0)
struct {
char *resource_uri;
ogs_sbi_client_t *client;
} auth_event;
OpenAPI_auth_result_e auth_result; OpenAPI_auth_result_e auth_result;
uint8_t rand[OGS_RAND_LEN]; uint8_t rand[OGS_RAND_LEN];

View File

@ -34,16 +34,16 @@ int ausf_initialize(void)
ogs_sbi_context_init(OpenAPI_nf_type_AUSF); ogs_sbi_context_init(OpenAPI_nf_type_AUSF);
ausf_context_init(); ausf_context_init();
rv = ogs_log_config_domain(
ogs_app()->logger.domain, ogs_app()->logger.level);
if (rv != OGS_OK) return rv;
rv = ogs_sbi_context_parse_config(APP_NAME, "nrf", "scp"); rv = ogs_sbi_context_parse_config(APP_NAME, "nrf", "scp");
if (rv != OGS_OK) return rv; if (rv != OGS_OK) return rv;
rv = ausf_context_parse_config(); rv = ausf_context_parse_config();
if (rv != OGS_OK) return rv; if (rv != OGS_OK) return rv;
rv = ogs_log_config_domain(
ogs_app()->logger.domain, ogs_app()->logger.level);
if (rv != OGS_OK) return rv;
rv = ausf_sbi_open(); rv = ausf_sbi_open();
if (rv != OGS_OK) return rv; if (rv != OGS_OK) return rv;

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