|
libe3 0.6.1
C++ library for E3AP RAN vendor integration
|
E3 Subscription Manager. More...
#include <subscription_manager.hpp>
Public Member Functions | |
| SubscriptionManager (SubscriptionClock clock={}) | |
| Construct a new Subscription Manager. | |
| ~SubscriptionManager () | |
| Destructor. | |
| SubscriptionManager (const SubscriptionManager &)=delete | |
| SubscriptionManager & | operator= (const SubscriptionManager &)=delete |
| SubscriptionManager (SubscriptionManager &&)=delete | |
| SubscriptionManager & | operator= (SubscriptionManager &&)=delete |
| void | set_sm_lifecycle_callback (SmLifecycleCallback callback) |
| Set callback for SM lifecycle events. | |
| std::pair< ErrorCode, uint32_t > | register_dapp () |
| Register a dApp from E3 Setup Request. | |
| ErrorCode | unregister_dapp (uint32_t dapp_id) |
| Unregister a dApp and clean up all its subscriptions. | |
| bool | is_dapp_registered (uint32_t dapp_id) const |
| Check if a dApp is registered. | |
| std::vector< uint32_t > | get_registered_dapps () const |
| Get list of registered dApp IDs. | |
| std::pair< ErrorCode, uint32_t > | add_subscription (uint32_t dapp_id, uint32_t ran_function_id, const std::vector< uint32_t > &telemetry_ids={}, const std::vector< uint32_t > &control_ids={}, uint32_t periodicity_us=0, uint32_t subscription_time_s=0) |
| Add a subscription between dApp and RAN function. | |
| std::vector< ExpiredSubscription > | expire_subscriptions () |
| Remove every subscription whose time has run out. | |
| ErrorCode | remove_subscription (uint32_t dapp_id, uint32_t ran_function_id) |
| Remove a subscription between dApp and RAN function. | |
| ErrorCode | remove_subscription_by_id (uint32_t dapp_id, uint32_t subscription_id) |
| Remove a subscription by its ID. | |
| bool | is_subscribed (uint32_t dapp_id, uint32_t ran_function_id) const |
| Check if dApp is subscribed to a RAN function. | |
| std::vector< uint32_t > | get_dapp_subscriptions (uint32_t dapp_id) const |
| Get all RAN functions a dApp is subscribed to. | |
| void | touch_dapp (uint32_t dapp_id) |
| Record that a message from a dApp has just arrived. | |
| std::optional< uint64_t > | dapp_generation (uint32_t dapp_id) const |
| Which registration of a dApp id is current. | |
| std::vector< uint32_t > | idle_dapps (std::chrono::seconds idle_for) const |
Registered dApps that have not sent a message for at least idle_for. | |
| std::vector< uint32_t > | get_subscribed_dapps (uint32_t ran_function_id) const |
| Get all dApps subscribed to a RAN function. | |
| std::optional< SubscriptionDetails > | get_subscription_details (uint32_t dapp_id, uint32_t ran_function_id) const |
| Get subscription details for a specific dApp + RAN function pair. | |
| size_t | get_subscriber_count (uint32_t ran_function_id) const |
| Get count of subscribers for a RAN function. | |
| std::vector< uint32_t > | get_active_ran_functions () const |
| Get all RAN functions that have at least one subscriber. | |
| bool | has_subscribers (uint32_t ran_function_id) const |
| Check if any dApp is subscribed to a RAN function. | |
| size_t | dapp_count () const |
| Get total number of registered dApps. | |
| size_t | subscription_count () const |
| Get total number of active subscriptions. | |
| void | clear () |
| Clear all registrations and subscriptions. | |
E3 Subscription Manager.
Thread-safe manager for dApp registrations and RAN function subscriptions. Handles:
This class is ported from the original C e3_subscription_manager with modern C++ idioms for thread safety and memory management.
Definition at line 76 of file subscription_manager.hpp.
|
explicit |
Construct a new Subscription Manager.
| clock | Source of "now" for subscription expiry, so tests can move time without sleeping. Defaults to std::chrono::steady_clock. |
Definition at line 34 of file subscription_manager.cpp.
| libe3::SubscriptionManager::~SubscriptionManager | ( | ) |
Destructor.
Definition at line 39 of file subscription_manager.cpp.
|
delete |
|
delete |
| std::pair< ErrorCode, uint32_t > libe3::SubscriptionManager::add_subscription | ( | uint32_t | dapp_id, |
| uint32_t | ran_function_id, | ||
| const std::vector< uint32_t > & | telemetry_ids = {}, | ||
| const std::vector< uint32_t > & | control_ids = {}, | ||
| uint32_t | periodicity_us = 0, | ||
| uint32_t | subscription_time_s = 0 ) |
Add a subscription between dApp and RAN function.
| dapp_id | dApp identifier |
| ran_function_id | RAN function identifier (0-255) |
| telemetry_ids | Telemetry IDs the dApp wants |
| control_ids | Control IDs the dApp wants |
| periodicity_us | Reporting periodicity in microseconds (0 = SM default) |
| subscription_time_s | Seconds the subscription lasts (0 = no limit). When it runs out the subscription is removed as if the dApp had deleted it, see expire_subscriptions(). |
Definition at line 159 of file subscription_manager.cpp.
| void libe3::SubscriptionManager::clear | ( | ) |
Clear all registrations and subscriptions.
Definition at line 520 of file subscription_manager.cpp.
| size_t libe3::SubscriptionManager::dapp_count | ( | ) | const |
Get total number of registered dApps.
Definition at line 505 of file subscription_manager.cpp.
| std::optional< uint64_t > libe3::SubscriptionManager::dapp_generation | ( | uint32_t | dapp_id | ) | const |
Which registration of a dApp id is current.
An id is handed out again after its dApp is removed, so a record that names a dApp by id alone can end up naming a later one. Remember the generation next to the id and compare before acting on it.
| dapp_id | The dApp |
Definition at line 412 of file subscription_manager.cpp.
| std::vector< ExpiredSubscription > libe3::SubscriptionManager::expire_subscriptions | ( | ) |
Remove every subscription whose time has run out.
Removal is silent towards the dApp: E3AP has no "subscription expired" PDU. The SM lifecycle callback fires for a RAN function that loses its last subscriber. Call this periodically; get_subscribed_dapps() already leaves out an expired subscription in between.
Definition at line 246 of file subscription_manager.cpp.
| std::vector< uint32_t > libe3::SubscriptionManager::get_active_ran_functions | ( | ) | const |
Get all RAN functions that have at least one subscriber.
Definition at line 482 of file subscription_manager.cpp.
| std::vector< uint32_t > libe3::SubscriptionManager::get_dapp_subscriptions | ( | uint32_t | dapp_id | ) | const |
Get all RAN functions a dApp is subscribed to.
| dapp_id | The dApp |
Definition at line 393 of file subscription_manager.cpp.
| std::vector< uint32_t > libe3::SubscriptionManager::get_registered_dapps | ( | ) | const |
Get list of registered dApp IDs.
Definition at line 145 of file subscription_manager.cpp.
| std::vector< uint32_t > libe3::SubscriptionManager::get_subscribed_dapps | ( | uint32_t | ran_function_id | ) | const |
Get all dApps subscribed to a RAN function.
Leaves out a dApp whose subscription time has run out, even before expire_subscriptions() removes it, so no indication goes past the deadline.
| ran_function_id | RAN function to look up |
Definition at line 436 of file subscription_manager.cpp.
| size_t libe3::SubscriptionManager::get_subscriber_count | ( | uint32_t | ran_function_id | ) | const |
Get count of subscribers for a RAN function.
| ran_function_id | The RAN function |
Definition at line 468 of file subscription_manager.cpp.
| std::optional< SubscriptionDetails > libe3::SubscriptionManager::get_subscription_details | ( | uint32_t | dapp_id, |
| uint32_t | ran_function_id ) const |
Get subscription details for a specific dApp + RAN function pair.
| dapp_id | dApp that holds the subscription |
| ran_function_id | RAN function it is for |
Definition at line 457 of file subscription_manager.cpp.
| bool libe3::SubscriptionManager::has_subscribers | ( | uint32_t | ran_function_id | ) | const |
Check if any dApp is subscribed to a RAN function.
| ran_function_id | The RAN function |
Definition at line 494 of file subscription_manager.cpp.
| std::vector< uint32_t > libe3::SubscriptionManager::idle_dapps | ( | std::chrono::seconds | idle_for | ) | const |
Registered dApps that have not sent a message for at least idle_for.
A dApp that registered and never spoke counts from its registration. Nothing is removed; the caller decides, then calls unregister_dapp().
| idle_for | Time without a message from the dApp |
Definition at line 422 of file subscription_manager.cpp.
| bool libe3::SubscriptionManager::is_dapp_registered | ( | uint32_t | dapp_id | ) | const |
Check if a dApp is registered.
| dapp_id | dApp identifier |
Definition at line 140 of file subscription_manager.cpp.
| bool libe3::SubscriptionManager::is_subscribed | ( | uint32_t | dapp_id, |
| uint32_t | ran_function_id ) const |
Check if dApp is subscribed to a RAN function.
| dapp_id | The dApp |
| ran_function_id | The RAN function |
Definition at line 383 of file subscription_manager.cpp.
|
delete |
|
delete |
| std::pair< ErrorCode, uint32_t > libe3::SubscriptionManager::register_dapp | ( | ) |
Register a dApp from E3 Setup Request.
The SubscriptionManager assigns a unique dApp ID automatically.
Definition at line 58 of file subscription_manager.cpp.
| ErrorCode libe3::SubscriptionManager::remove_subscription | ( | uint32_t | dapp_id, |
| uint32_t | ran_function_id ) |
Remove a subscription between dApp and RAN function.
| dapp_id | dApp identifier |
| ran_function_id | RAN function identifier |
Definition at line 292 of file subscription_manager.cpp.
| ErrorCode libe3::SubscriptionManager::remove_subscription_by_id | ( | uint32_t | dapp_id, |
| uint32_t | subscription_id ) |
Remove a subscription by its ID.
| dapp_id | dApp identifier |
| subscription_id | Subscription ID |
Definition at line 334 of file subscription_manager.cpp.
| void libe3::SubscriptionManager::set_sm_lifecycle_callback | ( | SmLifecycleCallback | callback | ) |
Set callback for SM lifecycle events.
| callback | Called when a RAN function gains its first or loses its last subscriber |
Definition at line 49 of file subscription_manager.cpp.
| size_t libe3::SubscriptionManager::subscription_count | ( | ) | const |
Get total number of active subscriptions.
Definition at line 510 of file subscription_manager.cpp.
| void libe3::SubscriptionManager::touch_dapp | ( | uint32_t | dapp_id | ) |
Record that a message from a dApp has just arrived.
Only messages the dApp sends count. A message to the dApp proves nothing: the RAN broadcasts, so it is sent whether or not the dApp is still there.
| dapp_id | dApp identifier; an id that is not registered is ignored |
Definition at line 403 of file subscription_manager.cpp.
| ErrorCode libe3::SubscriptionManager::unregister_dapp | ( | uint32_t | dapp_id | ) |
Unregister a dApp and clean up all its subscriptions.
| dapp_id | dApp identifier |
Definition at line 84 of file subscription_manager.cpp.