class SNMP::PDU

Constants

ERROR_STATUS_CODE
ERROR_STATUS_NAME

Attributes

error_index[RW]
request_id[RW]
varbind_list[RW]
vb_list[RW]

Public Class Methods

decode(pdu_class, pdu_data, mib=nil) click to toggle source
# File lib/snmp/pdu.rb, line 135
def self.decode(pdu_class, pdu_data, mib=nil)
  request_id, remainder = decode_integer(pdu_data)
  error_status, remainder = decode_integer(remainder)
  error_index, remainder = decode_integer(remainder)
  varbind_list, remainder = VarBindList.decode(remainder, mib)
  assert_no_remainder(remainder)
  pdu_class.new(request_id, varbind_list, error_status, error_index)
end
new(request_id, varbind_list, error_status=0, error_index=0) click to toggle source
# File lib/snmp/pdu.rb, line 168
def initialize(request_id, varbind_list, error_status=0, error_index=0)
  @request_id = request_id
  self.error_status = error_status
  @error_index = error_index.to_int
  @varbind_list = varbind_list
end

Public Instance Methods

each_varbind(&block) click to toggle source
# File lib/snmp/pdu.rb, line 198
def each_varbind(&block)
  @varbind_list.each(&block)
end
encode_pdu(pdu_tag) click to toggle source
# File lib/snmp/pdu.rb, line 190
def encode_pdu(pdu_tag)
  pdu_data = encode_integer(@request_id)
  pdu_data << encode_integer(@error_status)
  pdu_data << encode_integer(@error_index)
  pdu_data << @varbind_list.encode
  encode_tlv(pdu_tag, pdu_data)
end
error_status() click to toggle source
# File lib/snmp/pdu.rb, line 186
def error_status
  ERROR_STATUS_NAME[@error_status]
end
error_status=(status) click to toggle source
# File lib/snmp/pdu.rb, line 175
def error_status=(status)
  @error_status = ERROR_STATUS_CODE[status]
  unless @error_status
    if status.respond_to?(:to_int) && ERROR_STATUS_NAME[status.to_int]
      @error_status = status
    else
      raise InvalidErrorStatus, status.to_s
    end
  end
end