Sha256: 566b46ce4b0c1e708356fb791348d377e79ca78d2e2f15bc474b49c81b590989
Contents?: true
Size: 1.09 KB
Versions: 6
Compression:
Stored size: 1.09 KB
Contents
require 'pio/type/mac_address' module Pio module Type # Adds ethernet_header macro. module EthernetHeader # rubocop:disable MethodLength # rubocop:disable AbcSize def ethernet_header(options = { ether_type: 0x0800 }) class_eval do mac_address :destination_mac mac_address :source_mac uint16 :ether_type_internal, initial_value: options[: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: options[: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 # rubocop:enable MethodLength # rubocop:enable AbcSize end end end
Version data entries
6 entries across 6 versions & 1 rubygems