1
<?xml version="1.0" encoding="latin1" ?>
2
<!DOCTYPE chapter SYSTEM "chapter.dtd">
7
<year>1997</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>Definition of Agent Net if</title>
26
<responsible></responsible>
32
<file>snmp_agent_netif.xml</file>
35
<image file="snmp_agent_netif_1">
36
<icaption>The Purpose of Agent Net if</icaption>
38
<p>The Network Interface (Net if) process delivers SNMP PDUs to a
39
master agent, and receives SNMP PDUs from the master agent. The most
40
common behaviour of a Net if process is that is receives bytes from
41
a network, decodes them into an SNMP PDU, which it sends to a master
42
agent. When the master agent has processed the PDU, it sends a
43
response PDU to the Net if process, which encodes the PDU into bytes
44
and transmits the bytes onto the network.
46
<p>However, that simple behaviour can be modified in numerous
47
ways. For example, the Net if process can apply some kind of
48
encrypting/decrypting scheme on the bytes or
49
act as a proxy filter, which sends some packets to a proxy agent and
50
some packets to the master agent.
52
<p>It is also possible to write your own Net if process. The default
53
Net if process is implemented in the module <c>snmpa_net_if</c> and
54
it uses UDP as the transport protocol.
56
<p>This section describes how to write a Net if process.
60
<marker id="mandatory_functions"></marker>
61
<title>Mandatory Functions</title>
62
<p>A Net if process must implement the SNMP agent
63
<seealso marker="snmpa_network_interface">network interface behaviour</seealso>.
68
<title>Messages</title>
69
<p>The section <em>Messages</em> describes mandatory messages, which
70
Net if must send and be able to receive.
74
<title>Outgoing Messages</title>
75
<p>Net if must send the following message when it receives an
76
SNMP PDU from the network that is aimed for the MasterAgent:
79
MasterAgent ! {snmp_pdu, Vsn, Pdu, PduMS, ACMData, From, Extra}
81
<list type="bulleted">
82
<item><c>Vsn</c> is either <c>'version-1'</c>,
83
<c>'version-2'</c>, or <c>'version-3'</c>.
85
<item><c>Pdu</c> is an SNMP PDU record, as defined in
86
<c>snmp_types.hrl</c>, with the SNMP request.
88
<item><c>PduMS</c> is the Maximum Size of the response Pdu
89
allowed. Normally this is returned from
90
<c>snmpa_mpd:process_packet</c> (see Reference Manual).
92
<item><c>ACMData</c> is data used by the Access Control Module
93
in use. Normally this is returned from
94
<c>snmpa_mpd:process_packet</c> (see Reference Manual).
96
<item><c>From</c> is the source address. If UDP over IP is
97
used, this should be a 2-tuple <c>{IP, UDPport}</c>, where
98
<c>IP</c> is a 4-tuple with the IP address, and <c>UDPport</c>
101
<item><c>Extra</c> is any term the Net if process wishes to
102
send to the agent. This term can be retrieved by the
103
instrumentation functions by calling
104
<c>snmp:current_net_if_data()</c>. This data is also sent back
105
to the Net if process when the agent generates a response to
108
<p>The following message is used to report that a response to a
109
request has been received. The only request an agent can send
110
is an Inform-Request.
113
Pid ! {snmp_response_received, Vsn, Pdu, From}
115
<list type="bulleted">
116
<item><c>Pid</c> is the Process that waits for the response
117
for the request. The Pid was specified in the
118
<c>send_pdu_req</c> message <seealso marker="#message">(see below)</seealso>.
120
<item><c>Vsn</c> is either <c>'version-1'</c>, <c>'version-2'</c>, or
123
<item><c>Pdu</c> is the SNMP Pdu received
125
<item><c>From</c> is the source address. If UDP over IP is
126
used, this should be a 2-tuple <c>{IP, UDPport}</c>, where
127
<c>IP</c> is a 4-tuple with the IP address, and <c>UDPport</c>
134
<title>Incoming Messages</title>
135
<p>This section describes the incoming messages which a Net if
136
process must be able to receive.
138
<list type="bulleted">
140
<p><c>{snmp_response, Vsn, Pdu, Type, ACMData, To, Extra}</c></p>
141
<p>This message is sent to the Net if process from a master
142
agent as a response to a previously received request.
144
<list type="bulleted">
145
<item><c>Vsn</c> is either <c>'version-1'</c>,
146
<c>'version-2'</c>, or <c>'version-3'</c>.
148
<item><c>Pdu</c> is an SNMP PDU record (as defined in
149
snmp_types.hrl) with the SNMP response.
151
<item><c>Type</c> is the <c>#pdu.type</c> of the original
154
<item><c>ACMData</c> is data used by the Access Control
155
Module in use. Normally this is just sent to
156
<c>snmpa_mpd:generate_response_message</c> (see Reference Manual).
158
<item><c>To</c> is the destination address. If UDP over IP
159
is used, this should be a 2-tuple <c>{IP, UDPport}</c>,
160
where <c>IP</c> is a 4-tuple with the IP address, and
161
<c>UDPport</c> is an integer.
163
<item><c>Extra</c> is the term that the Net if process
164
sent to the agent when the request was sent to the agent.
169
<p><c>{discarded_pdu, Vsn, ReqId, ACMData, Variable, Extra}</c></p>
170
<p>This message is sent from a master agent if it for some
171
reason decided to discard the pdu.
173
<list type="bulleted">
174
<item><c>Vsn</c> is either <c>'version-1'</c>,
175
<c>'version-2'</c>, or <c>'version-3'</c>.
177
<item><c>ReqId</c> is the request id of the original
180
<item><c>ACMData</c> is data used by the Access Control
181
Module in use. Normally this is just sent to
182
<c>snmpa_mpd:generate_response_message</c> (see Reference Manual).
184
<item><c>Variable</c> is the name of an snmp counter that
185
represents the error, e.g. <c>snmpInBadCommunityUses</c>.
187
<item><c>Extra</c> is the term that the Net if process
188
sent to the agent when the request was sent to the agent.
193
<p><c>{send_pdu, Vsn, Pdu, MsgData, To}</c></p>
194
<p>This message is sent from a master agent when a trap is
197
<list type="bulleted">
198
<item><c>Vsn</c> is either <c>'version-1'</c>,
199
<c>'version-2'</c>, or <c>'version-3'</c>.
201
<item><c>Pdu</c> is an SNMP PDU record (as defined in
202
snmp_types.hrl) with the SNMP response.
204
<item><c>MsgData</c> is the message specific data used in
205
the SNMP message. This value is normally sent to
206
<c>snmpa_mpd:generate_message/4</c>. In SNMPv1 and
207
SNMPv2c, this message data is the community string. In
208
SNMPv3, it is the context information.
210
<item><c>To</c> is a list of the destination addresses and
211
their corresponding security parameters. This value is
212
normally sent to <c>snmpa_mpd:generate_message/4</c>.
217
<p><c>{send_pdu_req, Vsn, Pdu, MsgData, To, Pid}</c></p>
218
<p>This <marker id="message"></marker>
219
message is sent from a master
220
agent when a request is
221
to be sent. The only request an agent can send is
222
Inform-Request. The net if process needs to remember the
223
request id and the Pid, and when a response is received for
224
the request id, send it to Pid, using a
225
<c>snmp_response_received</c> message.
227
<list type="bulleted">
228
<item><c>Vsn</c> is either <c>'version-1'</c>,
229
<c>'version-2'</c>, or <c>'version-3'</c>.
231
<item><c>Pdu</c> is an SNMP PDU record (as defined in
232
snmp_types.hrl) with the SNMP response.
234
<item><c>MsgData</c> is the message specific data used in
235
the SNMP message. This value is normally sent to
236
<c>snmpa_mpd:generate_message/4</c>. In SNMPv1 and
237
SNMPv2c, this message data is the community string. In
238
SNMPv3, it is the context information.
240
<item><c>To</c> is a list of the destination addresses and
241
their corresponding security parameters. This value is
242
normally sent to <c>snmpa_mpd:generate_message/4</c>.
244
<item><c>Pid</c> is a process identifier.
253
<p>Since the Net if process is responsible for encoding and
254
decoding of SNMP messages, it must also update the relevant
255
counters in the SNMP group in MIB-II. It can use the functions
256
in the module <c>snmpa_mpd</c> for this purpose (refer to the
257
Reference Manual, section <c>snmp</c>,
258
module <seealso marker="snmp_pdus">snmpa_mpd</seealso>
261
<p>There are also some useful functions for encoding and
262
decoding of SNMP messages in the module
263
<seealso marker="snmp_pdus">snmp_pdus</seealso>.