pub trait IpPacket<I: IpExt> {
type TransportPacket<'a>: MaybeTransportPacket
where Self: 'a;
type TransportPacketMut<'a>: MaybeTransportPacketMut<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) -> I::Proto;
fn maybe_transport_packet<'a>(&'a self) -> Self::TransportPacket<'a>;
fn transport_packet_mut<'a>(&'a mut self) -> Self::TransportPacketMut<'a>;
}
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.
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.
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.