Sha256: bc21fbc2decb316265facfe1975c306995f9c2b9bba44494799af894743f4821

Contents?: true

Size: 1.3 KB

Versions: 16

Compression:

Stored size: 1.3 KB

Contents

require 'English'
require 'forwardable'
require 'pio/lldp/frame'
require 'pio/lldp/options'

# Packet parser and generator library.
module Pio
  # LLDP frame parser and generator.
  class Lldp
    extend Forwardable

    def_delegator :@frame, :destination_mac
    def_delegator :@frame, :source_mac
    def_delegator :@frame, :ether_type
    def_delegator :@frame, :chassis_id
    def_delegator :@frame, :dpid
    def_delegator :@frame, :optional_tlv
    def_delegator :@frame, :port_id
    alias_method :port_number, :port_id
    def_delegator :@frame, :ttl
    def_delegator :@frame, :port_description
    def_delegator :@frame, :system_name
    def_delegator :@frame, :system_description
    def_delegator :@frame, :system_capabilities
    def_delegator :@frame, :enabled_capabilities
    def_delegator :@frame, :management_address
    def_delegator :@frame, :organizationally_specific

    def self.read(raw_data)
      begin
        frame = Frame.read(raw_data)
      rescue
        raise Pio::ParseError, $ERROR_INFO.message
      end

      lldp = allocate
      lldp.instance_variable_set :@frame, frame
      lldp
    end

    def initialize(options)
      @frame = Frame.new(Options.new(options).to_hash)
    end

    def to_binary
      @frame.to_binary_s + "\000" * (64 - @frame.num_bytes)
    end
  end
  LLDP = Lldp
end

Version data entries

16 entries across 16 versions & 1 rubygems

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