Sha256: ac74a756d88512a4ca468bdad836929c6544c621e6d53f9a431e9361a684d8fd

Contents?: true

Size: 778 Bytes

Versions: 1

Compression:

Stored size: 778 Bytes

Contents

require 'bindata'
require 'pio/ethernet_header'
require 'pio/type/ip_address'
require 'pio/type/mac_address'

module Pio
  class Arp
    # ARP parser.
    class Format < BinData::Record
      include EthernetHeader

      endian :big

      ethernet_header ether_type: 0x0806
      uint16 :hardware_type, value: 1
      uint16 :protocol_type, value: 0x0800
      uint8 :hardware_length, value: 6
      uint8 :protocol_length, value: 4
      uint16 :operation
      mac_address :sender_hardware_address
      ip_address :sender_protocol_address
      mac_address :target_hardware_address
      ip_address :target_protocol_address

      def message_type
        operation
      end

      def to_binary
        to_binary_s + "\000" * (64 - num_bytes)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pio-0.16.0 lib/pio/arp/format.rb