From 0ef8976d536f17c37429e004630059aa4b3bb411 Mon Sep 17 00:00:00 2001 From: David Rupprecht Date: Tue, 31 Aug 2021 08:58:08 +0200 Subject: [PATCH] Remove length from class and pass by reference --- lib/include/srsran/asn1/nas_5g_ies.h | 664 +++++++++++---------------- lib/include/srsran/asn1/nas_5g_msg.h | 6 +- lib/src/asn1/nas_5g_ies.cc | 136 ++++-- lib/src/asn1/nas_5g_msg.cc | 6 +- lib/test/asn1/nas_5g_msg_test.cc | 18 +- 5 files changed, 378 insertions(+), 452 deletions(-) diff --git a/lib/include/srsran/asn1/nas_5g_ies.h b/lib/include/srsran/asn1/nas_5g_ies.h index 2c780076c..1467de9f4 100644 --- a/lib/include/srsran/asn1/nas_5g_ies.h +++ b/lib/include/srsran/asn1/nas_5g_ies.h @@ -55,7 +55,6 @@ public: }; typedef nas_enumerated follow_on_request_bit_type; - uint32_t length; follow_on_request_bit_type follow_on_request_bit; registration_type_type registration_type; @@ -88,7 +87,6 @@ public: }; typedef nas_enumerated nas_key_set_identifier_type; - uint32_t length; security_context_flag_type security_context_flag; nas_key_set_identifier_type nas_key_set_identifier; @@ -223,7 +221,6 @@ public: }; // eui_64 - uint32_t length; // Getters suci_s& suci() @@ -331,27 +328,26 @@ private: class capability_5gmm_t { public: - uint32_t length; - bool sgc; - bool iphc_cp_c_io_t_5g; - bool n3_data; - bool cp_c_io_t_5g; - bool restrict_ec; - bool lpp; - bool ho_attach; - bool s1_mode; - bool racs; - bool nssaa; - bool lcs_5g; - bool v2_xcnpc5; - bool v2_xcepc5; - bool v2_x; - bool up_c_io_t_5g; - bool srvcc_5g; - bool ehc_cp_c_io_t_5g; - bool multiple_up; - bool wusa; - bool cag; + bool sgc; + bool iphc_cp_c_io_t_5g; + bool n3_data; + bool cp_c_io_t_5g; + bool restrict_ec; + bool lpp; + bool ho_attach; + bool s1_mode; + bool racs; + bool nssaa; + bool lcs_5g; + bool v2_xcnpc5; + bool v2_xcepc5; + bool v2_x; + bool up_c_io_t_5g; + bool srvcc_5g; + bool ehc_cp_c_io_t_5g; + bool multiple_up; + bool wusa; + bool cag; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -363,46 +359,47 @@ public: class ue_security_capability_t { public: - uint32_t length; - bool ea0_5g_supported; - bool ea1_128_5g_supported; - bool ea2_128_5g_supported; - bool ea3_128_5g_supported; - bool ea4_5g_supported; - bool ea5_5g_supported; - bool ea6_5g_supported; - bool ea7_5g_supported; - bool ia0_5g_supported; - bool ia1_128_5g_supported; - bool ia2_128_5g_supported; - bool ia3_128_5g_supported; - bool ia4_5g_supported; - bool ia5_5g_supported; - bool ia6_5g_supported; - bool ia7_5g_supported; - bool eps_caps_present; - bool eea0_supported; - bool eea1_128_supported; - bool eea2_128_supported; - bool eea3_128_supported; - bool eea4_supported; - bool eea5_supported; - bool eea6_supported; - bool eea7_supported; - bool eia0_supported; - bool eia1_128_supported; - bool eia2_128_supported; - bool eia3_128_supported; - bool eia4_supported; - bool eia5_supported; - bool eia6_supported; - bool eia7_supported; + bool ea0_5g_supported; + bool ea1_128_5g_supported; + bool ea2_128_5g_supported; + bool ea3_128_5g_supported; + bool ea4_5g_supported; + bool ea5_5g_supported; + bool ea6_5g_supported; + bool ea7_5g_supported; + bool ia0_5g_supported; + bool ia1_128_5g_supported; + bool ia2_128_5g_supported; + bool ia3_128_5g_supported; + bool ia4_5g_supported; + bool ia5_5g_supported; + bool ia6_5g_supported; + bool ia7_5g_supported; + bool eps_caps_present; + bool eea0_supported; + bool eea1_128_supported; + bool eea2_128_supported; + bool eea3_128_supported; + bool eea4_supported; + bool eea5_supported; + bool eea6_supported; + bool eea7_supported; + bool eia0_supported; + bool eia1_128_supported; + bool eia2_128_supported; + bool eia3_128_supported; + bool eia4_supported; + bool eia5_supported; + bool eia6_supported; + bool eia7_supported; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); }; // ue_security_capability_t +// IE: S-NSSAI +// Reference: 9.11.2.8 // IE: S-NSSAI // Reference: 9.11.2.8 class s_nssai_t @@ -421,7 +418,7 @@ public: }; typedef nas_enumerated SST_type; - uint32_t length; + SST_type type; uint8_t sst; uint32_t sd; uint8_t mapped_hplmn_sst; @@ -437,7 +434,6 @@ public: class nssai_t { public: - uint32_t length; std::vector s_nssai_list; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -450,7 +446,6 @@ public: class tracking_area_identity_5gs_t { public: - uint32_t length; std::array mcc; std::array mnc; uint32_t tac; @@ -465,68 +460,67 @@ public: class s1_ue_network_capability_t { public: - uint32_t length; - bool eea0_supported; - bool eea1_128_supported; - bool eea2_128_supported; - bool eea3_128_supported; - bool eea4_supported; - bool eea5_supported; - bool eea6_supported; - bool eea7_supported; - bool eia0_supported; - bool eia1_128_supported; - bool eia2_128_supported; - bool eia3_128_supported; - bool eia4_supported; - bool eia5_supported; - bool eia6_supported; - bool eia7_supported; - bool uea0_supported; - bool uea1_128_supported; - bool uea2_128_supported; - bool uea3_128_supported; - bool uea4_supported; - bool uea5_supported; - bool uea6_supported; - bool uea7_supported; - bool ucs2_support; - bool uia1_128_supported; - bool uia2_128_supported; - bool uia3_128_supported; - bool uia4_supported; - bool uia5_supported; - bool uia6_supported; - bool uia7_supported; - bool pro_se_dd_supported; - bool pro_se_supported; - bool h245_ash_supported; - bool acc_csfb_supported; - bool llp_supported; - bool lcs_supported; - bool srvcc_capability_supported; - bool nf_capability_supported; - bool e_pco_supported; - bool hc_cp_c_io_t_supported; - bool e_rw_o_pdn_supported; - bool s1_u_data_supported; - bool up_c_io_t_supported; - bool cp_c_io_t_supported; - bool pro_se_relay_supported; - bool pro_se_dc_supported; - bool max_15_eps_bearer_supported; - bool sgc_supported; - bool n1mode_supported; - bool dcnr_supported; - bool cp_backoff_supported; - bool restrict_ec_supported; - bool v2_x_pc5_supported; - bool multiple_drb_supported; - bool nr_pc5_supported; - bool up_mt_edt_supported; - bool cp_mt_edt_supported; - bool wus_supported; - bool racs_supported; + bool eea0_supported; + bool eea1_128_supported; + bool eea2_128_supported; + bool eea3_128_supported; + bool eea4_supported; + bool eea5_supported; + bool eea6_supported; + bool eea7_supported; + bool eia0_supported; + bool eia1_128_supported; + bool eia2_128_supported; + bool eia3_128_supported; + bool eia4_supported; + bool eia5_supported; + bool eia6_supported; + bool eia7_supported; + bool uea0_supported; + bool uea1_128_supported; + bool uea2_128_supported; + bool uea3_128_supported; + bool uea4_supported; + bool uea5_supported; + bool uea6_supported; + bool uea7_supported; + bool ucs2_support; + bool uia1_128_supported; + bool uia2_128_supported; + bool uia3_128_supported; + bool uia4_supported; + bool uia5_supported; + bool uia6_supported; + bool uia7_supported; + bool pro_se_dd_supported; + bool pro_se_supported; + bool h245_ash_supported; + bool acc_csfb_supported; + bool llp_supported; + bool lcs_supported; + bool srvcc_capability_supported; + bool nf_capability_supported; + bool e_pco_supported; + bool hc_cp_c_io_t_supported; + bool e_rw_o_pdn_supported; + bool s1_u_data_supported; + bool up_c_io_t_supported; + bool cp_c_io_t_supported; + bool pro_se_relay_supported; + bool pro_se_dc_supported; + bool max_15_eps_bearer_supported; + bool sgc_supported; + bool n1mode_supported; + bool dcnr_supported; + bool cp_backoff_supported; + bool restrict_ec_supported; + bool v2_x_pc5_supported; + bool multiple_drb_supported; + bool nr_pc5_supported; + bool up_mt_edt_supported; + bool cp_mt_edt_supported; + bool wus_supported; + bool racs_supported; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -538,23 +532,22 @@ public: class uplink_data_status_t { public: - uint32_t length; - bool psi_7; - bool psi_6; - bool psi_5; - bool psi_4; - bool psi_3; - bool psi_2; - bool psi_1; - bool psi_0; - bool psi_15; - bool psi_14; - bool psi_13; - bool psi_12; - bool psi_11; - bool psi_10; - bool psi_9; - bool psi_8; + bool psi_7; + bool psi_6; + bool psi_5; + bool psi_4; + bool psi_3; + bool psi_2; + bool psi_1; + bool psi_0; + bool psi_15; + bool psi_14; + bool psi_13; + bool psi_12; + bool psi_11; + bool psi_10; + bool psi_9; + bool psi_8; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -566,23 +559,22 @@ public: class pdu_session_status_t { public: - uint32_t length; - bool psi_7; - bool psi_6; - bool psi_5; - bool psi_4; - bool psi_3; - bool psi_2; - bool psi_1; - bool psi_0; - bool psi_15; - bool psi_14; - bool psi_13; - bool psi_12; - bool psi_11; - bool psi_10; - bool psi_9; - bool psi_8; + bool psi_7; + bool psi_6; + bool psi_5; + bool psi_4; + bool psi_3; + bool psi_2; + bool psi_1; + bool psi_0; + bool psi_15; + bool psi_14; + bool psi_13; + bool psi_12; + bool psi_11; + bool psi_10; + bool psi_9; + bool psi_8; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -594,9 +586,8 @@ public: class mico_indication_t { public: - uint32_t length; - bool sprti; - bool aai; + bool sprti; + bool aai; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -608,9 +599,8 @@ public: class ue_status_t { public: - uint32_t length; - bool n1_mode_reg; - bool s1_mode_reg; + bool n1_mode_reg; + bool s1_mode_reg; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -622,23 +612,22 @@ public: class allowed_pdu_session_status_t { public: - uint32_t length; - bool psi_7; - bool psi_6; - bool psi_5; - bool psi_4; - bool psi_3; - bool psi_2; - bool psi_1; - bool psi_0; - bool psi_15; - bool psi_14; - bool psi_13; - bool psi_12; - bool psi_11; - bool psi_10; - bool psi_9; - bool psi_8; + bool psi_7; + bool psi_6; + bool psi_5; + bool psi_4; + bool psi_3; + bool psi_2; + bool psi_1; + bool psi_0; + bool psi_15; + bool psi_14; + bool psi_13; + bool psi_12; + bool psi_11; + bool psi_10; + bool psi_9; + bool psi_8; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -660,7 +649,6 @@ public: }; typedef nas_enumerated UE_usage_setting_type; - uint32_t length; UE_usage_setting_type ue_usage_setting; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -686,7 +674,6 @@ public: }; typedef nas_enumerated drx_value_type; - uint32_t length; drx_value_type drx_value; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -699,7 +686,6 @@ public: class eps_nas_message_container_t { public: - uint32_t length; std::vector eps_nas_message_container; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -725,7 +711,6 @@ public: class ladn_indication_t { public: - uint32_t length; std::vector ladn_dnn_values; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -755,7 +740,6 @@ public: }; typedef nas_enumerated Payload_container_type_type; - uint32_t length; Payload_container_type_type payload_container_type; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -768,7 +752,6 @@ public: class payload_container_t { public: - uint32_t length; std::vector payload_container_contents; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -781,9 +764,8 @@ public: class network_slicing_indication_t { public: - uint32_t length; - bool nssci; - bool dcni; + bool nssci; + bool dcni; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -839,7 +821,6 @@ public: }; typedef nas_enumerated PNB_EPS_CIoT_type; - uint32_t length; PNB_EPS_CIoT_type pnb_eps_c_io_t; PNB_5GS_CIoT_type pnb_5gs_c_io_t; NG_RAN_RCU_type ng_ran_rcu; @@ -855,8 +836,6 @@ public: class mobile_station_classmark_2_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -867,8 +846,6 @@ public: class supported_codec_list_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -879,7 +856,6 @@ public: class message_container_t { public: - uint32_t length; std::vector nas_message_container; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -892,23 +868,22 @@ public: class eps_bearer_context_status_t { public: - uint32_t length; - bool ebi_7; - bool ebi_6; - bool ebi_5; - bool ebi_4; - bool ebi_3; - bool ebi_2; - bool ebi_1; - bool ebi_0; - bool ebi_15; - bool ebi_14; - bool ebi_13; - bool ebi_12; - bool ebi_11; - bool ebi_10; - bool ebi_9; - bool ebi_8; + bool ebi_7; + bool ebi_6; + bool ebi_5; + bool ebi_4; + bool ebi_3; + bool ebi_2; + bool ebi_1; + bool ebi_0; + bool ebi_15; + bool ebi_14; + bool ebi_13; + bool ebi_12; + bool ebi_11; + bool ebi_10; + bool ebi_9; + bool ebi_8; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -968,7 +943,6 @@ public: }; typedef nas_enumerated eDRX_value_type; - uint32_t length; Paging_Time_Window_type paging__time__window; eDRX_value_type e_drx_value; @@ -998,7 +972,6 @@ public: }; typedef nas_enumerated Unit_type; - uint32_t length; Unit_type unit; uint8_t timer_value; @@ -1012,7 +985,6 @@ public: class ue_radio_capability_id_t { public: - uint32_t length; std::vector ue_radio_capability_id; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1025,8 +997,6 @@ public: class mapped_nssai_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1037,8 +1007,7 @@ public: class additional_information_requested_t { public: - uint32_t length; - bool cipher_key; + bool cipher_key; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1050,8 +1019,6 @@ public: class wus_assistance_information_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1062,8 +1029,7 @@ public: class n5gc_indication_t { public: - uint32_t length; - bool n5gcreg; + bool n5gcreg; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1090,7 +1056,6 @@ public: }; typedef nas_enumerated nb_n1_mode_drx_value_type; - uint32_t length; nb_n1_mode_drx_value_type nb_n1_mode_drx_value; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1145,7 +1110,6 @@ public: }; typedef nas_enumerated registration_result_type; - uint32_t length; Emergency_registered_type emergency_registered; NSSAA_to_be_performed_type nssaa_to_be_performed; SMS_allowed_type sms_allowed; @@ -1161,8 +1125,6 @@ public: class plmn_list_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1185,8 +1147,6 @@ public: }; typedef nas_enumerated type_of_list_type; - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1197,8 +1157,6 @@ public: class rejected_nssai_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1209,8 +1167,6 @@ public: class network_feature_support_5gs_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1221,23 +1177,22 @@ public: class pdu_session_reactivation_result_t { public: - uint32_t length; - bool psi_7; - bool psi_6; - bool psi_5; - bool psi_4; - bool psi_3; - bool psi_2; - bool psi_1; - bool psi_0; - bool psi_15; - bool psi_14; - bool psi_13; - bool psi_12; - bool psi_11; - bool psi_10; - bool psi_9; - bool psi_8; + bool psi_7; + bool psi_6; + bool psi_5; + bool psi_4; + bool psi_3; + bool psi_2; + bool psi_1; + bool psi_0; + bool psi_15; + bool psi_14; + bool psi_13; + bool psi_12; + bool psi_11; + bool psi_10; + bool psi_9; + bool psi_8; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1249,8 +1204,6 @@ public: class pdu_session_reactivation_result_error_cause_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1261,8 +1214,6 @@ public: class ladn_information_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1273,8 +1224,6 @@ public: class service_area_list_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1285,8 +1234,7 @@ public: class gprs_timer_2_t { public: - uint32_t length; - uint8_t timer_value; + uint8_t timer_value; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1298,8 +1246,6 @@ public: class emergency_number_list_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1310,8 +1256,6 @@ public: class extended_emergency_number_list_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1322,8 +1266,6 @@ public: class sor_transparent_container_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1334,7 +1276,6 @@ public: class eap_message_t { public: - uint32_t length; std::vector eap_message; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1359,7 +1300,6 @@ public: }; typedef nas_enumerated NSSAI_inclusion_mode_type; - uint32_t length; NSSAI_inclusion_mode_type nssai_inclusion_mode; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1372,8 +1312,6 @@ public: class operator_defined_access_category_definitions_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1384,8 +1322,7 @@ public: class non_3_gpp_nw_provided_policies_t { public: - uint32_t length; - bool n3_en; + bool n3_en; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1407,7 +1344,6 @@ public: }; typedef nas_enumerated Deletion_request_type; - uint32_t length; Deletion_request_type deletion_request; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1420,8 +1356,6 @@ public: class ciphering_key_data_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1432,8 +1366,6 @@ public: class cag_information_list_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1444,9 +1376,8 @@ public: class truncated_5g_s_tmsi_configuration_t { public: - uint32_t length; - uint8_t truncated_amf__set_id_value; - uint8_t truncated_amf__pointer_value; + uint8_t truncated_amf__set_id_value; + uint8_t truncated_amf__pointer_value; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1508,7 +1439,6 @@ public: }; typedef nas_enumerated cause_5gmm_type; - uint32_t length; cause_5gmm_type cause_5gmm; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1552,7 +1482,6 @@ public: }; typedef nas_enumerated access_type_type; - uint32_t length; switch_off_type switch_off; re_registration_required_type re_registration_required; access_type_type access_type; @@ -1567,8 +1496,6 @@ public: class spare_half_octet_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1599,7 +1526,6 @@ public: }; typedef nas_enumerated Service_type_value_type; - uint32_t length; Service_type_value_type service_type_value; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1624,7 +1550,6 @@ public: }; typedef nas_enumerated control_plane_service_type_value_type; - uint32_t length; control_plane_service_type_value_type control_plane_service_type_value; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1637,8 +1562,6 @@ public: class network_name_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1649,13 +1572,12 @@ public: class time_zone_t { public: - uint32_t length; - uint8_t year; - uint8_t month; - uint8_t day; - uint8_t hour; - uint8_t second; - uint8_t time_zone; + uint8_t year; + uint8_t month; + uint8_t day; + uint8_t hour; + uint8_t second; + uint8_t time_zone; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1667,8 +1589,7 @@ public: class time_zone_and_time_t { public: - uint32_t length; - uint8_t time_zone; + uint8_t time_zone; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1692,7 +1613,6 @@ public: }; typedef nas_enumerated value_type; - uint32_t length; value_type value; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1705,8 +1625,7 @@ public: class sms_indication_t { public: - uint32_t length; - bool sms_availability_indication; + bool sms_availability_indication; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1728,7 +1647,6 @@ public: }; typedef nas_enumerated SCMR_type; - uint32_t length; SCMR_type scmr; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1741,7 +1659,6 @@ public: class abba_t { public: - uint32_t length; std::vector abba_contents; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1754,7 +1671,6 @@ public: class authentication_parameter_rand_t { public: - uint32_t length; std::array rand; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1767,7 +1683,6 @@ public: class authentication_parameter_autn_t { public: - uint32_t length; std::vector autn; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1780,7 +1695,6 @@ public: class authentication_response_parameter_t { public: - uint32_t length; std::vector res; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1793,7 +1707,6 @@ public: class authentication_failure_parameter_t { public: - uint32_t length; std::vector auth_failure; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1821,7 +1734,6 @@ public: }; typedef nas_enumerated identity_types; - uint32_t length; identity_types type_of_identity; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1866,7 +1778,6 @@ public: }; typedef nas_enumerated ciphering_algorithm_type; - uint32_t length; ciphering_algorithm_type ciphering_algorithm; integrity_protection_algorithm_type integrity_protection_algorithm; @@ -1890,7 +1801,6 @@ public: }; typedef nas_enumerated imeisv_request_type; - uint32_t length; imeisv_request_type imeisv_request; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -1935,7 +1845,6 @@ public: }; typedef nas_enumerated ciphering_algorithm_type; - uint32_t length; ciphering_algorithm_type ciphering_algorithm; integrity_protection_algorithm_type integrity_protection_algorithm; @@ -1949,9 +1858,8 @@ public: class additional_5g_security_information_t { public: - uint32_t length; - bool rinmr; - bool hdp; + bool rinmr; + bool hdp; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -1963,45 +1871,44 @@ public: class s1_ue_security_capability_t { public: - uint32_t length; - bool eea0; - bool eea1_128; - bool eea2_128; - bool eea3_128; - bool eea4; - bool eea5; - bool eea6; - bool eea7; - bool eia0; - bool eia1_128; - bool eia2_128; - bool eia3_128; - bool eia4; - bool eia5; - bool eia6; - bool eia7; - bool uea0; - bool uea1; - bool uea2; - bool uea3; - bool uea4; - bool uea5; - bool uea6; - bool uea7; - bool uia1; - bool uia2; - bool uia3; - bool uia4; - bool uia5; - bool uia6; - bool uia7; - bool gea1; - bool gea2; - bool gea3; - bool gea4; - bool gea5; - bool gea6; - bool gea7; + bool eea0; + bool eea1_128; + bool eea2_128; + bool eea3_128; + bool eea4; + bool eea5; + bool eea6; + bool eea7; + bool eia0; + bool eia1_128; + bool eia2_128; + bool eia3_128; + bool eia4; + bool eia5; + bool eia6; + bool eia7; + bool uea0; + bool uea1; + bool uea2; + bool uea3; + bool uea4; + bool uea5; + bool uea6; + bool uea7; + bool uia1; + bool uia2; + bool uia3; + bool uia4; + bool uia5; + bool uia6; + bool uia7; + bool gea1; + bool gea2; + bool gea3; + bool gea4; + bool gea5; + bool gea6; + bool gea7; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -2023,7 +1930,6 @@ public: }; typedef nas_enumerated Access_type_value_type; - uint32_t length; Access_type_value_type access_type_value; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2036,8 +1942,7 @@ public: class pdu_session_identity_2_t { public: - uint32_t length; - uint8_t pdu_session_identity_2_value; + uint8_t pdu_session_identity_2_value; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -2064,7 +1969,6 @@ public: }; typedef nas_enumerated Request_type_value_type; - uint32_t length; Request_type_value_type request_type_value; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2077,7 +1981,6 @@ public: class additional_information_t { public: - uint32_t length; std::vector additional_information_value; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2099,7 +2002,6 @@ public: }; typedef nas_enumerated MA_PDU_session_information_value_type; - uint32_t length; MA_PDU_session_information_value_type ma_pdu_session_information_value; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2124,7 +2026,6 @@ public: }; typedef nas_enumerated Downlink_data_expected_type; - uint32_t length; Downlink_data_expected_type downlink_data_expected; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2159,7 +2060,6 @@ public: }; typedef nas_enumerated max_data_rate_UPIP_downlink_type; - uint32_t length; max_data_rate_UPIP_uplink_type max_data_rate_upip_uplink; max_data_rate_UPIP_downlink_type max_data_rate_upip_downlink; @@ -2187,7 +2087,6 @@ public: }; typedef nas_enumerated PDU_session_type_value_type; - uint32_t length; PDU_session_type_value_type pdu_session_type_value; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2215,7 +2114,6 @@ public: }; typedef nas_enumerated SSC_mode_value_type; - uint32_t length; SSC_mode_value_type ssc_mode_value; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2228,8 +2126,6 @@ public: class capability_5gsm_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -2240,7 +2136,6 @@ public: class maximum_number_of_supported_packet_filters_t { public: - uint32_t length; uint16_t maximum_number_of_supported_packet_filters; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2253,8 +2148,7 @@ public: class always_on_pdu_session_requested_t { public: - uint32_t length; - bool apsi; + bool apsi; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -2266,7 +2160,6 @@ public: class sm_pdu_dn_request_container_t { public: - uint32_t length; std::vector dn_specific_identity; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2279,8 +2172,6 @@ public: class extended_protocol_configuration_options_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -2291,8 +2182,6 @@ public: class ip_header_compression_configuration_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -2303,7 +2192,6 @@ public: class ds_tt__ethernet_port_mac_address_t { public: - uint32_t length; std::array ds_tt__ethernet_port_mac_address_contents; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2316,7 +2204,6 @@ public: class ue_ds_tt_residence_time_t { public: - uint32_t length; std::array ue_ds_tt_residence_time_contents; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2329,7 +2216,6 @@ public: class port_management_information_container_t { public: - uint32_t length; std::vector port_management_information_container; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2353,7 +2239,6 @@ public: }; typedef nas_enumerated CID_Length_type; - uint32_t length; CID_Length_type cid__length; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2377,7 +2262,6 @@ public: }; typedef nas_enumerated PDU_session_type_value_type; - uint32_t length; bool si6_lla; PDU_session_type_value_type pdu_session_type_value; std::array ipv4; @@ -2395,7 +2279,6 @@ class qo_s_rules_t { public: struct qos_rule_t {}; - uint32_t length; std::vector qos_rules; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2442,7 +2325,6 @@ public: }; typedef nas_enumerated unit_session_AMBR_type; - uint32_t length; unit_session_AMBR_type unit_session_ambr_for_downlink; uint16_t session_ambr_for_downlink; unit_session_AMBR_type unit_session_ambr_for_uplink; @@ -2509,7 +2391,6 @@ public: }; typedef nas_enumerated cause_value_type; - uint32_t length; cause_value_type cause_value; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2534,7 +2415,6 @@ public: }; typedef nas_enumerated Unit_type; - uint32_t length; Unit_type unit; uint8_t timer_value; @@ -2548,8 +2428,7 @@ public: class always_on_pdu_session_indication_t { public: - uint32_t length; - bool apsr; + bool apsr; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -2561,8 +2440,6 @@ public: class mapped_eps_bearer_contexts_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -2573,8 +2450,6 @@ public: class qo_s_flow_descriptions_t { public: - uint32_t length; - SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -2595,7 +2470,6 @@ public: }; typedef nas_enumerated EPT_S1_type; - uint32_t length; EPT_S1_type ept_s1; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2608,7 +2482,6 @@ public: class serving_plmn_rate_control_t { public: - uint32_t length; uint16_t serving_plmn_rate_control_value; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2621,7 +2494,6 @@ public: class atsss_container_t { public: - uint32_t length; std::vector nas_message_container; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2634,8 +2506,7 @@ public: class control_plane_only_indication_t { public: - uint32_t length; - bool cpoi; + bool cpoi; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -2647,10 +2518,9 @@ public: class allowed_ssc_mode_t { public: - uint32_t length; - bool ssc3; - bool ssc2; - bool ssc1; + bool ssc3; + bool ssc2; + bool ssc1; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); @@ -2672,7 +2542,6 @@ public: }; typedef nas_enumerated abo_type; - uint32_t length; abo_type abo; SRSASN_CODE pack(asn1::bit_ref& bref); @@ -2685,9 +2554,8 @@ public: class re_attempt_indicator_t { public: - uint32_t length; - bool eplmnc; - bool ratc; + bool eplmnc; + bool ratc; SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE unpack(asn1::cbit_ref& bref); diff --git a/lib/include/srsran/asn1/nas_5g_msg.h b/lib/include/srsran/asn1/nas_5g_msg.h index 5edb3f20e..53d6b37b1 100644 --- a/lib/include/srsran/asn1/nas_5g_msg.h +++ b/lib/include/srsran/asn1/nas_5g_msg.h @@ -1813,11 +1813,11 @@ public: nas_5gs_hdr hdr; SRSASN_CODE pack(unique_byte_buffer_t& buf); - SRSASN_CODE pack(std::vector buf); + SRSASN_CODE pack(std::vector& buf); SRSASN_CODE unpack(const unique_byte_buffer_t& buf); - SRSASN_CODE unpack(const std::vector buf); + SRSASN_CODE unpack(const std::vector& buf); SRSASN_CODE unpack_outer_hdr(const unique_byte_buffer_t& buf); - SRSASN_CODE unpack_outer_hdr(const std::vector buf); + SRSASN_CODE unpack_outer_hdr(const std::vector& buf); void set(msg_types::options e = msg_types::nulltype) { hdr.message_type = e; }; // Getters diff --git a/lib/src/asn1/nas_5g_ies.cc b/lib/src/asn1/nas_5g_ies.cc index 9e5975dee..286c01a9b 100644 --- a/lib/src/asn1/nas_5g_ies.cc +++ b/lib/src/asn1/nas_5g_ies.cc @@ -121,6 +121,7 @@ SRSASN_CODE mobile_identity_5gs_t::pack(asn1::bit_ref& bref) SRSASN_CODE mobile_identity_5gs_t::unpack(asn1::cbit_ref& bref) { // Length + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); uint8_t tmp; HANDLE_CODE(bref.unpack(tmp, 5)); @@ -447,6 +448,7 @@ SRSASN_CODE capability_5gmm_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.1 SRSASN_CODE capability_5gmm_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 1 || length > 13) { asn1::log_error("Decoding Failed (5GMM capability): Length (%d) is not in range of min: 1 and max 13 bytes", @@ -548,6 +550,7 @@ SRSASN_CODE ue_security_capability_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.54 SRSASN_CODE ue_security_capability_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 2 || length > 8) { asn1::log_error("Decoding Failed (UE security capability): Length (%d) is not in range of min: 2 and max 8 bytes", @@ -622,6 +625,7 @@ SRSASN_CODE nssai_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.37 SRSASN_CODE nssai_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 2 || length > 144) { asn1::log_error("Decoding Failed (NSSAI): Length (%d) is not in range of min: 2 and max 144 bytes", length); @@ -749,6 +753,7 @@ SRSASN_CODE s1_ue_network_capability_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.48 SRSASN_CODE s1_ue_network_capability_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 2 || length > 13) { asn1::log_error( @@ -893,6 +898,7 @@ SRSASN_CODE uplink_data_status_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.57 SRSASN_CODE uplink_data_status_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 2 || length > 32) { asn1::log_error("Decoding Failed (Uplink data status): Length (%d) is not in range of min: 2 and max 32 bytes", @@ -963,6 +969,7 @@ SRSASN_CODE pdu_session_status_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.44 SRSASN_CODE pdu_session_status_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 2 || length > 32) { asn1::log_error("Decoding Failed (PDU session status): Length (%d) is not in range of min: 2 and max 32 bytes", @@ -1042,6 +1049,7 @@ SRSASN_CODE ue_status_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.56 SRSASN_CODE ue_status_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 1) { asn1::log_error("Decoding Failed (UE status): Length (%d) does not equal expected length 1", length); @@ -1096,6 +1104,7 @@ SRSASN_CODE allowed_pdu_session_status_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.13 SRSASN_CODE allowed_pdu_session_status_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 2 || length > 32) { asn1::log_error( @@ -1152,6 +1161,7 @@ SRSASN_CODE ue_usage_setting_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.55 SRSASN_CODE ue_usage_setting_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 1) { asn1::log_error("Decoding Failed (UE usage setting): Length (%d) does not equal expected length 1", length); @@ -1191,6 +1201,7 @@ SRSASN_CODE drx_parameters_5gs_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.2A SRSASN_CODE drx_parameters_5gs_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 1) { asn1::log_error("Decoding Failed (5GS DRX parameters): Length (%d) does not equal expected length 1", length); @@ -1222,6 +1233,7 @@ SRSASN_CODE eps_nas_message_container_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.24 SRSASN_CODE eps_nas_message_container_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); eps_nas_message_container.resize(length); HANDLE_CODE(bref.unpack_bytes(eps_nas_message_container.data(), length)); @@ -1243,7 +1255,7 @@ SRSASN_CODE ladn_indication_t::pack(asn1::bit_ref& bref) bref.align_bytes_zero(); uint16_t length = (uint16_t)(ceilf((float)bref.distance(bref_length) / 8) - 2); - // MIN 0 not check because auf uint underflow + // min. length of 0 not checked: uint underflow if (length > 808) { asn1::log_error("Encoding Failed (LADN indication): Packed length (%d) is not in range of max 808 bytes", length); return asn1::SRSASN_ERROR_ENCODE_FAIL; @@ -1256,8 +1268,9 @@ SRSASN_CODE ladn_indication_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.29 SRSASN_CODE ladn_indication_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); - // MIN 0 not check because auf uint underflow + // min. length of 0 not checked: uint underflow if (length > 808) { asn1::log_error("Decoding Failed (LADN indication): Length (%d) is not in range of max 808 bytes", length); return asn1::SRSASN_ERROR_DECODE_FAIL; @@ -1299,7 +1312,7 @@ SRSASN_CODE payload_container_t::pack(asn1::bit_ref& bref) bref.align_bytes_zero(); uint16_t length = (uint16_t)(ceilf((float)bref.distance(bref_length) / 8) - 2); - // MAX 65535 not check because auf uint overflow + // max. length of 65535 not checked: uint overflow if (length < 1) { asn1::log_error("Encoding Failed (Payload container): Packed length (%d) is not in range of min: 1 bytes", length); return asn1::SRSASN_ERROR_ENCODE_FAIL; @@ -1312,8 +1325,9 @@ SRSASN_CODE payload_container_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.39 SRSASN_CODE payload_container_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); - // MAX 65535 not check because auf uint overflow + // max. length of 65535 not checked: uint overflow if (length < 1) { asn1::log_error("Decoding Failed (Payload container): Length (%d) is not in range of min: 1 bytes", length); return asn1::SRSASN_ERROR_DECODE_FAIL; @@ -1371,6 +1385,7 @@ SRSASN_CODE update_type_5gs_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.9A SRSASN_CODE update_type_5gs_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); // 2 Spare bits bref.advance_bits(2); HANDLE_CODE(pnb_eps_c_io_t.unpack(bref)); @@ -1406,6 +1421,7 @@ SRSASN_CODE mobile_station_classmark_2_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.31C SRSASN_CODE mobile_station_classmark_2_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 3) { asn1::log_error("Decoding Failed (Mobile station classmark 2): Length (%d) does not equal expected length 3", @@ -1444,6 +1460,7 @@ SRSASN_CODE supported_codec_list_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.51A SRSASN_CODE supported_codec_list_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 3) { asn1::log_error("Decoding Failed (Supported codec list): Length (%d) is not in range of min: 3 bytes", length); @@ -1481,6 +1498,7 @@ SRSASN_CODE message_container_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.33 SRSASN_CODE message_container_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); if (length < 1 || length > 65532) { asn1::log_error("Decoding Failed (message container): Length (%d) is not in range of min: 1 and max 65532 bytes", @@ -1533,6 +1551,7 @@ SRSASN_CODE eps_bearer_context_status_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.23A SRSASN_CODE eps_bearer_context_status_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 2) { asn1::log_error("Decoding Failed (EPS bearer context status): Length (%d) does not equal expected length 2", @@ -1585,6 +1604,7 @@ SRSASN_CODE extended_drx_parameters_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.26A SRSASN_CODE extended_drx_parameters_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 1) { asn1::log_error("Decoding Failed (Extended DRX parameters): Length (%d) does not equal expected length 1", length); @@ -1621,6 +1641,7 @@ SRSASN_CODE gprs_timer_3_t::pack(asn1::bit_ref& bref) // Reference: 9.11.2.5 SRSASN_CODE gprs_timer_3_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 1) { asn1::log_error("Decoding Failed (GPRS timer 3): Length (%d) does not equal expected length 1", length); @@ -1651,6 +1672,7 @@ SRSASN_CODE ue_radio_capability_id_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.68 SRSASN_CODE ue_radio_capability_id_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); ue_radio_capability_id.resize(length); HANDLE_CODE(bref.unpack_bytes(ue_radio_capability_id.data(), length)); @@ -1683,6 +1705,7 @@ SRSASN_CODE mapped_nssai_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.31B SRSASN_CODE mapped_nssai_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 2 || length > 40) { asn1::log_error("Decoding Failed (Mapped NSSAI): Length (%d) is not in range of min: 2 and max 40 bytes", length); @@ -1717,6 +1740,7 @@ SRSASN_CODE additional_information_requested_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.12A SRSASN_CODE additional_information_requested_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); // 7 Spare bits bref.advance_bits(7); HANDLE_CODE(bref.unpack(cipher_key, 1)); @@ -1749,6 +1773,7 @@ SRSASN_CODE wus_assistance_information_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.71 SRSASN_CODE wus_assistance_information_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 1) { asn1::log_error("Decoding Failed (WUS assistance information): Length (%d) is not in range of min: 1 bytes", @@ -1809,6 +1834,7 @@ SRSASN_CODE nb_n1_mode_drx_parameters_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.73 SRSASN_CODE nb_n1_mode_drx_parameters_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 1) { asn1::log_error("Decoding Failed (NB-N1 mode DRX parameters): Length (%d) does not equal expected length 1", @@ -1852,6 +1878,7 @@ SRSASN_CODE registration_result_5gs_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.6 SRSASN_CODE registration_result_5gs_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 1) { asn1::log_error("Decoding Failed (5GS registration result): Length (%d) does not equal expected length 1", length); @@ -1887,6 +1914,7 @@ SRSASN_CODE plmn_list_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.45 SRSASN_CODE plmn_list_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); // TODO proper unpacking bref.advance_bits(length * 8); @@ -1920,6 +1948,7 @@ SRSASN_CODE tracking_area_identity_list_5gs_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.9 SRSASN_CODE tracking_area_identity_list_5gs_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 7) { asn1::log_error("Decoding Failed (5GS tracking area identity list): Length (%d) does not equal expected length 7", @@ -1953,6 +1982,7 @@ SRSASN_CODE rejected_nssai_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.46 SRSASN_CODE rejected_nssai_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); // TODO proper unpacking bref.advance_bits(length * 8); @@ -1986,6 +2016,7 @@ SRSASN_CODE network_feature_support_5gs_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.5 SRSASN_CODE network_feature_support_5gs_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 1 || length > 3) { asn1::log_error( @@ -2040,6 +2071,7 @@ SRSASN_CODE pdu_session_reactivation_result_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.42 SRSASN_CODE pdu_session_reactivation_result_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 2 || length > 32) { asn1::log_error( @@ -2099,6 +2131,7 @@ SRSASN_CODE pdu_session_reactivation_result_error_cause_t::pack(asn1::bit_ref& b // Reference: 9.11.3.43 SRSASN_CODE pdu_session_reactivation_result_error_cause_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); if (length < 2 || length > 512) { asn1::log_error("Decoding Failed (PDU session reactivation result error cause): Length (%d) is not in range of " @@ -2125,7 +2158,7 @@ SRSASN_CODE ladn_information_t::pack(asn1::bit_ref& bref) bref.align_bytes_zero(); uint16_t length = (uint16_t)(ceilf((float)bref.distance(bref_length) / 8) - 2); - // MIN 0 not check because auf uint underflow + // min. length of 0 not checked: uint underflow if (length > 1712) { asn1::log_error("Encoding Failed (LADN information): Packed length (%d) is not in range of max 1712 bytes", length); return asn1::SRSASN_ERROR_ENCODE_FAIL; @@ -2138,8 +2171,9 @@ SRSASN_CODE ladn_information_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.30 SRSASN_CODE ladn_information_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); - // MIN 0 not check because auf uint underflow + // min. length of 0 not checked: uint underflow if (length > 1712) { asn1::log_error("Decoding Failed (LADN information): Length (%d) is not in range of max 1712 bytes", length); return asn1::SRSASN_ERROR_DECODE_FAIL; @@ -2171,6 +2205,7 @@ SRSASN_CODE service_area_list_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.49 SRSASN_CODE service_area_list_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); // TODO proper unpacking bref.advance_bits(length * 8); @@ -2202,6 +2237,7 @@ SRSASN_CODE gprs_timer_2_t::pack(asn1::bit_ref& bref) // Reference: 9.11.2.4 SRSASN_CODE gprs_timer_2_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 1) { asn1::log_error("Decoding Failed (GPRS timer 2): Length (%d) does not equal expected length 1", length); @@ -2238,6 +2274,7 @@ SRSASN_CODE emergency_number_list_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.23 SRSASN_CODE emergency_number_list_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 3 || length > 48) { asn1::log_error("Decoding Failed (Emergency number list): Length (%d) is not in range of min: 3 and max 48 bytes", @@ -2263,7 +2300,7 @@ SRSASN_CODE extended_emergency_number_list_t::pack(asn1::bit_ref& bref) bref.align_bytes_zero(); uint16_t length = (uint16_t)(ceilf((float)bref.distance(bref_length) / 8) - 2); - // MAX 65535 not check because auf uint overflow + // max. length of 65535 not checked: uint overflow if (length < 4) { asn1::log_error( "Encoding Failed (Extended emergency number list): Packed length (%d) is not in range of min: 4 bytes", length); @@ -2277,8 +2314,9 @@ SRSASN_CODE extended_emergency_number_list_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.26 SRSASN_CODE extended_emergency_number_list_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); - // MAX 65535 not check because auf uint overflow + // max. length of 65535 not checked: uint overflow if (length < 4) { asn1::log_error("Decoding Failed (Extended emergency number list): Length (%d) is not in range of min: 4 bytes", length); @@ -2316,6 +2354,7 @@ SRSASN_CODE sor_transparent_container_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.51 SRSASN_CODE sor_transparent_container_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); if (length < 17) { asn1::log_error("Decoding Failed (SOR transparent container): Length (%d) is not in range of min: 17 bytes", @@ -2353,6 +2392,7 @@ SRSASN_CODE eap_message_t::pack(asn1::bit_ref& bref) // Reference: 9.11.2.2 SRSASN_CODE eap_message_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); if (length < 4 || length > 1500) { asn1::log_error("Decoding Failed (EAP message): Length (%d) is not in range of min: 4 and max 1500 bytes", length); @@ -2404,6 +2444,7 @@ SRSASN_CODE operator_defined_access_category_definitions_t::pack(asn1::bit_ref& // Reference: 9.11.3.38 SRSASN_CODE operator_defined_access_category_definitions_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); // TODO proper unpacking bref.advance_bits(length * 8); @@ -2477,6 +2518,7 @@ SRSASN_CODE ciphering_key_data_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.18C SRSASN_CODE ciphering_key_data_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); if (length < 31 || length > 2672) { asn1::log_error("Decoding Failed (Ciphering key data): Length (%d) is not in range of min: 31 and max 2672 bytes", @@ -2510,6 +2552,7 @@ SRSASN_CODE cag_information_list_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.18A SRSASN_CODE cag_information_list_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); // TODO proper unpacking bref.advance_bits(length * 8); @@ -2544,6 +2587,7 @@ SRSASN_CODE truncated_5g_s_tmsi_configuration_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.70 SRSASN_CODE truncated_5g_s_tmsi_configuration_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 1) { asn1::log_error("Decoding Failed (Truncated 5G-S-TMSI configuration): Length (%d) does not equal expected length 1", @@ -2666,6 +2710,7 @@ SRSASN_CODE network_name_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.35 SRSASN_CODE network_name_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); // TODO proper unpacking bref.advance_bits(length * 8); @@ -2740,6 +2785,7 @@ SRSASN_CODE daylight_saving_time_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.19 SRSASN_CODE daylight_saving_time_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 1) { asn1::log_error("Decoding Failed (Daylight saving time): Length (%d) does not equal expected length 1", length); @@ -2813,6 +2859,7 @@ SRSASN_CODE abba_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.10 SRSASN_CODE abba_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 2) { asn1::log_error("Decoding Failed (ABBA): Length (%d) is not in range of min: 2 bytes", length); @@ -2865,6 +2912,7 @@ SRSASN_CODE authentication_parameter_autn_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.15 SRSASN_CODE authentication_parameter_autn_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 16) { asn1::log_error("Decoding Failed (Authentication parameter AUTN): Length (%d) does not equal expected length 16", @@ -2902,6 +2950,7 @@ SRSASN_CODE authentication_response_parameter_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.17 SRSASN_CODE authentication_response_parameter_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 16) { asn1::log_error( @@ -2939,6 +2988,7 @@ SRSASN_CODE authentication_failure_parameter_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.14 SRSASN_CODE authentication_failure_parameter_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 14) { asn1::log_error("Decoding Failed (Authentication failure parameter): Length (%d) does not equal expected length 14", @@ -3065,6 +3115,7 @@ SRSASN_CODE additional_5g_security_information_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.12 SRSASN_CODE additional_5g_security_information_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 1) { asn1::log_error( @@ -3148,6 +3199,7 @@ SRSASN_CODE s1_ue_security_capability_t::pack(asn1::bit_ref& bref) // Reference: 9.11.3.48A SRSASN_CODE s1_ue_security_capability_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 2 || length > 5) { asn1::log_error( @@ -3277,15 +3329,15 @@ SRSASN_CODE s_nssai_t::pack(asn1::bit_ref& bref) asn1::bit_ref bref_length = bref; HANDLE_CODE(bref.advance_bits(8)); - if (length == s_nssai_t::SST_type_::options::sst) { + if (type == s_nssai_t::SST_type_::options::sst) { HANDLE_CODE(bref.pack(sst, 8)); - } else if (length == s_nssai_t::SST_type_::options::sst_and_mapped_hplmn_sst) { + } else if (type == s_nssai_t::SST_type_::options::sst_and_mapped_hplmn_sst) { HANDLE_CODE(bref.pack(sst, 8)); HANDLE_CODE(bref.pack(mapped_hplmn_sst, 8)); - } else if (length == s_nssai_t::SST_type_::options::sst_and_sd) { + } else if (type == s_nssai_t::SST_type_::options::sst_and_sd) { HANDLE_CODE(bref.pack(sst, 8)); HANDLE_CODE(bref.pack(sd, 24)); - } else if (length == s_nssai_t::SST_type_::options::sst_sd_mapped_hplmn_sst_and_mapped_hplmn_sd) { + } else if (type == s_nssai_t::SST_type_::options::sst_sd_mapped_hplmn_sst_and_mapped_hplmn_sd) { HANDLE_CODE(bref.pack(sst, 8)); HANDLE_CODE(bref.pack(sd, 24)); HANDLE_CODE(bref.pack(mapped_hplmn_sst, 8)); @@ -3310,26 +3362,31 @@ SRSASN_CODE s_nssai_t::pack(asn1::bit_ref& bref) // Reference: 9.11.2.8 SRSASN_CODE s_nssai_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 1 || length > 8) { asn1::log_error("Decoding Failed (S-NSSAI): Length (%d) is not in range of min: 1 and max 8 bytes", length); return asn1::SRSASN_ERROR_DECODE_FAIL; } if (length == s_nssai_t::SST_type_::options::sst) { + type = s_nssai_t::SST_type_::options::sst; HANDLE_CODE(bref.unpack(sst, 8)); } else if (length == s_nssai_t::SST_type_::options::sst_and_mapped_hplmn_sst) { + type = s_nssai_t::SST_type_::options::sst_and_mapped_hplmn_sst; HANDLE_CODE(bref.unpack(sst, 8)); HANDLE_CODE(bref.unpack(mapped_hplmn_sst, 8)); } else if (length == s_nssai_t::SST_type_::options::sst_and_sd) { + type = s_nssai_t::SST_type_::options::sst_and_sd; HANDLE_CODE(bref.unpack(sst, 8)); HANDLE_CODE(bref.unpack(sd, 24)); } else if (length == s_nssai_t::SST_type_::options::sst_sd_mapped_hplmn_sst_and_mapped_hplmn_sd) { + type = s_nssai_t::SST_type_::options::sst_sd_mapped_hplmn_sst_and_mapped_hplmn_sd; HANDLE_CODE(bref.unpack(sst, 8)); HANDLE_CODE(bref.unpack(sd, 24)); HANDLE_CODE(bref.unpack(mapped_hplmn_sst, 8)); HANDLE_CODE(bref.unpack(mapped_hplmn_sd, 24)); } else { - asn1::log_error("Not such a length type for s_nssai"); + asn1::log_error("Not such a type for s_nssai"); return SRSASN_ERROR_DECODE_FAIL; } return SRSASN_SUCCESS; @@ -3359,6 +3416,7 @@ SRSASN_CODE dnn_t::pack(asn1::bit_ref& bref) // Reference: 9.11.2.1B SRSASN_CODE dnn_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 1 || length > 100) { asn1::log_error("Decoding Failed (DNN): Length (%d) is not in range of min: 1 and max 100 bytes", length); @@ -3394,6 +3452,7 @@ SRSASN_CODE additional_information_t::pack(asn1::bit_ref& bref) // Reference: 9.11.2.1 SRSASN_CODE additional_information_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 1) { asn1::log_error("Decoding Failed (Additional information): Length (%d) is not in range of min: 1 bytes", length); @@ -3524,6 +3583,7 @@ SRSASN_CODE capability_5gsm_t::pack(asn1::bit_ref& bref) // Reference: 9.11.4.1 SRSASN_CODE capability_5gsm_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 1 || length > 13) { asn1::log_error("Decoding Failed (5GSM capability): Length (%d) is not in range of min: 1 and max 13 bytes", @@ -3603,6 +3663,7 @@ SRSASN_CODE sm_pdu_dn_request_container_t::pack(asn1::bit_ref& bref) // Reference: 9.11.4.15 SRSASN_CODE sm_pdu_dn_request_container_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 1 || length > 253) { asn1::log_error( @@ -3628,7 +3689,7 @@ SRSASN_CODE extended_protocol_configuration_options_t::pack(asn1::bit_ref& bref) bref.align_bytes_zero(); uint16_t length = (uint16_t)(ceilf((float)bref.distance(bref_length) / 8) - 2); - // MAX 65535 not check because auf uint overflow + // max. length of 65535 not checked: uint overflow if (length < 1) { asn1::log_error( "Encoding Failed (Extended protocol configuration options): Packed length (%d) is not in range of min: 1 bytes", @@ -3643,8 +3704,9 @@ SRSASN_CODE extended_protocol_configuration_options_t::pack(asn1::bit_ref& bref) // Reference: 9.11.4.6 SRSASN_CODE extended_protocol_configuration_options_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); - // MAX 65535 not check because auf uint overflow + // max. length of 65535 not checked: uint overflow if (length < 1) { asn1::log_error( "Decoding Failed (Extended protocol configuration options): Length (%d) is not in range of min: 1 bytes", @@ -3670,7 +3732,7 @@ SRSASN_CODE ip_header_compression_configuration_t::pack(asn1::bit_ref& bref) bref.align_bytes_zero(); uint8_t length = (uint8_t)(ceilf((float)bref.distance(bref_length) / 8) - 1); - // MAX 255 not check because auf uint overflow + // max. length of 255 not checked: uint overflow if (length < 3) { asn1::log_error( "Encoding Failed (IP header compression configuration): Packed length (%d) is not in range of min: 3 bytes", @@ -3685,8 +3747,9 @@ SRSASN_CODE ip_header_compression_configuration_t::pack(asn1::bit_ref& bref) // Reference: 9.11.4.24 SRSASN_CODE ip_header_compression_configuration_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); - // MAX 255 not check because auf uint overflow + // max. length of 255 not checked: uint overflow if (length < 3) { asn1::log_error( "Decoding Failed (IP header compression configuration): Length (%d) is not in range of min: 3 bytes", length); @@ -3725,6 +3788,7 @@ SRSASN_CODE ds_tt__ethernet_port_mac_address_t::pack(asn1::bit_ref& bref) // Reference: 9.11.4.25 SRSASN_CODE ds_tt__ethernet_port_mac_address_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 6) { asn1::log_error("Decoding Failed (DS-TT Ethernet port MAC address): Length (%d) does not equal expected length 6", @@ -3761,6 +3825,7 @@ SRSASN_CODE ue_ds_tt_residence_time_t::pack(asn1::bit_ref& bref) // Reference: 9.11.4.26 SRSASN_CODE ue_ds_tt_residence_time_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 8) { asn1::log_error("Decoding Failed (UE-DS-TT residence time): Length (%d) does not equal expected length 8", length); @@ -3783,7 +3848,7 @@ SRSASN_CODE port_management_information_container_t::pack(asn1::bit_ref& bref) bref.align_bytes_zero(); uint16_t length = (uint16_t)(ceilf((float)bref.distance(bref_length) / 8) - 2); - // MAX 65535 not check because auf uint overflow + // max. length of 65535 not checked: uint overflow if (length < 1) { asn1::log_error( "Encoding Failed (Port management information container): Packed length (%d) is not in range of min: 1 bytes", @@ -3798,8 +3863,9 @@ SRSASN_CODE port_management_information_container_t::pack(asn1::bit_ref& bref) // Reference: 9.11.4.27 SRSASN_CODE port_management_information_container_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); - // MAX 65535 not check because auf uint overflow + // max. length of 65535 not checked: uint overflow if (length < 1) { asn1::log_error( "Decoding Failed (Port management information container): Length (%d) is not in range of min: 1 bytes", length); @@ -3839,6 +3905,7 @@ SRSASN_CODE ethernet_header_compression_configuration_t::pack(asn1::bit_ref& bre // Reference: 9.11.4.28 SRSASN_CODE ethernet_header_compression_configuration_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 1) { asn1::log_error( @@ -3894,6 +3961,7 @@ SRSASN_CODE pdu_address_t::pack(asn1::bit_ref& bref) // Reference: 9.11.4.10 SRSASN_CODE pdu_address_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 5 || length > 29) { asn1::log_error("Decoding Failed (PDU address): Length (%d) is not in range of min: 5 and max 29 bytes", length); @@ -3940,7 +4008,7 @@ SRSASN_CODE qo_s_rules_t::pack(asn1::bit_ref& bref) bref.align_bytes_zero(); uint16_t length = (uint16_t)(ceilf((float)bref.distance(bref_length) / 8) - 2); - // MAX 65535 not check because auf uint overflow + // max. length of 65535 not checked: uint overflow if (length < 4) { asn1::log_error("Encoding Failed (QoS rules): Packed length (%d) is not in range of min: 4 bytes", length); return asn1::SRSASN_ERROR_ENCODE_FAIL; @@ -3953,8 +4021,9 @@ SRSASN_CODE qo_s_rules_t::pack(asn1::bit_ref& bref) // Reference: 9.11.4.13 SRSASN_CODE qo_s_rules_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); - // MAX 65535 not check because auf uint overflow + // max. length of 65535 not checked: uint overflow if (length < 4) { asn1::log_error("Decoding Failed (QoS rules): Length (%d) is not in range of min: 4 bytes", length); return asn1::SRSASN_ERROR_DECODE_FAIL; @@ -3991,6 +4060,7 @@ SRSASN_CODE session_ambr_t::pack(asn1::bit_ref& bref) // Reference: 9.11.4.14 SRSASN_CODE session_ambr_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 6) { asn1::log_error("Decoding Failed (Session-AMBR): Length (%d) does not equal expected length 6", length); @@ -4070,7 +4140,7 @@ SRSASN_CODE mapped_eps_bearer_contexts_t::pack(asn1::bit_ref& bref) bref.align_bytes_zero(); uint16_t length = (uint16_t)(ceilf((float)bref.distance(bref_length) / 8) - 2); - // MAX 65535 not check because auf uint overflow + // max. length of 65535 not checked: uint overflow if (length < 4) { asn1::log_error("Encoding Failed (Mapped EPS bearer contexts): Packed length (%d) is not in range of min: 4 bytes", length); @@ -4084,8 +4154,9 @@ SRSASN_CODE mapped_eps_bearer_contexts_t::pack(asn1::bit_ref& bref) // Reference: 9.11.4.8 SRSASN_CODE mapped_eps_bearer_contexts_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); - // MAX 65535 not check because auf uint overflow + // max. length of 65535 not checked: uint overflow if (length < 4) { asn1::log_error("Decoding Failed (Mapped EPS bearer contexts): Length (%d) is not in range of min: 4 bytes", length); @@ -4110,7 +4181,7 @@ SRSASN_CODE qo_s_flow_descriptions_t::pack(asn1::bit_ref& bref) bref.align_bytes_zero(); uint16_t length = (uint16_t)(ceilf((float)bref.distance(bref_length) / 8) - 2); - // MAX 65535 not check because auf uint overflow + // max. length of 65535 not checked: uint overflow if (length < 3) { asn1::log_error("Encoding Failed (QoS flow descriptions): Packed length (%d) is not in range of min: 3 bytes", length); @@ -4124,8 +4195,9 @@ SRSASN_CODE qo_s_flow_descriptions_t::pack(asn1::bit_ref& bref) // Reference: 9.11.4.12 SRSASN_CODE qo_s_flow_descriptions_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); - // MAX 65535 not check because auf uint overflow + // max. length of 65535 not checked: uint overflow if (length < 3) { asn1::log_error("Decoding Failed (QoS flow descriptions): Length (%d) is not in range of min: 3 bytes", length); return asn1::SRSASN_ERROR_DECODE_FAIL; @@ -4165,6 +4237,7 @@ SRSASN_CODE network_feature_support_5gsm_t::pack(asn1::bit_ref& bref) // Reference: 9.11.4.18 SRSASN_CODE network_feature_support_5gsm_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length < 1 || length > 13) { asn1::log_error( @@ -4207,6 +4280,7 @@ SRSASN_CODE serving_plmn_rate_control_t::pack(asn1::bit_ref& bref) // Reference: 9.11.4.20 SRSASN_CODE serving_plmn_rate_control_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 2) { asn1::log_error("Decoding Failed (Serving PLMN rate control): Length (%d) does not equal expected length 2", @@ -4229,8 +4303,8 @@ SRSASN_CODE atsss_container_t::pack(asn1::bit_ref& bref) bref.align_bytes_zero(); uint16_t length = (uint16_t)(ceilf((float)bref.distance(bref_length) / 8) - 2); - // MIN 0 not check because auf uint underflow - // MAX 65535 not check because auf uint overflow + // min. length of 0 not checked: uint underflow + // max. length of 65535 not checked: uint overflow HANDLE_CODE(bref_length.pack(length, 16)); return SRSASN_SUCCESS; } @@ -4239,12 +4313,9 @@ SRSASN_CODE atsss_container_t::pack(asn1::bit_ref& bref) // Reference: 9.11.4.22 SRSASN_CODE atsss_container_t::unpack(asn1::cbit_ref& bref) { + uint16_t length = 0; HANDLE_CODE(bref.unpack(length, 16)); - // MIN 0 not check because auf uint underflow - if (length > 65535) { - asn1::log_error("Decoding Failed (ATSSS container): Length (%d) is not in range of max 65535 bytes", length); - return asn1::SRSASN_ERROR_DECODE_FAIL; - } + // min. length of 0 not checked: uint underflow nas_message_container.resize(length); HANDLE_CODE(bref.unpack_bytes(nas_message_container.data(), length)); return SRSASN_SUCCESS; @@ -4343,6 +4414,7 @@ SRSASN_CODE re_attempt_indicator_t::pack(asn1::bit_ref& bref) // Reference: 9.11.4.17 SRSASN_CODE re_attempt_indicator_t::unpack(asn1::cbit_ref& bref) { + uint8_t length = 0; HANDLE_CODE(bref.unpack(length, 8)); if (length != 1) { asn1::log_error("Decoding Failed (Re-attempt indicator): Length (%d) does not equal expected length 1", length); diff --git a/lib/src/asn1/nas_5g_msg.cc b/lib/src/asn1/nas_5g_msg.cc index 91af1bca4..d6ef9f599 100644 --- a/lib/src/asn1/nas_5g_msg.cc +++ b/lib/src/asn1/nas_5g_msg.cc @@ -3621,7 +3621,7 @@ SRSASN_CODE nas_5gs_msg::pack(unique_byte_buffer_t& buf) return SRSASN_SUCCESS; } -SRSASN_CODE nas_5gs_msg::pack(std::vector buf) +SRSASN_CODE nas_5gs_msg::pack(std::vector& buf) { buf.resize(SRSRAN_MAX_BUFFER_SIZE_BYTES); asn1::bit_ref msg_bref(buf.data(), buf.size()); @@ -3883,7 +3883,7 @@ SRSASN_CODE nas_5gs_msg::unpack_outer_hdr(const unique_byte_buffer_t& buf) return SRSASN_SUCCESS; } -SRSASN_CODE nas_5gs_msg::unpack_outer_hdr(const std::vector buf) +SRSASN_CODE nas_5gs_msg::unpack_outer_hdr(const std::vector& buf) { asn1::cbit_ref msg_bref(buf.data(), buf.size()); HANDLE_CODE(hdr.unpack_outer(msg_bref)); @@ -3897,7 +3897,7 @@ SRSASN_CODE nas_5gs_msg::unpack(const unique_byte_buffer_t& buf) return SRSASN_SUCCESS; } -SRSASN_CODE nas_5gs_msg::unpack(const std::vector buf) +SRSASN_CODE nas_5gs_msg::unpack(const std::vector& buf) { asn1::cbit_ref msg_bref(buf.data(), buf.size()); HANDLE_CODE(unpack(msg_bref)); diff --git a/lib/test/asn1/nas_5g_msg_test.cc b/lib/test/asn1/nas_5g_msg_test.cc index 7926964a4..6457a56b3 100644 --- a/lib/test/asn1/nas_5g_msg_test.cc +++ b/lib/test/asn1/nas_5g_msg_test.cc @@ -177,7 +177,6 @@ int registration_request_unpacking_packing_test(srsran::nas_pcap* pcap) key_set_identifier_t::security_context_flag_type_::options::native_security_context); TESTASSERT(reg_request_msg.ng_ksi.nas_key_set_identifier == key_set_identifier_t::nas_key_set_identifier_type_::options::no_key_is_available_or_reserved); - TESTASSERT(reg_request_msg.mobile_identity_5gs.length == 11); TESTASSERT(reg_request_msg.mobile_identity_5gs.type() == mobile_identity_5gs_t::identity_types_::options::guti_5g); mobile_identity_5gs_t::guti_5g_s guti_5g_ = reg_request_msg.mobile_identity_5gs.guti_5g(); TESTASSERT(guti_5g_.amf_pointer == 0x0); @@ -211,7 +210,6 @@ int registration_request_unpacking_packing_test(srsran::nas_pcap* pcap) TESTASSERT(reg_request_msg.ue_security_capability.eps_caps_present == false); TESTASSERT(reg_request_msg.s1_ue_network_capability_present == true); - TESTASSERT(reg_request_msg.s1_ue_network_capability.length == 7); TESTASSERT(reg_request_msg.s1_ue_network_capability.eea0_supported == true); TESTASSERT(reg_request_msg.s1_ue_network_capability.eea1_128_supported == true); @@ -376,7 +374,6 @@ int registration_request_unpacking_packing_test_2(srsran::nas_pcap* pcap) key_set_identifier_t::security_context_flag_type_::options::native_security_context); TESTASSERT(reg_request_msg.ng_ksi.nas_key_set_identifier == key_set_identifier_t::nas_key_set_identifier_type_::options::no_key_is_available_or_reserved); - TESTASSERT(reg_request_msg.mobile_identity_5gs.length == 54); TESTASSERT(reg_request_msg.mobile_identity_5gs.type() == mobile_identity_5gs_t::identity_types_::options::suci); TESTASSERT(reg_request_msg.mobile_identity_5gs.suci().supi_format.value == mobile_identity_5gs_t::suci_s::supi_format_type_::options::imsi); @@ -475,7 +472,6 @@ int deregistration_request_unpacking_packing_test(srsran::nas_pcap* pcap) TESTASSERT(dereg_request_msg.ng_ksi.security_context_flag == key_set_identifier_t::security_context_flag_type_::options::native_security_context); TESTASSERT(dereg_request_msg.ng_ksi.nas_key_set_identifier == 0); - TESTASSERT(dereg_request_msg.mobile_identity_5gs.length == 11); TESTASSERT(dereg_request_msg.mobile_identity_5gs.type() == mobile_identity_5gs_t::identity_types_::options::guti_5g); mobile_identity_5gs_t::guti_5g_s guti_5g_ = dereg_request_msg.mobile_identity_5gs.guti_5g(); TESTASSERT(guti_5g_.amf_pointer == 0x0); @@ -551,14 +547,14 @@ int authentication_request_unpacking_packing_test(srsran::nas_pcap* pcap) TESTASSERT(auth_request_msg.ng_ksi.security_context_flag == key_set_identifier_t::security_context_flag_type_::options::native_security_context); TESTASSERT(auth_request_msg.ng_ksi.nas_key_set_identifier == 0); - TESTASSERT(auth_request_msg.abba.length == 2); + TESTASSERT(auth_request_msg.abba.abba_contents.size() == 2); TESTASSERT(auth_request_msg.abba.abba_contents[0] == 0x00); TESTASSERT(auth_request_msg.abba.abba_contents[1] == 0x00); TESTASSERT(auth_request_msg.authentication_parameter_rand_present == true); TESTASSERT(auth_request_msg.authentication_parameter_rand.rand[0] == 0x16); TESTASSERT(auth_request_msg.authentication_parameter_rand.rand[15] == 0x71); TESTASSERT(auth_request_msg.authentication_parameter_autn_present == true); - TESTASSERT(auth_request_msg.authentication_parameter_autn.length == 16); + TESTASSERT(auth_request_msg.authentication_parameter_autn.autn.size() == 16); TESTASSERT(auth_request_msg.authentication_parameter_autn.autn[0] == 0xa3); TESTASSERT(auth_request_msg.authentication_parameter_autn.autn[15] == 0xed); @@ -609,7 +605,6 @@ int authentication_resp_request_unpacking_packing_test(srsran::nas_pcap* pcap) authentication_response_t& auth_resp = nas_msg.authentication_response(); TESTASSERT(auth_resp.authentication_response_parameter_present == true); - TESTASSERT(auth_resp.authentication_response_parameter.length == 16); TESTASSERT(auth_resp.authentication_response_parameter.res.size() == 16); TESTASSERT(auth_resp.authentication_response_parameter.res[0] == 0xa1); TESTASSERT(auth_resp.authentication_response_parameter.res[15] == 0x08); @@ -763,7 +758,6 @@ int security_command_unpacking_packing_test(srsran::nas_pcap* pcap) TESTASSERT(sec_command_msg.imeisv_request.imeisv_request == true); TESTASSERT(sec_command_msg.additional_5g_security_information_present == true); - TESTASSERT(sec_command_msg.additional_5g_security_information.length == 1); TESTASSERT(sec_command_msg.additional_5g_security_information.rinmr == false); TESTASSERT(sec_command_msg.additional_5g_security_information.hdp == false); @@ -1011,7 +1005,6 @@ int security_complete_unpacking_packing_test(srsran::nas_pcap* pcap) TESTASSERT(imeisv.imeisv[15] == 5); TESTASSERT(sec_complete_msg.nas_message_container_present == true); - TESTASSERT(sec_complete_msg.nas_message_container.length == 87); TESTASSERT(sec_complete_msg.nas_message_container.nas_message_container.size() == 87); nas_5gs_msg inner_message; TESTASSERT(inner_message.unpack(sec_complete_msg.nas_message_container.nas_message_container) == SRSRAN_SUCCESS); @@ -1246,7 +1239,6 @@ int deregistration_request_unpacking_packing_test_2(srsran::nas_pcap* pcap) key_set_identifier_t::security_context_flag_type_::options::native_security_context); TESTASSERT(dereg_req_ue_o.ng_ksi.nas_key_set_identifier == 0); TESTASSERT(dereg_req_ue_o.mobile_identity_5gs.type() == mobile_identity_5gs_t::identity_types_::options::guti_5g); - TESTASSERT(dereg_req_ue_o.mobile_identity_5gs.length == 11); mobile_identity_5gs_t::guti_5g_s guti_5g = dereg_req_ue_o.mobile_identity_5gs.guti_5g(); TESTASSERT(guti_5g.mcc[0] == 0); @@ -1345,7 +1337,6 @@ int pdu_session_establishment_request_unpacking_packing_test(srsran::nas_pcap* p ul_nas_transport_t& ul_nas = nas_msg.ul_nas_transport(); TESTASSERT(ul_nas.payload_container_type.payload_container_type == payload_container_type_t::Payload_container_type_type_::options::n1_sm_information); - TESTASSERT(ul_nas.payload_container.length == 6); TESTASSERT(ul_nas.payload_container.payload_container_contents.size() == 6); TESTASSERT(ul_nas.payload_container.payload_container_contents[0] == 0x2e); TESTASSERT(ul_nas.payload_container.payload_container_contents[5] == 0xff); @@ -1382,11 +1373,9 @@ int pdu_session_establishment_request_unpacking_packing_test(srsran::nas_pcap* p TESTASSERT(ul_nas.request_type.request_type_value == request_type_t::Request_type_value_type_::options::initial_request); TESTASSERT(ul_nas.s_nssai_present == true); - TESTASSERT(ul_nas.s_nssai.length == 4); TESTASSERT(ul_nas.s_nssai.sst == 1); TESTASSERT(ul_nas.s_nssai.sd == 66051); TESTASSERT(ul_nas.dnn_present == true); - TESTASSERT(ul_nas.dnn.length == 9); TESTASSERT(ul_nas.dnn.dnn_value.size() == 9); TESTASSERT(ul_nas.dnn.dnn_value[0] == 0x08); TESTASSERT(ul_nas.dnn.dnn_value[1] == 0x69); @@ -1501,7 +1490,6 @@ int pdu_session_est_req_accecpt(srsran::nas_pcap* pcap) dl_nas_transport_t& dl_nas = nas_msg.dl_nas_transport(); TESTASSERT(dl_nas.payload_container_type.payload_container_type == payload_container_type_t::Payload_container_type_type_::options::n1_sm_information); - TESTASSERT(dl_nas.payload_container.length == 29); TESTASSERT(dl_nas.payload_container.payload_container_contents.size() == 29); TESTASSERT(dl_nas.payload_container.payload_container_contents[0] == 0x2e); TESTASSERT(dl_nas.payload_container.payload_container_contents[28] == 0x01); @@ -1521,8 +1509,6 @@ int pdu_session_est_req_accecpt(srsran::nas_pcap* pcap) TESTASSERT(pdu_sess_est_acc.selected_pdu_session_type.pdu_session_type_value == pdu_session_type_t::PDU_session_type_value_type_::options::ipv4); - TESTASSERT(pdu_sess_est_acc.authorized__qo_s_rules.length == 8); - TESTASSERT(pdu_sess_est_acc.session_ambr.length == 6); TESTASSERT(pdu_sess_est_acc.session_ambr.unit_session_ambr_for_downlink == session_ambr_t::unit_session_AMBR_type_::options::inc_by_1_kbps); TESTASSERT(pdu_sess_est_acc.session_ambr.session_ambr_for_downlink == 59395);