Class: PacketGen::Header::Eth
- Defined in:
- lib/packetgen/header/eth.rb
Overview
An Ethernet header consists of:
-
a destination MAC address (MacAddr),
-
a source MAC address (MacAddr),
-
a #ethertype (
BinStruct::Int16
), -
and a body (a
BinStruct::String
or another PacketGen::Headerable class).
Defined Under Namespace
Classes: MacAddr
Instance Attribute Summary collapse
- #body ⇒ BinStruct::String, Headerable
-
#dst ⇒ ::String
Destination MAC address.
-
#ethertype ⇒ Integer
16-bit integer to determine payload type.
-
#src ⇒ ::String
Source MAC address.
Instance Method Summary collapse
-
#reply! ⇒ self
Invert destination and source addresses.
-
#to_w(iface) ⇒ void
send Eth packet on wire.
Methods inherited from Base
bind, calculate_and_set_length, #header_id, inherited, #initialize, #ip_header, #ll_header
Methods included from PacketGen::Headerable
#added_to_packet, included, #method_name, #packet, #packet=, #parse?, #protocol_name, #read, #to_s
Constructor Details
This class inherits a constructor from PacketGen::Header::Base
Instance Attribute Details
#body ⇒ BinStruct::String, Headerable
110 |
# File 'lib/packetgen/header/eth.rb', line 110 define_attr :body, BinStruct::String |
#dst ⇒ ::String
Destination MAC address
100 |
# File 'lib/packetgen/header/eth.rb', line 100 define_attr :dst, MacAddr, default: '00:00:00:00:00:00' |
#ethertype ⇒ Integer
Returns 16-bit integer to determine payload type.
107 |
# File 'lib/packetgen/header/eth.rb', line 107 define_attr :ethertype, BinStruct::Int16, default: 0 |
#src ⇒ ::String
Source MAC address
104 |
# File 'lib/packetgen/header/eth.rb', line 104 define_attr :src, MacAddr, default: '00:00:00:00:00:00' |
Instance Method Details
#reply! ⇒ self
Invert destination and source addresses
122 123 124 125 |
# File 'lib/packetgen/header/eth.rb', line 122 def reply! self[:src], self[:dst] = self[:dst], self[:src] self end |