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.30.1 lib/pio/lldp/options.rb
pio-0.30.0 lib/pio/lldp/options.rb
pio-0.29.0 lib/pio/lldp/options.rb
pio-0.28.1 lib/pio/lldp/options.rb
pio-0.28.0 lib/pio/lldp/options.rb
pio-0.27.2 lib/pio/lldp/options.rb
pio-0.27.1 lib/pio/lldp/options.rb
pio-0.27.0 lib/pio/lldp/options.rb
pio-0.26.0 lib/pio/lldp/options.rb
pio-0.25.0 lib/pio/lldp/options.rb
pio-0.24.2 lib/pio/lldp/options.rb
pio-0.24.1 lib/pio/lldp/options.rb
pio-0.24.0 lib/pio/lldp/options.rb
pio-0.23.1 lib/pio/lldp/options.rb
pio-0.23.0 lib/pio/lldp/options.rb
pio-0.22.0 lib/pio/lldp/options.rb
pio-0.21.1 lib/pio/lldp/options.rb
pio-0.21.0 lib/pio/lldp/options.rb
pio-0.20.1 lib/pio/lldp/options.rb
pio-0.20.0 lib/pio/lldp/options.rb