---
name: "snmp_pdus"
section: "3erl"
platform: "linux"
package: "erlang-manpages"
version: "1:25.2.3+dfsg-1+deb12u4"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/snmp_pdus"
---

# snmp\_pdus(3erl)

Encode and Decode Functions for SNMP PDUs

## NAME

snmp\_pdus - Encode and Decode Functions for SNMP PDUs

## DESCRIPTION

RFC1157, RFC1905 and/or RFC2272 should be studied carefully before using this module, *snmp\_pdus*.

The module *snmp\_pdus* contains functions for encoding and decoding of SNMP protocol data units (PDUs). In short, this module converts a list of bytes to Erlang record representations and vice versa. The record definitions can be found in the file *snmp/include/snmp\_types.hrl*. If snmpv3 is used, the module that includes *snmp\_types.hrl* must define the constant *SNMP\_USE\_V3* before the header file is included. Example:

```
-define(SNMP_USE_V3, true).
-include_lib("snmp/include/snmp_types.hrl").
```

Encoding and decoding must be done explicitly when writing your own Net if process.

## EXPORTS

**dec\_message(\[byte()\]) -\> Message**\

Types:

Message = #message\

Decodes a list of bytes into an SNMP Message. Note, if there is a v3 message, the *msgSecurityParameters* are not decoded. They must be explicitly decoded by a call to a security model specific decoding function, e.g. *dec\_usm\_security\_parameters/1*. Also note, if the *scopedPDU* is encrypted, the OCTET STRING encoded *encryptedPDU* will be present in the *data* field.

**dec\_message\_only(\[byte()\]) -\> Message**\

Types:

Message = #message\

Decodes a list of bytes into an SNMP Message, but does not decode the data part of the Message. That means, data is still a list of bytes, normally an encoded *PDU* (v1 and V2) or an encoded and possibly encrypted *scopedPDU* (v3).

**dec\_pdu(\[byte()\]) -\> Pdu**\

Types:

Pdu = #pdu\

Decodes a list of bytes into an SNMP Pdu.

**dec\_scoped\_pdu(\[byte()\]) -\> ScopedPdu**\

Types:

ScopedPdu = #scoped\_pdu\

Decodes a list of bytes into an SNMP ScopedPdu.

**dec\_scoped\_pdu\_data(\[byte()\]) -\> ScopedPduData**\

Types:

ScopedPduData = #scoped\_pdu \| EncryptedPDU\
 EncryptedPDU = \[byte()\]\

Decodes a list of bytes into either a scoped pdu record, or - if the scoped pdu was encrypted - to a list of bytes.

**dec\_usm\_security\_parameters(\[byte()\]) -\> UsmSecParams**\

Types:

UsmSecParams = #usmSecurityParameters\

Decodes a list of bytes into an SNMP UsmSecurityParameters

**enc\_message(Message) -\> \[byte()\]**\

Types:

Message = #message\

Encodes a message record to a list of bytes.

**enc\_message\_only(Message) -\> \[byte()\]**\

Types:

Message = #message\

*Message* is a record where the *data* field is assumed to be encoded (a list of bytes). If there is a v1 or v2 message, the *data* field is an encoded *PDU*, and if there is a v3 message, *data* is an encoded and possibly encrypted *scopedPDU*.

**enc\_pdu(Pd) -\> \[byte()\]**\

Types:

Pdu = #pdu\

Encodes an SNMP Pdu into a list of bytes.

**enc\_scoped\_pdu(ScopedPdu) -\> \[byte()\]**\

Types:

ScopedPdu = #scoped\_pdu\

Encodes an SNMP ScopedPdu into a list of bytes, which can be encrypted, and after encryption, encoded with a call to *enc\_encrypted\_scoped\_pdu/1*; or it can be used as the *data* field in a *message* record, which then can be encoded with *enc\_message\_only/1*.

**enc\_usm\_security\_parameters(UsmSecParams) -\> \[byte()\]**\

Types:

UsmSecParams = #usmSecurityParameters\

Encodes SNMP UsmSecurityParameters into a list of bytes.
