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

dApp-role E3AP session with a batched, lock-free inbound ring. More...

#include <e3_dapp_session.hpp>

Classes

struct  Impl
 What a DAppSession holds: the agent, the event queue and the setup snapshot. More...

Public Member Functions

 DAppSession (libe3::E3Config config, std::size_t queue_capacity=8192)
 Construct the session and register all inbound handlers.
 ~DAppSession ()
 Stops the agent and drops the queue.
 DAppSession (const DAppSession &)=delete
DAppSession & operator= (const DAppSession &)=delete
int start ()
 Start the agent, re-arming the inbound ring so a stop()->start() cycle works again.
int wait_for_setup (int timeout_ms)
 Block until the setup handshake completes.
int release ()
 Send a ReleaseMessage (session keeps running until stop).
void stop ()
 Stop the agent and shut down the ring so a blocked poll_events returns an empty batch (i.e. empty-after-stop means "done"). Restartable via start.
long dapp_id () const
 dApp id assigned at setup.
std::string ran_identifier () const
 RAN identifier from the SetupResponse.
int setup_response_code () const
 SetupResponse code.
std::size_t setup_ran_function_count () const
 Number of RAN functions advertised in the SetupResponse.
uint32_t setup_ran_function_id (std::size_t i) const
 RAN function id of an advertised entry.
std::vector< uint32_t > setup_ran_function_telemetry (std::size_t i) const
 Telemetry ids of an advertised entry.
std::vector< uint32_t > setup_ran_function_control (std::size_t i) const
 Control ids of an advertised entry.
std::vector< uint8_t > setup_ran_function_data (std::size_t i) const
 Opaque ranFunctionData bytes of an advertised entry.
int64_t subscribe (uint32_t ran_function_id, std::vector< uint32_t > telemetry_ids, std::vector< uint32_t > control_ids, int sub_time_ms, int periodicity)
 Subscribe to a RAN function (after a positive setup).
int unsubscribe (uint32_t ran_function_id)
 Delete a previously created subscription.
int64_t send_control (uint32_t ran_function_id, uint32_t control_id, std::vector< uint8_t > action_data, uint32_t sequence_id=0, bool request_ack=false)
 Send a dApp control action to the RAN.
int64_t send_report (uint32_t ran_function_id, std::vector< uint8_t > report_data, uint32_t sequence_id)
 Send a dApp report to the RAN.
int send_message_ack (uint32_t request_id, int response_code)
 Acknowledge a request. DEPRECATED TO BE REMOVED: answer an xApp control with send_control_response.
int send_control_response (uint32_t request_id, uint32_t ran_function_id, uint32_t control_id, int response_code, int cause, std::string detail, std::vector< uint8_t > outcome)
 Answer an xApp control that has request_ack (E3_EVENT_XAPP_CONTROL).
std::vector< E3Event > poll_events (std::size_t max_batch, int timeout_ms)
 Drain up to max_batch inbound events, waiting up to timeout_ms for the first.
unsigned long long dropped_events () const
 Total inbound events dropped due to ring overflow (backpressure).

Detailed Description

dApp-role E3AP session with a batched, lock-free inbound ring.

Thread model: two producers push into the ring — the setup-response handler (libe3 setup thread) and the other handlers (libe3 inbound thread), which run concurrently at startup; the Python drainer thread is the single consumer via poll_events. The ring is MPMC, so this is safe (do not "optimize" it to SPSC). All outbound verbs are thread-safe (delegated to libe3::E3Agent).

Definition at line 122 of file e3_dapp_session.hpp.

Constructor & Destructor Documentation

◆ DAppSession() [1/2]

libe3::py::DAppSession::DAppSession ( libe3::E3Config config,
std::size_t queue_capacity = 8192 )
explicit

Construct the session and register all inbound handlers.

Parameters
configAgent config; role is forced to E3Role::DAPP.
queue_capacityInbound ring capacity (rounded up to a power of two). Sized for high-throughput headroom; overflow increments the drop counter (dropped_events) rather than blocking libe3.

Definition at line 83 of file e3_dapp_session.cpp.

◆ ~DAppSession()

libe3::py::DAppSession::~DAppSession ( )

Stops the agent and drops the queue.

Definition at line 181 of file e3_dapp_session.cpp.

