libe3 0.2.5
C++ library for E3AP RAN vendor integration
Loading...
Searching...
No Matches
asn1_encoder.hpp
Go to the documentation of this file.
1/**
2 * @file asn1_encoder.hpp
3 * @brief ASN.1 APER Encoder for E3AP PDUs
4 *
5 * SPDX-FileCopyrightText: Copyright (c) 2026 Northeastern University
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
9#ifndef LIBE3_ASN1_ENCODER_HPP
10#define LIBE3_ASN1_ENCODER_HPP
11
12#include "libe3/e3_encoder.hpp"
13
14// Forward declarations for ASN.1 generated types
15extern "C" {
16struct E3_PDU;
17}
18
19namespace libe3 {
20
21/**
22 * @brief ASN.1 APER encoder implementation
23 *
24 * Uses asn1c-generated code to encode/decode E3AP PDUs using
25 * Aligned Packed Encoding Rules (APER).
26 */
27class Asn1E3Encoder : public E3Encoder {
28public:
29 Asn1E3Encoder() = default;
30 ~Asn1E3Encoder() override = default;
31
32 // E3Encoder interface
33 EncodeResult<EncodedMessage> encode(const Pdu& pdu) override;
34 EncodeResult<Pdu> decode(const EncodedMessage& encoded) override;
35 EncodeResult<Pdu> decode(const uint8_t* data, size_t size) override;
36 EncodingFormat format() const noexcept override { return EncodingFormat::ASN1; }
37
38private:
39 static constexpr size_t BUFFER_SIZE = 65536;
40
41 // Encoding helpers
42 E3_PDU* pdu_to_asn1(const Pdu& pdu) const;
43 Pdu asn1_to_pdu(const E3_PDU* asn1_pdu) const;
44};
45
46} // namespace libe3
47
48#endif // LIBE3_ASN1_ENCODER_HPP
EncodeResult< Pdu > decode(const EncodedMessage &encoded) override
Decode bytes to a PDU.
~Asn1E3Encoder() override=default
EncodingFormat format() const noexcept override
Get the encoding format.
EncodeResult< EncodedMessage > encode(const Pdu &pdu) override
Encode a PDU to bytes.
E3Encoder(const E3Encoder &)=delete
Abstract E3 Encoder interface for PDU encoding/decoding.
EncodingFormat
E3AP encoding formats supported by the library.
Definition types.hpp:51
@ ASN1
ASN.1 PER encoding (standard O-RAN format).
Definition types.hpp:52
tl::expected< T, ErrorCode > EncodeResult
Result type for encoding/decoding operations.
Encoded message wrapper.
Definition types.hpp:175
Generic E3AP PDU structure.
Definition types.hpp:345