Sha256: f727b91f1d5ce909e2a85c827f60bd89b29def284c703900eed24cff1d9a0f23

Contents?: true

Size: 938 Bytes

Versions: 1

Compression:

Stored size: 938 Bytes

Contents

# frozen_string_literal: true

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'
      DEFAULT_SOURCE_MAC = '01:02:03:04:05:06'

      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

1 entries across 1 versions & 1 rubygems

Version Path
pio-0.30.2 lib/pio/lldp/options.rb