Sha256: 1d7c2c8c559082ee40b1b52ced87a145a30c6c8b29123b3a435d1a7819733a3c

Contents?: true

Size: 807 Bytes

Versions: 3

Compression:

Stored size: 807 Bytes

Contents

# encoding: utf-8

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

module Pio
  class Arp
    # ARP parser.
    class Format < BinData::Record
      extend Type::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

3 entries across 3 versions & 1 rubygems

Version Path
pio-0.8.1 lib/pio/arp/format.rb
pio-0.8.0 lib/pio/arp/format.rb
pio-0.7.0 lib/pio/arp/format.rb