SnmpKit.SnmpLib.PDU.Builder (snmpkit v2.0.1)
High-level PDU and message building functions for SNMP operations.
This module provides functions to build various types of SNMP PDUs and messages, including GET, GETNEXT, SET, GETBULK requests, and responses.
Summary
Functions
Builds a GETBULK request PDU for SNMPv2c.
Builds a GETNEXT request PDU.
Builds a GET request PDU.
Builds a GET request PDU with multiple varbinds.
Builds an SNMPv2c inform PDU (an acknowledged notification); see
build_trap_v2/4 for the varbinds.
Builds an SNMP message structure.
Builds a response PDU.
Builds a SET request PDU.
Builds a SET request PDU carrying several varbinds ({oid, type, value}).
Builds an SNMPv1 Trap-PDU (RFC 1157).
Builds an SNMPv2c trap PDU. The mandatory sysUpTime.0 and
snmpTrapOID.0 varbinds are prepended to varbinds.
Creates an error response PDU from a request PDU.
Validates a PDU structure.
Validates a community string against an encoded SNMP message.
Types
@type error_status() :: SnmpKit.SnmpLib.PDU.Constants.error_status()
@type message() :: SnmpKit.SnmpLib.PDU.Constants.message()
@type oid() :: SnmpKit.SnmpLib.PDU.Constants.oid()
@type pdu() :: SnmpKit.SnmpLib.PDU.Constants.pdu()
@type pdu_type() :: SnmpKit.SnmpLib.PDU.Constants.pdu_type()
@type snmp_value() :: SnmpKit.SnmpLib.PDU.Constants.snmp_value()
@type snmp_version() :: SnmpKit.SnmpLib.PDU.Constants.snmp_version()
@type varbind() :: SnmpKit.SnmpLib.PDU.Constants.varbind()
Functions
@spec build_get_bulk_request( oid(), non_neg_integer(), non_neg_integer(), non_neg_integer() ) :: pdu()
Builds a GETBULK request PDU for SNMPv2c.
Parameters
oid_list: Starting OIDrequest_id: Request identifiernon_repeaters: Number of non-repeating variables (default: 0)max_repetitions: Maximum repetitions (default: 10)
@spec build_get_next_request(oid(), non_neg_integer()) :: pdu()
Builds a GETNEXT request PDU.
@spec build_get_request(oid(), non_neg_integer()) :: pdu()
Builds a GET request PDU.
@spec build_get_request_multi([varbind()], non_neg_integer()) :: pdu()
Builds a GET request PDU with multiple varbinds.
@spec build_inform(non_neg_integer(), oid(), [varbind()], non_neg_integer()) :: pdu()
Builds an SNMPv2c inform PDU (an acknowledged notification); see
build_trap_v2/4 for the varbinds.
@spec build_message(pdu(), binary(), snmp_version()) :: message()
Builds an SNMP message structure.
Parameters
pdu: The PDU to include in the messagecommunity: Community stringversion: SNMP version (:v1, :v2c, etc.)
@spec build_response(non_neg_integer(), error_status(), non_neg_integer(), [varbind()]) :: pdu()
Builds a response PDU.
@spec build_set_request(oid(), {atom(), any()}, non_neg_integer()) :: pdu()
Builds a SET request PDU.
@spec build_set_request_multi([varbind()], non_neg_integer()) :: pdu()
Builds a SET request PDU carrying several varbinds ({oid, type, value}).
@spec build_trap_v1( oid(), :inet.ip4_address() | binary(), 0..6, non_neg_integer(), non_neg_integer(), [varbind()] ) :: pdu()
Builds an SNMPv1 Trap-PDU (RFC 1157).
agent_addr is an IPv4 tuple or 4-byte binary; generic_trap is 0..6
(6 = enterpriseSpecific); time_stamp is sysUpTime in centiseconds.
@spec build_trap_v2(non_neg_integer(), oid(), [varbind()], non_neg_integer()) :: pdu()
Builds an SNMPv2c trap PDU. The mandatory sysUpTime.0 and
snmpTrapOID.0 varbinds are prepended to varbinds.
@spec create_error_response(pdu(), error_status(), non_neg_integer()) :: pdu()
Creates an error response PDU from a request PDU.
Examples
error_pdu = SnmpKit.SnmpLib.PDU.Builder.create_error_response(request_pdu, 2, 1)
Validates a PDU structure.
Validates a community string against an encoded SNMP message.