13#ifndef LIBE3_TYPES_HPP
14#define LIBE3_TYPES_HPP
44 return static_cast<uint64_t
>(
45 std::chrono::duration_cast<std::chrono::nanoseconds>(
46 std::chrono::system_clock::now().time_since_epoch()
179#define X(name, val) name = val,
190 switch (
static_cast<int>(code)) {
192#define X(name, val) case val: return #name;
195 default:
return "UNKNOWN_ERROR_CODE";
236 const uint8_t*
data() const noexcept {
return buffer.data(); }
489 return std::get_if<T>(&
choice);
499 return std::get_if<T>(&
choice);
521#if defined(LIBE3_HAS_ZMQ) && !LIBE3_HAS_ZMQ
582#if defined(LIBE3_ENABLE_ASN1)
584#elif defined(LIBE3_ENABLE_JSON)
673using Timestamp = std::chrono::time_point<std::chrono::steady_clock>;
715 default:
return "unknown";
729 default:
return "unknown";
742 default:
return "unknown";
768 default:
return "unspecified";
802 case ErrorCode::SUCCESS:
return "Success";
803 case ErrorCode::INVALID_PARAM:
return "Invalid parameter";
804 case ErrorCode::NOT_INITIALIZED:
return "Not initialized";
805 case ErrorCode::ALREADY_INITIALIZED:
return "Already initialized";
806 case ErrorCode::NOT_CONNECTED:
return "Not connected";
807 case ErrorCode::CONNECTION_FAILED:
return "Connection failed";
808 case ErrorCode::TIMEOUT:
return "Timeout";
809 case ErrorCode::ENCODE_FAILED:
return "Encode failed";
810 case ErrorCode::DECODE_FAILED:
return "Decode failed";
811 case ErrorCode::SM_NOT_FOUND:
return "Service Model not found";
812 case ErrorCode::SM_ALREADY_REGISTERED:
return "Service Model already registered";
813 case ErrorCode::BUFFER_TOO_SMALL:
return "Buffer too small";
814 case ErrorCode::INTERNAL_ERROR:
return "Internal error";
815 case ErrorCode::SUBSCRIPTION_EXISTS:
return "Subscription already exists";
816 case ErrorCode::SUBSCRIPTION_NOT_FOUND:
return "Subscription not found";
817 case ErrorCode::DAPP_NOT_REGISTERED:
return "dApp not registered";
818 case ErrorCode::TRANSPORT_ERROR:
return "Transport error";
819 case ErrorCode::STATE_ERROR:
return "State error";
820 case ErrorCode::SM_START_FAILED:
return "Service Model start failed";
821 case ErrorCode::NOT_FOUND:
return "Not found";
822 case ErrorCode::CANCELLED:
return "Operation cancelled";
823 default:
return "Unknown error";
842 default:
return "Unknown";
855 default:
return "unknown";
868 default:
return "unknown";
882 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
Largest xAppControlData of an xApp control action, in bytes.
ErrorCode
Error codes returned by libe3 operations Use shared error-code list (see libe3/error_codes....
const char * ErrorCodeToString(ErrorCode code)
Convert ErrorCode to string name (C++ wrapper).
constexpr size_t MAX_DAPP_REPORT_DATA_SIZE
Largest reportData of a dApp report, in bytes.
E3TransportLayer
Transport layer types (matches Python E3TransportLayer).
@ SCTP
SCTP (O-RAN standard).
@ IPC
Unix Domain Sockets / IPC.
std::variant< SetupRequest, SetupResponse, SubscriptionRequest, SubscriptionDelete, SubscriptionResponse, IndicationMessage, DAppControlAction, DAppReport, XAppControlAction, ReleaseMessage, MessageAck, ControlResponse > PduChoice
Generic E3AP PDU using std::variant for type-safe union.
const char * cause_to_string(Cause cause) noexcept
Convert Cause to the name E3AP gives it in JSON and in logs.
constexpr size_t MAX_PENDING_CONTROLS
Most dApp controls a RAN holds an answer for at once.
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
Largest protocolData of an indication, in bytes.
const char * pdu_type_to_string(PduType type) noexcept
Convert PduType to string representation.
@ MESSAGE_ACK
DEPRECATED TO BE REMOVED: libe3 no longer sends it, see CONTROL_RESPONSE.
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
Default encode and receive buffer size, in bytes.
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
ranFunctionList SIZE (0..64)
Cause
Why a RAN refused a request (E3-Cause).
@ SETUP_REQUIRED
The dApp has not completed setup.
@ UNSPECIFIED
No more specific cause applies.
@ PROTOCOL_ERROR
The message was malformed or out of sequence.
@ SETUP_ALREADY_COMPLETE
A second setup on one association.
@ RESOURCE_EXHAUSTED
The RAN has no room for the request.
@ DUPLICATE
The request repeats one that is already active.
@ SHUTTING_DOWN
The RAN is stopping.
@ NOT_FOUND
The subscription or procedure the request names does not exist.
@ AUTHORIZATION_REJECTED
The dApp is not allowed to do this.
@ INVALID_REQUEST
The request is well formed but its content is not acceptable.
@ UNSUPPORTED_RAN_FUNCTION
The RAN function is not served.
@ PAYLOAD_TOO_LARGE
The payload is over the bound the RAN accepts.
@ UNSUPPORTED_PROTOCOL_VERSION
The E3AP version of the dApp is not served.
@ UNSUPPORTED_IDENTIFIER
A telemetry or control identifier is not advertised by the RAN function.
@ TRANSPORT_OVERRUN
The transport could not keep up.
Cause cause_from_value(long value) noexcept
Read a Cause from its wire value.
constexpr size_t MAX_DETAIL_SIZE
Largest detail text of a negative response, in bytes (E3-Text).
ActionType
E3AP action types for Setup and Subscription requests.
@ UPDATE
Update existing entry.
@ DELETE
Delete existing entry.
@ INSERT
Insert/create new entry.
DisconnectReason
Why a dApp's session with the RAN ended (see DisconnectHandler).
@ CONNECTION_LOST
The peer closed the connection or the link failed.
@ RELEASED_BY_RAN
The RAN sent a ReleaseMessage for this dApp.
constexpr uint32_t LIBE3_PROTOCOL_VERSION
Protocol version this library speaks.
constexpr size_t MAX_ACTION_DATA_SIZE
Largest actionData of a dApp control action, in bytes.
constexpr size_t MAX_CONTROL_OUTCOME_SIZE
Largest controlOutcome of a control response, in bytes.
Cause cause_from_string(const std::string &name) noexcept
Read a Cause from its E3AP name.
const char * error_code_to_string(ErrorCode code) noexcept
Convert ErrorCode to string representation.
constexpr size_t MAX_IDENTIFIER_LIST_SIZE
telemetry and control lists SIZE (0..256)
E3AP Control Response structure.
uint32_t request_id
Message id of the control this answers.
uint32_t control_identifier
Control the answer is about.
std::optional< Cause > cause
Why the control was refused (negative only).
ResponseCode response_code
Response code (positive/negative).
uint32_t ran_function_identifier
RAN function of the control.
uint32_t dapp_identifier
dApp the control belongs to
std::optional< std::string > detail
std::optional< std::vector< uint8_t > > control_outcome
What a Service Model answers to a control (see ServiceModel::respond_to_control).
ResponseCode response_code
Whether the control was applied.
std::optional< std::string > detail
UTF-8 text for the cause, up to MAX_DETAIL_SIZE bytes.
std::optional< Cause > cause
Why not (negative only).
std::vector< uint8_t > outcome
Opaque service-model content; empty for none.
E3AP dApp Control Action structure.
uint32_t ran_function_identifier
RAN function the control is for.
std::vector< uint8_t > action_data
uint32_t dapp_identifier
dApp that sends the control
uint32_t control_identifier
Control identifier.
uint64_t generation
Counts registrations: an id handed out again gets a higher one.
Timestamp last_seen
Monotonic timestamp of the last message from the dApp, or of its registration.
Timestamp registered_time
Monotonic timestamp of when the dApp registered.
uint32_t dapp_identifier
Assigned dApp identifier (1–100).
E3AP dApp Report structure.
uint32_t dapp_identifier
dApp that sends the report
std::vector< uint8_t > report_data
uint32_t ran_function_identifier
RAN function the report is for.
uint64_t recv_seq
Set by the inbound loop; keys the [latrec] L-stage records.
Configuration for E3Agent.
std::vector< std::string > allowed_peers
Literal addresses a dApp may connect from (POSIX link, RAN role, TCP and SCTP).
uint32_t reconnect_interval_ms
Milliseconds a dApp waits before it registers with the RAN again (dApp role).
std::string dapp_version
dApp version advertised in SetupRequest
size_t maximum_associations
Most dApps connected at once (POSIX link, RAN role).
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 of the inbound channel (ZeroMQ).
E3Role role
Role: RAN (today's default — binds sockets) or DAPP (connects).
int log_level
Logging verbosity: 0=none, 1=error, 2=warn, 3=info, 4=debug, 5=trace.
size_t socket_buffer_bytes
SO_SNDBUF and SO_RCVBUF of the SCTP sockets of the POSIX link, in bytes.
uint16_t setup_port
Port of the setup channel; the one port of the POSIX link.
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 of the outbound channel (ZeroMQ).
uint16_t subscriber_port
Port of the inbound control/subscription channel (ZeroMQ).
uint32_t dapp_idle_timeout_s
Seconds a RAN waits for a message from a dApp before it removes the dApp.
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).
bool sctp_delayed_sack
Whether SCTP may delay the SACK of a message (POSIX link).
std::string setup_endpoint
Endpoint URI of the setup channel; the one endpoint of the POSIX link.
uint16_t publisher_port
Port of the outbound indication/publication channel (ZeroMQ).
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()=default
Empty message with no format set.
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
Opaque payload of the service model.
uint32_t dapp_identifier
dApp the indication is for
E3AP Message Acknowledgment structure.
std::optional< Cause > cause
Why the request was refused (negative only).
ResponseCode response_code
Response code (positive/negative).
std::optional< std::string > detail
UTF-8 text for the cause, up to MAX_DETAIL_SIZE bytes.
uint32_t request_id
ID of the request being acknowledged.
uint64_t enqueue_seq
Set by queue_outbound; keys the [latrec] L-stage records.
PduType type
Which alternative of choice is set.
T * get_if() noexcept
Get PDU data with type checking.
PduChoice choice
The message itself.
uint64_t timestamp
Producer timestamp, in nanoseconds since the Unix epoch.
Pdu()
SetupRequest-typed PDU with a default-constructed message and a fresh timestamp.
uint32_t message_id
Unique message identifier.
const T * get_if() const noexcept
Get PDU data with type checking.
RAN Function Definition for Setup Response.
uint32_t ran_function_identifier
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
Opaque description of the function, 1..262144 bytes over ASN.1.
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; 1..64 bytes over ASN.1.
std::string dapp_version
Version of the dApp (e.g., "0.0.0"); 1..32 bytes over ASN.1.
std::string e3ap_protocol_version
E3AP protocol version (e.g., "0.0.0"); 1..32 bytes over ASN.1.
std::string dapp_name
Name of the dApp; 1..64 bytes over ASN.1.
E3AP Setup Response structure.
std::string ran_identifier
RAN identifier (mandatory); 1..64 bytes over ASN.1.
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).
std::optional< Cause > cause
Why the setup was refused (negative only).
ResponseCode response_code
Response code (positive/negative).
std::optional< std::string > detail
UTF-8 text for the cause, up to MAX_DETAIL_SIZE bytes.
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
Microseconds between indications, 0 = every event (ASN.1: 0 to 60000000).
std::optional< uint32_t > subscription_time
How long to keep the subscription (0-86400 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< Cause > cause
Why the subscription was refused (negative only).
std::optional< uint32_t > subscription_id
Subscription ID (optional).
std::optional< std::vector< uint32_t > > telemetry_identifier_list
Granted telemetry ids (absent = not reported, empty = none granted).
std::optional< uint32_t > ran_function_identifier
RAN function the grant is for.
uint32_t request_id
ID of the corresponding SubscriptionRequest.
std::optional< std::string > detail
UTF-8 text for the cause, up to MAX_DETAIL_SIZE bytes.
uint32_t dapp_identifier
dApp identifier
std::optional< uint32_t > periodicity
Least microseconds the RAN keeps between two indications (absent = not reported).
std::optional< std::vector< uint32_t > > control_identifier_list
Granted control ids (absent = not reported, empty = none granted).
ResponseCode response_code
Response code (positive/negative).
E3AP xApp Control Action structure.
std::vector< uint8_t > xapp_control_data
uint32_t dapp_identifier
dApp the control is for
uint32_t ran_function_identifier
RAN function the control is for.