13#ifndef LIBE3_TYPES_HPP
14#define LIBE3_TYPES_HPP
42 return static_cast<uint64_t
>(
43 std::chrono::duration_cast<std::chrono::nanoseconds>(
44 std::chrono::system_clock::now().time_since_epoch()
142#define X(name, val) name = val,
151 switch (
static_cast<int>(code)) {
152#define X(name, val) case val: return #name;
155 default:
return "UNKNOWN_ERROR_CODE";
185 const uint8_t*
data() const noexcept {
return buffer.data(); }
378 return std::get_if<T>(&
choice);
383 return std::get_if<T>(&
choice);
405#if defined(LIBE3_HAS_ZMQ) && !LIBE3_HAS_ZMQ
427#if defined(LIBE3_ENABLE_ASN1)
429#elif defined(LIBE3_ENABLE_JSON)
491using Timestamp = std::chrono::time_point<std::chrono::steady_clock>;
528 default:
return "unknown";
540 default:
return "unknown";
551 default:
return "unknown";
560 case ErrorCode::SUCCESS:
return "Success";
561 case ErrorCode::INVALID_PARAM:
return "Invalid parameter";
562 case ErrorCode::NOT_INITIALIZED:
return "Not initialized";
563 case ErrorCode::ALREADY_INITIALIZED:
return "Already initialized";
564 case ErrorCode::NOT_CONNECTED:
return "Not connected";
565 case ErrorCode::CONNECTION_FAILED:
return "Connection failed";
566 case ErrorCode::TIMEOUT:
return "Timeout";
567 case ErrorCode::ENCODE_FAILED:
return "Encode failed";
568 case ErrorCode::DECODE_FAILED:
return "Decode failed";
569 case ErrorCode::SM_NOT_FOUND:
return "Service Model not found";
570 case ErrorCode::SM_ALREADY_REGISTERED:
return "Service Model already registered";
571 case ErrorCode::BUFFER_TOO_SMALL:
return "Buffer too small";
572 case ErrorCode::INTERNAL_ERROR:
return "Internal error";
573 case ErrorCode::SUBSCRIPTION_EXISTS:
return "Subscription already exists";
574 case ErrorCode::SUBSCRIPTION_NOT_FOUND:
return "Subscription not found";
575 case ErrorCode::DAPP_NOT_REGISTERED:
return "dApp not registered";
576 case ErrorCode::TRANSPORT_ERROR:
return "Transport error";
577 case ErrorCode::STATE_ERROR:
return "State error";
578 case ErrorCode::SM_START_FAILED:
return "Service Model start failed";
579 case ErrorCode::NOT_FOUND:
return "Not found";
580 case ErrorCode::CANCELLED:
return "Operation cancelled";
581 default:
return "Unknown error";
598 default:
return "Unknown";
609 default:
return "unknown";
620 default:
return "unknown";
632 default:
return "unknown";
libe3 error codes - shared C/C++ definitions
#define LIBE3_ERROR_CODE_LIST
X-macro list of all libe3 error codes.
constexpr size_t MAX_XAPP_CTRL_DATA_SIZE
ErrorCode
Error codes returned by libe3 operations Use shared error-code list (see libe3/error_codes....
std::variant< SetupRequest, SetupResponse, SubscriptionRequest, SubscriptionDelete, SubscriptionResponse, IndicationMessage, DAppControlAction, DAppReport, XAppControlAction, ReleaseMessage, MessageAck > PduChoice
Generic E3AP PDU using std::variant for type-safe union.
const char * ErrorCodeToString(ErrorCode code)
Convert ErrorCode to string name (C++ wrapper).
constexpr size_t MAX_DAPP_REPORT_DATA_SIZE
E3TransportLayer
Transport layer types (matches Python E3TransportLayer).
@ SCTP
SCTP (O-RAN standard).
@ IPC
Unix Domain Sockets / IPC.
AgentState
Agent state machine states.
@ STOPPED
Agent fully stopped.
@ RUNNING
Main processing loop active.
@ CONNECTING
Connection in progress.
@ CONNECTED
Connected and ready for operations.
@ UNINITIALIZED
Agent not yet initialized.
@ INITIALIZED
Agent initialized but not connected.
@ STOPPING
Shutdown in progress.
uint64_t now_realtime_ns() noexcept
Current realtime clock reading, in nanoseconds since the Unix epoch.
E3Role
Role this E3 endpoint plays in the protocol.
@ RAN
RAN function (binds sockets; today's only behaviour).
@ DAPP
dApp (connects to a RAN agent)
ResponseCode
E3AP response codes.
@ NEGATIVE
Request rejected.
@ POSITIVE
Request accepted.
constexpr size_t MAX_PROTOCOL_DATA_SIZE
const char * pdu_type_to_string(PduType type) noexcept
Convert PduType to string representation.
E3LinkLayer
Link layer types (matches Python E3LinkLayer).
@ POSIX
POSIX socket-based transport.
@ ZMQ
ZeroMQ-based transport.
std::chrono::time_point< std::chrono::steady_clock > Timestamp
Timestamp type using steady_clock for monotonic time.
const char * action_type_to_string(ActionType type) noexcept
Convert ActionType to string representation.
const char * agent_state_to_string(AgentState state) noexcept
Convert AgentState to string representation.
EncodingFormat
E3AP encoding formats supported by the library.
@ JSON
JSON encoding (for development/debugging).
@ ASN1
ASN.1 PER encoding (standard O-RAN format).
@ PROTOBUF
Protocol Buffers encoding.
const char * role_to_string(E3Role role) noexcept
Convert E3Role to string representation.
constexpr size_t DEFAULT_BUFFER_SIZE
const char * response_code_to_string(ResponseCode code) noexcept
Convert ResponseCode to string representation.
const char * transport_layer_to_string(E3TransportLayer layer) noexcept
Convert E3TransportLayer to string representation.
const char * link_layer_to_string(E3LinkLayer layer) noexcept
Convert E3LinkLayer to string representation.
constexpr size_t MAX_RAN_FUNCTIONS
ActionType
E3AP action types for Setup and Subscription requests.
@ UPDATE
Update existing entry.
@ DELETE
Delete existing entry.
@ INSERT
Insert/create new entry.
constexpr uint32_t LIBE3_PROTOCOL_VERSION
constexpr size_t MAX_ACTION_DATA_SIZE
const char * error_code_to_string(ErrorCode code) noexcept
Convert ErrorCode to string representation.
E3AP dApp Control Action structure.
uint32_t ran_function_identifier
std::vector< uint8_t > action_data
uint32_t control_identifier
Control identifier.
Timestamp registered_time
Monotonic timestamp of when the dApp registered.
uint32_t dapp_identifier
Assigned dApp identifier (1–100).
E3AP dApp Report structure.
std::vector< uint8_t > report_data
uint32_t ran_function_identifier
uint64_t recv_seq
Set by the inbound loop; keys the [latrec] L-stage records.
Configuration for E3Agent.
std::string dapp_version
dApp version advertised in SetupRequest
std::string e3ap_version
E3AP protocol version advertised during setup.
std::string log_path
Path of the shared log file. Empty (default) => auto-generated.
std::string subscriber_endpoint
Endpoint URI for inbound channel.
int log_level
Logging verbosity: 0=none, 1=error, 2=warn, 3=info, 4=debug, 5=trace.
uint16_t setup_port
Port used for E3AP setup channel.
uint32_t send_timeout_ms
Send operation timeout in milliseconds.
int io_thread_affinity
CPU core to pin the subscriber and publisher I/O threads to.
int io_thread_niceness
Nice value applied to the subscriber and publisher I/O threads.
EncodingFormat encoding
PDU encoding format (ASN.1 PER or JSON).
E3LinkLayer link_layer
Link-layer transport (ZMQ or POSIX).
uint32_t connect_timeout_ms
Connection establishment timeout in milliseconds.
std::string publisher_endpoint
Endpoint URI for outbound channel.
uint16_t subscriber_port
Port used for inbound control/subscription channel.
std::string dapp_name
dApp name advertised in SetupRequest
uint32_t recv_timeout_ms
Receive operation timeout in milliseconds.
std::string ran_identifier
Unique identifier for this RAN function (e.g. "DU-1").
size_t send_buffer_size
Size of the send buffer in bytes.
E3TransportLayer transport_layer
Transport-layer protocol (SCTP, TCP, IPC).
size_t receive_buffer_size
Size of the receive buffer in bytes.
size_t io_threads
Number of I/O threads (used by ZMQ context).
std::string setup_endpoint
Endpoint URI for setup channel.
uint16_t publisher_port
Port used for outbound indication/publication channel.
std::string vendor
Vendor name for SetupRequest (optional).
std::vector< uint8_t > buffer
Encoded data buffer.
bool empty() const noexcept
const uint8_t * data() const noexcept
EncodedMessage(std::vector< uint8_t > buf, EncodingFormat fmt)
EncodingFormat format
Format used for encoding.
size_t size() const noexcept
uint8_t * data() noexcept
E3AP Indication Message structure.
uint32_t ran_function_identifier
RAN function identifier.
std::vector< uint8_t > protocol_data
E3AP Message Acknowledgment structure.
ResponseCode response_code
Response code (positive/negative).
uint32_t request_id
ID of the request being acknowledged.
uint64_t enqueue_seq
Set by queue_outbound; keys the [latrec] L-stage records.
T * get_if() noexcept
Get PDU data with type checking.
uint64_t timestamp
Producer timestamp, in nanoseconds since the Unix epoch.
uint32_t message_id
Unique message identifier.
const T * get_if() const noexcept
RAN Function Definition for Setup Response.
uint32_t ran_function_identifier
std::vector< uint32_t > telemetry_identifier_list
List of telemetry identifiers.
std::vector< uint32_t > control_identifier_list
List of control identifiers.
std::vector< uint8_t > ran_function_data
RAN Function definition (SM identification).
uint32_t ran_function_id
Unique identifier for this RAN function.
std::string sm_version
Service Model version string (e.g. "1.0.0").
std::string sm_name
Human-readable Service Model name.
E3AP Release Message structure.
uint32_t dapp_identifier
dApp identifier
E3AP Setup Request structure.
std::string vendor
Vendor name (max 30 chars).
std::string dapp_version
Version of the dApp (e.g., "0.0.0").
std::string e3ap_protocol_version
E3AP protocol version (e.g., "0.0.0").
std::string dapp_name
Name of the dApp.
E3AP Setup Response structure.
std::string ran_identifier
RAN identifier (mandatory).
uint32_t request_id
ID of the corresponding SetupRequest.
std::optional< uint32_t > dapp_identifier
Assigned dApp identifier (optional).
std::vector< RanFunctionDef > ran_function_list
List of available RAN functions (optional).
ResponseCode response_code
Response code (positive/negative).
std::optional< std::string > e3ap_protocol_version
E3AP protocol version (optional).
E3AP Subscription Delete structure.
uint32_t dapp_identifier
dApp identifier
uint32_t subscription_id
Subscription ID to delete.
Subscription entry representing dApp-RAN function association.
Timestamp created_time
Monotonic timestamp of when the subscription was created.
uint32_t dapp_identifier
Identifier of the subscribed dApp.
uint32_t ran_function_id
RAN function the dApp is subscribed to.
E3AP Subscription Request structure.
std::optional< uint32_t > periodicity
Periodicity of data delivery (0-10000 microseconds).
std::optional< uint32_t > subscription_time
How long to keep the subscription (0-3600 sec).
uint32_t ran_function_identifier
RAN function to subscribe to.
std::vector< uint32_t > control_identifier_list
List of control identifiers.
std::vector< uint32_t > telemetry_identifier_list
List of telemetry identifiers.
uint32_t dapp_identifier
dApp identifier
E3AP Subscription Response structure.
std::optional< uint32_t > subscription_id
Subscription ID (optional).
uint32_t request_id
ID of the corresponding SubscriptionRequest.
uint32_t dapp_identifier
dApp identifier
ResponseCode response_code
Response code (positive/negative).
E3AP xApp Control Action structure.
std::vector< uint8_t > xapp_control_data
uint32_t ran_function_identifier