pub trait IpPacket<I: FilterIpExt> {
type TransportPacket<'a>: MaybeTransportPacket
where Self: 'a;
type TransportPacketMut<'a>: MaybeTransportPacketMut<I>
where Self: 'a;
type IcmpError<'a>: MaybeIcmpErrorPayload<I>
where Self: 'a;
type IcmpErrorMut<'a>: MaybeIcmpErrorMut<I>
where Self: 'a;
// Required methods
fn src_addr(&self) -> I::Addr;
fn set_src_addr(&mut self, addr: I::Addr);
fn dst_addr(&self) -> I::Addr;
fn set_dst_addr(&mut self, addr: I::Addr);
fn protocol(&self) -> Option<I::Proto>;
fn maybe_transport_packet<'a>(&'a self) -> Self::TransportPacket<'a>;
fn transport_packet_mut<'a>(&'a mut self) -> Self::TransportPacketMut<'a>;
fn maybe_icmp_error<'a>(&'a self) -> Self::IcmpError<'a>;
fn icmp_error_mut<'a>(&'a mut self) -> Self::IcmpErrorMut<'a>;
// Provided method
fn conntrack_packet(&self) -> Option<PacketMetadata<I>> { ... }
}
Expand description
An IP packet that provides header inspection.
Required Associated Types§
Sourcetype TransportPacket<'a>: MaybeTransportPacket
where
Self: 'a
type TransportPacket<'a>: MaybeTransportPacket where Self: 'a
The type that provides access to transport-layer header inspection, if a transport header is contained in the body of the IP packet.
Sourcetype TransportPacketMut<'a>: MaybeTransportPacketMut<I>
where
Self: 'a
type TransportPacketMut<'a>: MaybeTransportPacketMut<I> where Self: 'a
The type that provides access to transport-layer header modification, if a transport header is contained in the body of the IP packet.
Sourcetype IcmpError<'a>: MaybeIcmpErrorPayload<I>
where
Self: 'a
type IcmpError<'a>: MaybeIcmpErrorPayload<I> where Self: 'a
The type that provides access to IP- and transport-layer information within an ICMP error packet, if this IP packet contains one.
Sourcetype IcmpErrorMut<'a>: MaybeIcmpErrorMut<I>
where
Self: 'a
type IcmpErrorMut<'a>: MaybeIcmpErrorMut<I> where Self: 'a
The type that provides mutable access to the message within an ICMP error packet, if this IP packet contains one.
Required Methods§
Sourcefn set_src_addr(&mut self, addr: I::Addr)
fn set_src_addr(&mut self, addr: I::Addr)
Sets the source IP address of the packet.
Sourcefn set_dst_addr(&mut self, addr: I::Addr)
fn set_dst_addr(&mut self, addr: I::Addr)
Sets the destination IP address of the packet.
Sourcefn maybe_transport_packet<'a>(&'a self) -> Self::TransportPacket<'a>
fn maybe_transport_packet<'a>(&'a self) -> Self::TransportPacket<'a>
Returns a type that provides access to the transport-layer packet contained in the body of the IP packet, if one exists.
This method returns an owned type parameterized on a lifetime that is tied
to the lifetime of Self, rather than, for example, a reference to a
non-parameterized type (&Self::TransportPacket
). This is because
implementors may need to parse the transport header from the body of the IP
packet and materialize the results into a new type when this is called, but
that type may also need to retain a reference to the backing buffer in order
to modify the transport header.
Sourcefn transport_packet_mut<'a>(&'a mut self) -> Self::TransportPacketMut<'a>
fn transport_packet_mut<'a>(&'a mut self) -> Self::TransportPacketMut<'a>
Returns a type that provides the ability to modify the transport-layer packet contained in the body of the IP packet, if one exists.
This method returns an owned type parameterized on a lifetime that is tied
to the lifetime of Self, rather than, for example, a reference to a
non-parameterized type (&Self::TransportPacketMut
). This is because
implementors may need to parse the transport header from the body of the IP
packet and materialize the results into a new type when this is called, but
that type may also need to retain a reference to the backing buffer in order
to modify the transport header.
Sourcefn maybe_icmp_error<'a>(&'a self) -> Self::IcmpError<'a>
fn maybe_icmp_error<'a>(&'a self) -> Self::IcmpError<'a>
Returns a type that provides the ability to access the IP- and transport-layer headers contained within the body of the ICMP error message, if one exists in this packet.
NOTE: See the note on IpPacket::maybe_transport_packet
.
Sourcefn icmp_error_mut<'a>(&'a mut self) -> Self::IcmpErrorMut<'a>
fn icmp_error_mut<'a>(&'a mut self) -> Self::IcmpErrorMut<'a>
Returns a type that provides the ability to modify the IP- and transport-layer headers contained within the body of the ICMP error message, if one exists in this packet.
NOTE: See the note on IpPacket::transport_packet_mut
.
Provided Methods§
Sourcefn conntrack_packet(&self) -> Option<PacketMetadata<I>>
fn conntrack_packet(&self) -> Option<PacketMetadata<I>>
The header information to be used for connection tracking.
For the transport header, this currently returns the same information as
IpPacket::maybe_transport_packet
, but may be different for packets
such as ICMP errors. In that case, we care about the inner IP packet for
connection tracking, but use the outer header for filtering.
Subtlety: For ICMP packets, only request/response messages will have a transport packet defined (and currently only ECHO messages do). This gets us basic tracking for free, and lets us implicitly ignore ICMP errors, which are not meant to be tracked.
If other ICMP message types eventually have TransportPacket impls, then this would lead to multiple message types being mapped to the same tuple if they happen to have the same ID.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.