◆ DAppSession() [2/2]

libe3::py::DAppSession::DAppSession ( const DAppSession & )
delete

Member Function Documentation

◆ dapp_id()

long libe3::py::DAppSession::dapp_id ( ) const

dApp id assigned at setup.

Returns
the id, or -1 if not yet assigned.

Definition at line 210 of file e3_dapp_session.cpp.

◆ dropped_events()

unsigned long long libe3::py::DAppSession::dropped_events ( ) const

Total inbound events dropped due to ring overflow (backpressure).

Returns
the count.

Definition at line 354 of file e3_dapp_session.cpp.

◆ operator=()

DAppSession & libe3::py::DAppSession::operator= ( const DAppSession & )
delete

◆ poll_events()

std::vector< E3Event > libe3::py::DAppSession::poll_events ( std::size_t max_batch,
int timeout_ms )

Drain up to max_batch inbound events, waiting up to timeout_ms for the first.

Blocks on the ring for the first event (latency ≈ ring wakeup), then sweeps up any further already-queued events without blocking. timeout_ms <= 0 polls non-blocking (does not busy-wait). Returns an empty vector on a quiet tick or after stop. The SWIG wrapper releases the GIL for the whole call so libe3's threads run freely while Python waits.

Parameters
max_batchmost events to return
timeout_mslongest wait for the first event, in milliseconds
Returns
the events, empty on a quiet tick or after stop

Definition at line 323 of file e3_dapp_session.cpp.

◆ ran_identifier()

std::string libe3::py::DAppSession::ran_identifier ( ) const

RAN identifier from the SetupResponse.

Returns
the identifier, or "" if none.

Definition at line 215 of file e3_dapp_session.cpp.

◆ release()

int libe3::py::DAppSession::release ( )

Send a ReleaseMessage (session keeps running until stop).

Returns
ErrorCode as int.

Definition at line 201 of file e3_dapp_session.cpp.

◆ send_control()

int64_t libe3::py::DAppSession::send_control ( uint32_t ran_function_id,
uint32_t control_id,
std::vector< uint8_t > action_data,
uint32_t sequence_id = 0,
bool request_ack = false )

Send a dApp control action to the RAN.

Parameters
ran_function_idRAN function the control is for
control_idcontrol identifier granted by the RAN
action_dataopaque E3SM control payload
sequence_idcorrelation id of the xApp procedure this control re-issues; 0 when the dApp decided on its own.
request_acktrue to ask the RAN for a control response (an E3_EVENT_CONTROL_RESPONSE event) once it has dealt with the control. The RAN answers a control it refuses itself either way.
Returns
the assigned message id (positive, 1..4294967295) on success, so the caller can correlate a later response by id; a negative ErrorCode on failure. Returned as int64_t because a message id now spans the full uint32 range and would alias onto the negative error codes if narrowed to int.

Definition at line 277 of file e3_dapp_session.cpp.

◆ send_control_response()

int libe3::py::DAppSession::send_control_response ( uint32_t request_id,
uint32_t ran_function_id,
uint32_t control_id,
int response_code,
int cause,
std::string detail,
std::vector< uint8_t > outcome )

Answer an xApp control that has request_ack (E3_EVENT_XAPP_CONTROL).

Parameters
request_idthe event's request_id
ran_function_idthe event's ran_function_id
control_idthe control the dApp applied, from the list the RAN advertised for the function
response_code0=applied (positive), 1=not applied (negative)
causewhy not, a libe3 Cause value 0 to 14, or -1 for none
detailtext for the cause, up to 512 bytes, empty for none
outcomewhat the dApp reports about the control, up to 32768 bytes, empty for none
Returns
ErrorCode as int.

Definition at line 310 of file e3_dapp_session.cpp.

◆ send_message_ack()

int libe3::py::DAppSession::send_message_ack ( uint32_t request_id,
int response_code )

Acknowledge a request. DEPRECATED TO BE REMOVED: answer an xApp control with send_control_response.

Parameters
request_idrequest being acknowledged.
response_code0=positive,1=negative.
Returns
ErrorCode as int.

Definition at line 305 of file e3_dapp_session.cpp.

◆ send_report()

int64_t libe3::py::DAppSession::send_report ( uint32_t ran_function_id,
std::vector< uint8_t > report_data,
uint32_t sequence_id )

