libe3 0.6.1
C++ library for E3AP RAN vendor integration
Loading...
Searching...
No Matches
libe3::E3Interface Class Reference

E3Interface - Internal protocol coordination. More...

#include <e3_interface.hpp>

Public Member Functions

 E3Interface (const E3Config &config)
 Construct with configuration.
 ~E3Interface ()
 Destructor - ensures clean shutdown.
 E3Interface (const E3Interface &)=delete
E3Interface & operator= (const E3Interface &)=delete
 E3Interface (E3Interface &&)=delete
E3Interface & operator= (E3Interface &&)=delete
ErrorCode init ()
 Initialize the interface.
ErrorCode start ()
 Start the interface processing loops.
void stop ()
 Stop the interface.
AgentState state () const noexcept
 Get current state.
bool is_running () const noexcept
 Check if interface is running.
SubscriptionManager & subscription_manager () noexcept
 Get the subscription manager.
LockFreeQueue< Pdu > & response_queue () noexcept
 Get the response queue for outbound messages.
ErrorCode queue_outbound (Pdu pdu)
 Queue a PDU for outbound transmission.
std::vector< uint32_t > get_available_ran_functions () const
 Get available RAN functions.
ErrorCode register_sm (std::unique_ptr< ServiceModel > sm)
 Register a Service Model.
void set_dapp_report_handler (DAppReportHandler handler)
 Set the callback for a dApp report that reaches the RAN.
void set_dapp_status_changed_handler (DAppStatusChangedHandler handler)
 Set the callback for a dApp that connects, subscribes, unsubscribes or leaves.
void set_setup_response_handler (SetupResponseHandler handler)
 Set the callback for a SetupResponse.
void set_subscription_response_handler (SubscriptionResponseHandler handler)
 Set the callback for a SubscriptionResponse.
void set_indication_handler (IndicationHandler handler)
 Set the callback for an IndicationMessage.
void set_xapp_control_handler (XAppControlHandler handler)
 Set the callback for an XAppControlAction.
void set_message_ack_handler (MessageAckHandler handler)
 Set the callback for a MessageAck. DEPRECATED TO BE REMOVED.
void set_control_response_handler (ControlResponseHandler handler)
 Set the callback for a ControlResponse (either role).
void set_disconnect_handler (DisconnectHandler handler)
std::optional< uint32_t > dapp_id () const noexcept
std::vector< uint32_t > active_subscription_ids () const
std::vector< uint32_t > subscribed_ran_functions () const
std::vector< RanFunctionDef > remote_ran_functions () const
ErrorCode queue_subscription_request (uint32_t ran_function_id, std::vector< uint32_t > telemetry_ids, std::vector< uint32_t > control_ids, std::optional< uint32_t > sub_time=std::nullopt, std::optional< uint32_t > periodicity=std::nullopt, uint32_t *out_request_id=nullptr)
 Queue a SubscriptionRequest for the outbound loop to send.
ErrorCode queue_subscription_delete (uint32_t ran_function_id)
ErrorCode queue_dapp_control_action (uint32_t ran_function_id, uint32_t control_id, std::vector< uint8_t > action_data, uint32_t sequence_id=0, uint32_t *out_message_id=nullptr, bool request_ack=false)
ErrorCode queue_control_response (uint32_t request_id, uint32_t ran_function_id, uint32_t control_id, const ControlResult &result)
ErrorCode respond_to_control (uint32_t dapp_id, uint32_t request_id, const ControlResult &result)
ErrorCode queue_dapp_report (uint32_t ran_function_id, std::vector< uint8_t > report_data, uint32_t sequence_id, uint32_t *out_message_id=nullptr)
ErrorCode queue_release_message ()
ErrorCode wait_for_setup (std::chrono::milliseconds timeout)
void notify_dapp_status_changed ()
 Tell the status handler that a dApp connected, subscribed, unsubscribed or left.
uint32_t generate_message_id ()
 Generate the next message ID, monotonic within 1..4294967295.
uint32_t sanitize_request_message_id (uint32_t request_id)
 Return a request id that can be echoed into a response.

Detailed Description

E3Interface - Internal protocol coordination.

This class is the internal coordination layer that:

  • Manages E3AP lifecycle (Setup, Subscription, Control, Release)
  • Owns inbound/outbound processing threads
  • Coordinates between connector, encoder, and subscription manager
  • Supports simulation mode for testing without real RAN

This class is NOT directly exposed to library users. Users interact with the E3Agent facade which owns an E3Interface instance.

Definition at line 70 of file e3_interface.hpp.

