NAME
snmp_msg_Encode, snmp_msg_Decode - Encode and Decode an ASN1/BER encoded SNMP packet

SYNOPSIS
cc [ flag ... ] file ... -lsnmp [ library ... ]

#include <sys/types.h>
#include <snmp/snmp.h>

unsigned char *snmp_msg_Encode(unsigned char * Buf, int * BufLenP, unsigned char * Community, int CommLen, int Version, struct snmp_pdu * PDU);

unsigned char *snmp_msg_Decode(unsigned char * Buf, int * BufLenP, unsigned char * Community, int *CommLen, int *Version, struct snmp_pdu * PDU);

DESCRIPTION
These functions encode/decode an SNMP PDU to/from an ASN1/BER stream. Buf points to a buffer containing (or about to contain) the stream, and BuflenP points to the number of bytes left in the buffer. Community is the community string to use (length CommLen). When decoding, this buffer is filled, and must contain enough space for the data. Version is the version (or is set to the version) of this SNMP transaction. PDU is an empty PDU structure to fill in with the decoded data.

RETURN VALUES
Upon error, both functions return NULL. Otherwise, they return a pointer to the next byte in Buf, and set BufLenP to the number of bytes remaining in the buffer.

ERRORS
If any of these return unsuccessfully, snmp_api_error() will be set.

NOTES
ASN parsing errors are counted and available via snmpInASNParseErrs(3) and snmpInBadVersions(3)