| 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
EthMac :eth_dst # See EthMac EthMac :eth_src # See EthMac Int16 :eth_proto, Default: 0x8000 # IP 0x0800, Arp 0x0806 String :body
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"