Module: Pio::Ethernet

Included in:
Arp::Format, Dhcp::Frame, EthernetFrame, EthernetHeader, Icmp::Format, Lldp::Frame, Parser::IPv4Packet, Udp
Defined in:
lib/pio/ethernet_header.rb

Overview

Adds ethernet_header macro.

Defined Under Namespace

Modules: Type

Constant Summary collapse

MINIMUM_FRAME_SIZE =
64

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

This method smells of :reek:TooManyStatements rubocop:disable MethodLength



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pio/ethernet_header.rb', line 24

def self.included(klass)
  def klass.ethernet_header(options = nil)
    mac_address :destination_mac
    mac_address :source_mac
    if options
      ether_type :ether_type, value: options.fetch(:ether_type)
    else
      ether_type :ether_type
    end
    bit3 :vlan_pcp, onlyif: :vlan?
    bit1 :vlan_cfi, onlyif: :vlan?
    bit12 :vlan_vid, onlyif: :vlan?
    uint16 :ether_type_vlan, value: :ether_type, onlyif: :vlan?
  end
end

Instance Method Details

#ethernet_header_lengthObject

rubocop:enable MethodLength



41
42
43
# File 'lib/pio/ethernet_header.rb', line 41

def ethernet_header_length
  vlan? ? 18 : 14
end