pub trait IpPacket<B: SplitByteSlice, 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 dscp_and_ecn(&self) -> DscpAndEcn;
fn set_ttl(&mut self, ttl: u8)
where B: SplitByteSliceMut;
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, ()>
where B: SplitByteSliceMut;
fn to_vec(&self) -> Vec<u8>;
// 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 dscp_and_ecn(&self) -> DscpAndEcn
fn dscp_and_ecn(&self) -> DscpAndEcn
The Differentiated Services Code Point (DSCP) and the Explicit Congestion Notification (ECN).
Sourcefn set_ttl(&mut self, ttl: u8)where
B: SplitByteSliceMut,
fn set_ttl(&mut self, ttl: u8)where
B: SplitByteSliceMut,
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, ()>where
B: SplitByteSliceMut,
fn reassemble_fragmented_packet<BV: BufferViewMut<B>, IT: Iterator<Item = Vec<u8>>>(
buffer: BV,
header: Vec<u8>,
body_fragments: IT,
) -> IpParseResult<I, ()>where
B: SplitByteSliceMut,
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
.
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.