pub struct BoundSocketMap<I: Ip, D: DeviceIdentifier, A: SocketMapAddrSpec, S: SocketMapStateSpec> { /* private fields */ }
Expand description
A map from socket addresses to sockets.
The types of keys and IDs is determined by the SocketMapStateSpec
parameter. Each listener and connected socket stores additional state.
Listener and connected sockets are keyed independently, but share the same
address vector space. Conflicts are detected on attempted insertion of new
sockets.
Listener addresses map to listener-address-specific state, and likewise
with connected addresses. Depending on protocol (determined by the
SocketMapStateSpec
protocol), these address states can hold one or more
socket identifiers (e.g. UDP sockets with SO_REUSEPORT
set can share an
address).
Implementations§
Source§impl<I: Ip, D: DeviceIdentifier, A: SocketMapAddrSpec, S: SocketMapStateSpec> BoundSocketMap<I, D, A, S>
impl<I: Ip, D: DeviceIdentifier, A: SocketMapAddrSpec, S: SocketMapStateSpec> BoundSocketMap<I, D, A, S>
Source§impl<I: Ip, D: DeviceIdentifier, A: SocketMapAddrSpec, S> BoundSocketMap<I, D, A, S>
impl<I: Ip, D: DeviceIdentifier, A: SocketMapAddrSpec, S> BoundSocketMap<I, D, A, S>
Sourcepub fn listeners(
&self,
) -> Sockets<&SocketMap<AddrVec<I, D, A>, Bound<S>>, Listener>where
S: SocketMapConflictPolicy<ListenerAddr<ListenerIpAddr<I::Addr, A::LocalIdentifier>, D>, <S as SocketMapStateSpec>::ListenerSharingState, I, D, A>,
S::ListenerAddrState: SocketMapAddrStateSpec<Id = S::ListenerId, SharingState = S::ListenerSharingState>,
pub fn listeners(
&self,
) -> Sockets<&SocketMap<AddrVec<I, D, A>, Bound<S>>, Listener>where
S: SocketMapConflictPolicy<ListenerAddr<ListenerIpAddr<I::Addr, A::LocalIdentifier>, D>, <S as SocketMapStateSpec>::ListenerSharingState, I, D, A>,
S::ListenerAddrState: SocketMapAddrStateSpec<Id = S::ListenerId, SharingState = S::ListenerSharingState>,
Returns an iterator over the listeners on the socket map.
Sourcepub fn listeners_mut(
&mut self,
) -> Sockets<&mut SocketMap<AddrVec<I, D, A>, Bound<S>>, Listener>where
S: SocketMapConflictPolicy<ListenerAddr<ListenerIpAddr<I::Addr, A::LocalIdentifier>, D>, <S as SocketMapStateSpec>::ListenerSharingState, I, D, A>,
S::ListenerAddrState: SocketMapAddrStateSpec<Id = S::ListenerId, SharingState = S::ListenerSharingState>,
pub fn listeners_mut(
&mut self,
) -> Sockets<&mut SocketMap<AddrVec<I, D, A>, Bound<S>>, Listener>where
S: SocketMapConflictPolicy<ListenerAddr<ListenerIpAddr<I::Addr, A::LocalIdentifier>, D>, <S as SocketMapStateSpec>::ListenerSharingState, I, D, A>,
S::ListenerAddrState: SocketMapAddrStateSpec<Id = S::ListenerId, SharingState = S::ListenerSharingState>,
Returns a mutable iterator over the listeners on the socket map.
Sourcepub fn conns(
&self,
) -> Sockets<&SocketMap<AddrVec<I, D, A>, Bound<S>>, Connection>where
S: SocketMapConflictPolicy<ConnAddr<ConnIpAddr<I::Addr, A::LocalIdentifier, A::RemoteIdentifier>, D>, <S as SocketMapStateSpec>::ConnSharingState, I, D, A>,
S::ConnAddrState: SocketMapAddrStateSpec<Id = S::ConnId, SharingState = S::ConnSharingState>,
pub fn conns(
&self,
) -> Sockets<&SocketMap<AddrVec<I, D, A>, Bound<S>>, Connection>where
S: SocketMapConflictPolicy<ConnAddr<ConnIpAddr<I::Addr, A::LocalIdentifier, A::RemoteIdentifier>, D>, <S as SocketMapStateSpec>::ConnSharingState, I, D, A>,
S::ConnAddrState: SocketMapAddrStateSpec<Id = S::ConnId, SharingState = S::ConnSharingState>,
Returns an iterator over the connections on the socket map.
Sourcepub fn conns_mut(
&mut self,
) -> Sockets<&mut SocketMap<AddrVec<I, D, A>, Bound<S>>, Connection>where
S: SocketMapConflictPolicy<ConnAddr<ConnIpAddr<I::Addr, A::LocalIdentifier, A::RemoteIdentifier>, D>, <S as SocketMapStateSpec>::ConnSharingState, I, D, A>,
S::ConnAddrState: SocketMapAddrStateSpec<Id = S::ConnId, SharingState = S::ConnSharingState>,
pub fn conns_mut(
&mut self,
) -> Sockets<&mut SocketMap<AddrVec<I, D, A>, Bound<S>>, Connection>where
S: SocketMapConflictPolicy<ConnAddr<ConnIpAddr<I::Addr, A::LocalIdentifier, A::RemoteIdentifier>, D>, <S as SocketMapStateSpec>::ConnSharingState, I, D, A>,
S::ConnAddrState: SocketMapAddrStateSpec<Id = S::ConnId, SharingState = S::ConnSharingState>,
Returns a mutable iterator over the connections on the socket map.
Sourcepub fn get_shadower_counts(&self, addr: &AddrVec<I, D, A>) -> usize
pub fn get_shadower_counts(&self, addr: &AddrVec<I, D, A>) -> usize
Gets the number of shadower entries for addr
.
Source§impl<I, D, A, S> BoundSocketMap<I, D, A, S>where
I: BroadcastIpExt<Addr: MulticastAddress>,
D: DeviceIdentifier,
A: SocketMapAddrSpec,
S: SocketMapStateSpec + SocketMapConflictPolicy<ListenerAddr<ListenerIpAddr<I::Addr, A::LocalIdentifier>, D>, <S as SocketMapStateSpec>::ListenerSharingState, I, D, A> + SocketMapConflictPolicy<ConnAddr<ConnIpAddr<I::Addr, A::LocalIdentifier, A::RemoteIdentifier>, D>, <S as SocketMapStateSpec>::ConnSharingState, I, D, A>,
impl<I, D, A, S> BoundSocketMap<I, D, A, S>where
I: BroadcastIpExt<Addr: MulticastAddress>,
D: DeviceIdentifier,
A: SocketMapAddrSpec,
S: SocketMapStateSpec + SocketMapConflictPolicy<ListenerAddr<ListenerIpAddr<I::Addr, A::LocalIdentifier>, D>, <S as SocketMapStateSpec>::ListenerSharingState, I, D, A> + SocketMapConflictPolicy<ConnAddr<ConnIpAddr<I::Addr, A::LocalIdentifier, A::RemoteIdentifier>, D>, <S as SocketMapStateSpec>::ConnSharingState, I, D, A>,
Sourcepub fn iter_receivers(
&self,
(src_ip, src_port): (Option<SocketIpAddr<I::Addr>>, Option<A::RemoteIdentifier>),
(dst_ip, dst_port): (SocketIpAddr<I::Addr>, A::LocalIdentifier),
device: D,
broadcast: Option<I::BroadcastMarker>,
) -> Option<FoundSockets<AddrEntry<'_, I, D, A, S>, impl Iterator<Item = AddrEntry<'_, I, D, A, S>> + '_>>
pub fn iter_receivers( &self, (src_ip, src_port): (Option<SocketIpAddr<I::Addr>>, Option<A::RemoteIdentifier>), (dst_ip, dst_port): (SocketIpAddr<I::Addr>, A::LocalIdentifier), device: D, broadcast: Option<I::BroadcastMarker>, ) -> Option<FoundSockets<AddrEntry<'_, I, D, A, S>, impl Iterator<Item = AddrEntry<'_, I, D, A, S>> + '_>>
Finds the socket(s) that should receive an incoming packet.
Uses the provided addresses and receiving device to look up sockets that
should receive a matching incoming packet. Returns None
if no sockets
were found, or the results of the lookup.