pub struct E2ERegistry { /* private fields */ }Expand description
Registry mapping message keys to E2E profile configurations and the per-source / per-key counter state.
On a shared subnet several devices send the same (service, method) under
the same fixed instance id. The profile configuration is endpoint-agnostic
(one per E2EKey), but the receive counter state must be independent
per device — otherwise two senders’ interleaved counters collide into
spurious WrongSequence results. Receive state is therefore keyed by
(source, key) and created lazily the first time a source is seen.
Transmit (protect) counter state stays per-key: a fan-out publish sends the
same protected bytes (one counter) to every subscriber, and per-recipient
transmit counters are handled a layer up (e.g. iris_someip_client).
no_std-friendly: every map is a fixed-capacity FnvIndexMap, so
construction and the entire lifetime of the registry are heap-free.
Construction is const, so a static instance can be declared in
firmware boot code. Profile/transmit slots are bounded by
E2E_REGISTRY_CAP; receive slots by E2E_RX_STATE_CAP.
Implementations§
Source§impl E2ERegistry
impl E2ERegistry
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Create an empty registry. const-constructible so it can live
in static storage on bare-metal targets.
Sourcepub fn register(
&mut self,
key: E2EKey,
profile: E2EProfile,
) -> Result<(), E2ERegistryFull>
pub fn register( &mut self, key: E2EKey, profile: E2EProfile, ) -> Result<(), E2ERegistryFull>
Register an E2E profile for the given key, creating fresh transmit state and clearing any prior per-source receive state for the key.
Replacing the profile of an already-registered key always
succeeds (the existing slots are reused). Adding a new key when
the registry already holds E2E_REGISTRY_CAP entries returns
Err(E2ERegistryFull); the caller is
responsible for sizing the cap to its workload’s high-water
mark.
§Errors
E2ERegistryFull when the registry is full and key is not
already present.
Sourcepub fn unregister(&mut self, key: &E2EKey)
pub fn unregister(&mut self, key: &E2EKey)
Remove E2E configuration (and all state) for the given key.
Sourcepub fn contains_key(&self, key: &E2EKey) -> bool
pub fn contains_key(&self, key: &E2EKey) -> bool
Returns true if a profile is registered for key.
Sourcepub fn check<'a>(
&mut self,
source: IpAddr,
key: E2EKey,
payload: &'a [u8],
upper_header: [u8; 8],
) -> Option<(E2ECheckStatus, &'a [u8])>
pub fn check<'a>( &mut self, source: IpAddr, key: E2EKey, payload: &'a [u8], upper_header: [u8; 8], ) -> Option<(E2ECheckStatus, &'a [u8])>
Run E2E check for key against source’s receive counter state, if
configured.
Returns None if no profile is registered for key. Otherwise returns
the check status and the best available payload (stripped E2E header on
success, original bytes on check failure).
Sourcepub fn protect(
&mut self,
key: E2EKey,
payload: &[u8],
upper_header: [u8; 8],
output: &mut [u8],
) -> Option<Result<usize, Error>>
pub fn protect( &mut self, key: E2EKey, payload: &[u8], upper_header: [u8; 8], output: &mut [u8], ) -> Option<Result<usize, Error>>
Run E2E protect for key if configured.
Returns None if no profile is registered for key.
Sourcepub fn reset_source(&mut self, source: IpAddr)
pub fn reset_source(&mut self, source: IpAddr)
Drop all per-source receive state for source (e.g. on its reboot), so
its next frame starts a fresh counter sequence. Configuration and
transmit state are untouched.