Constructor & Destructor Documentation

◆ E3Interface() [1/3]

libe3::E3Interface::E3Interface ( const E3Config & config)
explicit

Construct with configuration.

Parameters
configRole, transport, encoding and tuning for this interface

Definition at line 212 of file e3_interface.cpp.

◆ ~E3Interface()

libe3::E3Interface::~E3Interface ( )

Destructor - ensures clean shutdown.

Definition at line 233 of file e3_interface.cpp.

◆ E3Interface() [2/3]

libe3::E3Interface::E3Interface ( const E3Interface & )
delete

◆ E3Interface() [3/3]

libe3::E3Interface::E3Interface ( E3Interface && )
delete

Member Function Documentation

◆ active_subscription_ids()

std::vector< uint32_t > libe3::E3Interface::active_subscription_ids ( ) const
Returns
The subscription identifiers the RAN granted and that have not ended

Definition at line 2052 of file e3_interface.cpp.

◆ dapp_id()

std::optional< uint32_t > libe3::E3Interface::dapp_id ( ) const
noexcept
Returns
The dApp identifier the RAN assigned, or nothing before setup completes

Definition at line 2046 of file e3_interface.cpp.

◆ generate_message_id()

uint32_t libe3::E3Interface::generate_message_id ( )

Generate the next message ID, monotonic within 1..4294967295.

Wraps a lock-free counter into the ASN.1 E3-MessageID range, skipping 0. Monotonic (not random) so an id is unique, letting a caller correlate a response by the id it was assigned.

Returns
The next message id

Definition at line 181 of file e3_interface.cpp.

◆ get_available_ran_functions()

std::vector< uint32_t > libe3::E3Interface::get_available_ran_functions ( ) const

Get available RAN functions.

Returns
The identifiers of the registered Service Models, sorted

Definition at line 531 of file e3_interface.cpp.

◆ init()

ErrorCode libe3::E3Interface::init ( )

Initialize the interface.

Creates connector, encoder, and initializes internal state.

Returns
ErrorCode::SUCCESS on success

Definition at line 238 of file e3_interface.cpp.

◆ is_running()

bool libe3::E3Interface::is_running ( ) const
inlinenoexcept

Check if interface is running.

Returns
True while the state is RUNNING

Definition at line 124 of file e3_interface.hpp.

◆ notify_dapp_status_changed()

void libe3::E3Interface::notify_dapp_status_changed ( )

Tell the status handler that a dApp connected, subscribed, unsubscribed or left.

Definition at line 570 of file e3_interface.cpp.

◆ operator=() [1/2]

E3Interface & libe3::E3Interface::operator= ( const E3Interface & )
delete

◆ operator=() [2/2]

E3Interface & libe3::E3Interface::operator= ( E3Interface && )
delete

◆ queue_control_response()

ErrorCode libe3::E3Interface::queue_control_response ( uint32_t request_id,
uint32_t ran_function_id,
uint32_t control_id,
const ControlResult & result )

Queue a ControlResponse that answers an xApp control (dApp role).

Parameters
request_idmessage id of the xApp control this answers
ran_function_idRAN function of the control
control_idcontrol the answer is about
resultcode, reason and outcome to send
Returns
SUCCESS once queued; STATE_ERROR on a RAN-role agent; NOT_INITIALIZED before setup has assigned a dApp id; INVALID_PARAM for an outcome over MAX_CONTROL_OUTCOME_SIZE; otherwise the queueing error

Definition at line 2165 of file e3_interface.cpp.

◆ queue_dapp_control_action()

ErrorCode libe3::E3Interface::queue_dapp_control_action ( uint32_t ran_function_id,
uint32_t control_id,
std::vector< uint8_t > action_data,
uint32_t sequence_id = 0,
uint32_t * out_message_id = nullptr,
bool request_ack = false )

Queue a dApp control action for the outbound loop to send.

Parameters
ran_function_idRAN function the control is for
control_idcontrol identifier granted by the RAN
action_dataopaque payload of the Service Model
sequence_idcorrelation id of the xApp procedure this control re-issues; 0 for none
out_message_idwhen non-null, receives the assigned E3-MessageID on success, so the caller can correlate a later response back to this send
request_acktrue to ask the RAN for a ControlResponse
Returns
SUCCESS once queued; otherwise the queueing error

Definition at line 2130 of file e3_interface.cpp.

◆ queue_dapp_report()

ErrorCode libe3::E3Interface::queue_dapp_report ( uint32_t ran_function_id,
std::vector< uint8_t > report_data,
uint32_t sequence_id,
uint32_t * out_message_id = nullptr )

