Sha256: 0a4b3d13c00ad2f9be2e787d37e8f06350131121d214b811200b674860b30abb

Contents?: true

Size: 921 Bytes

Versions: 39

Compression:

Stored size: 921 Bytes

Contents

require 'pio/options'

module Pio
  class Lldp
    # User options for creating an LLDP frame.
    class Options < Pio::Options
      mandatory_option :dpid
      mandatory_option :port_number
      option :destination_mac
      option :source_mac

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

      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

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

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
pio-0.19.0 lib/pio/lldp/options.rb
pio-0.18.2 lib/pio/lldp/options.rb
pio-0.18.1 lib/pio/lldp/options.rb
pio-0.18.0 lib/pio/lldp/options.rb
pio-0.17.0 lib/pio/lldp/options.rb
pio-0.16.0 lib/pio/lldp/options.rb
pio-0.15.2 lib/pio/lldp/options.rb
pio-0.15.1 lib/pio/lldp/options.rb
pio-0.15.0 lib/pio/lldp/options.rb
pio-0.14.0 lib/pio/lldp/options.rb
pio-0.13.0 lib/pio/lldp/options.rb
pio-0.12.0 lib/pio/lldp/options.rb
pio-0.11.2 lib/pio/lldp/options.rb
pio-0.11.1 lib/pio/lldp/options.rb
pio-0.11.0 lib/pio/lldp/options.rb
pio-0.10.1 lib/pio/lldp/options.rb
pio-0.10.0 lib/pio/lldp/options.rb
pio-0.9.0 lib/pio/lldp/options.rb
pio-0.8.2 lib/pio/lldp/options.rb