From e50ce393c39024c76c5887f6cf29978f83b1cecd Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 13:24:33 +0200 Subject: [PATCH 01/31] PSEA - Initialization of PduSessionEstablishmentAccept message capture --- CMakeLists.txt | 1 + .../ESM/MSG/PduSessionEstablishmentAccept.c | 23 ++++++++++++++++ .../ESM/MSG/PduSessionEstablishmentAccept.h | 27 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c create mode 100644 openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 06184ac619..d3fd4b4a2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2383,6 +2383,7 @@ set(libnrnas_emm_msg_OBJS ${NAS_SRC}COMMON/EMM/MSG/RegistrationComplete.c ${NAS_SRC}COMMON/EMM/MSG/FGSUplinkNasTransport.c ${NAS_SRC}COMMON/ESM/MSG/PduSessionEstablishRequest.c + ${NAS_SRC}COMMON/ESM/MSG/PduSessionEstablishmentAccept.c ) set(libnrnas_ies_OBJS diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c new file mode 100644 index 0000000000..aef93a6632 --- /dev/null +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -0,0 +1,23 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "PduSessionEstablishmentAccept.h" +#include "common/utils/LOG/log.h" \ No newline at end of file diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h new file mode 100644 index 0000000000..7fd4006fef --- /dev/null +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h @@ -0,0 +1,27 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef PDU_SESSION_ESTABLISHMENT_ACCEPT_H_ +#define PDU_SESSION_ESTABLISHMENT_ACCEPT_H_ + +#include + +#endif \ No newline at end of file From e057c85e60b49de47d4b598c03cf8d5f34be0176 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 13:33:25 +0200 Subject: [PATCH 02/31] PSEA - Macros for Optional IE Identifiers --- .../COMMON/ESM/MSG/PduSessionEstablishmentAccept.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h index 7fd4006fef..bb5bc9304c 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h @@ -24,4 +24,17 @@ #include +/* PDU Session Establish Accept Optional IE Identifiers - TS 24.501 Table 8.3.2.1.1 */ + +#define IEI_5GSM_CAUSE 0x59 /* 5GSM cause 9.11.4.2 */ +#define IEI_PDU_ADDRESS 0x29 /* PDU address 9.11.4.10 */ +#define IEI_RQ_TIMER_VALUE 0x56 /* GPRS timer 9.11.2.3 */ +#define IEI_SNSSAI 0x22 /* S-NSSAI 9.11.2.8 */ +#define IEI_ALWAYSON_PDU 0x80 /* Always-on PDU session indication 9.11.4.3 */ +#define IEI_MAPPED_EPS 0x75 /* Mapped EPS bearer contexts 9.11.4.8 */ +#define IEI_EAP_MSG 0x78 /* EAP message 9.11.2.2 */ +#define IEI_AUTH_QOS_DESC 0x79 /* QoS flow descriptions 9.11.4.12 */ +#define IEI_EXT_CONF_OPT 0x7b /* Extended protocol configuration options 9.11.4.6 */ +#define IEI_DNN 0x25 /* DNN 9.11.2.1B */ + #endif \ No newline at end of file From 34e50a2fdf8e865e287df2e46ecbaf41376843ba Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 13:34:47 +0200 Subject: [PATCH 03/31] PSEA - Macros for PDU Session type values --- openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h index bb5bc9304c..83a1a641b9 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h @@ -37,4 +37,10 @@ #define IEI_EXT_CONF_OPT 0x7b /* Extended protocol configuration options 9.11.4.6 */ #define IEI_DNN 0x25 /* DNN 9.11.2.1B */ +/* PDU Session type value - TS 24.501 Table 9.11.4.10.1*/ + +#define PDU_SESSION_TYPE_IPV4 0b001 +#define PDU_SESSION_TYPE_IPV6 0b010 +#define PDU_SESSION_TYPE_IPV4V6 0b011 + #endif \ No newline at end of file From 92e01d8346c2028d24028f84a611ed9b0018fb1f Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 13:40:48 +0200 Subject: [PATCH 04/31] PSEA - Macros for Rule Operation Codes --- .../COMMON/ESM/MSG/PduSessionEstablishmentAccept.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h index 83a1a641b9..b95ee1b43e 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h @@ -43,4 +43,15 @@ #define PDU_SESSION_TYPE_IPV6 0b010 #define PDU_SESSION_TYPE_IPV4V6 0b011 +/* Rule operation codes - TS 24.501 Table 9.11.4.13.1 */ + +#define ROC_RESERVED_0 0b000 /* Reserved */ +#define ROC_CREATE_NEW_QOS_RULE 0b001 /* Create new QoS rule */ +#define ROC_DELETE_QOS_RULE 0b010 /* Delete existing QoS rule */ +#define ROC_MODIFY_QOS_RULE_ADD_PF 0b011 /* Modify existing QoS rule and add packet filters */ +#define ROC_MODIFY_QOS_RULE_REPLACE_PF 0b100 /* Modify existing QoS rule and replace all packet filters */ +#define ROC_MODIFY_QOS_RULE_DELETE_PF 0b101 /* Modify existing QoS rule and delete packet filters */ +#define ROC_MODIFY_QOS_RULE_WITHOUT_PF 0b110 /* Modify existing QoS rule without modifying packet filters */ +#define ROC_RESERVED_1 0b111 /* Reserved */ + #endif \ No newline at end of file From ff059d76077b7fd3c38c999504fb3daf6dba83f0 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 14:01:22 +0200 Subject: [PATCH 05/31] PSEA - Macro for DNN ASCII --- openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h index b95ee1b43e..bd5c459640 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h @@ -54,4 +54,8 @@ #define ROC_MODIFY_QOS_RULE_WITHOUT_PF 0b110 /* Modify existing QoS rule without modifying packet filters */ #define ROC_RESERVED_1 0b111 /* Reserved */ +/* DNN - ASCII Codes */ + +#define ASCII_ACK 0x06 /* Delimiter in the DNN IEI */ + #endif \ No newline at end of file From b3abb8f64f5123c9ade2e64d282e69adea8f7d7c Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 14:11:50 +0200 Subject: [PATCH 06/31] PSEA - Mandatory Presence IE --- .../ESM/MSG/PduSessionEstablishmentAccept.h | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h index bd5c459640..bc71ac846e 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h @@ -58,4 +58,45 @@ #define ASCII_ACK 0x06 /* Delimiter in the DNN IEI */ +/* Mandatory Presence IE - TS 24.501 Table 8.3.2.1.1 */ + +typedef struct packet_filter_create_qos_rule_s { + uint8_t pf_dir; /* Packet filter direction */ + uint8_t pf_id; /* Packet filter identifier */ + uint8_t length; /* Length of packet filter contents */ +} packet_filter_type1_t; /* TS 24.501 Figure 9.11.4.13.3 */ + +typedef struct packet_filter_modify_qos_rule_s { + uint8_t pf_id; /* Packet filter identifier */ +} packet_filter_type2_t; /* TS 24.501 Figure 9.11.4.13.4 */ + +typedef struct packet_filter_s { + union pf_type { + packet_filter_type1_t type_1; + packet_filter_type2_t type_2; + } pf_type; +} packet_filter_t; + +typedef struct qos_rule_s { + uint8_t id; /* QoS rule identifier */ + uint16_t length; /* Length of QoS Rule */ + uint8_t oc; /* Rule operation code (3bits) */ + uint8_t dqr; /* DQR bit (1 bit) */ + uint8_t nb_pf; /* Number of packet filters (4 bits) */ + uint8_t prcd; /* QoS rule precedence */ + uint8_t qfi; /* QoS Flow Identifier */ +} qos_rule_t; + +typedef struct auth_qos_rules_s { + uint16_t length; /* Length of QoS rules IE */ +} auth_qos_rule_t; /* QoS Rule as defined in 24.501 Figure 9.11.4.13.2 */ + +typedef struct session_ambr_s { + uint8_t length; /* Length of Session-AMBR contents */ + uint8_t unit_dl; /* Unit for Session-AMBR for downlink */ + uint16_t sess_dl; /* Session-AMBR for downlink */ + uint8_t unit_ul; /* Unit for Session-AMBR for uplink */ + uint16_t sess_ul; /* Session-AMBR for uplink */ +} session_ambr_t; /* TS 24.501 Figure 9.11.4.14.1 */ + #endif \ No newline at end of file From 724164c3954cc64a04f80ee3c2f8d7c1e3d6f862 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 14:14:53 +0200 Subject: [PATCH 07/31] PSEA - Optional Presence IE --- .../ESM/MSG/PduSessionEstablishmentAccept.h | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h index bc71ac846e..27565f5bf0 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h @@ -99,4 +99,29 @@ typedef struct session_ambr_s { uint16_t sess_ul; /* Session-AMBR for uplink */ } session_ambr_t; /* TS 24.501 Figure 9.11.4.14.1 */ +/* Optional Presence IE - TS 24.501 Table 8.3.2.1.1 */ + +typedef struct pdu_address_s { + uint8_t pdu_iei; /* PDU Address IEI (0x29) */ + uint8_t pdu_length; /* Length of PDU address contents */ + uint8_t pdu_type; /* PDU session type value */ + uint8_t pdu_addr_oct1; /* PDU address information (1st Octet)*/ + uint8_t pdu_addr_oct2; /* PDU address information (2nd Octet)*/ + uint8_t pdu_addr_oct3; /* PDU address information (3rd Octet)*/ + uint8_t pdu_addr_oct4; /* PDU address information (4th Octet)*/ +} pdu_address_t; /* TS 24.501 9.11.4.10 */ + +typedef struct dnn_s { + uint8_t dnn_iei; /* DNN IEI (0x25) */ + uint8_t dnn_length; /* Length of DNN contents */ +} dnn_t; /* TS 24.501 9.11.2.1A */ + +typedef struct ext_pP_t { + uint16_t length; +} ext_pP_t; /* TS 24.008 10.5.6.3A - Ommited, only length is processed*/ + +typedef struct qos_fd_s { + uint16_t length; +} qos_fd_t; /* TS 24.501 9.11.4.12 - Ommited, only length is processed*/ + #endif \ No newline at end of file From 9682ba9bf669a7efec37cfdc05300ac0f68a5065 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 14:17:16 +0200 Subject: [PATCH 08/31] PSEA - Message struct definition --- .../ESM/MSG/PduSessionEstablishmentAccept.h | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h index 27565f5bf0..63a57cb229 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h @@ -124,4 +124,37 @@ typedef struct qos_fd_s { uint16_t length; } qos_fd_t; /* TS 24.501 9.11.4.12 - Ommited, only length is processed*/ +typedef struct pdu_session_establishment_accept_msg_s { + /* Mandatory presence */ + uint8_t epd; /* Extended Protocol Discriminator */ + uint8_t pdu_id; /* PDU Session ID */ + uint8_t pti; /* Procedure Transaction Identity */ + uint8_t msg_type; /* Message Type */ + uint8_t pdu_type; /* PDU Session Type */ + uint8_t ssc_mode; /* SSC mode */ + auth_qos_rule_t qos_rules; /* Authorized QoS rules */ + session_ambr_t sess_ambr; /* Session-AMBR */ + + /* Optional presence */ + dnn_t dnn_ie; /* Data Network Name */ + pdu_address_t pdu_addr_ie; /* PDU Address */ + ext_pP_t ext_pp_ie; /* Extended Protocol Configuration Options */ + qos_fd_t qos_fd_ie; /* QoS flow descriptions */ +} pdu_session_establishment_accept_msg_t; /* 24.501 Table 8.3.2.1.1 */ + +typedef struct security_protected_plain_nas_5gs_msg_s { + uint8_t epd; /* Extended Protocol Discriminator */ + uint8_t sht; /* Security Header Type */ + uint8_t msg_type; /* Message Type */ + uint8_t payload_type; /* Payload Container Type */ + uint16_t payload_len; /* Payload Container Length */ +} security_protected_plain_nas_5gs_msg_t; + +typedef struct security_protected_nas_5gs_msg_s { + uint8_t epd; /* Extended Protocol Discriminator */ + uint8_t sht; /* Security Header Type */ + uint32_t mac; /* Message Authentication Code */ + uint8_t sqn; /* Sequence Number */ +} security_protected_nas_5gs_msg_t; /* 24.501 Figure 9.1.1.2 */ + #endif \ No newline at end of file From e638715dcc5883419a5bc9c7d112d051712cc400 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 14:20:34 +0200 Subject: [PATCH 09/31] PSEA - Include the PSEA header file to NAS --- openair3/NAS/NR_UE/nr_nas_msg_sim.c | 1 + 1 file changed, 1 insertion(+) diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index 2b2d9b08a5..378ca3d848 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -38,6 +38,7 @@ #include "aka_functions.h" #include "secu_defs.h" #include "PduSessionEstablishRequest.h" +#include "PduSessionEstablishmentAccept.h" #include "intertask_interface.h" #include "openair2/RRC/NAS/nas_config.h" #include From 4148e5aae66f29525decd101f1228712a4604ead Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 14:30:31 +0200 Subject: [PATCH 10/31] PSEA - Init capture function --- openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 6 +++++- openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index aef93a6632..d0b90d6f4c 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -20,4 +20,8 @@ */ #include "PduSessionEstablishmentAccept.h" -#include "common/utils/LOG/log.h" \ No newline at end of file +#include "common/utils/LOG/log.h" + +void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_length){ + return; +} \ No newline at end of file diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h index 63a57cb229..94a523285b 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h @@ -157,4 +157,6 @@ typedef struct security_protected_nas_5gs_msg_s { uint8_t sqn; /* Sequence Number */ } security_protected_nas_5gs_msg_t; /* 24.501 Figure 9.1.1.2 */ +void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_length); + #endif \ No newline at end of file From 0f1d68e2e38816a0e5a876e05ec846b6dc9b5afb Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 14:32:29 +0200 Subject: [PATCH 11/31] PSEA - Include necessary NAS header files --- openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index d0b90d6f4c..1ff1bb0614 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -21,6 +21,8 @@ #include "PduSessionEstablishmentAccept.h" #include "common/utils/LOG/log.h" +#include "nr_nas_msg_sim.h" +#include "openair2/RRC/NAS/nas_config.h" void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_length){ return; From 7a5e38399346390ec8d5465f3fe5f0aee5dcce89 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 14:37:44 +0200 Subject: [PATCH 12/31] PSEA - Capture - Security Protected NAS header & message --- .../ESM/MSG/PduSessionEstablishmentAccept.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index 1ff1bb0614..5690f131ba 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -25,5 +25,21 @@ #include "openair2/RRC/NAS/nas_config.h" void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_length){ + uint8_t offset = 0; + security_protected_nas_5gs_msg_t sec_nas_hdr; + security_protected_plain_nas_5gs_msg_t sec_nas_msg; + pdu_session_establishment_accept_msg_t psea_msg; + sec_nas_hdr.epd = *(buffer + (offset++)); + sec_nas_hdr.sht = *(buffer + (offset++)); + sec_nas_hdr.mac = htonl(*(uint32_t *)(buffer + offset)); + offset+=sizeof(sec_nas_hdr.mac); + sec_nas_hdr.sqn = *(buffer + (offset++)); + sec_nas_msg.epd = *(buffer + (offset++)); + sec_nas_msg.sht = *(buffer + (offset++)); + sec_nas_msg.msg_type = *(buffer + (offset++)); + sec_nas_msg.payload_type = *(buffer + (offset++)); + sec_nas_msg.payload_len = htons(*(uint16_t *)(buffer + offset)); + offset+=sizeof(sec_nas_msg.payload_len); + return; } \ No newline at end of file From fbe010420c53b407989db69a3c7143a8c1180453 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 14:40:02 +0200 Subject: [PATCH 13/31] PSEA - Capture - PduSessionEstablishmentAccept message --- .../NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index 5690f131ba..9e03b37299 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -40,6 +40,15 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng sec_nas_msg.payload_type = *(buffer + (offset++)); sec_nas_msg.payload_len = htons(*(uint16_t *)(buffer + offset)); offset+=sizeof(sec_nas_msg.payload_len); + /* Mandatory Presence IEs */ + psea_msg.epd = *(buffer + (offset++)); + psea_msg.pdu_id = *(buffer + (offset++)); + psea_msg.pti = *(buffer + (offset++)); + psea_msg.msg_type = *(buffer + (offset++)); + psea_msg.pdu_type = *(buffer + offset) & 0x0f; + psea_msg.ssc_mode = (*(buffer + (offset++)) & 0xf0) >> 4; + psea_msg.qos_rules.length = htons(*(uint16_t *)(buffer + offset)); + offset+=sizeof(psea_msg.qos_rules.length); return; } \ No newline at end of file From 352362ac975315acbfbf964a8dc8222d3a9308a8 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 14:46:05 +0200 Subject: [PATCH 14/31] PSEA - Capture - Authorized QoS Rules, but Ommit the Packet Filters --- .../ESM/MSG/PduSessionEstablishmentAccept.c | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index 9e03b37299..96851c974f 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -49,6 +49,33 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng psea_msg.ssc_mode = (*(buffer + (offset++)) & 0xf0) >> 4; psea_msg.qos_rules.length = htons(*(uint16_t *)(buffer + offset)); offset+=sizeof(psea_msg.qos_rules.length); + /* Supports the capture of only one QoS Rule, + it should be changed for multiple QoS Rules */ + qos_rule_t qos_rule; + qos_rule.id = *(buffer + (offset++)); + qos_rule.length = htons(*(uint16_t *)(buffer + offset)); + offset+=sizeof(qos_rule.length); + qos_rule.oc = (*(buffer + offset) & 0xE0) >> 5; + qos_rule.dqr = (*(buffer + offset) & 0x10) >> 4; + qos_rule.nb_pf = *(buffer + (offset++)) & 0x0F; + + if(qos_rule.nb_pf) { + packet_filter_t pf; + + if(qos_rule.oc == ROC_CREATE_NEW_QOS_RULE || + ROC_MODIFY_QOS_RULE_ADD_PF || + ROC_MODIFY_QOS_RULE_REPLACE_PF) { + pf.pf_type.type_1.pf_dir = (*(buffer + offset) & 0x30) >> 4; + pf.pf_type.type_1.pf_id = *(buffer + offset++) & 0x0F; + pf.pf_type.type_1.length = *(buffer + offset++); + offset += (qos_rule.nb_pf * pf.pf_type.type_1.length); /* Ommit the Packet filter List */ + } else if (qos_rule.oc == ROC_MODIFY_QOS_RULE_DELETE_PF) { + offset += qos_rule.nb_pf; + } + } + + qos_rule.prcd = *(buffer + offset++); + qos_rule.qfi = *(buffer + offset++); return; } \ No newline at end of file From d9958e4e0f2582f7c8466ceab01e5eb5ff90fda2 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 14:48:13 +0200 Subject: [PATCH 15/31] PSEA - Capture - Session AMBR (Ommited) --- openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index 96851c974f..c958f6d326 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -76,6 +76,8 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng qos_rule.prcd = *(buffer + offset++); qos_rule.qfi = *(buffer + offset++); + psea_msg.sess_ambr.length = *(buffer + offset++); + offset += psea_msg.sess_ambr.length; /* Ommit the Seassion-AMBR */ return; } \ No newline at end of file From 21c4415a37189cedd8c722c2f91d0bf9a4b38889 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 14:53:45 +0200 Subject: [PATCH 16/31] PSEA - Prepare the Optional Presence IE capture --- .../ESM/MSG/PduSessionEstablishmentAccept.c | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index c958f6d326..d921b2a956 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -79,5 +79,36 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng psea_msg.sess_ambr.length = *(buffer + offset++); offset += psea_msg.sess_ambr.length; /* Ommit the Seassion-AMBR */ + /* Optional Presence IEs */ + uint8_t psea_iei = *(buffer + offset++); + + while(offset < msg_length) { + switch (psea_iei) { + case IEI_5GSM_CAUSE: /* Ommited */ + break; + case IEI_PDU_ADDRESS: + break; + case IEI_RQ_TIMER_VALUE: /* Ommited */ + break; + case IEI_SNSSAI: /* Ommited */ + break; + case IEI_ALWAYSON_PDU: /* Ommited */ + break; + case IEI_MAPPED_EPS: /* Ommited */ + break; + case IEI_EAP_MSG: /* Ommited */ + break; + case IEI_AUTH_QOS_DESC: /* Ommited */ + break; + case IEI_EXT_CONF_OPT: /* Ommited */ + break; + case IEI_DNN: + break; + + default: + break; + } + } + return; } \ No newline at end of file From 3fee83e05b6ae509251f3f837149d9f1a5bb1ac1 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 14:56:17 +0200 Subject: [PATCH 17/31] PSEA - Capture - Position of 5GSM Cause (Ommited) --- openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index d921b2a956..833d763b29 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -85,7 +85,10 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng while(offset < msg_length) { switch (psea_iei) { case IEI_5GSM_CAUSE: /* Ommited */ + LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received 5GSM Cause IEI\n"); + offset++; break; + case IEI_PDU_ADDRESS: break; case IEI_RQ_TIMER_VALUE: /* Ommited */ From d355b1a7f2d1177e6bf14f775816a0dd0874c195 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 14:57:46 +0200 Subject: [PATCH 18/31] PSEA - Capture - PDU Address IE --- .../ESM/MSG/PduSessionEstablishmentAccept.c | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index 833d763b29..77aa413735 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -24,6 +24,8 @@ #include "nr_nas_msg_sim.h" #include "openair2/RRC/NAS/nas_config.h" +extern char *baseNetAddress; + void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_length){ uint8_t offset = 0; security_protected_nas_5gs_msg_t sec_nas_hdr; @@ -90,7 +92,30 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng break; case IEI_PDU_ADDRESS: + LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received PDU Address IE\n"); + psea_msg.pdu_addr_ie.pdu_length = *(buffer + offset++); + psea_msg.pdu_addr_ie.pdu_type = *(buffer + offset++); + + if (psea_msg.pdu_addr_ie.pdu_type == PDU_SESSION_TYPE_IPV4) { + psea_msg.pdu_addr_ie.pdu_addr_oct1 = *(buffer + offset++); + psea_msg.pdu_addr_ie.pdu_addr_oct2 = *(buffer + offset++); + psea_msg.pdu_addr_ie.pdu_addr_oct3 = *(buffer + offset++); + psea_msg.pdu_addr_ie.pdu_addr_oct4 = *(buffer + offset++); + nas_getparams(); + sprintf(baseNetAddress, "%d.%d", psea_msg.pdu_addr_ie.pdu_addr_oct1, psea_msg.pdu_addr_ie.pdu_addr_oct2); + nas_config(1,psea_msg.pdu_addr_ie.pdu_addr_oct3, psea_msg.pdu_addr_ie.pdu_addr_oct4, "oaitun_ue"); + LOG_I(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received UE IP: %d.%d.%d.%d\n", + psea_msg.pdu_addr_ie.pdu_addr_oct1, + psea_msg.pdu_addr_ie.pdu_addr_oct2, + psea_msg.pdu_addr_ie.pdu_addr_oct3, + psea_msg.pdu_addr_ie.pdu_addr_oct4); + } else { + offset += psea_msg.pdu_addr_ie.pdu_length; + } + + psea_iei = *(buffer + offset++); break; + case IEI_RQ_TIMER_VALUE: /* Ommited */ break; case IEI_SNSSAI: /* Ommited */ From 7707669f9765692e46bdef0299cb714a6997d065 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 14:58:48 +0200 Subject: [PATCH 19/31] PSEA - Capture - Position of RQ Timer Value (Ommited) --- openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index 77aa413735..632162e301 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -117,7 +117,12 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng break; case IEI_RQ_TIMER_VALUE: /* Ommited */ + LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received RQ timer value IE\n"); + offset++; /* TS 24.008 10.5.7.3 */ + psea_iei = *(buffer + offset++); + break; + case IEI_SNSSAI: /* Ommited */ break; case IEI_ALWAYSON_PDU: /* Ommited */ From 1b89529719c5bb6e8e290003acb4be3e0fd8a346 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 14:59:42 +0200 Subject: [PATCH 20/31] PSEA - Capture - Position of S-NSSAI (Ommited) --- openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index 632162e301..caf5ff05cb 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -120,11 +120,15 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received RQ timer value IE\n"); offset++; /* TS 24.008 10.5.7.3 */ psea_iei = *(buffer + offset++); - break; case IEI_SNSSAI: /* Ommited */ + LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received S-NSSAI IE\n"); + uint8_t snssai_length = *(buffer + offset); + offset += (snssai_length + sizeof(snssai_length)); + psea_iei = *(buffer + offset++); break; + case IEI_ALWAYSON_PDU: /* Ommited */ break; case IEI_MAPPED_EPS: /* Ommited */ From ff05fed29c12d02b7bf3028e99b3b778b8d8ca8d Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 15:00:22 +0200 Subject: [PATCH 21/31] PSEA - Capture - Position of Always-on PDU Session Indication (Ommited) --- openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index caf5ff05cb..2a156967b5 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -130,7 +130,11 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng break; case IEI_ALWAYSON_PDU: /* Ommited */ + LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Always-on PDU Session indication IE\n"); + offset++; + psea_iei = *(buffer + offset++); break; + case IEI_MAPPED_EPS: /* Ommited */ break; case IEI_EAP_MSG: /* Ommited */ From ca903df0a821aba17b9f692b0e3a7edfdf1c83f9 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 15:01:01 +0200 Subject: [PATCH 22/31] PSEA - Capture - Position of Mapped EPS bearer contexts (Ommited) --- openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index 2a156967b5..c7ddebcdcd 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -136,7 +136,12 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng break; case IEI_MAPPED_EPS: /* Ommited */ + LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Mapped EPS bearer context IE\n"); + uint16_t mapped_eps_length = htons(*(uint16_t *)(buffer + offset)); + offset += mapped_eps_length; + psea_iei = *(buffer + offset++); break; + case IEI_EAP_MSG: /* Ommited */ break; case IEI_AUTH_QOS_DESC: /* Ommited */ From f001961e4eb63f2c6b1f16f2bd41793a1fec2eb4 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 15:01:45 +0200 Subject: [PATCH 23/31] PSEA - Capture - Position of EAP message (Ommited) --- openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index c7ddebcdcd..bedad2f5dd 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -143,7 +143,12 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng break; case IEI_EAP_MSG: /* Ommited */ + LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received EAP message IE\n"); + uint16_t eap_length = htons(*(uint16_t *)(buffer + offset)); + offset += (eap_length + sizeof(eap_length)); + psea_iei = *(buffer + offset++); break; + case IEI_AUTH_QOS_DESC: /* Ommited */ break; case IEI_EXT_CONF_OPT: /* Ommited */ From 80542f05037ceed0faa08d22a9cc5e4dd0684385 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 15:02:23 +0200 Subject: [PATCH 24/31] PSEA - Capture - Position of Authorized QoS flow descriptions (Ommited) --- openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index bedad2f5dd..5916589e1c 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -150,7 +150,12 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng break; case IEI_AUTH_QOS_DESC: /* Ommited */ + LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Authorized QoS flow descriptions IE\n"); + psea_msg.qos_fd_ie.length = htons(*(uint16_t *)(buffer + offset)); + offset += (psea_msg.qos_fd_ie.length + sizeof(psea_msg.qos_fd_ie.length)); + psea_iei = *(buffer + offset++); break; + case IEI_EXT_CONF_OPT: /* Ommited */ break; case IEI_DNN: From 844fec61a8ab16056965fb083a3f081e4001d58d Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 15:02:57 +0200 Subject: [PATCH 25/31] PSEA - Capture - Position of Extended protocol configuration options (Ommited) --- openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index 5916589e1c..ddcbb65f2d 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -157,7 +157,12 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng break; case IEI_EXT_CONF_OPT: /* Ommited */ + LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Extended protocol configuration options IE\n"); + psea_msg.ext_pp_ie.length = htons(*(uint16_t *)(buffer + offset)); + offset += (psea_msg.ext_pp_ie.length + sizeof(psea_msg.ext_pp_ie.length )); + psea_iei = *(buffer + offset++); break; + case IEI_DNN: break; From 5ebfed3f90bab0a67faa7e506bb2943d8191e4ab Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 15:04:46 +0200 Subject: [PATCH 26/31] PSEA - Capture - DNN IE --- .../COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index ddcbb65f2d..7e16cd80bb 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -164,6 +164,19 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng break; case IEI_DNN: + LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received DNN IE\n"); + psea_msg.dnn_ie.dnn_length = *(buffer + offset++); + uint8_t i=0; + char apn[20]; + + while (*(buffer + offset + i) != ASCII_ACK) { + apn[i] = *(buffer + offset + i); + ++i; + } + + LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - APN: %s\n", apn); + offset += psea_msg.dnn_ie.dnn_length; + psea_iei = *(buffer + offset++); break; default: From 5594594c97d8becc0d02fe391cb83e01513375d0 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 15:06:13 +0200 Subject: [PATCH 27/31] PSEA - Handle uknown IE, ommits the rest message length --- openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index 7e16cd80bb..16e5d4ca8d 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -180,6 +180,8 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng break; default: + LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Not known IE\n"); + offset = msg_length; break; } } From c31b0f8fa0ebd5ee9706c8a5fca756349375152a Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 15:14:38 +0200 Subject: [PATCH 28/31] Use values from PSEA message to set QFI and PDU Session ID from CN --- openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index 16e5d4ca8d..b689377ddb 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -23,6 +23,7 @@ #include "common/utils/LOG/log.h" #include "nr_nas_msg_sim.h" #include "openair2/RRC/NAS/nas_config.h" +#include "openair2/SDAP/nr_sdap/nr_sdap.h" extern char *baseNetAddress; @@ -186,5 +187,6 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng } } + set_qfi_pduid(qos_rule.qfi, psea_msg.pdu_id); return; } \ No newline at end of file From 99c77d6fc052c5efd6288a9de4c32d8c262d6b66 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 15:19:40 +0200 Subject: [PATCH 29/31] Use the new function to capture PSEA message --- openair3/NAS/NR_UE/nr_nas_msg_sim.c | 38 ++--------------------------- 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index 378ca3d848..9c4ea33e23 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -909,42 +909,8 @@ void *nas_nrue_task(void *args_p) LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(PduSessionEstablishRequest)\n"); } } else if(msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC){ - uint8_t offset = 0; - uint8_t *payload_container = NULL; - offset += SECURITY_PROTECTED_5GS_NAS_MESSAGE_HEADER_LENGTH; - uint16_t payload_container_length = htons(((dl_nas_transport_t *)(pdu_buffer + offset))->payload_container_length); - if ((payload_container_length >= PAYLOAD_CONTAINER_LENGTH_MIN) && (payload_container_length <= PAYLOAD_CONTAINER_LENGTH_MAX)) { - offset += (PLAIN_5GS_NAS_MESSAGE_HEADER_LENGTH + 3); - } - - if (offset < NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length) { - payload_container = pdu_buffer + offset; - } - offset = 0; - uint8_t pdu_id = *(pdu_buffer+14); - while(offset < payload_container_length) { - // Fixme: this is not good 'type' 0x29 searching in TLV like structure - // AND fix dirsty code copy hereafter of the same!!! - if (*(payload_container + offset) == 0x29) { // PDU address IEI - if ((*(payload_container+offset+1) == 0x05) && (*(payload_container +offset+2) == 0x01)) { // IPV4 - nas_getparams(); - sprintf(baseNetAddress, "%d.%d", *(payload_container+offset+3), *(payload_container+offset+4)); - int third_octet = *(payload_container+offset+5); - int fourth_octet = *(payload_container+offset+6); - LOG_I(NAS, "Received PDU Session Establishment Accept, UE IP: %d.%d.%d.%d\n", - *(payload_container+offset+3), *(payload_container+offset+4), - *(payload_container+offset+5), *(payload_container+offset+6)); - nas_config(1,third_octet,fourth_octet,"oaitun_ue"); - } - } - if (*(payload_container + offset) == 0x79) { - uint8_t qfi = *(payload_container+offset+3); - set_qfi_pduid(qfi, pdu_id); - break; - } - offset++; - } - } + capture_pdu_session_establishment_accept(pdu_buffer, NAS_CONN_ESTABLI_CNF (msg_p).nasMsg.length); + } break; } From 24241e1b97177410d36c6cdaab763f24ddb904e6 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 15:20:29 +0200 Subject: [PATCH 30/31] PSEA - Log - Change the debug to trace --- .../ESM/MSG/PduSessionEstablishmentAccept.c | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index b689377ddb..a3fe2100b1 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -88,12 +88,12 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng while(offset < msg_length) { switch (psea_iei) { case IEI_5GSM_CAUSE: /* Ommited */ - LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received 5GSM Cause IEI\n"); + LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received 5GSM Cause IEI\n"); offset++; break; case IEI_PDU_ADDRESS: - LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received PDU Address IE\n"); + LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received PDU Address IE\n"); psea_msg.pdu_addr_ie.pdu_length = *(buffer + offset++); psea_msg.pdu_addr_ie.pdu_type = *(buffer + offset++); @@ -105,7 +105,7 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng nas_getparams(); sprintf(baseNetAddress, "%d.%d", psea_msg.pdu_addr_ie.pdu_addr_oct1, psea_msg.pdu_addr_ie.pdu_addr_oct2); nas_config(1,psea_msg.pdu_addr_ie.pdu_addr_oct3, psea_msg.pdu_addr_ie.pdu_addr_oct4, "oaitun_ue"); - LOG_I(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received UE IP: %d.%d.%d.%d\n", + LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received UE IP: %d.%d.%d.%d\n", psea_msg.pdu_addr_ie.pdu_addr_oct1, psea_msg.pdu_addr_ie.pdu_addr_oct2, psea_msg.pdu_addr_ie.pdu_addr_oct3, @@ -118,54 +118,54 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng break; case IEI_RQ_TIMER_VALUE: /* Ommited */ - LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received RQ timer value IE\n"); + LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received RQ timer value IE\n"); offset++; /* TS 24.008 10.5.7.3 */ psea_iei = *(buffer + offset++); break; case IEI_SNSSAI: /* Ommited */ - LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received S-NSSAI IE\n"); + LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received S-NSSAI IE\n"); uint8_t snssai_length = *(buffer + offset); offset += (snssai_length + sizeof(snssai_length)); psea_iei = *(buffer + offset++); break; case IEI_ALWAYSON_PDU: /* Ommited */ - LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Always-on PDU Session indication IE\n"); + LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Always-on PDU Session indication IE\n"); offset++; psea_iei = *(buffer + offset++); break; case IEI_MAPPED_EPS: /* Ommited */ - LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Mapped EPS bearer context IE\n"); + LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Mapped EPS bearer context IE\n"); uint16_t mapped_eps_length = htons(*(uint16_t *)(buffer + offset)); offset += mapped_eps_length; psea_iei = *(buffer + offset++); break; case IEI_EAP_MSG: /* Ommited */ - LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received EAP message IE\n"); + LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received EAP message IE\n"); uint16_t eap_length = htons(*(uint16_t *)(buffer + offset)); offset += (eap_length + sizeof(eap_length)); psea_iei = *(buffer + offset++); break; case IEI_AUTH_QOS_DESC: /* Ommited */ - LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Authorized QoS flow descriptions IE\n"); + LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Authorized QoS flow descriptions IE\n"); psea_msg.qos_fd_ie.length = htons(*(uint16_t *)(buffer + offset)); offset += (psea_msg.qos_fd_ie.length + sizeof(psea_msg.qos_fd_ie.length)); psea_iei = *(buffer + offset++); break; case IEI_EXT_CONF_OPT: /* Ommited */ - LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Extended protocol configuration options IE\n"); + LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Extended protocol configuration options IE\n"); psea_msg.ext_pp_ie.length = htons(*(uint16_t *)(buffer + offset)); offset += (psea_msg.ext_pp_ie.length + sizeof(psea_msg.ext_pp_ie.length )); psea_iei = *(buffer + offset++); break; case IEI_DNN: - LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received DNN IE\n"); + LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received DNN IE\n"); psea_msg.dnn_ie.dnn_length = *(buffer + offset++); uint8_t i=0; char apn[20]; @@ -175,13 +175,13 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng ++i; } - LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - APN: %s\n", apn); + LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - APN: %s\n", apn); offset += psea_msg.dnn_ie.dnn_length; psea_iei = *(buffer + offset++); break; default: - LOG_D(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Not known IE\n"); + LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Not known IE\n"); offset = msg_length; break; } From 3f1d515aafca461286fdc8cce744b715f06e8e4a Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 5 Oct 2022 15:39:21 +0200 Subject: [PATCH 31/31] PSEA - Slight cosmetic changes --- .../NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 8 ++++---- .../NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h | 2 +- openair3/NAS/NR_UE/nr_nas_msg_sim.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index a3fe2100b1..cbcd767c11 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -27,7 +27,8 @@ extern char *baseNetAddress; -void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_length){ +void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_length) +{ uint8_t offset = 0; security_protected_nas_5gs_msg_t sec_nas_hdr; security_protected_plain_nas_5gs_msg_t sec_nas_msg; @@ -52,8 +53,7 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng psea_msg.ssc_mode = (*(buffer + (offset++)) & 0xf0) >> 4; psea_msg.qos_rules.length = htons(*(uint16_t *)(buffer + offset)); offset+=sizeof(psea_msg.qos_rules.length); - /* Supports the capture of only one QoS Rule, - it should be changed for multiple QoS Rules */ + /* Supports the capture of only one QoS Rule, it should be changed for multiple QoS Rules */ qos_rule_t qos_rule; qos_rule.id = *(buffer + (offset++)); qos_rule.length = htons(*(uint16_t *)(buffer + offset)); @@ -104,7 +104,7 @@ void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_leng psea_msg.pdu_addr_ie.pdu_addr_oct4 = *(buffer + offset++); nas_getparams(); sprintf(baseNetAddress, "%d.%d", psea_msg.pdu_addr_ie.pdu_addr_oct1, psea_msg.pdu_addr_ie.pdu_addr_oct2); - nas_config(1,psea_msg.pdu_addr_ie.pdu_addr_oct3, psea_msg.pdu_addr_ie.pdu_addr_oct4, "oaitun_ue"); + nas_config(1, psea_msg.pdu_addr_ie.pdu_addr_oct3, psea_msg.pdu_addr_ie.pdu_addr_oct4, "oaitun_ue"); LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received UE IP: %d.%d.%d.%d\n", psea_msg.pdu_addr_ie.pdu_addr_oct1, psea_msg.pdu_addr_ie.pdu_addr_oct2, diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h index 94a523285b..ca92e54418 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h @@ -157,6 +157,6 @@ typedef struct security_protected_nas_5gs_msg_s { uint8_t sqn; /* Sequence Number */ } security_protected_nas_5gs_msg_t; /* 24.501 Figure 9.1.1.2 */ -void capture_pdu_session_establishment_accept(uint8_t *buffer, uint32_t msg_length); +void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_length); #endif \ No newline at end of file diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index 9c4ea33e23..890af23d1f 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -909,7 +909,7 @@ void *nas_nrue_task(void *args_p) LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(PduSessionEstablishRequest)\n"); } } else if(msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC){ - capture_pdu_session_establishment_accept(pdu_buffer, NAS_CONN_ESTABLI_CNF (msg_p).nasMsg.length); + capture_pdu_session_establishment_accept_msg(pdu_buffer, NAS_CONN_ESTABLI_CNF (msg_p).nasMsg.length); } break;