Sha256: 13e6b48db1d3dd3faa547caed806b070b53833c421e137b734facca71350d1ad

Contents?: true

Size: 1.29 KB

Versions: 38

Compression:

Stored size: 1.29 KB

Contents

require 'pio/arp/message'
require 'pio/mac'
require 'pio/options'

module Pio
  class Arp
    # ARP Reply packet generator
    class Reply < Message
      OPERATION = 2
      public_class_method :new

      # User options for creating an Arp Reply.
      class Options < Pio::Options
        mandatory_option :source_mac
        mandatory_option :destination_mac
        mandatory_option :sender_protocol_address
        mandatory_option :target_protocol_address

        def initialize(options)
          validate options
          @source_mac = Mac.new(options[:source_mac]).freeze
          @destination_mac = Mac.new(options[:destination_mac]).freeze
          @sender_protocol_address =
            IPv4Address.new(options[:sender_protocol_address]).freeze
          @target_protocol_address =
            IPv4Address.new(options[:target_protocol_address]).freeze
        end

        def to_hash
          {
            operation: OPERATION,
            source_mac: @source_mac,
            destination_mac: @destination_mac,
            sender_hardware_address: @source_mac,
            target_hardware_address: @destination_mac,
            sender_protocol_address: @sender_protocol_address,
            target_protocol_address: @target_protocol_address
          }.freeze
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
pio-0.30.0 lib/pio/arp/reply.rb
pio-0.29.0 lib/pio/arp/reply.rb
pio-0.28.1 lib/pio/arp/reply.rb
pio-0.28.0 lib/pio/arp/reply.rb
pio-0.27.2 lib/pio/arp/reply.rb
pio-0.27.1 lib/pio/arp/reply.rb
pio-0.27.0 lib/pio/arp/reply.rb
pio-0.26.0 lib/pio/arp/reply.rb
pio-0.25.0 lib/pio/arp/reply.rb
pio-0.24.2 lib/pio/arp/reply.rb
pio-0.24.1 lib/pio/arp/reply.rb
pio-0.24.0 lib/pio/arp/reply.rb
pio-0.23.1 lib/pio/arp/reply.rb
pio-0.23.0 lib/pio/arp/reply.rb
pio-0.22.0 lib/pio/arp/reply.rb
pio-0.21.1 lib/pio/arp/reply.rb
pio-0.21.0 lib/pio/arp/reply.rb
pio-0.20.1 lib/pio/arp/reply.rb
pio-0.20.0 lib/pio/arp/reply.rb
pio-0.19.0 lib/pio/arp/reply.rb