Class: Pio::Lldp::Options

Inherits:
Options
  • Object
show all
Defined in:
lib/pio/lldp/options.rb

Overview

User options for creating an LLDP frame.

Constant Summary collapse

DEFAULT_DESTINATION_MAC =
'01:80:c2:00:00:0e'
DEFAULT_SOURCE_MAC =
'01:02:03:04:05:06'

Instance Method Summary collapse

Methods inherited from Options

mandatory_option, option

Constructor Details

#initialize(options) ⇒ Options

Returns a new instance of Options.



17
18
19
20
21
22
23
24
25
# File 'lib/pio/lldp/options.rb', line 17

def initialize(options)
  validate options
  @dpid = options[:dpid].freeze
  @port_id = options[:port_number].freeze
  @destination_mac =
    Mac.new(options[:destination_mac] || DEFAULT_DESTINATION_MAC).freeze
  @source_mac =
    Mac.new(options[:source_mac] || DEFAULT_SOURCE_MAC).freeze
end

Instance Method Details

#to_hashObject



27
28
29
30
31
32
33
34
# File 'lib/pio/lldp/options.rb', line 27

def to_hash
  {
    chassis_id: @dpid,
    port_id: @port_id,
    destination_mac: @destination_mac,
    source_mac: @source_mac
  }.freeze
end