aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/doc/src/snmp_agent_netif.xml
blob: d751740a82ae6346cec33837dd4ace0a1f5071c1 (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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE chapter SYSTEM "chapter.dtd">

<chapter>
  <header>
    <copyright>
      <year>1997</year><year>2009</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      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.
    
    </legalnotice>

    <title>Definition of Agent Net if</title>
    <prepared></prepared>
    <responsible></responsible>
    <docno></docno>
    <approved></approved>
    <checked></checked>
    <date></date>
    <rev></rev>
    <file>snmp_agent_netif.xml</file>
  </header>
  <p></p>
  <image file="snmp_agent_netif_1.gif">
    <icaption>The Purpose of Agent Net if</icaption>
  </image>
  <p>The Network Interface (Net if) process delivers SNMP PDUs to a
    master agent, and receives SNMP PDUs from the master agent. The most
    common behaviour of a Net if process is that is receives bytes from
    a network, decodes them into an SNMP PDU, which it sends to a master
    agent. When the master agent has processed the PDU, it sends a
    response PDU to the Net if process, which encodes the PDU into bytes
    and transmits the bytes onto the network.
    </p>
  <p>However, that simple behaviour can be modified in numerous
    ways. For example, the Net if process can apply some kind of
    encrypting/decrypting scheme on the bytes or
    act as a proxy filter, which sends some packets to a proxy agent and
    some packets to the master agent.
    </p>
  <p>It is also possible to write your own Net if process. The default
    Net if process is implemented in the module <c>snmpa_net_if</c> and
    it uses UDP as the transport protocol.
    </p>
  <p>This section describes how to write a Net if process.
    </p>

  <section>
    <marker id="mandatory_functions"></marker>
    <title>Mandatory Functions</title>
    <p>A Net if process must implement the SNMP agent 
      <seealso marker="snmpa_network_interface">network interface behaviour</seealso>.
      </p>
  </section>

  <section>
    <marker id="messages"></marker>
    <title>Messages</title>
    <p>The section <em>Messages</em> describes mandatory messages, which
      Net if must send and be able to receive.     
      </p>

    <section>
      <marker id="outgoing_messages"></marker>
      <title>Outgoing Messages</title>
      <p>Net if must send the following message when it receives an
      SNMP PDU from the network that is aimed for the MasterAgent:
      </p>
      <marker id="om_snmp_pdu"></marker>
      <pre>
MasterAgent ! {snmp_pdu, Vsn, Pdu, PduMS, ACMData, From, Extra}
      </pre>
      <list type="bulleted">
        <item><c>Vsn</c> is either <c>'version-1'</c>,
        <c>'version-2'</c>, or <c>'version-3'</c>.
        </item>
        <item><c>Pdu</c> is an SNMP PDU record, as defined in
        <c>snmp_types.hrl</c>, with the SNMP request.
        </item>
        <item><c>PduMS</c> is the Maximum Size of the response Pdu
         allowed.  Normally this is returned from
        <c>snmpa_mpd:process_packet</c> (see Reference Manual).
        </item>
        <item><c>ACMData</c> is data used by the Access Control Module
         in use.  Normally this is returned from
        <c>snmpa_mpd:process_packet</c> (see Reference Manual).
        </item>
        <item><c>From</c> is the source address. If UDP over IP is
         used, this should be a 2-tuple <c>{IP, UDPport}</c>, where
        <c>IP</c> is a 4-tuple with the IP address, and <c>UDPport</c>
         is an integer.
        </item>
        <item><c>Extra</c> is any term the Net if process wishes to
         send to the agent. This term can be retrieved by the
         instrumentation functions by calling
        <c>snmp:current_net_if_data()</c>. This data is also sent back
         to the Net if process when the agent generates a response to
         the request.</item>
      </list>
      <p>The following message is used to report that a response to a
      request has been received.  The only request an agent can send
      is an Inform-Request.
      </p>
      <marker id="om_snmp_response_received"></marker>
      <pre>
Pid ! {snmp_response_received, Vsn, Pdu, From}
      </pre>
      <list type="bulleted">
        <item><c>Pid</c> is the Process that waits for the response
         for the request.  The Pid was specified in the
        <c>send_pdu_req</c> message <seealso marker="#message">(see below)</seealso>.
        </item>
        <item><c>Vsn</c> is either <c>'version-1'</c>, <c>'version-2'</c>, or
        <c>'version-3'</c>.
        </item>
        <item><c>Pdu</c> is the SNMP Pdu received
        </item>
        <item><c>From</c> is the source address. If UDP over IP is
         used, this should be a 2-tuple <c>{IP, UDPport}</c>, where
        <c>IP</c> is a 4-tuple with the IP address, and <c>UDPport</c>
         is an integer.
        </item>
      </list>
    </section>

    <section>
      <marker id="incoming_messages"></marker>
      <title>Incoming Messages</title>
      <p>This section describes the incoming messages which a Net if
      process must be able to receive.
      </p>
      <list type="bulleted">
        <item>
	  <marker id="im_snmp_response"></marker>
          <p><c>{snmp_response, Vsn, Pdu, Type, ACMData, To, Extra}</c></p>
          <p>This message is sent to the Net if process from a master
            agent as a response to a previously received request.
            </p>
          <list type="bulleted">
            <item>
	      <p><c>Vsn</c> is either <c>'version-1'</c>,
	      <c>'version-2'</c>, or <c>'version-3'</c>. </p>
            </item>
            <item>
	      <p><c>Pdu</c> is an SNMP PDU record (as defined in
	      snmp_types.hrl) with the SNMP response. </p>
            </item>
            <item>
	      <p><c>Type</c> is the <c>#pdu.type</c> 
	      of the original request. </p>
            </item>
            <item>
	      <p><c>ACMData</c> is data used by the Access Control
	      Module in use.  Normally this is just sent to
	      <c>snmpa_mpd:generate_response_message</c> 
	      (see Reference Manual). </p>
            </item>
            <item>
	      <p><c>To</c> is the destination address. If UDP over IP
	      is used, this should be a 2-tuple <c>{IP, UDPport}</c>,
	      where <c>IP</c> is a 4-tuple with the IP address, and
	      <c>UDPport</c> is an integer. </p>
            </item>
            <item>
	      <p><c>Extra</c> is the term that the Net if process
	      sent to the agent when the request was sent to the agent. </p>
            </item>
          </list>
        </item>
        <item>
	  <marker id="im_discarded_pdu"></marker>
          <p><c>{discarded_pdu, Vsn, ReqId, ACMData, Variable, Extra}</c></p>
          <p>This message is sent from a master agent if it for some
	  reason decided to discard the pdu. </p>
          <list type="bulleted">
            <item>
	      <p><c>Vsn</c> is either <c>'version-1'</c>,
	      <c>'version-2'</c>, or <c>'version-3'</c>. </p>
            </item>
            <item>
	      <p><c>ReqId</c> is the request id of the original request. </p>
            </item>
            <item>
	      <p><c>ACMData</c> is data used by the Access Control
	      Module in use. Normally this is just sent to
	      <c>snmpa_mpd:generate_response_message</c> 
	      (see Reference Manual). </p>
            </item>
            <item>
	      <p><c>Variable</c> is the name of an snmp counter that
	      represents the error, e.g. <c>snmpInBadCommunityUses</c>. </p>
            </item>
            <item>
	      <p><c>Extra</c> is the term that the Net if process
	      sent to the agent when the request was sent to the agent. </p>
            </item>
          </list>
        </item>
        <item>
	  <marker id="im_send_pdu"></marker>
          <p><c>{send_pdu, Vsn, Pdu, MsgData, To, Extra}</c></p>
          <p>This message is sent from a master agent when a trap is
            to be sent. </p>
          <list type="bulleted">
            <item>
	      <p><c>Vsn</c> is either <c>'version-1'</c>,
	      <c>'version-2'</c>, or <c>'version-3'</c>.</p>
            </item>
	    <item>
	      <p><c>Pdu</c> is an SNMP PDU record (as defined in
	      snmp_types.hrl) with the SNMP response. </p>
	    </item>
            <item>
	      <p><c>MsgData</c> is the message specific data used in
	      the SNMP message.  This value is normally sent to
	      <c>snmpa_mpd:generate_message/4</c>.  In SNMPv1 and
	      SNMPv2c, this message data is the community string.  In
	      SNMPv3, it is the context information. </p>
            </item>
            <item>
	      <p><c>To</c> is a list of the destination addresses and
	      their corresponding security parameters.  This value is
	      normally sent to <c>snmpa_mpd:generate_message/4</c>. </p>
            </item>
            <item>
	      <p><c>Extra</c> is any term that the notification sender
	      wishes to pass to the Net if process when sending a notification 
	      (see 
	      <seealso marker="snmpa#send_notification2">send notification
	      </seealso> for more info). </p>
            </item>
          </list>
        </item>
        <item>
	  <marker id="im_send_pdu_req"></marker>
          <p><c>{send_pdu_req, Vsn, Pdu, MsgData, To, Pid, Extra}</c></p>
          <p>This message is sent from a master agent when a request is to 
	  be sent.  The only request an agent can send is Inform-Request.  
	  The net if process needs to remember the request id and the Pid, 
	  and when a response is received for the request id, send it to Pid, 
	  using a <c>snmp_response_received</c> message. </p>
	  <list type="bulleted">
	    <item>
	      <p><c>Vsn</c> is either <c>'version-1'</c>,
	      <c>'version-2'</c>,  or <c>'version-3'</c>.</p>
	    </item>
	    <item>
	      <p><c>Pdu</c> is an SNMP PDU record (as defined in
	      snmp_types.hrl) with the SNMP response. </p>
	    </item>
	    <item>
	      <p><c>MsgData</c> is the message specific data used in
	      the SNMP message.  This value is normally sent to
	      <c>snmpa_mpd:generate_message/4</c>. In SNMPv1 and
	      SNMPv2c, this message data is the community string. In
	      SNMPv3, it is the context information. </p>
	    </item>
	    <item>
	      <p><c>To</c> is a list of the destination addresses and
	      their corresponding security parameters. This value is
	      normally sent to <c>snmpa_mpd:generate_message/4</c>. </p>
	    </item>
	    <item>
	      <p><c>Pid</c> is a process identifier. </p>
	    </item>
            <item>
	      <p><c>Extra</c> is any term that the notification sender
	      wishes to pass to the Net if process when sending a notification 
	      (see 
	      <seealso marker="snmpa#send_notification2">send notification
	      </seealso> for more info). </p>
            </item>
	  </list>
        </item>
      </list>
    </section>

    <section>
      <title>Notes</title>
      <p>Since the Net if process is responsible for encoding and
        decoding of SNMP messages, it must also update the relevant
        counters in the SNMP group in MIB-II. It can use the functions
        in the module <c>snmpa_mpd</c> for this purpose (refer to the 
        Reference Manual, section <c>snmp</c>, 
        module <seealso marker="snmp_pdus">snmpa_mpd</seealso>
        for more details.)
        </p>
      <p>There are also some useful functions for encoding and
        decoding of SNMP messages in the module 
        <seealso marker="snmp_pdus">snmp_pdus</seealso>.
        </p>
    </section>
  </section>
</chapter>