19962009 Ericsson AB. All Rights Reserved. The contents of this file are subject to the Erlang Public License, Version 1.1, (the "License"); you may not use this file except in compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. snmp_pdus snmp_pdus.xml
snmp_pdus Encode and Decode Functions for SNMP PDUs

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.

dec_message([byte()]) -> Message Decode an SNMP Message 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 Decode an SNMP Message, but not the data part 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 Decode an SNMP Pdu Pdu = #pdu

Decodes a list of bytes into an SNMP Pdu.

dec_scoped_pdu([byte()]) -> ScopedPdu Decode an SNMP ScopedPdu ScopedPdu = #scoped_pdu

Decodes a list of bytes into an SNMP ScopedPdu.

dec_scoped_pdu_data([byte()]) -> ScopedPduData Decode an SNMP ScopedPduData 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 Decode SNMP UsmSecurityParameters UsmSecParams = #usmSecurityParameters

Decodes a list of bytes into an SNMP UsmSecurityParameters

enc_encrypted_scoped_pdu(EncryptedScopedPdu) -> [byte()] Encode an encrypted SNMP scopedPDU EncryptedScopedPdu = [byte()]

Encodes an encrypted SNMP ScopedPdu into an OCTET STRING that can be used as the data field in a message record, that later can be encoded with a call to enc_message_only/1.

This function should be used whenever the ScopedPDU is encrypted.

enc_message(Message) -> [byte()] Encode an SNMP Message Message = #message

Encodes a message record to a list of bytes.

enc_message_only(Message) -> [byte()] Encode an SNMP Message, but not the data part 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()] Encode an SNMP Pdu Pdu = #pdu

Encodes an SNMP Pdu into a list of bytes.

enc_scoped_pdu(ScopedPdu) -> [byte()] Encode an SNMP scopedPDU 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()] Encode SNMP UsmSecurityParameters UsmSecParams = #usmSecurityParameters

Encodes SNMP UsmSecurityParameters into a list of bytes.