struct Tuntap::IpPacket

Overview

Provides easy access to the IP header and its payload.

Defined in:

tuntap/ip_packet.cr

Constructors

Instance Method Summary

Constructor Detail

def self.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.


[View source]

Instance Method Detail

def [](*args, **options) #

[View source]
def [](*args, **options, &) #

[View source]
def destination_address : String #

The destination address of the IP header as readable string.


[View source]
def destination_mac : String #

The destination hardware address.


[View source]
def ethernet : Header::Ethernet #

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


[View source]
def frame : Bytes #

The whole packet


[View source]
def has_ethernet? : Bool #

Does the frame have an ethernet header?


[View source]
def has_pi? : Bool #

Does the frame has the PI header?


[View source]
def ip_header_length #

Length of the IP header


[View source]
def ipv4 : Header::Ipv4 #

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


[View source]
def pi : Header::Pi #

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


[View source]
def size(*args, **options) #

[View source]
def size(*args, **options, &) #

[View source]
def source_address : String #

The source address of the IP header as readable string.


[View source]
def source_mac : String #

The source hardware address.


[View source]
def without_ethernet : Bytes #

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


[View source]
def without_ip : Bytes #

Returns the IP payload


[View source]
def without_pi : Bytes #

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


[View source]