SnmpKit.SnmpSim.PDUHelper (snmpkit v2.0.1)

Provides utility functions for PDU manipulation.

Summary

Functions

RFC 1157 4.1.3: an SNMPv1 agent answers a GET/GETNEXT that runs off the end of the MIB (or names an unknown object) with error-status noSuchName(2), error-index set to the offending varbind, and the request's varbinds echoed unchanged. SNMPv2c instead reports per-varbind exceptions with error-status 0 (RFC 3416 4.2.2 / 4.2.3).

Converts a PDU version atom (e.g., :v1, :v2c) to its integer representation. Defaults to 2 (for SNMPv2c) if the atom is not :v1.

Normalizes the version carried in a simulator PDU to :v1 or :v2c.

Functions

apply_v1_error_semantics(response, atom, request_varbinds)

@spec apply_v1_error_semantics(map(), :v1 | :v2c, list()) :: map()

RFC 1157 4.1.3: an SNMPv1 agent answers a GET/GETNEXT that runs off the end of the MIB (or names an unknown object) with error-status noSuchName(2), error-index set to the offending varbind, and the request's varbinds echoed unchanged. SNMPv2c instead reports per-varbind exceptions with error-status 0 (RFC 3416 4.2.2 / 4.2.3).

Given a response built with v2c semantics, this converts it to the v1 form when needed. request_varbinds are the varbinds of the original request.

pdu_version_to_int(arg1)

Converts a PDU version atom (e.g., :v1, :v2c) to its integer representation. Defaults to 2 (for SNMPv2c) if the atom is not :v1.

snmp_version(arg1)

@spec snmp_version(map() | term()) :: :v1 | :v2c

Normalizes the version carried in a simulator PDU to :v1 or :v2c.

The UDP server sets version to the message version plus one (1 = SNMPv1, 2 = SNMPv2c); other callers pass :v1 / :v2c / :v2 atoms or the raw wire value (0 = SNMPv1, 1 = SNMPv2c) with :wire tagging. Anything unrecognised is treated as SNMPv2c.