Class: NETSNMP::V3Session

Inherits:
Session
  • Object
show all
Defined in:
lib/netsnmp/v3_session.rb

Overview

Abstraction for the v3 semantics.

Constant Summary

Constants inherited from Session

Session::TIMEOUT

Constants included from Loggable

Loggable::DEBUG, Loggable::DEBUG_LEVEL

Instance Method Summary collapse

Methods inherited from Session

#close

Methods included from Loggable

#initialize_logger

Constructor Details

#initialize(context: "", **opts) ⇒ V3Session

Returns a new instance of V3Session.

Parameters:

  • version (String, Integer)

    SNMP version (always 3)



7
8
9
10
11
12
# File 'lib/netsnmp/v3_session.rb', line 7

def initialize(context: "", **opts)
  @context = context
  @security_parameters = opts.delete(:security_parameters)
  super
  @message_serializer = Message.new(**opts)
end

Instance Method Details

#build_pdu(type, *vars) ⇒ NETSNMP::ScopedPDU

Returns a pdu.

Returns:

See Also:

  • NETSNMP::V3Session.{NETSNMP{NETSNMP::Session{NETSNMP::Session#build_pdu}


17
18
19
20
# File 'lib/netsnmp/v3_session.rb', line 17

def build_pdu(type, *vars)
  engine_id = security_parameters.engine_id
  ScopedPDU.build(type, engine_id: engine_id, context: @context, varbinds: vars)
end

#send(pdu) ⇒ Object

See Also:

  • NETSNMP::V3Session.{NETSNMP{NETSNMP::Session{NETSNMP::Session#send}


23
24
25
26
27
28
29
# File 'lib/netsnmp/v3_session.rb', line 23

def send(pdu)
  log { "sending request..." }
  encoded_request = encode(pdu)
  encoded_response = @transport.send(encoded_request)
  response_pdu, * = decode(encoded_response)
  response_pdu
end