pub trait IpPacket<B: ByteSlice, I: IpExt>: Sized + Debug + ParsablePacket<B, (), Error = IpParseError<I>> {
    type Builder: IpPacketBuilder<I>;
    type VersionSpecificMeta;

    // Required methods
    fn src_ip(&self) -> I::Addr;
    fn dst_ip(&self) -> I::Addr;
    fn proto(&self) -> I::Proto;
    fn ttl(&self) -> u8;
    fn set_ttl(&mut self, ttl: u8)
       where B: ByteSliceMut;
    fn body(&self) -> &[u8] ;
    fn version_specific_meta(&self) -> Self::VersionSpecificMeta;
    fn as_ip_addr_ref(&self) -> IpAddr<&Ipv4Packet<B>, &Ipv6Packet<B>>;
    fn reassemble_fragmented_packet<BV: BufferViewMut<B>, IT: Iterator<Item = Vec<u8>>>(
        buffer: BV,
        header: Vec<u8>,
        body_fragments: IT
    ) -> IpParseResult<I, Self>
       where B: ByteSliceMut;

    // Provided method
    fn into_metadata(self) -> (I::Addr, I::Addr, I::Proto, ParseMetadata) { ... }
}
Expand description

An IPv4 or IPv6 packet.

IpPacket is implemented by Ipv4Packet and Ipv6Packet.

Required Associated Types§

source

type Builder: IpPacketBuilder<I>

A builder for this packet type.

source

type VersionSpecificMeta

Metadata which is only present in the packet format of a specific version of the IP protocol.

Required Methods§

source

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

The source IP address.

source

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

The destination IP address.

source

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

The protocol number.

source

fn ttl(&self) -> u8

The Time to Live (TTL) (IPv4) or Hop Limit (IPv6) field.

source

fn set_ttl(&mut self, ttl: u8)
where B: ByteSliceMut,

Set the Time to Live (TTL) (IPv4) or Hop Limit (IPv6) field.

set_ttl updates the packet’s TTL/Hop Limit in place.

source

fn body(&self) -> &[u8]

Get the body.

source

fn version_specific_meta(&self) -> Self::VersionSpecificMeta

Gets packet metadata relevant only for this version of the IP protocol.

source

fn as_ip_addr_ref(&self) -> IpAddr<&Ipv4Packet<B>, &Ipv6Packet<B>>

Converts a packet reference into a dynamically-typed reference.

source

fn reassemble_fragmented_packet<BV: BufferViewMut<B>, IT: Iterator<Item = Vec<u8>>>( buffer: BV, header: Vec<u8>, body_fragments: IT ) -> IpParseResult<I, Self>
where B: ByteSliceMut,

Reassembles a fragmented packet into a parsed IP packet.

Provided Methods§

source

fn into_metadata(self) -> (I::Addr, I::Addr, I::Proto, ParseMetadata)

Consume the packet and return some metadata.

Consume the packet and return the source address, destination address, protocol, and ParseMetadata.

Object Safety§

This trait is not object safe.

Implementors§