Class: NETSNMP::V3Session
Overview
Abstraction for the v3 semantics.
Constant Summary
Constants inherited from Session
Constants included from Loggable
Loggable::DEBUG, Loggable::DEBUG_LEVEL
Instance Method Summary collapse
-
#build_pdu(type, *vars) ⇒ NETSNMP::ScopedPDU
A pdu.
-
#initialize(context: "", **opts) ⇒ V3Session
constructor
A new instance of V3Session.
- #send(pdu) ⇒ Object
Methods inherited from Session
Methods included from Loggable
Constructor Details
#initialize(context: "", **opts) ⇒ V3Session
Returns a new instance of V3Session.
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.
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
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 |