1snmpm_user(3)              Erlang Module Definition              snmpm_user(3)
2
3
4

NAME

6       snmpm_user - Behaviour module for the SNMP manager user.
7

DESCRIPTION

9       This  module  defines  the  behaviour of the manager user. A snmpm_user
10       compliant module must export the following functions:
11
12         * handle_error/3
13
14         * handle_agent/4
15
16         * handle_pdu/4
17
18         * handle_trap/3
19
20         * handle_inform/3
21
22         * handle_report/3
23
24         * handle_invalid_result/2
25
26       The semantics of them and their exact signatures are explained below.
27
28       Some of the function has no defined return value (void()), they can  of
29       course return anything. But the functions that do have specified return
30       value(s) must adhere to this. None of the functions  can  use  exit  of
31       throw to return.
32
33       If  the  manager  is not configured to use any particular transport do‐
34       main, the behaviour handle_agent/4 will  for  backwards  copmpatibility
35       reasons be called with the old IpAddr and PortNumber arguments
36

DATA TYPES

38       snmp_gen_info() = {ErrorStatus :: atom(),
39                          ErrorIndex  :: pos_integer(),
40                          Varbinds    :: [snmp:varbind()]}
41       snmp_v1_trap_info() :: {Enteprise :: snmp:oid(),
42                               Generic   :: integer(),
43                               Spec      :: integer(),
44                               Timestamp :: integer(),
45                               Varbinds  :: [snmp:varbind()]}
46
47

EXPORTS

49       handle_error(ReqId, Reason, UserData) -> void()
50
51              Types:
52
53                 ReqId = netif | integer()
54                 Reason  =  {unexpected_pdu,  SnmpInfo}  |  {invalid_sec_info,
55                 SecInfo, SnmpInfo} | {empty_message, Addr, Port} | term()
56                 SnmpInfo = snmp_gen_info()
57                 SecInfo = term()
58                 Addr = ip_address()
59                 Port = integer()
60                 UserData = term()
61
62              This function is called when the manager needs to communicate an
63              "asynchronous"  error to the user: e.g. failure to send an asyn‐
64              chronous message (i.e. encoding error), a received  message  was
65              discarded  due to security error, the manager failed to generate
66              a response message to a received inform-request, or when receiv‐
67              ing  an  unexpected PDU from an agent (could be an expired async
68              request).
69
70              If ReqId is less then 0, it means that this information was  not
71              available  to  the manager (that info was never retrieved before
72              the message was discarded).
73
74              For SnmpInfo see handle_agent below.
75
76              Note that there is a special case when the value  of  ReqId  has
77              the  value  of the atom netif. This means that the NetIF process
78              has suffered a "fatal" error and been restarted.  With  possible
79              loss of traffic!
80
81       handle_agent(Domain, Addr, Type, SnmpInfo, UserData) -> Reply
82
83              Types:
84
85                 Domain = transportDomainUdpIpv4 | transportDomainUdpIpv6
86                 Addr = {inet:ip_address(), inet:port_number()}
87                 Type = pdu | trap | report | inform
88                 SnmpInfo  = SnmpPduInfo | SnmpTrapInfo | SnmpReportInfo | Sn‐
89                 mpInformInfo
90                 SnmpPduInfo = snmp_gen_info()
91                 SnmpTrapInfo = snmp_v1_trap_info()
92                 SnmpReportInfo = snmp_gen_info()
93                 SnmpInformInfo = snmp_gen_info()
94                 UserData = term()
95                 Reply = ignore | {register, UserId, TargetName, AgentConfig}
96                 UserId = term()
97                 TargetName = target_name()
98                 AgentConfig = [agent_config()]
99
100              This function is called when a message is received from  an  un‐
101              known agent.
102
103              Note that this will always be the default user that is called.
104
105              For more info about the agent_config(), see register_agent.
106
107              The arguments Type and SnmpInfo relates in the following way:
108
109                * pdu - SnmpPduInfo (see handle_pdu for more info).
110
111                * trap - SnmpTrapInfo (see handle_trap for more info).
112
113                * report - SnmpReportInfo (see handle_report for more info).
114
115                * inform - SnmpInformInfo (see handle_inform for more info).
116
117              The  only user which would return {register, UserId, TargetName,
118              AgentConfig} is the default user.
119
120       handle_pdu(TargetName, ReqId, SnmpPduInfo, UserData) -> void()
121
122              Types:
123
124                 TargetName = target_name()
125                 ReqId = term()
126                 SnmpPduInfo = snmp_gen_info()
127                 UserData = term()
128
129              Handle the reply to an asynchronous request, such as  async_get,
130              async_get_next or async_set.
131
132              It could also be a late reply to a synchronous request.
133
134              ReqId is returned by the asynchronous request function.
135
136       handle_trap(TargetName, SnmpTrapInfo, UserData) -> Reply
137
138              Types:
139
140                 TargetName = TargetName2 = target_name()
141                 SnmpTrapInfo = snmp_v1_trap_info() | snmp_gen_info()
142                 UserData = term()
143                 Reply = ignore | unregister | {register, UserId, TargetName2,
144                 AgentConfig}
145                 UserId = term()
146                 AgentConfig = [agent_config()]
147
148              Handle a trap/notification message from an agent.
149
150              For more info about the agent_config(), see register_agent
151
152              The only user which would return {register, UserId, TargetName2,
153              agent_info()} is the default user.
154
155       handle_inform(TargetName, SnmpInformInfo, UserData) -> Reply
156
157              Types:
158
159                 TargetName = TargetName2 = target_name()
160                 SnmpInformInfo = snmp_gen_info()
161                 UserData = term()
162                 Reply  =  ignore | no_reply | unregister | {register, UserId,
163                 TargetName2, AgentConfig}
164                 UserId = term()
165                 AgentConfig = [agent_config()]
166
167              Handle a inform message.
168
169              For more info about the agent_config(), see register_agent
170
171              The only user which would return {register, UserId, TargetName2,
172              AgentConfig} is the default user.
173
174              If  the  inform request behaviour configuration option is set to
175              user or {user, integer()}, the response (acknowledgment) to this
176              inform-request will be sent when this function returns.
177
178       handle_report(TargetName, SnmpReportInfo, UserData) -> Reply
179
180              Types:
181
182                 TargetName = TargetName2 = target_name()
183                 Addr = ip_address()
184                 Port = integer()
185                 SnmpReportInfo = snmp_gen_info()
186                 UserData = term()
187                 Reply = ignore | unregister | {register, UserId, TargetName2,
188                 AgentConfig}
189                 UserId = term()
190                 AgentConfig = [agent_config()]
191
192              Handle a report message.
193
194              For more info about the agent_config(), see register_agent
195
196              The only user which would return {register, UserId, TargetName2,
197              AgentConfig} is the default user.
198
199       handle_invalid_result(IN, OUT) -> void()
200
201              Types:
202
203                 IN = {Func, Args}
204                 Func = atom()
205                 Args = list()
206                 OUT = {crash, CrashInfo} | {result, InvalidResult}
207                 CrashInfo = {ErrorType, Error, Stacktrace}
208                 ErrorType = atom()
209                 Error = term()
210                 Stacktrace = list()
211                 InvalidResult = term()
212
213              If any of the other callback functions crashes (exit, throw or a
214              plain crash) or return an invalid result (if a valid return  has
215              been  specified), this function is called. The purpose is to al‐
216              low the user handle this error (for instance to issue  an  error
217              report).
218
219              IN  reprecents the function called (and its arguments). OUT rep‐
220              resents the unexpected/invalid result.
221
222
223
224Ericsson AB                        snmp 5.15                     snmpm_user(3)
Impressum