#[non_exhaustive]pub struct ReinitializeContext {
pub state: ReinitializedState,
pub source_mac: MacAddr,
pub source_network: Option<NpduAddress>,
pub provenance: TransportProvenance,
pub invoke_id: u8,
/* private fields */
}Expand description
The ReinitializeDevice request a ReinitializeHandler is asked to carry
out, and who sent it.
The addresses are claims, not an authenticated operator. For routed
traffic source_mac is the last router, so restrict routed requesters by
source_network. Only the certificate accessors are verified:
principal names the direct SC peer that sent the
request itself, and is None for a routed one;
forwarding_peer_principal and
direct_sc_identity name the immediate hop,
a router included. Neither the mutation policy nor the
ServerPolicy sees this service, so a handler that
serves only some peers checks them here.
The server builds the context; new lets a test build one
to call a handler directly.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.state: ReinitializedStateThe requested state, one of those Clause 16.4 defines.
source_mac: MacAddrImmediate data-link peer (or router) address.
source_network: Option<NpduAddress>Originating NPDU source when the request was routed.
provenance: TransportProvenanceImmutable ingress snapshot, retained after the admitting connection closes.
invoke_id: u8Confirmed-request invoke identifier.
Implementations§
Source§impl ReinitializeContext
impl ReinitializeContext
Sourcepub fn new(
state: ReinitializedState,
source_mac: MacAddr,
source_network: Option<NpduAddress>,
provenance: TransportProvenance,
invoke_id: u8,
) -> Self
pub fn new( state: ReinitializedState, source_mac: MacAddr, source_network: Option<NpduAddress>, provenance: TransportProvenance, invoke_id: u8, ) -> Self
A context with these fields, for calling a handler outside the server,
such as in its unit tests. Outside bacnet-transport only
TransportProvenance::unverified can be built.
Sourcepub fn after_reply(&self, hook: impl FnOnce() + Send + 'static)
pub fn after_reply(&self, hook: impl FnOnce() + Send + 'static)
Run hook once this request’s SimpleACK has been handed to the
transport, with no server lock held: the place to restart, or to
start the backup or restore step, after replying (Clause 16.4.2).
Hooks run in the order registered, on the task that answered the
request, so each should be quick and hand longer work to a task or
thread of its own. On MS/TP, handed off means queued: the frame
still waits for the token, so a hook that stops the server or the
port at once can drop the reply; wait a short while first. Hooks
registered through a clone of the context after the handler returns
never run. They are dropped unrun when the request is
answered with an Error instead (the handler refused it or panicked,
or the Network Port activation after it failed), when the reply
could not be handed over, and when BACnetServer::stop aborts the
request task first. A panic in one is logged and the next still runs.
A context built with new outside the server never runs
its hooks unless a test runs them itself.
Sourcepub fn principal(&self) -> Option<ScPrincipal>
pub fn principal(&self) -> Option<ScPrincipal>
The principal of the peer that originated the request: the verified
leaf certificate of a direct BACnet/SC connection, when the request
carries no routed source. None for other ingress, hub-relayed and
routed requests included (see crate::policy).
Sourcepub fn forwarding_peer_principal(&self) -> Option<ScPrincipal>
pub fn forwarding_peer_principal(&self) -> Option<ScPrincipal>
The principal of the direct BACnet/SC peer that handed this request
over, a router included when the request was routed; None off a
verified direct SC connection. Trusting it trusts everything that
peer forwards.
Sourcepub fn certificate(&self) -> Option<&ScPeerCertificate>
Available on crate feature sc-tls only.
pub fn certificate(&self) -> Option<&ScPeerCertificate>
sc-tls only.The verified leaf certificate of the peer that originated the
request: the one principal fingerprints, for
rules by subject, Subject Alternative Name or issuer, which
survive certificate renewal. None exactly when principal()
is: other ingress, hub-relayed and routed requests (see
crate::policy). Its contents are the peer’s: don’t log them.
Sourcepub fn forwarding_peer_certificate(&self) -> Option<&ScPeerCertificate>
Available on crate feature sc-tls only.
pub fn forwarding_peer_certificate(&self) -> Option<&ScPeerCertificate>
sc-tls only.The verified leaf certificate of the direct BACnet/SC peer that
handed this request over, a router included when the request
was routed: the one
forwarding_peer_principal
fingerprints. None off a verified direct SC connection.
Sourcepub fn direct_sc_identity(&self) -> Option<DirectScIdentity>
pub fn direct_sc_identity(&self) -> Option<DirectScIdentity>
The immediate direct-SC hop’s verified leaf and connection incarnation: for a routed request, the router that forwarded it. Absent off a verified direct SC connection. Separate from claimed addresses.