Queue a dApp report for the outbound loop to send.

Parameters
ran_function_idRAN function the report is for
report_dataopaque payload of the Service Model
sequence_idcorrelation id the dApp assigns to this detection; mandatory, not 0
out_message_idwhen non-null, receives the assigned E3-MessageID on success
Returns
SUCCESS once queued; INVALID_PARAM for a sequence id of 0; otherwise the queueing error

Definition at line 2193 of file e3_interface.cpp.

◆ queue_outbound()

ErrorCode libe3::E3Interface::queue_outbound ( Pdu pdu)

Queue a PDU for outbound transmission.

Parameters
pduPDU to send; it is moved into the queue
Returns
SUCCESS once queued; the queueing error otherwise

Definition at line 502 of file e3_interface.cpp.

◆ queue_release_message()

ErrorCode libe3::E3Interface::queue_release_message ( )

Queue a ReleaseMessage that ends this dApp's session.

Returns
SUCCESS once queued; otherwise the queueing error

Definition at line 2226 of file e3_interface.cpp.

◆ queue_subscription_delete()

ErrorCode libe3::E3Interface::queue_subscription_delete ( uint32_t ran_function_id)

Queue a SubscriptionDelete for the outbound loop to send.

Parameters
ran_function_idRAN function whose subscription ends
Returns
SUCCESS once queued; STATE_ERROR on a RAN-role agent; NOT_INITIALIZED before setup has assigned a dApp id; SUBSCRIPTION_NOT_FOUND when the dApp holds none for it; otherwise the queueing error

Definition at line 2106 of file e3_interface.cpp.

◆ queue_subscription_request()

ErrorCode libe3::E3Interface::queue_subscription_request ( uint32_t ran_function_id,
std::vector< uint32_t > telemetry_ids,
std::vector< uint32_t > control_ids,
std::optional< uint32_t > sub_time = std::nullopt,
std::optional< uint32_t > periodicity = std::nullopt,
uint32_t * out_request_id = nullptr )

Queue a SubscriptionRequest for the outbound loop to send.

Parameters
ran_function_idRAN function to subscribe to
telemetry_idstelemetry identifiers requested
control_idscontrol identifiers requested
sub_timehow long to keep the subscription, in seconds; unset leaves it to the RAN
periodicitymicroseconds between indications, 0 = every event
out_request_idwhen non-null, receives the assigned E3-MessageID on success, so the caller can correlate the eventual SubscriptionResponse (which echoes request_id) back to this request.
Returns
SUCCESS once queued; STATE_ERROR on a RAN-role agent; NOT_INITIALIZED before setup has assigned a dApp id; otherwise the queueing error.

Definition at line 2068 of file e3_interface.cpp.

◆ register_sm()

ErrorCode libe3::E3Interface::register_sm ( std::unique_ptr< ServiceModel > sm)

Register a Service Model.

Parameters
smService Model to register; ownership moves to the registry
Returns
SUCCESS, or the registry's error

Definition at line 535 of file e3_interface.cpp.

◆ remote_ran_functions()

std::vector< RanFunctionDef > libe3::E3Interface::remote_ran_functions ( ) const
Returns
The RAN functions the RAN advertised in its setup response

Definition at line 2062 of file e3_interface.cpp.

◆ respond_to_control()

ErrorCode libe3::E3Interface::respond_to_control ( uint32_t dapp_id,
uint32_t request_id,
const ControlResult & result )

Answer a dApp control the RAN holds an answer for (RAN role, called by Service Models).

Parameters
dapp_iddApp whose control is answered
request_idmessage id of the dApp control
resultcode, reason and outcome to send
Returns
SUCCESS once queued; NOT_FOUND when no answer is owed: the dApp did not ask for one, or the control was answered already; INVALID_PARAM for an outcome over MAX_CONTROL_OUTCOME_SIZE

Definition at line 1388 of file e3_interface.cpp.

◆ response_queue()

LockFreeQueue< Pdu > & libe3::E3Interface::response_queue ( )
inlinenoexcept

Get the response queue for outbound messages.

Returns
The queue the outbound loop drains

Definition at line 140 of file e3_interface.hpp.

◆ sanitize_request_message_id()

uint32_t libe3::E3Interface::sanitize_request_message_id ( uint32_t request_id)

Return a request id that can be echoed into a response.

The decoders do not enforce integer range constraints, so a peer-supplied message id of 0, outside E3-MessageID's 1..4294967295, can reach the handlers; echoing it into a response would fail the encode. Every non-zero id passes through unchanged, 0 is replaced with a fresh generated id.

