Class: PacketGen::Header::SNMP::GetRequest

Inherits:
RASN1::Model
  • Object
show all
Defined in:
lib/packetgen/header/snmp.rb

Overview

Class to handle GetRequest PDU

GetRequest-PDU ::= [0] IMPLICIT PDU

PDU ::= SEQUENCE {
            request-id INTEGER (-214783648..214783647),

            error-status                -- sometimes ignored
                INTEGER {
                    noError(0),
                    tooBig(1),
                    noSuchName(2),      -- for proxy compatibility
                    badValue(3),        -- for proxy compatibility
                    readOnly(4),        -- for proxy compatibility
                    genErr(5),
                    noAccess(6),
                    wrongType(7),
                    wrongLength(8),
                    wrongEncoding(9),
                    wrongValue(10),
                    noCreation(11),
                    inconsistentValue(12),
                    resourceUnavailable(13),
                    commitFailed(14),
                    undoFailed(15),
                    authorizationError(16),
                    notWritable(17),
                    inconsistentName(18)
                },

            error-index                 -- sometimes ignored
                INTEGER (0..max-bindings),

            variable-bindings           -- values are sometimes ignored
                VarBindList
        }

This class defines a GetRequest SNMP PDU. It defines 4 attributes:

  • an :id (request-id, type RASN1::Types::Integer),

  • an :error (error-status, type +RASN1::Types::Integer with enumeration definition from ERRORS),

  • an :error_index (type RASN1::Types::Integer),

  • a :barbindlist (variable-bindings, type VariableBindings).

Examples:

req = PacketGen::Header::SNMP::GetRequest.new(id: 1, error: "no_error")
req[:id].value    #=> 1
req[:error].value #=> "no_error"
req[:error].to_i  #=> 0
req[:varbindlist] << { name: "1.2.3.4", value: RASN1::Types::OctetString.new(value: "abcd") }

Author:

  • Sylvain Daubert

  • LemonTree55

Since:

  • 2.0.0

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ GetRequest

Returns a new instance of GetRequest.

Since:

  • 2.0.0


204
205
206
# File 'lib/packetgen/header/snmp.rb', line 204

def initialize(args={})
  super
end