Skip to main content

build_ip_packet

Function build_ip_packet 

Source
pub(crate) fn build_ip_packet(
    src: &Address,
    dst: &Address,
    ttl: u8,
    identifier: u16,
    payload: PacketPayload,
) -> Vec<u8> 
Expand description

Wrap a transport-layer payload in an IPv4 or IPv6 header.

The IP protocol / IPv6 next-header is derived from the payload variant. identifier is written to the IPv4 Identification field, or to the low 16 bits of the IPv6 Flow Label.

§Returns

The packet as a vector of bytes.

§Panics

If src and dst are different IP versions (or unset).