class PacketGen::Header::Eth

An Ethernet header consists of:

Create a Ethernet header

# standalone
eth = PacketGen::Header::Eth.new
# in a packet
pkt = PacketGen.gen('Eth')
# access to Ethernet header
pkt.eth   # => PacketGen::Header::Eth

Ethernet attributes

eth.dst = "00:01:02:03:04:05"
eth.src        # => "00:01:01:01:01:01"
eth[:src]      # => PacketGen::Header::Eth::MacAddr
eth.ethertype  # => 16-bit Integer
eth.body = "This is a body"

@author Sylvain Daubert

Public Instance Methods

reply!() click to toggle source

Invert destination and source addresses @return [self] @since 2.7.0

# File lib/packetgen/header/eth.rb, line 107
def reply!
  self[:src], self[:dst] = self[:dst], self[:src]
  self
end
to_w(iface) click to toggle source

send Eth packet on wire. @param [String] iface interface name @return [void]

# File lib/packetgen/header/eth.rb, line 100
def to_w(iface)
  Inject.inject(iface: iface, data: self)
end