Trait IpPacket

Source
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§

Source

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.

Source

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§

Source

fn src_addr(&self) -> I::Addr

The source IP address of the packet.

Source

fn set_src_addr(&mut self, addr: I::Addr)

Sets the source IP address of the packet.

Source

fn dst_addr(&self) -> I::Addr

The destination IP address of the packet.

Source

fn set_dst_addr(&mut self, addr: I::Addr)

Sets the destination IP address of the packet.

Source

fn protocol(&self) -> I::Proto

The IP protocol of the packet.

Source

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.

Source

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.

Implementations on Foreign Types§

Source§

impl<B: SplitByteSliceMut> IpPacket<Ipv4> for Ipv4Packet<B>

Source§

type TransportPacket<'a> = &'a Ipv4Packet<B> where Self: 'a

Source§

type TransportPacketMut<'a> = Option<ParsedTransportHeaderMut<'a, Ipv4>> where B: 'a

Source§

fn src_addr(&self) -> Ipv4Addr

Source§

fn set_src_addr(&mut self, addr: Ipv4Addr)

Source§

fn dst_addr(&self) -> Ipv4Addr

Source§

fn set_dst_addr(&mut self, addr: Ipv4Addr)

Source§

fn protocol(&self) -> Ipv4Proto

Source§

fn maybe_transport_packet(&self) -> Self::TransportPacket<'_>

Source§

fn transport_packet_mut(&mut self) -> Self::TransportPacketMut<'_>

Source§

impl<B: SplitByteSliceMut> IpPacket<Ipv6> for Ipv6Packet<B>

Source§

type TransportPacket<'a> = &'a Ipv6Packet<B> where Self: 'a

Source§

type TransportPacketMut<'a> = Option<ParsedTransportHeaderMut<'a, Ipv6>> where B: 'a

Source§

fn src_addr(&self) -> Ipv6Addr

Source§

fn set_src_addr(&mut self, addr: Ipv6Addr)

Source§

fn dst_addr(&self) -> Ipv6Addr

Source§

fn set_dst_addr(&mut self, addr: Ipv6Addr)

Source§

fn protocol(&self) -> Ipv6Proto

Source§

fn maybe_transport_packet(&self) -> Self::TransportPacket<'_>

Source§

fn transport_packet_mut(&mut self) -> Self::TransportPacketMut<'_>

Source§

impl<I: IpExt, S: TransportPacketSerializer<I>, B: IpPacketBuilder<I>> IpPacket<I> for Nested<S, B>

Source§

type TransportPacket<'a> = &'a S where Self: 'a

Source§

type TransportPacketMut<'a> = &'a mut S where Self: 'a

Source§

fn src_addr(&self) -> I::Addr

Source§

fn set_src_addr(&mut self, addr: I::Addr)

Source§

fn dst_addr(&self) -> I::Addr

Source§

fn set_dst_addr(&mut self, addr: I::Addr)

Source§

fn protocol(&self) -> I::Proto

Source§

fn maybe_transport_packet(&self) -> Self::TransportPacket<'_>

Source§

fn transport_packet_mut(&mut self) -> Self::TransportPacketMut<'_>

Implementors§

Source§

impl<I: IpExt, B: BufferMut> IpPacket<I> for ForwardedPacket<I, B>

Source§

type TransportPacket<'a> = &'a ForwardedPacket<I, B> where Self: 'a

Source§

type TransportPacketMut<'a> = Option<ParsedTransportHeaderMut<'a, I>> where Self: 'a

Source§

impl<I: IpExt, S: TransportPacketSerializer<I>> IpPacket<I> for TxPacket<'_, I, S>

Source§

type TransportPacket<'a> = &'a S where Self: 'a

Source§

type TransportPacketMut<'a> = &'a mut S where Self: 'a