13#ifndef LIBE3_SM_INTERFACE_HPP
14#define LIBE3_SM_INTERFACE_HPP
50 virtual std::string
name()
const = 0;
162 uint32_t request_message_id,
179 uint32_t request_message_id,
209 uint32_t request_message_id,
212 if (!control_responder_) {
213 return ErrorCode::NOT_INITIALIZED;
215 return control_responder_(dapp_id, request_message_id, result);
231 std::vector<uint8_t> protocol_data
238 pdu.
choice = std::move(msg);
248 if (!outbound_emitter_) {
249 return ErrorCode::NOT_INITIALIZED;
251 return outbound_emitter_(std::move(pdu));
259 if (!subscribers_provider_) {
262 return subscribers_provider_();
270 outbound_emitter_ = std::move(emitter);
278 control_responder_ = std::move(responder);
286 subscribers_provider_ = std::move(provider);
292 std::function<std::vector<uint32_t>()> subscribers_provider_;
300using SmFactory = std::function<std::unique_ptr<ServiceModel>()>;
385 SmRegistry() =
default;
386 ~SmRegistry() =
default;
387 SmRegistry(
const SmRegistry&) =
delete;
388 SmRegistry& operator=(
const SmRegistry&) =
delete;
390 mutable std::mutex mutex_;
391 std::unordered_map<uint32_t, std::unique_ptr<ServiceModel>> sms_;
392 std::unordered_map<uint32_t, SmFactory> factories_;
Abstract Service Model interface.
virtual std::string name() const =0
Get SM name.
ErrorCode respond_to_control(uint32_t dapp_id, uint32_t request_message_id, const ControlResult &result)
Answer a dApp control.
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.
static Pdu make_message_ack_pdu(uint32_t request_message_id, ResponseCode response_code)
Build a MessageAck PDU for a control/request message.
std::vector< uint32_t > get_subscribers() const
Get currently subscribed dApps for this SM's RAN function.
virtual uint32_t version() const =0
Get SM version.
static Pdu make_indication_pdu(uint32_t dapp_id, uint32_t ran_function_id, std::vector< uint8_t > protocol_data)
Build an IndicationMessage PDU.
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.
void set_subscribers_provider(std::function< std::vector< uint32_t >()> provider)
Set subscriber provider 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).
virtual ~ServiceModel()=default
virtual void destroy()=0
Destroy the SM and release resources.
void set_outbound_emitter(std::function< ErrorCode(Pdu &&)> emitter)
Set the outbound PDU emitter callback (used by E3Interface).
ErrorCode emit_outbound(Pdu &&pdu)
Emit an outbound PDU produced by the SM.
virtual ErrorCode handle_control_action(uint32_t request_message_id, const DAppControlAction &action)=0
Process a control action from a dApp.
virtual ErrorCode start()=0
Start the SM processing.
virtual void stop()=0
Stop the SM processing.
virtual std::vector< uint8_t > ran_function_data() const
RAN-function-specific opaque data (required, 1..32768 bytes).
virtual std::vector< uint32_t > control_ids() const =0
Get control IDs supported by this SM.
virtual bool is_running() const =0
Check if SM is currently running.
virtual ErrorCode init()=0
Initialize the SM.
ErrorCode start_sm(uint32_t ran_function_id)
Start SM for a RAN function.
static SmRegistry & instance()
Get the singleton instance.
ServiceModel * get_by_ran_function(uint32_t ran_function_id)
Get SM by RAN function ID.
bool is_sm_running(uint32_t ran_function_id) const
Check if SM is running.
ErrorCode unregister_sm(uint32_t ran_function_id)
Unregister a Service Model by RAN function ID.
ErrorCode register_sm(std::unique_ptr< ServiceModel > sm)
Register a Service Model.
ErrorCode stop_sm(uint32_t ran_function_id)
Stop SM for a RAN function.
ErrorCode register_sm_factory(uint32_t ran_function_id, SmFactory factory)
Register a Service Model factory.
std::vector< uint32_t > get_available_ran_functions() const
Get all available RAN function IDs.
void clear()
Clear all registered SMs.
ErrorCode
Error codes returned by libe3 operations Use shared error-code list (see libe3/error_codes....
ResponseCode
E3AP response codes.
@ MESSAGE_ACK
DEPRECATED TO BE REMOVED: libe3 no longer sends it, see CONTROL_RESPONSE.
std::function< std::unique_ptr< ServiceModel >()> SmFactory
Factory function type for creating SM instances.
What a Service Model answers to a control (see ServiceModel::respond_to_control).
E3AP dApp Control Action structure.
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.
ResponseCode response_code
Response code (positive/negative).
uint32_t request_id
ID of the request being acknowledged.
Generic E3AP PDU structure.
PduChoice choice
The message itself.
E3AP Protocol Types - Vendor-neutral type definitions.