struct

Tuntap::IpPacket

Inherits Struct / Value / Object

Provides easy access to the IP header and its payload.

Constructors

new(frame : Bytes, has_pi : Bool = true, has_ethernet : Bool = false)

Encapsulates frame as a IPv4 packet with or without the PI header (has_pi). has_ethernet commonly refers to the source being a TUN (= false) or TAP (= true) device.

Source

Instance methods

[](*args, **options)
Source
[](*args, **options, &)
Source
destination_address

The destination address of the IP header as readable string.

Source
destination_mac

The destination hardware address.

Source
ethernet

Returns the ethernet header. If this packet does not have it, the returned header will contain junk data.

Source
frame

The whole packet

Source
has_ethernet?

Does the frame have an ethernet header?

Source
has_pi?

Does the frame has the PI header?

Source
ip_header_length

Length of the IP header

Source
ipv4

Returns the IPv4 header from the packet. No check is done if the packet really contains IPv4 data.

Source
pi

Returns the PI header. If this packet does not have it, the returned header will contain junk data.

Source
size(*args, **options)
Source
size(*args, **options, &)
Source
source_address

The source address of the IP header as readable string.

Source
source_mac

The source hardware address.

Source
without_ethernet

Returns the frame without the ethernet header (if there is one).

Source
without_ip

Returns the IP payload

Source
without_pi

Returns the frame without the PI header (if there is one)

Source