Module: Pio::Type::EthernetHeader
- Included in:
- Arp::Format, Dhcp::Frame, Icmp::Format, Lldp::Frame, PacketIn::DataParser::EthernetHeaderParser, PacketIn::DataParser::IPv4Packet
- Defined in:
- lib/pio/type/ethernet_header.rb
Overview
Adds ethernet_header macro.
Instance Method Summary collapse
-
#ethernet_header(options = { ether_type: 0x0800 }) ⇒ Object
rubocop:disable MethodLength rubocop:disable AbcSize.
Instance Method Details
#ethernet_header(options = { ether_type: 0x0800 }) ⇒ Object
rubocop:disable MethodLength rubocop:disable AbcSize
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/pio/type/ethernet_header.rb', line 9 def ethernet_header( = { ether_type: 0x0800 }) class_eval do mac_address :destination_mac mac_address :source_mac uint16 :ether_type_internal, initial_value: [:ether_type] bit3 :vlan_pcp_internal, onlyif: -> { vlan? } bit1 :vlan_cfi, onlyif: -> { vlan? } bit12 :vlan_vid_internal, onlyif: -> { vlan? } uint16 :ether_type_vlan, onlyif: -> { vlan? }, initial_value: [:ether_type] def ether_type ether_type_internal end def vlan_vid vlan? ? vlan_vid_internal : 0xffff end def vlan_pcp vlan? ? vlan_pcp_internal : 0 end def vlan? ether_type == 0x8100 end end end |