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

Abstract Service Model interface. More...

#include <sm_interface.hpp>

Inheritance diagram for libe3::ServiceModel:
e3_service_model_handle_s

Public Member Functions

virtual ~ServiceModel ()=default
virtual std::string name () const =0
 Get SM name.
virtual uint32_t version () const =0
 Get SM version.
virtual uint32_t ran_function_id () const =0
 Get RAN function ID for this SM.
virtual std::vector< uint32_t > telemetry_ids () const =0
 Get telemetry IDs supported by this SM.
virtual std::vector< uint32_t > control_ids () const =0
 Get control IDs supported by this SM.
virtual std::vector< uint8_t > ran_function_data () const
 RAN-function-specific opaque data (required, 1..32768 bytes).
virtual std::optional< uint32_t > granted_periodicity (uint32_t requested_us) const
 The least time between two indications that this SM keeps for a subscription.
virtual ErrorCode init ()=0
 Initialize the SM.
virtual void destroy ()=0
 Destroy the SM and release resources.
virtual ErrorCode start ()=0
 Start the SM processing.
virtual void stop ()=0
 Stop the SM processing.
virtual bool is_running () const =0
 Check if SM is currently running.
virtual ErrorCode handle_control_action (uint32_t request_message_id, const DAppControlAction &action)=0
 Process a control action from a dApp.

Protected Member Functions

 ServiceModel ()=default
ErrorCode respond_to_control (uint32_t dapp_id, uint32_t request_message_id, const ControlResult &result)
 Answer a dApp control.
ErrorCode emit_outbound (Pdu &&pdu)
 Emit an outbound PDU produced by the SM.
std::vector< uint32_t > get_subscribers () const
 Get currently subscribed dApps for this SM's RAN function.
void set_outbound_emitter (std::function< ErrorCode(Pdu &&)> emitter)
 Set the outbound PDU emitter callback (used by E3Interface).
void set_control_responder (std::function< ErrorCode(uint32_t, uint32_t, const ControlResult &)> responder)
 Set the control responder callback (used by E3Interface).
void set_subscribers_provider (std::function< std::vector< uint32_t >()> provider)
 Set subscriber provider callback (used by E3Interface).

Static Protected Member Functions

static Pdu make_message_ack_pdu (uint32_t request_message_id, ResponseCode response_code)
 Build a MessageAck PDU for a control/request message.
static Pdu make_indication_pdu (uint32_t dapp_id, uint32_t ran_function_id, std::vector< uint8_t > protocol_data)
 Build an IndicationMessage PDU.

Friends

class E3Interface

Detailed Description

Abstract Service Model interface.

This is the extension point for RAN vendors to implement their Service Models. The E3 agent treats E3SM as opaque - all SM-specific encoding/decoding happens in the implementations of this interface.

RAN vendors should:

  1. Derive from this class for each supported SM
  2. Implement the required virtual methods
  3. Register their SMs with the E3Agent

Definition at line 42 of file sm_interface.hpp.

Constructor & Destructor Documentation

◆ ~ServiceModel()

virtual libe3::ServiceModel::~ServiceModel ( )
virtualdefault

◆ ServiceModel()

libe3::ServiceModel::ServiceModel ( )
protecteddefault

Member Function Documentation

◆ control_ids()

virtual std::vector< uint32_t > libe3::ServiceModel::control_ids ( ) const
pure virtual

Get control IDs supported by this SM.

Returns
The control identifiers the SM supports

Implemented in e3_service_model_handle_s.

◆ destroy()

virtual void libe3::ServiceModel::destroy ( )
pure virtual

Destroy the SM and release resources.

Called when the SM is being unregistered.

Implemented in e3_service_model_handle_s.

◆ emit_outbound()

ErrorCode libe3::ServiceModel::emit_outbound ( Pdu && pdu)
inlineprotected

Emit an outbound PDU produced by the SM.

Parameters
pduThe PDU to send
Returns
ErrorCode::SUCCESS if it was queued, ErrorCode::NOT_INITIALIZED if no emitter is set

