SnmpKit.Agent.Request (snmpkit v2.0.1)

Answers one request PDU against an agent's registered subtrees: GET, GETNEXT, GETBULK and SET with SNMPv1 and SNMPv2c/v3 semantics (RFC 1157, RFC 3416, and the v1/v2 error mapping of RFC 3584). Used by SnmpKit.Agent; it has no state of its own.

Summary

Functions

Handles pdu (as delivered by SnmpKit.SnmpSim.Core.Server) and returns the response PDU. subtrees must be sorted by prefix, longest first; level is the requester's access: :read, :write, or :none for a principal the agent does not know, whose request is not answered at all (:drop), whatever its type. The server drops unknown communities and USM rejects unknown v3 users before a PDU gets here, so :none is a second line of defence, not the normal path.

The value at oid, as the agent would answer a GET for it.

The object after oid, as the agent would answer a GETNEXT.

Types

subtree()

@type subtree() :: %{prefix: [non_neg_integer()], module: module(), ctx: term()}

Functions

handle(pdu, subtrees, level)

@spec handle(map(), [subtree()], :read | :write | :none) :: map() | :drop

Handles pdu (as delivered by SnmpKit.SnmpSim.Core.Server) and returns the response PDU. subtrees must be sorted by prefix, longest first; level is the requester's access: :read, :write, or :none for a principal the agent does not know, whose request is not answered at all (:drop), whatever its type. The server drops unknown communities and USM rejects unknown v3 users before a PDU gets here, so :none is a second line of defence, not the normal path.

lookup(oid, subtrees)

@spec lookup([non_neg_integer()], [subtree()]) ::
  {:ok, {atom(), term()}} | {:error, :no_such_object | :no_such_instance}

The value at oid, as the agent would answer a GET for it.

next(oid, subtrees)

@spec next([non_neg_integer()], [subtree()]) ::
  {:ok, {[non_neg_integer()], atom(), term()}} | :end_of_mib_view

The object after oid, as the agent would answer a GETNEXT.