Skip to main content

LocalSubnet

Struct LocalSubnet 

Source
#[non_exhaustive]
pub struct LocalSubnet { pub broadcast: SocketAddrV4, pub mask: Option<Ipv4Addr>, pub alone: bool, pub directed: Option<Ipv4Addr>, }
Expand description

A node’s own IP subnet as its B/IP network uses it: the broadcast address that reaches the network’s devices there and, when the caller knows it, the subnet mask.

A BBMD passes it to the decisions that can send to its subnet, Tables::forwarded_npdu and Tables::distribute_broadcast.

It is #[non_exhaustive], so a new detail of the subnet isn’t a breaking change: outside this crate, build it with LocalSubnet::new and set mask when it is known.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§broadcast: SocketAddrV4

Where a broadcast to the network’s devices goes: the subnet’s directed broadcast address (or 255.255.255.255) at the B/IP network’s UDP port (Annex J.1.2). For a B/IP-M node it is the multicast group and its port instead (Annex J.8.1): the group acts as the node’s subnet, and broadcasts go to it and come from it alone (Addressed::classify).

§mask: Option<Ipv4Addr>

The mask of the subnet the node’s own B/IP address is on, when the caller knows it. With it, a BBMD doesn’t broadcast a peer’s Forwarded-NPDU again when the peer sent it from this subnet at the BBMD’s own port: the network’s devices there heard it first hand. Leave it None when it isn’t known, or when the own address isn’t on the subnet, as behind NAT; such a forward is then broadcast. A BBMD that serves a multicast group doesn’t use it: a peer’s own broadcasts reach its IP subnet, not the group.

§alone: bool

Whether the node is the only device of its B/IP network on the subnet, as a BBMD behind a NAT router often is (Annex J.7.5). A BBMD then skips the local broadcast of a peer’s Forwarded-NPDU, as Annex J.4.5 permits (leaving how the BBMD knows to the installation), and, extending that permission, of a foreign device’s Distribute-Broadcast-To-Network: nothing there would receive either, and the BBMD’s own application still gets the message. false unless the caller sets it; set it only when no other device of the network shares the subnet, or they stop receiving remote broadcasts.

§directed: Option<Ipv4Addr>

For a B/IP-M node, whose broadcast is its multicast group, the IP subnet’s directed broadcast address, when the caller knows it. The node neither sends there nor takes broadcasts from there, but the address still reaches more than one node, so a datagram from it, or a Forwarded-NPDU naming it as the origin, is dropped (Groups). None for a plain node, whose broadcast address already is it.

Implementations§

Source§

impl LocalSubnet

Source

pub const fn new(broadcast: SocketAddrV4) -> Self

The subnet whose broadcasts go to broadcast, its mask not known, shared with other devices.

Source

pub const fn member(group: SocketAddrV4, directed: Option<Ipv4Addr>) -> Self

A B/IP-M node’s subnet (Annex J.8.1): broadcasts go to group, a multicast address at the network’s port, and directed, the IP subnet’s own broadcast address when known, stays a group address. A BBMD that serves the group (Annex J.8.3) has the same subnet.

Source

pub const fn is_group(&self) -> bool

Whether the broadcast address is a multicast group: the subnet of a B/IP-M node, or of the BBMD that serves its group (Annex J.8).

Trait Implementations§

Source§

impl Clone for LocalSubnet

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for LocalSubnet

Source§

impl Debug for LocalSubnet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for LocalSubnet

Source§

impl PartialEq for LocalSubnet

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LocalSubnet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.