1
<?xml version="1.0" encoding="latin1" ?>
2
<!DOCTYPE erlref SYSTEM "erlref.dtd">
7
<year>1996</year><year>2009</year>
8
<holder>Ericsson AB. All Rights Reserved.</holder>
11
The contents of this file are subject to the Erlang Public License,
12
Version 1.1, (the "License"); you may not use this file except in
13
compliance with the License. You should have received a copy of the
14
Erlang Public License along with this software. If not, it can be
15
retrieved online at http://www.erlang.org/.
17
Software distributed under the License is distributed on an "AS IS"
18
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
19
the License for the specific language governing rights and limitations
24
<title>snmp_pdus</title>
26
<responsible></responsible>
32
<file>snmp_pdus.xml</file>
34
<module>snmp_pdus</module>
35
<modulesummary>Encode and Decode Functions for SNMP PDUs</modulesummary>
37
<p>RFC1157, RFC1905 and/or RFC2272 should be studied carefully
38
before using this module, <c>snmp_pdus</c>.
40
<p>The module <c>snmp_pdus</c> contains functions for encoding
42
SNMP protocol data units (PDUs). In short, this module converts a
43
list of bytes to Erlang record representations and vice versa.
44
The record definitions can be found in the file
45
<c>snmp/include/snmp_types.hrl</c>. If snmpv3 is used, the module
46
that includes <c>snmp_types.hrl</c> must define the constant
47
<c>SNMP_USE_V3</c> before the header file is included. Example:</p>
49
-define(SNMP_USE_V3, true).
50
-include_lib("snmp/include/snmp_types.hrl"). </pre>
51
<p>Encoding and decoding must be done explicitly when writing your
57
<name>dec_message([byte()]) -> Message</name>
58
<fsummary>Decode an SNMP Message</fsummary>
60
<v>Message = #message</v>
63
<p>Decodes a list of bytes into an SNMP Message. Note, if there
64
is a v3 message, the <c>msgSecurityParameters</c> are not
65
decoded. They must be explicitly decoded by a call to a
66
security model specific decoding function,
67
e.g. <c>dec_usm_security_parameters/1</c>. Also note, if
68
the <c>scopedPDU</c> is encrypted, the OCTET STRING encoded
69
<c>encryptedPDU</c> will be present in the <c>data</c> field.</p>
73
<name>dec_message_only([byte()]) -> Message</name>
74
<fsummary>Decode an SNMP Message, but not the data part</fsummary>
76
<v>Message = #message</v>
79
<p>Decodes a list of bytes into an SNMP Message, but does not
80
decode the data part of the Message. That means, data is still
81
a list of bytes, normally an encoded <c>PDU</c> (v1 and V2) or an
82
encoded and possibly encrypted <c>scopedPDU</c> (v3).</p>
86
<name>dec_pdu([byte()]) -> Pdu</name>
87
<fsummary>Decode an SNMP Pdu</fsummary>
92
<p>Decodes a list of bytes into an SNMP Pdu.</p>
96
<name>dec_scoped_pdu([byte()]) -> ScopedPdu</name>
97
<fsummary>Decode an SNMP ScopedPdu</fsummary>
99
<v>ScopedPdu = #scoped_pdu</v>
102
<p>Decodes a list of bytes into an SNMP ScopedPdu.</p>
106
<name>dec_scoped_pdu_data([byte()]) -> ScopedPduData</name>
107
<fsummary>Decode an SNMP ScopedPduData</fsummary>
109
<v>ScopedPduData = #scoped_pdu | EncryptedPDU</v>
110
<v>EncryptedPDU = [byte()]</v>
113
<p>Decodes a list of bytes into either a scoped pdu record, or
114
- if the scoped pdu was encrypted - to a list of bytes.</p>
118
<name>dec_usm_security_parameters([byte()]) -> UsmSecParams</name>
119
<fsummary>Decode SNMP UsmSecurityParameters</fsummary>
121
<v>UsmSecParams = #usmSecurityParameters</v>
124
<p>Decodes a list of bytes into an SNMP UsmSecurityParameters</p>
128
<name>enc_encrypted_scoped_pdu(EncryptedScopedPdu) -> [byte()]</name>
129
<fsummary>Encode an encrypted SNMP scopedPDU</fsummary>
131
<v>EncryptedScopedPdu = [byte()]</v>
134
<p>Encodes an encrypted SNMP ScopedPdu into an OCTET STRING
135
that can be used as the <c>data</c> field in a
136
<c>message</c> record, that later can be encoded with a call
137
to <c>enc_message_only/1</c>.
139
<p>This function should be used whenever the <c>ScopedPDU</c>
144
<name>enc_message(Message) -> [byte()]</name>
145
<fsummary>Encode an SNMP Message</fsummary>
147
<v>Message = #message</v>
150
<p>Encodes a message record to a list of bytes.</p>
154
<name>enc_message_only(Message) -> [byte()]</name>
155
<fsummary>Encode an SNMP Message, but not the data part</fsummary>
157
<v>Message = #message</v>
160
<p><c>Message</c> is a record where the <c>data</c> field is
161
assumed to be encoded (a list of bytes). If there is a v1 or v2
162
message, the <c>data</c> field is an encoded <c>PDU</c>, and if
163
there is a v3 message, <c>data</c> is an encoded and possibly
164
encrypted <c>scopedPDU</c>.</p>
168
<name>enc_pdu(Pd) -> [byte()]</name>
169
<fsummary>Encode an SNMP Pdu</fsummary>
174
<p>Encodes an SNMP Pdu into a list of bytes.</p>
178
<name>enc_scoped_pdu(ScopedPdu) -> [byte()]</name>
179
<fsummary>Encode an SNMP scopedPDU</fsummary>
181
<v>ScopedPdu = #scoped_pdu</v>
184
<p>Encodes an SNMP ScopedPdu into a list of bytes, which can be
185
encrypted, and after encryption, encoded with
186
a call to <c>enc_encrypted_scoped_pdu/1</c>; or it can be
187
used as the <c>data</c> field in a <c>message</c> record, which
188
then can be encoded with <c>enc_message_only/1</c>.</p>
192
<name>enc_usm_security_parameters(UsmSecParams) -> [byte()]</name>
193
<fsummary>Encode SNMP UsmSecurityParameters</fsummary>
195
<v>UsmSecParams = #usmSecurityParameters</v>
198
<p>Encodes SNMP UsmSecurityParameters into a list of bytes.</p>