[][src]Struct ethox::wire::UdpPacket

pub struct UdpPacket<T: AsRef<[u8]>> { /* fields omitted */ }

A read/write wrapper around an User Datagram Protocol packet buffer.

Methods

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

pub fn new_unchecked(buffer: T) -> Packet<T>[src]

Imbue a raw octet buffer with UDP packet structure.

pub fn new_checked(buffer: T) -> Result<Packet<T>>[src]

Shorthand for a combination of new_unchecked and check_len.

pub fn check_len(&self) -> Result<()>[src]

Ensure that no accessor method will panic if called. Returns Err(Error::Truncated) if the buffer is too short. Returns Err(Error::Malformed) if the length field has a value smaller than the header length.

The result of this check is invalidated by calling set_len.

pub fn into_inner(self) -> T[src]

Consume the packet, returning the underlying buffer.

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

Return the source port field.

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

Return the destination port field.

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

Return the length field.

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

Return the checksum field.

pub fn verify_checksum(
    &self,
    src_addr: &IpAddress,
    dst_addr: &IpAddress
) -> bool
[src]

Validate the packet checksum.

Panics

This function panics unless src_addr and dst_addr belong to the same family, and that family is IPv4 or IPv6.

Fuzzing

This function always returns true when fuzzing.

impl<'a, T: AsRef<[u8]> + ?Sized> Packet<&'a T>[src]

pub fn payload(&self) -> &'a [u8][src]

Return a pointer to the payload.

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

pub fn set_src_port(&mut self, value: u16)[src]

Set the source port field.

pub fn set_dst_port(&mut self, value: u16)[src]

Set the destination port field.

pub fn set_len(&mut self, value: u16)[src]

Set the length field.

pub fn set_checksum(&mut self, value: u16)[src]

Set the checksum field.

pub fn fill_checksum(&mut self, src_addr: &IpAddress, dst_addr: &IpAddress)[src]

Compute and fill in the header checksum.

Panics

This function panics unless src_addr and dst_addr belong to the same family, and that family is IPv4 or IPv6.

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

Return a mutable pointer to the payload.

Trait Implementations

impl<T: AsRef<[u8]>> PrettyPrint for Packet<T>[src]

impl<T: PartialEq + AsRef<[u8]>> PartialEq<Packet<T>> for Packet<T>[src]

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

impl<T: Clone + AsRef<[u8]>> Clone for Packet<T>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a, T: AsRef<[u8]> + ?Sized> Display for Packet<&'a T>[src]

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

Auto Trait Implementations

impl<T> Send for UdpPacket<T> where
    T: Send

impl<T> Sync for UdpPacket<T> where
    T: Sync

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

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

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