Skip to main content

Module util

Module util 

Source
Expand description

Byte-order helpers, checksum computation, error types.

Enums§

BuildError
Error returned by packet builders when construction fails.

Traits§

PacketBuilder
Common interface for all packet builders.

Functions§

internet_checksum
Compute the 16-bit ones’ complement of the ones’ complement sum of data.
pseudo_header_checksum
Compute the TCP/UDP pseudo-header checksum.
read_u16be
Read a big-endian u16 from a 2-byte slice. Caller guarantees buf.len() >= 2.
read_u32be
Read a big-endian u32 from a 4-byte slice. Caller guarantees buf.len() >= 4.
seal_internet_checksum
Zero the 2-byte checksum field at csum_offset, compute the internet checksum over buf, and write the result back.
seal_transport_checksum
Zero the 2-byte checksum field at csum_offset, compute the TCP/UDP pseudo-header checksum over buf, and write the result back.
write_u16be
Write a big-endian u16 into a 2-byte slice. Caller guarantees buf.len() >= 2.
write_u32be
Write a big-endian u32 into a 4-byte slice. Caller guarantees buf.len() >= 4.