Sha256: 7dac3f6290db6831ddf666a7a1d456f8157399a846d315902a59a4f38f3c8c4c

Contents?: true

Size: 744 Bytes

Versions: 6

Compression:

Stored size: 744 Bytes

Contents

# encoding: utf-8

require 'bindata'

module Pio
  class Lldp
    # Port ID TLV
    class PortIdTlv < BinData::Primitive
      endian :big

      bit7 :tlv_type, value: 2
      bit9 :tlv_info_length, initial_value: -> { port_id.num_bytes + 1 }
      uint8 :subtype, initial_value: 7
      string :port_id, read_length: -> { tlv_info_length - 1 }

      def get
        tmp_id = port_id

        if subtype == 7
          BinData::Uint32be.read tmp_id
        else
          tmp_id
        end
      end

      def set(value)
        self.port_id = if subtype == 7
                         BinData::Uint32be.new(value).to_binary_s
                       else
                         value
                       end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pio-0.8.1 lib/pio/lldp/port_id_tlv.rb
pio-0.8.0 lib/pio/lldp/port_id_tlv.rb
pio-0.7.0 lib/pio/lldp/port_id_tlv.rb
pio-0.6.0 lib/pio/lldp/port_id_tlv.rb
pio-0.5.0 lib/pio/lldp/port_id_tlv.rb
pio-0.4.0 lib/pio/lldp/port_id_tlv.rb