aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/doc/src/snmp_pdus.xml
blob: f403b6edf4da2416ec6744d67823c3b1bec4e061 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">

<erlref>
  <header>
    <copyright>
      <year>1996</year><year>2016</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
 
          http://www.apache.org/licenses/LICENSE-2.0

      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
    
    </legalnotice>

    <title>snmp_pdus</title>
    <prepared></prepared>
    <responsible></responsible>
    <docno></docno>
    <approved></approved>
    <checked></checked>
    <date></date>
    <rev></rev>
    <file>snmp_pdus.xml</file>
  </header>
  <module since="">snmp_pdus</module>
  <modulesummary>Encode and Decode Functions for SNMP PDUs</modulesummary>
  <description>
    <p>RFC1157, RFC1905 and/or RFC2272 should be studied carefully
      before using this module, <c>snmp_pdus</c>.
      </p>
    <p>The module <c>snmp_pdus</c> 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
      <c>snmp/include/snmp_types.hrl</c>.  If snmpv3 is used, the module
      that includes <c>snmp_types.hrl</c> must define the constant
      <c>SNMP_USE_V3</c> before the header file is included.  Example:</p>
    <pre>
-define(SNMP_USE_V3, true).
-include_lib("snmp/include/snmp_types.hrl").    </pre>
    <p>Encoding and decoding must be done explicitly when writing your
      own Net if process.
      </p>
  </description>
  <funcs>
    <func>
      <name since="">dec_message([byte()]) -> Message</name>
      <fsummary>Decode an SNMP Message</fsummary>
      <type>
        <v>Message = #message</v>
      </type>
      <desc>
        <p>Decodes a list of bytes into an SNMP Message.  Note, if there
          is a v3 message, the <c>msgSecurityParameters</c> are not
          decoded.  They must be explicitly decoded by a call to a
          security model specific decoding function,
          e.g. <c>dec_usm_security_parameters/1</c>.  Also note, if
          the <c>scopedPDU</c> is encrypted, the OCTET STRING encoded
          <c>encryptedPDU</c> will be present in the <c>data</c> field.</p>
      </desc>
    </func>
    <func>
      <name since="">dec_message_only([byte()]) -> Message</name>
      <fsummary>Decode an SNMP Message, but not the data part</fsummary>
      <type>
        <v>Message = #message</v>
      </type>
      <desc>
        <p>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 <c>PDU</c> (v1 and V2) or an
          encoded and possibly encrypted <c>scopedPDU</c> (v3).</p>
      </desc>
    </func>
    <func>
      <name since="">dec_pdu([byte()]) -> Pdu</name>
      <fsummary>Decode an SNMP Pdu</fsummary>
      <type>
        <v>Pdu = #pdu</v>
      </type>
      <desc>
        <p>Decodes a list of bytes into an SNMP Pdu.</p>
      </desc>
    </func>
    <func>
      <name since="">dec_scoped_pdu([byte()]) -> ScopedPdu</name>
      <fsummary>Decode an SNMP ScopedPdu</fsummary>
      <type>
        <v>ScopedPdu = #scoped_pdu</v>
      </type>
      <desc>
        <p>Decodes a list of bytes into an SNMP ScopedPdu.</p>
      </desc>
    </func>
    <func>
      <name since="">dec_scoped_pdu_data([byte()]) -> ScopedPduData</name>
      <fsummary>Decode an SNMP ScopedPduData</fsummary>
      <type>
        <v>ScopedPduData = #scoped_pdu | EncryptedPDU</v>
        <v>EncryptedPDU = [byte()]</v>
      </type>
      <desc>
        <p>Decodes a list of bytes into either a scoped pdu record, or
          - if the scoped pdu was encrypted - to a list of bytes.</p>
      </desc>
    </func>
    <func>
      <name since="">dec_usm_security_parameters([byte()]) -> UsmSecParams</name>
      <fsummary>Decode SNMP UsmSecurityParameters</fsummary>
      <type>
        <v>UsmSecParams = #usmSecurityParameters</v>
      </type>
      <desc>
        <p>Decodes a list of bytes into an SNMP UsmSecurityParameters</p>
      </desc>
    </func>
    <func>
      <name since="">enc_encrypted_scoped_pdu(EncryptedScopedPdu) -> [byte()]</name>
      <fsummary>Encode an encrypted SNMP scopedPDU</fsummary>
      <type>
        <v>EncryptedScopedPdu = [byte()]</v>
      </type>
      <desc>
        <p>Encodes an encrypted SNMP ScopedPdu into an OCTET STRING
          that can be used as the <c>data</c> field in a
          <c>message</c> record, that later can be encoded with a call
          to <c>enc_message_only/1</c>. 
          </p>
        <p>This function should be used whenever the <c>ScopedPDU</c>
          is encrypted.</p>
      </desc>
    </func>
    <func>
      <name since="">enc_message(Message) -> [byte()]</name>
      <fsummary>Encode an SNMP Message</fsummary>
      <type>
        <v>Message = #message</v>
      </type>
      <desc>
        <p>Encodes a message record to a list of bytes.</p>
      </desc>
    </func>
    <func>
      <name since="">enc_message_only(Message) -> [byte()]</name>
      <fsummary>Encode an SNMP Message, but not the data part</fsummary>
      <type>
        <v>Message = #message</v>
      </type>
      <desc>
        <p><c>Message</c> is a record where the <c>data</c> field is
          assumed to be encoded (a list of bytes).  If there is a v1 or v2
          message, the <c>data</c> field is an encoded <c>PDU</c>, and if
          there is a v3 message, <c>data</c> is an encoded and possibly
          encrypted <c>scopedPDU</c>.</p>
      </desc>
    </func>
    <func>
      <name since="">enc_pdu(Pd) -> [byte()]</name>
      <fsummary>Encode an SNMP Pdu</fsummary>
      <type>
        <v>Pdu = #pdu</v>
      </type>
      <desc>
        <p>Encodes an SNMP Pdu into a list of bytes.</p>
      </desc>
    </func>
    <func>
      <name since="">enc_scoped_pdu(ScopedPdu) -> [byte()]</name>
      <fsummary>Encode an SNMP scopedPDU</fsummary>
      <type>
        <v>ScopedPdu = #scoped_pdu</v>
      </type>
      <desc>
        <p>Encodes an SNMP ScopedPdu into a list of bytes, which can be
          encrypted, and after encryption, encoded with
          a call to <c>enc_encrypted_scoped_pdu/1</c>; or it can be
          used as the <c>data</c> field in a <c>message</c> record, which
          then can be encoded with <c>enc_message_only/1</c>.</p>
      </desc>
    </func>
    <func>
      <name since="">enc_usm_security_parameters(UsmSecParams) -> [byte()]</name>
      <fsummary>Encode SNMP UsmSecurityParameters</fsummary>
      <type>
        <v>UsmSecParams = #usmSecurityParameters</v>
      </type>
      <desc>
        <p>Encodes SNMP UsmSecurityParameters into a list of bytes.</p>
      </desc>
    </func>
  </funcs>
  
</erlref>