Send a dApp report to the RAN.

Parameters
ran_function_idRAN function the report is for
report_dataopaque E3SM report payload
sequence_idcorrelation id this dApp assigns to the detection; mandatory on the wire, 1..4294967295 (0 is refused with INVALID_PARAM).
Returns
the assigned message id (positive, 1..4294967295) on success, so the caller can correlate a later response by id; a negative ErrorCode on failure.

Definition at line 293 of file e3_dapp_session.cpp.

◆ setup_ran_function_control()

std::vector< uint32_t > libe3::py::DAppSession::setup_ran_function_control ( std::size_t i) const

Control ids of an advertised entry.

Parameters
iindex of the entry.
Returns
the ids.

Definition at line 243 of file e3_dapp_session.cpp.

◆ setup_ran_function_count()

std::size_t libe3::py::DAppSession::setup_ran_function_count ( ) const

Number of RAN functions advertised in the SetupResponse.

Returns
the count.

Definition at line 226 of file e3_dapp_session.cpp.

◆ setup_ran_function_data()

std::vector< uint8_t > libe3::py::DAppSession::setup_ran_function_data ( std::size_t i) const

Opaque ranFunctionData bytes of an advertised entry.

Parameters
iindex of the entry.
Returns
the bytes.

Definition at line 249 of file e3_dapp_session.cpp.

◆ setup_ran_function_id()

uint32_t libe3::py::DAppSession::setup_ran_function_id ( std::size_t i) const

RAN function id of an advertised entry.

Parameters
iindex of the entry.
Returns
the id, 0 if out of range.

Definition at line 231 of file e3_dapp_session.cpp.

◆ setup_ran_function_telemetry()

std::vector< uint32_t > libe3::py::DAppSession::setup_ran_function_telemetry ( std::size_t i) const

Telemetry ids of an advertised entry.

Parameters
iindex of the entry.
Returns
the ids.

Definition at line 237 of file e3_dapp_session.cpp.

◆ setup_response_code()

int libe3::py::DAppSession::setup_response_code ( ) const

SetupResponse code.

Returns
0=positive, 1=negative, -1=not received.

Definition at line 220 of file e3_dapp_session.cpp.

◆ start()

int libe3::py::DAppSession::start ( )

Start the agent, re-arming the inbound ring so a stop()->start() cycle works again.

Returns
ErrorCode as int.

Definition at line 188 of file e3_dapp_session.cpp.

◆ stop()

void libe3::py::DAppSession::stop ( )

Stop the agent and shut down the ring so a blocked poll_events returns an empty batch (i.e. empty-after-stop means "done"). Restartable via start.

Definition at line 205 of file e3_dapp_session.cpp.

◆ subscribe()

int64_t libe3::py::DAppSession::subscribe ( uint32_t ran_function_id,
std::vector< uint32_t > telemetry_ids,
std::vector< uint32_t > control_ids,
int sub_time_ms,
int periodicity )

Subscribe to a RAN function (after a positive setup).

Parameters
ran_function_idRAN function to subscribe to
telemetry_idstelemetry identifiers requested
control_idscontrol identifiers requested
sub_time_mssubscription time in seconds (the name is historical), or -1 for unset. 0 is no limit. The RAN ends the subscription when it runs out.
periodicitymicroseconds between indications, 0 = every event, or -1 for unset. Over ASN.1 the range is 0 to 60000000. An OCUDU RAN reads the same number as milliseconds.
Returns
the assigned request id (positive, 1..4294967295) on success, so the caller can correlate the SubscriptionResponse by its request_id; a negative ErrorCode on failure.

Definition at line 255 of file e3_dapp_session.cpp.

◆ unsubscribe()

int libe3::py::DAppSession::unsubscribe ( uint32_t ran_function_id)

Delete a previously created subscription.

Parameters
ran_function_idRAN function it was for.
Returns
ErrorCode as int.

Definition at line 273 of file e3_dapp_session.cpp.

◆ wait_for_setup()

int libe3::py::DAppSession::wait_for_setup ( int timeout_ms)

Block until the setup handshake completes.

Parameters
timeout_mslongest wait, in milliseconds.
Returns
ErrorCode as int.

Definition at line 196 of file e3_dapp_session.cpp.


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