[][src]Struct packet::ip::v4::Packet

pub struct Packet<B> { /* fields omitted */ }

IPv4 packet parser.

Implementations

impl<B: AsRef<[u8]>> Packet<B>[src]

pub fn unchecked(buffer: B) -> Packet<B>[src]

Create an IPv4 packet without checking the buffer.

pub fn no_payload(buffer: B) -> Result<Packet<B>>[src]

Parse an IPv4 packet without checking the payload.

pub fn new(buffer: B) -> Result<Packet<B>>[src]

Parse an IPv4 packet, checking the buffer contents are correct.

impl<B: AsRef<[u8]>> Packet<B>[src]

pub fn to_owned(&self) -> Packet<Vec<u8>>[src]

Convert the packet to its owned version.

Notes

It would be nice if ToOwned could be implemented, but Packet already implements Clone and the impl would conflict.

impl<B: AsRef<[u8]>> Packet<B>[src]

pub fn version(&self) -> u8[src]

IP protocol version, will always be 4.

pub fn header(&self) -> u8[src]

Length of the IPv4 header in 32 bit words.

pub fn dscp(&self) -> u8[src]

DSCP value.

pub fn ecn(&self) -> u8[src]

ECN value.

pub fn length(&self) -> u16[src]

Total length of the packet in octets.

pub fn id(&self) -> u16[src]

ID of the packet.

pub fn flags(&self) -> Flags[src]

Flags of the packet.

pub fn offset(&self) -> u16[src]

Offset of the packet.

pub fn ttl(&self) -> u8[src]

Time to Live for the packet.

pub fn protocol(&self) -> Protocol[src]

Protocol of the inner packet.

pub fn checksum(&self) -> u16[src]

Checksum of the packet.

pub fn is_valid(&self) -> bool[src]

Verify the packet is valid by calculating the checksum.

pub fn source(&self) -> Ipv4Addr[src]

Source IP address.

pub fn destination(&self) -> Ipv4Addr[src]

Destination IP address.

pub fn options(&self) -> OptionIter<'_>[src]

IP options for the packet.

impl<B: AsRef<[u8]> + AsMut<[u8]>> Packet<B>[src]

pub fn set_dscp(&mut self, value: u8) -> Result<&mut Self>[src]

Differentiated Services Code Point.

pub fn set_ecn(&mut self, value: u8) -> Result<&mut Self>[src]

Explicit Congestion Notification.

pub fn set_id(&mut self, value: u16) -> Result<&mut Self>[src]

Packet ID.

pub fn set_flags(&mut self, value: Flags) -> Result<&mut Self>[src]

Packet flags.

pub fn set_offset(&mut self, value: u16) -> Result<&mut Self>[src]

Packet fragment offset.

pub fn set_ttl(&mut self, value: u8) -> Result<&mut Self>[src]

Time to Live.

pub fn set_source(&mut self, value: Ipv4Addr) -> Result<&mut Self>[src]

Source address.

pub fn set_destination(&mut self, value: Ipv4Addr) -> Result<&mut Self>[src]

Destination address.

pub fn set_protocol(&mut self, value: Protocol) -> Result<&mut Self>[src]

Inner protocol.

pub fn checked(&mut self) -> Checked<'_, B>[src]

Create a checksumed setter.

pub fn set_checksum(&mut self, value: u16) -> Result<&mut Self>[src]

Set the checksum value.

pub fn update_checksum(&mut self) -> Result<&mut Self>[src]

Recalculate and set the checksum value.

Trait Implementations

impl<B: AsRef<[u8]> + AsMut<[u8]>> AsMut<[u8]> for Packet<B>[src]

impl<'a, B: AsRef<[u8]>> AsPacket<'a, Packet<&'a [u8]>> for B[src]

impl<'a, B: Buffer> AsPacket<'a, Packet<&'a [u8]>> for Builder<B>[src]

impl<'a, B: AsRef<[u8]> + AsMut<[u8]>> AsPacketMut<'a, Packet<&'a mut [u8]>> for B[src]

impl<'a, B: Buffer> AsPacketMut<'a, Packet<&'a mut [u8]>> for Builder<B>[src]

impl<B: AsRef<[u8]>> AsRef<[u8]> for Packet<B>[src]

impl<B: Clone> Clone for Packet<B>[src]

impl<B: Copy> Copy for Packet<B>[src]

impl<B: AsRef<[u8]>> Debug for Packet<B>[src]

impl<'a, B: AsRef<[u8]> + Clone> From<&'a Packet<B>> for Packet<B>[src]

impl<B: AsRef<[u8]>> From<Packet<B>> for Packet<B>[src]

impl<B> Max for Packet<B>[src]

impl<B> Max for Packet<B>[src]

impl<B> Min for Packet<B>[src]

impl<B> Min for Packet<B>[src]

impl<B: AsRef<[u8]>> Packet for Packet<B>[src]

impl<B: AsRef<[u8]> + AsMut<[u8]>> PacketMut for Packet<B>[src]

impl<B: AsRef<[u8]>> Size for Packet<B>[src]

impl<B: AsRef<[u8]>> Size for Packet<B>[src]

Auto Trait Implementations

impl<B> RefUnwindSafe for Packet<B> where
    B: RefUnwindSafe

impl<B> Send for Packet<B> where
    B: Send

impl<B> Sync for Packet<B> where
    B: Sync

impl<B> Unpin for Packet<B> where
    B: Unpin

impl<B> UnwindSafe for Packet<B> where
    B: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Max for T where
    T: Max + Max
[src]

impl<T> Min for T where
    T: Min + Min
[src]

impl<T> Size for T where
    T: Size + Size
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.