Definition at line 247 of file sm_interface.hpp.

◆ get_subscribers()

std::vector< uint32_t > libe3::ServiceModel::get_subscribers ( ) const
inlineprotected

Get currently subscribed dApps for this SM's RAN function.

Returns
The identifiers of the subscribed dApps, empty when no provider is set

Definition at line 258 of file sm_interface.hpp.

◆ granted_periodicity()

virtual std::optional< uint32_t > libe3::ServiceModel::granted_periodicity ( uint32_t requested_us) const
inlinevirtual

The least time between two indications that this SM keeps for a subscription.

Sent to the dApp as the granted periodicity of its SubscriptionResponse. Override it only when the SM itself keeps its indications at least that far apart. The base implementation reports nothing, so the response then carries no periodicity ("not reported").

Parameters
requested_usPeriodicity the dApp asked for, in microseconds. 0 when it asked for none or for one indication per event.
Returns
Microseconds between two indications. std::nullopt or 0 when the SM keeps no interval or does not say; the response then has none.

Reimplemented in e3_service_model_handle_s.

Definition at line 110 of file sm_interface.hpp.

◆ handle_control_action()

virtual ErrorCode libe3::ServiceModel::handle_control_action ( uint32_t request_message_id,
const DAppControlAction & action )
pure virtual

Process a control action from a dApp.

Called by the E3 interface when a DAppControlAction is received for this service model. Implementations answer it with respond_to_control() and can emit outbound PDUs (e.g. IndicationMessage) via emit_outbound().

Parameters
request_message_idMessage identifier of the DAppControlAction
actionThe control action
Returns
ErrorCode::SUCCESS if the SM took the action

Implemented in e3_service_model_handle_s.

◆ init()

virtual ErrorCode libe3::ServiceModel::init ( )
pure virtual

Initialize the SM.

Called when the SM is first registered.

Returns
ErrorCode::SUCCESS on success

Implemented in e3_service_model_handle_s.

◆ is_running()

virtual bool libe3::ServiceModel::is_running ( ) const
pure virtual

Check if SM is currently running.

Returns
True while the SM is processing

Implemented in e3_service_model_handle_s.

◆ make_indication_pdu()

Pdu libe3::ServiceModel::make_indication_pdu ( uint32_t dapp_id,
uint32_t ran_function_id,
std::vector< uint8_t > protocol_data )
inlinestaticprotected

Build an IndicationMessage PDU.

This helper only builds the PDU. Implementations can emit it with emit_outbound() when appropriate.

Parameters
dapp_iddApp the indication is for
ran_function_idRAN function the indication comes from
protocol_dataOpaque payload of the SM
Returns
The PDU

Definition at line 228 of file sm_interface.hpp.

◆ make_message_ack_pdu()

Pdu libe3::ServiceModel::make_message_ack_pdu ( uint32_t request_message_id,
ResponseCode response_code )
inlinestaticprotected

Build a MessageAck PDU for a control/request message.

DEPRECATED TO BE REMOVED. A Service Model answers a control with respond_to_control(). This helper only builds the PDU.

Parameters
request_message_idMessage identifier of the message acknowledged
response_codeResult to report
Returns
The PDU

Definition at line 178 of file sm_interface.hpp.

◆ name()

virtual std::string libe3::ServiceModel::name ( ) const
pure virtual

Get SM name.

Returns
The name of the SM

Implemented in e3_service_model_handle_s.

◆ ran_function_data()

virtual std::vector< uint8_t > libe3::ServiceModel::ran_function_data ( ) const
inlinevirtual

RAN-function-specific opaque data (required, 1..32768 bytes).

Returns the byte vector advertised for this RAN function in the SetupResponse (ranFunctionList->ranFunctionData). E3AP declares the field mandatory and non-empty – OCTET STRING (SIZE (1..262144)), limited to 32768 bytes – so every SM must override this: even the most minimal SM carries at least its own name. An SM with nothing to advertise is not advertisable at all, since ranFunctionList itself is optional but its entries are not.

