Struct etherparse::UdpHeader[][src]

pub struct UdpHeader {
    pub source_port: u16,
    pub destination_port: u16,
    pub length: u16,
    pub checksum: u16,
}
Expand description

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

Returns an udp header for the given parameters

Calculate an udp header given an ipv4 header and the payload

Calculates the upd header checksum based on a ipv4 header.

Calculates the upd header checksum based on a ipv4 header.

Calculate an udp header given an ipv6 header and the payload

Calculates the checksum of the current udp header given an ipv6 header and the payload.

Calculates the checksum of the current udp header given an ipv6 source & destination address plus the payload.

👎 Deprecated since 0.10.1:

Use UdpHeader::from_slice instead.

Reads a udp header from a slice directly and returns a tuple containing the resulting header & unused part of the slice.

Reads a udp header from a slice directly and returns a tuple containing the resulting header & unused part of the slice.

Read an UdpHeader from a static sized byte array.

Tries to read an udp header from the current position.

Write the udp header without recalculating the checksum or length.

Length of the serialized header in bytes.

The function always returns the constant UdpHeader::SERIALIZED_SIZE and exists to keep the methods consistent with other headers.

Returns the serialized form of the header as a statically sized byte array.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Size of the header itself

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.