Struct etherparse::UdpHeader [−][src]
Udp header according to rfc768.
Fields
source_port: u16
Source port of the packet (optional).
destination_port: u16
Destination port of the packet.
length: u16
Length of the packet (includes the udp header length of 8 bytes).
checksum: u16
The checksum of the packet. The checksum is calculated from a pseudo header, the udp header and the payload. The pseudo header is composed of source and destination address, protocol number
Implementations
impl UdpHeader
[src]
pub fn without_ipv4_checksum(
source_port: u16,
destination_port: u16,
payload_length: usize
) -> Result<UdpHeader, ValueError>
[src]
source_port: u16,
destination_port: u16,
payload_length: usize
) -> Result<UdpHeader, ValueError>
Returns an udp header for the given parameters
pub fn with_ipv4_checksum(
source_port: u16,
destination_port: u16,
ip_header: &Ipv4Header,
payload: &[u8]
) -> Result<UdpHeader, ValueError>
[src]
source_port: u16,
destination_port: u16,
ip_header: &Ipv4Header,
payload: &[u8]
) -> Result<UdpHeader, ValueError>
Calculate an udp header given an ipv4 header and the payload
pub fn calc_checksum_ipv4(
&self,
ip_header: &Ipv4Header,
payload: &[u8]
) -> Result<u16, ValueError>
[src]
&self,
ip_header: &Ipv4Header,
payload: &[u8]
) -> Result<u16, ValueError>
Calculates the upd header checksum based on a ipv4 header.
pub fn calc_checksum_ipv4_raw(
&self,
source: [u8; 4],
destination: [u8; 4],
protocol: u8,
payload: &[u8]
) -> Result<u16, ValueError>
[src]
&self,
source: [u8; 4],
destination: [u8; 4],
protocol: u8,
payload: &[u8]
) -> Result<u16, ValueError>
Calculates the upd header checksum based on a ipv4 header.
pub fn with_ipv6_checksum(
source_port: u16,
destination_port: u16,
ip_header: &Ipv6Header,
payload: &[u8]
) -> Result<UdpHeader, ValueError>
[src]
source_port: u16,
destination_port: u16,
ip_header: &Ipv6Header,
payload: &[u8]
) -> Result<UdpHeader, ValueError>
Calculate an udp header given an ipv6 header and the payload
pub fn calc_checksum_ipv6(
&self,
ip_header: &Ipv6Header,
payload: &[u8]
) -> Result<u16, ValueError>
[src]
&self,
ip_header: &Ipv6Header,
payload: &[u8]
) -> Result<u16, ValueError>
Calculates the checksum of the current udp header given an ipv6 header and the payload.
pub fn calc_checksum_ipv6_raw(
&self,
source: &[u8; 16],
destination: &[u8; 16],
payload: &[u8]
) -> Result<u16, ValueError>
[src]
&self,
source: &[u8; 16],
destination: &[u8; 16],
payload: &[u8]
) -> Result<u16, ValueError>
Calculates the checksum of the current udp header given an ipv6 source & destination address plus the payload.
pub fn read_from_slice(slice: &[u8]) -> Result<(UdpHeader, &[u8]), ReadError>
[src]
Reads a udp header from a slice directly and returns a tuple containing the resulting header & unused part of the slice.
pub fn read<T: Read + Seek + Sized>(reader: &mut T) -> Result<UdpHeader, Error>
[src]
Tries to read an udp header from the current position.
pub fn write<T: Write + Sized>(&self, writer: &mut T) -> Result<(), WriteError>
[src]
Write the udp header without recalculating the checksum or length.
Trait Implementations
impl Clone for UdpHeader
[src]
impl Debug for UdpHeader
[src]
impl Default for UdpHeader
[src]
impl Eq for UdpHeader
[src]
impl PartialEq<UdpHeader> for UdpHeader
[src]
impl SerializedSize for UdpHeader
[src]
const SERIALIZED_SIZE: usize
[src]
Size of the header itself
impl StructuralEq for UdpHeader
[src]
impl StructuralPartialEq for UdpHeader
[src]
Auto Trait Implementations
impl RefUnwindSafe for UdpHeader
[src]
impl Send for UdpHeader
[src]
impl Sync for UdpHeader
[src]
impl Unpin for UdpHeader
[src]
impl UnwindSafe for UdpHeader
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,