Trait packet_formats::ip::IpPacket
source · 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§
sourcetype Builder: IpPacketBuilder<I>
type Builder: IpPacketBuilder<I>
A builder for this packet type.
sourcetype VersionSpecificMeta
type VersionSpecificMeta
Metadata which is only present in the packet format of a specific version of the IP protocol.
Required Methods§
sourcefn set_ttl(&mut self, ttl: u8)where
B: ByteSliceMut,
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.
sourcefn version_specific_meta(&self) -> Self::VersionSpecificMeta
fn version_specific_meta(&self) -> Self::VersionSpecificMeta
Gets packet metadata relevant only for this version of the IP protocol.
sourcefn as_ip_addr_ref(&self) -> IpAddr<&Ipv4Packet<B>, &Ipv6Packet<B>>
fn as_ip_addr_ref(&self) -> IpAddr<&Ipv4Packet<B>, &Ipv6Packet<B>>
Converts a packet reference into a dynamically-typed reference.
sourcefn 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,
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§
sourcefn into_metadata(self) -> (I::Addr, I::Addr, I::Proto, ParseMetadata)
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.