Parameters
request_idMessage id a peer sent
Returns
The same id when it is not 0, a fresh one otherwise

Definition at line 203 of file e3_interface.cpp.

◆ set_control_response_handler()

void libe3::E3Interface::set_control_response_handler ( ControlResponseHandler handler)
inline

Set the callback for a ControlResponse (either role).

Parameters
handlerCallback to call

Definition at line 200 of file e3_interface.hpp.

◆ set_dapp_report_handler()

void libe3::E3Interface::set_dapp_report_handler ( DAppReportHandler handler)
inline

Set the callback for a dApp report that reaches the RAN.

Parameters
handlerCallback to call

Definition at line 169 of file e3_interface.hpp.

◆ set_dapp_status_changed_handler()

void libe3::E3Interface::set_dapp_status_changed_handler ( DAppStatusChangedHandler handler)
inline

Set the callback for a dApp that connects, subscribes, unsubscribes or leaves.

Parameters
handlerCallback to call

Definition at line 174 of file e3_interface.hpp.

◆ set_disconnect_handler()

void libe3::E3Interface::set_disconnect_handler ( DisconnectHandler handler)
inline

Called once when the dApp's session with the RAN ends (see E3Agent::set_disconnect_handler).

Parameters
handlerCallback to call

Definition at line 205 of file e3_interface.hpp.

◆ set_indication_handler()

void libe3::E3Interface::set_indication_handler ( IndicationHandler handler)
inline

Set the callback for an IndicationMessage.

Parameters
handlerCallback to call

Definition at line 188 of file e3_interface.hpp.

◆ set_message_ack_handler()

void libe3::E3Interface::set_message_ack_handler ( MessageAckHandler handler)
inline

Set the callback for a MessageAck. DEPRECATED TO BE REMOVED.

Parameters
handlerCallback to call

Definition at line 196 of file e3_interface.hpp.

◆ set_setup_response_handler()

void libe3::E3Interface::set_setup_response_handler ( SetupResponseHandler handler)
inline

Set the callback for a SetupResponse.

Parameters
handlerCallback to call

Definition at line 180 of file e3_interface.hpp.

◆ set_subscription_response_handler()

void libe3::E3Interface::set_subscription_response_handler ( SubscriptionResponseHandler handler)
inline

Set the callback for a SubscriptionResponse.

Parameters
handlerCallback to call

Definition at line 184 of file e3_interface.hpp.

◆ set_xapp_control_handler()

void libe3::E3Interface::set_xapp_control_handler ( XAppControlHandler handler)
inline

Set the callback for an XAppControlAction.

Parameters
handlerCallback to call

Definition at line 192 of file e3_interface.hpp.

◆ start()

ErrorCode libe3::E3Interface::start ( )

Start the interface processing loops.

Spawns the setup, inbound, and outbound threads, plus the report worker on the RAN role.

Returns
ErrorCode::SUCCESS on success

Definition at line 318 of file e3_interface.cpp.

◆ state()

AgentState libe3::E3Interface::state ( ) const
inlinenoexcept

Get current state.

Returns
The lifecycle state of the interface

Definition at line 118 of file e3_interface.hpp.

◆ stop()

void libe3::E3Interface::stop ( )

Stop the interface.

Signals all threads to stop and waits for them to finish. It also ends the dApp's reconnecting, so the dApp stays down. Not to be called from the disconnect handler, which runs on a thread stop() joins.

Definition at line 407 of file e3_interface.cpp.

◆ subscribed_ran_functions()

std::vector< uint32_t > libe3::E3Interface::subscribed_ran_functions ( ) const
Returns
The RAN functions this dApp holds a subscription to

Definition at line 2057 of file e3_interface.cpp.

◆ subscription_manager()

SubscriptionManager & libe3::E3Interface::subscription_manager ( )
inlinenoexcept

Get the subscription manager.

Returns
The manager that holds the dApps and their subscriptions

Definition at line 132 of file e3_interface.hpp.

◆ wait_for_setup()

ErrorCode libe3::E3Interface::wait_for_setup ( std::chrono::milliseconds timeout)

Block until the setup handshake completes (or times out / fails). Only meaningful on dApp role.

Parameters
timeoutHow long to wait
Returns
SUCCESS when setup completed; TIMEOUT when it did not complete in time; CONNECTION_FAILED when it failed; INVALID_PARAM on a RAN-role interface

Definition at line 2242 of file e3_interface.cpp.


The documentation for this class was generated from the following files: