aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/doc/src/snmpa_mpd.xml
blob: 518100d30ceb3762d1891bef2ef2304adf198fde (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
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">

<erlref>
  <header>
    <copyright>
      <year>1999</year><year>2014</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>snmpa_mpd</title>
    <prepared></prepared>
    <responsible></responsible>
    <docno></docno>
    <approved></approved>
    <checked></checked>
    <date></date>
    <rev></rev>
    <file>snmpa_mpd.xml</file>
  </header>
  <module>snmpa_mpd</module>
  <modulesummary>Message Processing and Dispatch module for the SNMP agent</modulesummary>
  <description>
    <p>The module <c>snmpa_mpd</c> implements the version independent
      Message Processing and Dispatch functionality in SNMP for the agent. 
      It is supposed to be used from a Network Interface process 
      (<seealso marker="snmp_agent_netif">Definition of Agent Net if</seealso>).
      </p>

    <marker id="init"></marker>
  </description>

  <section>
    <title>DATA TYPES</title>
    <p>See the <seealso marker="snmpa_conf#types">
    data types in <c>snmpa_conf</c></seealso>.</p>
  </section>

  <funcs>
    <func>
      <name>init(Vsns) -> mpd_state()</name>
      <fsummary>Initialize the MPD module</fsummary>
      <type>
        <v>Vsns = [Vsn]</v>
        <v>Vsn = v1 | v2 | v3</v>
      </type>
      <desc>
        <p>This function can be called from the net_if process at start-up.
          The options list defines which versions to use.
          </p>
        <p>It also initializes some SNMP counters.
          </p>

        <marker id="process_packet"></marker>
      </desc>
    </func>

    <func>
      <name>process_packet(Packet, From, State, NoteStore, Log) -> {ok, Vsn, Pdu, PduMS, ACMData} | {discarded, Reason} | {discovery, DiscoPacket}</name>
      <name>process_packet(Packet, From, LocalEngineID, State, NoteStore, Log) -> {ok, Vsn, Pdu, PduMS, ACMData} | {discarded, Reason} | {discovery, DiscoPacket}</name>
      <fsummary>Process a packet received from the network</fsummary>
      <type>
        <v>Packet = binary()</v>
	<v>From = {TDomain, TAddr}</v>
        <v>TDomain = transportDomainUdpIpv4 | transportDomainUdpIpv6</v>
        <v>TAddr = {IpAddr, IpPort}</v>
        <v>LocalEngineID = string()</v>
        <v>IpAddr = <seealso marker="kernel:inet#type-ip_address">inet:ip_address()</seealso></v>
        <v>IpPort = inet:port_number()</v>
        <v>State = mpd_state()</v>
        <v>NoteStore = pid()</v>
        <v>Log = snmp_log()</v>
        <v>Vsn = 'version-1' | 'version-2' | 'version-3'</v>
        <v>Pdu = #pdu</v>
        <v>PduMs = integer()</v>
        <v>ACMData = acm_data()</v>
        <v>Reason = term()</v>
        <v>DiscoPacket = binary()</v>
      </type>
      <desc>
        <p>Processes an incoming packet.  Performs authentication and 
          decryption as necessary.  The return values should be passed to the
          agent.</p>

        <note>
          <p>Note that the use of the LocalEngineID argument is only intended 
            for special cases, if the agent is to "emulate" multiple EngineIDs!
            By default, the agent uses the value of <c>SnmpEngineID</c> 
            (see SNMP-FRAMEWORK-MIB). </p>
	</note>

        <marker id="generate_response_msg"></marker>
      </desc>
    </func>

    <func>
      <name>generate_response_msg(Vsn, RePdu, Type, ACMData, Log) -> {ok, Packet} | {discarded, Reason}</name>
      <name>generate_response_msg(Vsn, RePdu, Type, ACMData, LocalEngineID, Log) -> {ok, Packet} | {discarded, Reason}</name>
      <fsummary>Generate a response packet to be sent to the network</fsummary>
      <type>
        <v>Vsn = 'version-1' | 'version-2' | 'version-3'</v>
        <v>RePdu = #pdu</v>
        <v>Type = atom()</v>
        <v>ACMData = acm_data()</v>
        <v>LocalEngineID = string()</v>
        <v>Packet = binary()</v>
      </type>
      <desc>
        <p>Generates a possibly encrypted response packet to be sent to the
          network. <c>Type</c> is the <c>#pdu.type</c> of the original
          request.</p>

        <note>
          <p>Note that the use of the LocalEngineID argument is only intended 
            for special cases, if the agent is to "emulate" multiple EngineIDs!
            By default, the agent uses the value of <c>SnmpEngineID</c> 
            (see SNMP-FRAMEWORK-MIB). </p>
	</note>

        <marker id="generate_msg"></marker>
      </desc>
    </func>

    <func>
      <name>generate_msg(Vsn, NoteStore, Pdu, MsgData, To) -> {ok, PacketsAndAddresses} | {discarded, Reason}</name>
      <name>generate_msg(Vsn, NoteStore, Pdu, MsgData, LocalEngineID, To) -> {ok, PacketsAndAddresses} | {discarded, Reason}</name>
      <fsummary>Generate a request message to be sent to the network</fsummary>
      <type>
        <v>Vsn = 'version-1' | 'version-2' | 'version-3'</v>
        <v>NoteStore = pid()</v>
        <v>Pdu = #pdu</v>
        <v>MsgData = msg_data()</v>
        <v>LocalEngineID = string()</v>
        <v>To = [dest_addrs()]</v>
        <v>PacketsAndAddresses = [{TDomain, TAddress, Packet}]</v>
        <v>TDomain = snmpUDPDomain</v>
        <v>TAddress = {Ip, Udp}</v>
        <v>Ip = {integer(), integer(), integer(), integer()}</v>
        <v>Udp = integer()</v>
        <v>Packet = binary()</v>
      </type>
      <desc>
        <p>Generates a possibly encrypted request packet to be sent to the
          network.
          </p>
        <p><c>MsgData</c> is the message specific data used in
          the SNMP message.  This value is received in a
	  <seealso marker="snmp_agent_netif#im_send_pdu"><c>send_pdu</c></seealso>
          or
	  <seealso marker="snmp_agent_netif#im_send_pdu_req">
	  <c>send_pdu_req</c></seealso>
	  message from the agent.  In SNMPv1 and
          SNMPv2c, this message data is the community string.  In
          SNMPv3, it is the context information.</p>
	<p>
          <c>To</c> is a list of destination addresses and
          their corresponding security parameters.  This value is
          received in the same message from the agent and then transformed
	  trough <seealso marker="#process_taddrs"><c>process_taddrs</c></seealso>
	  before passed to this function.</p>

        <note>
          <p>Note that the use of the LocalEngineID argument is only intended 
            for special cases, if the agent is to "emulate" multiple EngineIDs!
            By default, the agent uses the value of <c>SnmpEngineID</c> 
            (see SNMP-FRAMEWORK-MIB). </p>
	</note>

        <marker id="process_taddrs"></marker>
      </desc>
    </func>

    <func>
      <name>process_taddrs(TDests) -> Dests</name>
      <fsummary>Transform addresses from internal MIB format to a less internal
      </fsummary>
      <type>
	<v>TDests = [TDest]</v>
	<v>TDest = {{TDomain, TAddr}, SecData} | {TDomain, TAddr}</v>
	<v>TDomain = term()  % Not at tuple</v>
	<v>TAddr = term()</v>
	<v>SecData = term()</v>
	<v>Dests = [Dest]</v>
	<v>Dest = {{Domain, Addr}, SecData} | {Domain, Addr}</v>
	<v>Domain = transportDomain()</v>
	<v>Addr = transportAddress()  % Depends on Domain</v>
      </type>
      <desc>
	<p>Transforms addresses from internal MIB format to one
	more useful to <seealso marker="snmp_agent_netif">Agent Net if</seealso>.
	</p>
	<p>See also <seealso marker="#generate_msg"><c>generate_msg</c>.</seealso>
	</p>

        <marker id="discarded_pdu"></marker>
      </desc>
    </func>

    <func>
      <name>discarded_pdu(Variable) -> void()</name>
      <fsummary>Increment the variable associated with a discarded pdu</fsummary>
      <type>
        <v>Variable = atom()</v>
      </type>
      <desc>
        <p>Increments the variable associated with a discarded pdu.
          This function can be used when the net_if process receives a
          <c>discarded_pdu</c> message from the agent.
          </p>
      </desc>
    </func>
  </funcs>
  
</erlref>