Sha256: f86daf44408819356b1de1248d41dd2c918b195416a3128fc3e9a85dcf16ff89

Contents?: true

Size: 1.31 KB

Versions: 6

Compression:

Stored size: 1.31 KB

Contents

# encoding: utf-8

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

6 entries across 6 versions & 1 rubygems

Version Path
pio-0.8.1 lib/pio/arp/reply.rb
pio-0.8.0 lib/pio/arp/reply.rb
pio-0.7.0 lib/pio/arp/reply.rb
pio-0.6.0 lib/pio/arp/reply.rb
pio-0.5.0 lib/pio/arp/reply.rb
pio-0.4.0 lib/pio/arp/reply.rb