/** * * \section COPYRIGHT * * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ #ifndef SRSRAN_NAS_5G_UTILS_H #define SRSRAN_NAS_5G_UTILS_H #include "srsran/asn1/asn1_utils.h" #include "srsran/common/byte_buffer.h" #include "srsran/config.h" using namespace asn1; namespace srsran { namespace nas_5g { struct ecies_scheme_profile_a_out { uint8_t ecc_ephemeral_key[33]; std::vector ciphertext; uint8_t mac_tag[8]; }; struct ecies_scheme_profile_b_out { uint8_t ecc_ephemeral_key[32]; std::vector ciphertext; uint8_t mac_tag[8]; }; template SRSASN_CODE unpack_enum(asn1::cbit_ref& bref, Enum* e) { uint32_t tmp = {}; HANDLE_CODE(bref.unpack(tmp, bl)); *e = static_cast(tmp); return SRSASN_SUCCESS; } template SRSASN_CODE pack_enum(asn1::bit_ref& bref, Enum e) { uint32_t tmp = static_cast(e); HANDLE_CODE(bref.pack(tmp, bl)); return SRSASN_SUCCESS; } template class nas_enumerated : public EnumType { public: static const uint32_t bit_length = bit_length_; nas_enumerated() {} nas_enumerated(typename EnumType::options o) { EnumType::value = o; } SRSASN_CODE pack(asn1::bit_ref& bref) const { uint32_t tmp = static_cast(EnumType::value); HANDLE_CODE(bref.pack(tmp, bit_length)); return SRSASN_SUCCESS; } SRSASN_CODE unpack(asn1::cbit_ref& bref) { uint32_t tmp = {}; HANDLE_CODE(bref.unpack(tmp, bit_length)); *this = static_cast(tmp); return SRSASN_SUCCESS; } EnumType& operator=(EnumType v) { EnumType::value = v; return *this; } operator typename EnumType::options() const { return EnumType::value; } }; SRSASN_CODE unpack_mcc_mnc(uint8_t* mcc_bytes, uint8_t* mnc_bytes, asn1::cbit_ref& bref); SRSASN_CODE pack_mcc_mnc(uint8_t* mcc_bytes, uint8_t* mnc_bytes, asn1::bit_ref& bref); } // namespace nas_5g } // namespace srsran #endif // MANUAL_H