Registration fails with ErrorCode::INVALID_PARAM if the returned vector is empty or longer than MAX_PROTOCOL_DATA_SIZE. The base implementation returns an empty vector so that failure is a loud diagnostic rather than a compile error in every existing SM; it is not a usable default.

Returns
The bytes advertised for this RAN function; registration fails if the vector is empty or oversized.

Reimplemented in e3_service_model_handle_s.

Definition at line 95 of file sm_interface.hpp.

◆ ran_function_id()

virtual uint32_t libe3::ServiceModel::ran_function_id ( ) const
pure virtual

Get RAN function ID for this SM.

Returns
The RAN function this SM serves

Implemented in e3_service_model_handle_s.

◆ respond_to_control()

ErrorCode libe3::ServiceModel::respond_to_control ( uint32_t dapp_id,
uint32_t request_message_id,
const ControlResult & result )
inlineprotected

Answer a dApp control.

Call it once per control, from any thread, when the outcome is known: from handle_control_action() or later, as an SM that applies the control asynchronously does. It sends a ControlResponse only when the dApp asked for one (request_ack), so an SM can call it for every control. The RAN function and the control identifier are filled in from the control. An SM that never answers sends nothing: the library does not invent an answer for a control that may still be applied.

Parameters
dapp_iddApp that sent the control (DAppControlAction::dapp_identifier)
request_message_idMessage identifier of the control, as passed to handle_control_action()
resultWhether the control was applied, why not, and what the SM reports about it
Returns
ErrorCode::SUCCESS if the answer was queued; ErrorCode::NOT_FOUND if none is owed (the dApp did not ask, or the control was answered already); ErrorCode::INVALID_PARAM if the outcome is over MAX_CONTROL_OUTCOME_SIZE; ErrorCode::NOT_INITIALIZED if no agent runs the SM

Definition at line 207 of file sm_interface.hpp.

◆ set_control_responder()

void libe3::ServiceModel::set_control_responder ( std::function< ErrorCode(uint32_t, uint32_t, const ControlResult &)> responder)
inlineprotected

Set the control responder callback (used by E3Interface).

Parameters
responderCallback that answers a dApp control

Definition at line 277 of file sm_interface.hpp.

◆ set_outbound_emitter()

void libe3::ServiceModel::set_outbound_emitter ( std::function< ErrorCode(Pdu &&)> emitter)
inlineprotected

Set the outbound PDU emitter callback (used by E3Interface).

Parameters
emitterCallback that queues a PDU

Definition at line 269 of file sm_interface.hpp.

◆ set_subscribers_provider()

void libe3::ServiceModel::set_subscribers_provider ( std::function< std::vector< uint32_t >()> provider)
inlineprotected

Set subscriber provider callback (used by E3Interface).

Parameters
providerCallback that lists the subscribed dApps

Definition at line 285 of file sm_interface.hpp.

◆ start()

virtual ErrorCode libe3::ServiceModel::start ( )
pure virtual

Start the SM processing.

Called when the first dApp subscribes to this SM's RAN function.

Returns
ErrorCode::SUCCESS on success

Implemented in e3_service_model_handle_s.

◆ stop()

virtual void libe3::ServiceModel::stop ( )
pure virtual

Stop the SM processing.

Called when the last dApp unsubscribes from this SM's RAN function.

Implemented in e3_service_model_handle_s.

◆ telemetry_ids()

virtual std::vector< uint32_t > libe3::ServiceModel::telemetry_ids ( ) const
pure virtual

Get telemetry IDs supported by this SM.

Returns
The telemetry identifiers the SM supports

Implemented in e3_service_model_handle_s.

◆ version()

virtual uint32_t libe3::ServiceModel::version ( ) const
pure virtual

Get SM version.

Returns
The version number of the SM

Implemented in e3_service_model_handle_s.

◆ E3Interface

friend class E3Interface
friend

Definition at line 294 of file sm_interface.hpp.


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