Class PacketFu::EthHeader
In: lib/packetfu/eth.rb
Parent: Struct.new(:eth_dst, :eth_src, :eth_proto, :body)

EthHeader is a complete Ethernet struct, used in EthPacket. It‘s the base header for all other protocols, such as IPHeader, TCPHeader, etc.

For more on the construction on MAC addresses, see en.wikipedia.org/wiki/MAC_address

Header Definition

 EthMac  :eth_dst                     # See EthMac
 EthMac  :eth_src                     # See EthMac
 Int16   :eth_proto, Default: 0x8000  # IP 0x0800, Arp 0x0806
 String  :body

Methods

eth_daddr   eth_daddr=   eth_dst   eth_dst=   eth_proto   eth_proto=   eth_saddr   eth_saddr=   eth_src   eth_src=   mac2str   new   read   str2mac   to_s  

Included Modules

StructFu

Public Class methods

Converts a readable MAC (11:22:33:44:55:66) to a binary string. Readable MAC‘s may be split on colons, dots, spaces, or underscores.

irb> PacketFu::EthHeader.mac2str("11:22:33:44:55:66")

#=> "\021\"3DUf"

Converts a binary string to a readable MAC (11:22:33:44:55:66).

irb> PacketFu::EthHeader.str2mac("\x11\x22\x33\x44\x55\x66")

#=> "11:22:33:44:55:66"

Public Instance methods

Gets the destination MAC address in a more readable way.

Set the destination MAC address in a more readable way.

Getter for the Ethernet destination address.

Setter for the Ethernet destination address.

Getter for the Ethernet protocol number.

Setter for the Ethernet protocol number.

Gets the source MAC address in a more readable way.

Sets the source MAC address in a more readable way.

Getter for the Ethernet source address.

Setter for the Ethernet source address.

Reads a string to populate the object.

Returns the object in string form.

[Validate]