/src/ocudu/lib/rrc/ue/rrc_asn1_helpers.h
Line | Count | Source |
1 | | // SPDX-FileCopyrightText: Copyright (C) 2021-2026 Software Radio Systems Limited |
2 | | // SPDX-License-Identifier: BSD-3-Clause-Open-MPI |
3 | | // Portions of this file may implement 3GPP specifications, which may be subject to additional licensing requirements. |
4 | | |
5 | | #pragma once |
6 | | |
7 | | #include "ocudu/adt/byte_buffer.h" |
8 | | #include "ocudu/adt/expected.h" |
9 | | #include "ocudu/asn1/rrc_nr/dl_dcch_msg.h" |
10 | | #include "ocudu/asn1/rrc_nr/ul_dcch_msg.h" |
11 | | #include "ocudu/asn1/rrc_nr/ul_dcch_msg_ies.h" |
12 | | #include "ocudu/rrc/rrc_resume.h" |
13 | | #include "ocudu/rrc/rrc_types.h" |
14 | | |
15 | | namespace ocudu::ocucp { |
16 | | |
17 | | // Helper to create PDU from RRC message. |
18 | | template <class T> |
19 | | byte_buffer pack_into_pdu(const T& msg, const char* context_name) |
20 | 0 | { |
21 | 0 | context_name = context_name == nullptr ? __FUNCTION__ : context_name; |
22 | 0 | byte_buffer pdu{}; |
23 | 0 | asn1::bit_ref bref{pdu}; |
24 | 0 | if (msg.pack(bref) == asn1::OCUDUASN_ERROR_ENCODE_FAIL) { |
25 | 0 | ocudulog::fetch_basic_logger("RRC").error("Failed to pack message in {}. Discarding it.", context_name); |
26 | 0 | } |
27 | 0 | return pdu; |
28 | 0 | } Unexecuted instantiation: ocudu::byte_buffer ocudu::ocucp::pack_into_pdu<asn1::rrc_nr::dl_ccch_msg_s>(asn1::rrc_nr::dl_ccch_msg_s const&, char const*) Unexecuted instantiation: ocudu::byte_buffer ocudu::ocucp::pack_into_pdu<asn1::rrc_nr::meas_cfg_s>(asn1::rrc_nr::meas_cfg_s const&, char const*) Unexecuted instantiation: ocudu::byte_buffer ocudu::ocucp::pack_into_pdu<asn1::rrc_nr::rrc_recfg_s>(asn1::rrc_nr::rrc_recfg_s const&, char const*) Unexecuted instantiation: ocudu::byte_buffer ocudu::ocucp::pack_into_pdu<asn1::rrc_nr::ho_prep_info_s>(asn1::rrc_nr::ho_prep_info_s const&, char const*) Unexecuted instantiation: ocudu::byte_buffer ocudu::ocucp::pack_into_pdu<asn1::rrc_nr::dl_dcch_msg_s>(asn1::rrc_nr::dl_dcch_msg_s const&, char const*) Unexecuted instantiation: ocudu::byte_buffer ocudu::ocucp::pack_into_pdu<asn1::rrc_nr::ue_radio_access_cap_info_s>(asn1::rrc_nr::ue_radio_access_cap_info_s const&, char const*) Unexecuted instantiation: ocudu::byte_buffer ocudu::ocucp::pack_into_pdu<asn1::rrc_nr::ho_cmd_s>(asn1::rrc_nr::ho_cmd_s const&, char const*) |
29 | | |
30 | | /// \brief Fills ASN.1 RRC Setup struct. |
31 | | /// \param[out] rrc_setup The RRC Setup ASN.1 struct to fill. |
32 | | /// \param[in] init_ul_rrc_transfer_msg The Init_UL_RRC_Transfer message received by the CU. |
33 | | /// \return True on success, otherwise false. |
34 | | bool fill_asn1_rrc_setup_msg(asn1::rrc_nr::rrc_setup_s& rrc_setup, const byte_buffer& mcg, uint8_t rrc_transaction_id); |
35 | | |
36 | | /// Extracts transaction id of RRC Setup complete message. |
37 | | expected<uint8_t> get_transaction_id(const asn1::rrc_nr::rrc_setup_complete_s& msg); |
38 | | |
39 | | /// Extracts transaction id of UL-DCCH message. |
40 | | expected<uint8_t> get_transaction_id(const asn1::rrc_nr::ul_dcch_msg_s& msg); |
41 | | |
42 | | /// \brief Fills ASN.1 RRC Security Mode Command struct. |
43 | | /// \param[out] rrc_smc The RRC security mode command ASN.1 struct to fill. |
44 | | /// \param[in] int_algo The selected integrity protection algorithm. |
45 | | /// \param[in] ciph_algo The selected ciphering algorithm. |
46 | | /// \param[in] rrc_transaction_id The RRC transaction id. |
47 | | void fill_asn1_rrc_smc_msg(asn1::rrc_nr::security_mode_cmd_s& rrc_smc, |
48 | | const security::integrity_algorithm& int_algo, |
49 | | const security::ciphering_algorithm& ciph_algo, |
50 | | uint8_t rrc_transaction_id); |
51 | | |
52 | | /// \brief Fills ASN.1 RRC Setup struct. |
53 | | /// \param[out] asn1_rrc_reconf The RRC Reconfiguration ASN.1 struct to fill. |
54 | | /// \param[in] rrc_transaction_id The RRC transaction id. |
55 | | /// \param[in] rrc_reconf The common type struct. |
56 | | void fill_asn1_rrc_reconfiguration_msg(asn1::rrc_nr::rrc_recfg_s& asn1_rrc_reconf, |
57 | | uint8_t rrc_transaction_id, |
58 | | const rrc_reconfiguration_procedure_request& rrc_reconf); |
59 | | |
60 | | /// \brief Fills ASN.1 RRC Resume struct. |
61 | | /// \param[out] asn1_rrc_resume The RRC Resume ASN.1 struct to fill. |
62 | | /// \param[in] rrc_transaction_id The RRC transaction id. |
63 | | /// \param[in] rrc_resume The common type struct. |
64 | | void fill_asn1_rrc_resume_msg(asn1::rrc_nr::rrc_resume_s& asn1_rrc_resume, |
65 | | uint8_t rrc_transaction_id, |
66 | | const rrc_resume_request_response& rrc_resume); |
67 | | |
68 | | } // namespace ocudu::ocucp |