Remove length from class and pass by reference

This commit is contained in:
David Rupprecht 2021-08-31 08:58:08 +02:00 committed by David Rupprecht
parent 88bb92dc0d
commit 0ef8976d53
5 changed files with 378 additions and 452 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1813,11 +1813,11 @@ public:
nas_5gs_hdr hdr;
SRSASN_CODE pack(unique_byte_buffer_t& buf);
SRSASN_CODE pack(std::vector<uint8_t> buf);
SRSASN_CODE pack(std::vector<uint8_t>& buf);
SRSASN_CODE unpack(const unique_byte_buffer_t& buf);
SRSASN_CODE unpack(const std::vector<uint8_t> buf);
SRSASN_CODE unpack(const std::vector<uint8_t>& buf);
SRSASN_CODE unpack_outer_hdr(const unique_byte_buffer_t& buf);
SRSASN_CODE unpack_outer_hdr(const std::vector<uint8_t> buf);
SRSASN_CODE unpack_outer_hdr(const std::vector<uint8_t>& buf);
void set(msg_types::options e = msg_types::nulltype) { hdr.message_type = e; };
// Getters

View File

@ -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);

View File

@ -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<uint8_t> buf)
SRSASN_CODE nas_5gs_msg::pack(std::vector<uint8_t>& 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<uint8_t> buf)
SRSASN_CODE nas_5gs_msg::unpack_outer_hdr(const std::vector<uint8_t>& 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<uint8_t> buf)
SRSASN_CODE nas_5gs_msg::unpack(const std::vector<uint8_t>& buf)
{
asn1::cbit_ref msg_bref(buf.data(), buf.size());
HANDLE_CODE(unpack(msg_bref));

View File

@ -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);