Class: SNMP::PDU

### Home Classes Methods

### In Files

- lib/snmp/pdu.rb

### Parent

Object

### Methods

- ::decode
- ::new
- #each_varbind
- #encode_pdu
- #error_status
- #error_status=

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- SNMP
- SNMP::BER
- SNMP::Counter32
- SNMP::Counter64
- SNMP::EndOfMibView
- SNMP::Gauge32
- SNMP::GetBulkRequest
- SNMP::GetNextRequest
- SNMP::GetRequest
- SNMP::InformRequest
- SNMP::Integer
- SNMP::Integer32
- SNMP::InvalidErrorStatus
- SNMP::InvalidGenericTrap
- SNMP::InvalidIpAddress
- SNMP::InvalidPduTag
- SNMP::InvalidTrapVarbind
- SNMP::IpAddress
- SNMP::MIB
- SNMP::MIB::ModuleNotLoadedError
- SNMP::Manager
- SNMP::Manager::Config
- SNMP::Message
- SNMP::NoSuchInstance
- SNMP::NoSuchObject
- SNMP::Null
- SNMP::ObjectId
- SNMP::ObjectName
- SNMP::OctetString
- SNMP::Opaque
- SNMP::PDU
- SNMP::ParseError
- SNMP::RequestId
- SNMP::RequestTimeout
- SNMP::Response
- SNMP::SNMPv1_Trap
- SNMP::SNMPv2_Trap
- SNMP::SetRequest
- SNMP::TimeTicks
- SNMP::TrapListener
- SNMP::TrapListener::Config
- SNMP::UDPServerTransport
- SNMP::UDPTransport
- SNMP::Unsigned32
- SNMP::UnsignedInteger
- SNMP::UnsupportedPduTag
- SNMP::UnsupportedValueTag
- SNMP::UnsupportedVersion
- SNMP::VarBind
- SNMP::VarBindList
- Fixnum
- Object

No matching classes.

# 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 122
    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 155
    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 185
    def each_varbind(&block)
      @varbind_list.each(&block)
    end

encode_pdu(pdu_tag) click to toggle source

    # File lib/snmp/pdu.rb, line 177
    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 173
    def error_status
      ERROR_STATUS_NAME[@error_status]
    end

error_status=(status) click to toggle source

    # File lib/snmp/pdu.rb, line 162
    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

[Validate]

Generated with the Darkfish Rdoc Generator 2.