Class: Pio::Arp::Request::Options

Inherits:
Options
  • Object
show all
Defined in:
lib/pio/arp/request.rb

Overview

User options for creating an Arp Request.

Constant Summary collapse

BROADCAST_MAC =
Mac.new(0xffffffffffff).freeze
ALL_ZERO_MAC =
Mac.new(0).freeze

Instance Method Summary collapse

Methods inherited from Options

mandatory_option, option

Constructor Details

#initialize(options) ⇒ Options

Returns a new instance of Options.



21
22
23
24
25
26
27
28
# File 'lib/pio/arp/request.rb', line 21

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

Instance Method Details

#to_hashObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/pio/arp/request.rb', line 30

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