1snmpm_user(3) Erlang Module Definition snmpm_user(3)
2
3
4
6 snmpm_user - Behaviour module for the SNMP manager user.
7
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
34 domain, the behaviour handle_agent/4 will for backwards copmpatibility
35 reasons be called with the old IpAddr and PortNumber arguments
36
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
49 handle_error(ReqId, Reason, UserData) -> void()
50
51 Types:
52
53 ReqId = 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 handle_agent(Domain, Addr, Type, SnmpInfo, UserData) -> Reply
77
78 Types:
79
80 Domain = transportDomainUdpIpv4 | transportDomainUdpIpv6
81 Addr = {inet:ip_address(), inet:port_number()}
82 Type = pdu | trap | report | inform
83 SnmpInfo = SnmpPduInfo | SnmpTrapInfo | SnmpReportInfo |
84 SnmpInformInfo
85 SnmpPduInfo = snmp_gen_info()
86 SnmpTrapInfo = snmp_v1_trap_info()
87 SnmpReportInfo = snmp_gen_info()
88 SnmpInformInfo = snmp_gen_info()
89 UserData = term()
90 Reply = ignore | {register, UserId, TargetName, AgentConfig}
91 UserId = term()
92 TargetName = target_name()
93 AgentConfig = [agent_config()]
94
95 This function is called when a message is received from an
96 unknown agent.
97
98 Note that this will always be the default user that is called.
99
100 For more info about the agent_config(), see register_agent.
101
102 The arguments Type and SnmpInfo relates in the following way:
103
104 * pdu - SnmpPduInfo (see handle_pdu for more info).
105
106 * trap - SnmpTrapInfo (see handle_trap for more info).
107
108 * report - SnmpReportInfo (see handle_report for more info).
109
110 * inform - SnmpInformInfo (see handle_inform for more info).
111
112 The only user which would return {register, UserId, TargetName,
113 AgentConfig} is the default user.
114
115 handle_pdu(TargetName, ReqId, SnmpPduInfo, UserData) -> void()
116
117 Types:
118
119 TargetName = target_name()
120 ReqId = term()
121 SnmpPduInfo = snmp_gen_info()
122 UserData = term()
123
124 Handle the reply to an asynchronous request, such as async_get,
125 async_get_next or async_set.
126
127 It could also be a late reply to a synchronous request.
128
129 ReqId is returned by the asynchronous request function.
130
131 handle_trap(TargetName, SnmpTrapInfo, UserData) -> Reply
132
133 Types:
134
135 TargetName = TargetName2 = target_name()
136 SnmpTrapInfo = snmp_v1_trap_info() | snmp_gen_info()
137 UserData = term()
138 Reply = ignore | unregister | {register, UserId, TargetName2,
139 AgentConfig}
140 UserId = term()
141 AgentConfig = [agent_config()]
142
143 Handle a trap/notification message from an agent.
144
145 For more info about the agent_config(), see register_agent
146
147 The only user which would return {register, UserId, TargetName2,
148 agent_info()} is the default user.
149
150 handle_inform(TargetName, SnmpInformInfo, UserData) -> Reply
151
152 Types:
153
154 TargetName = TargetName2 = target_name()
155 SnmpInformInfo = snmp_gen_info()
156 UserData = term()
157 Reply = ignore | no_reply | unregister | {register, UserId,
158 TargetName2, AgentConfig}
159 UserId = term()
160 AgentConfig = [agent_config()]
161
162 Handle a inform message.
163
164 For more info about the agent_config(), see register_agent
165
166 The only user which would return {register, UserId, TargetName2,
167 AgentConfig} is the default user.
168
169 If the inform request behaviour configuration option is set to
170 user or {user, integer()}, the response (acknowledgment) to this
171 inform-request will be sent when this function returns.
172
173 handle_report(TargetName, SnmpReportInfo, UserData) -> Reply
174
175 Types:
176
177 TargetName = TargetName2 = target_name()
178 Addr = ip_address()
179 Port = integer()
180 SnmpReportInfo = snmp_gen_info()
181 UserData = term()
182 Reply = ignore | unregister | {register, UserId, TargetName2,
183 AgentConfig}
184 UserId = term()
185 AgentConfig = [agent_config()]
186
187 Handle a report message.
188
189 For more info about the agent_config(), see register_agent
190
191 The only user which would return {register, UserId, TargetName2,
192 AgentConfig} is the default user.
193
194 handle_invalid_result(IN, OUT) -> void()
195
196 Types:
197
198 IN = {Func, Args}
199 Func = atom()
200 Args = list()
201 OUT = {crash, CrashInfo} | {result, InvalidResult}
202 CrashInfo = {ErrorType, Error, Stacktrace}
203 ErrorType = atom()
204 Error = term()
205 Stacktrace = list()
206 InvalidResult = term()
207
208 If any of the other callback functions crashes (exit, throw or a
209 plain crash) or return an invalid result (if a valid return has
210 been specified), this function is called. The purpose is to
211 allow the user handle this error (for instance to issue an error
212 report).
213
214 IN reprecents the function called (and its arguments). OUT rep‐
215 resents the unexpected/invalid result.
216
217
218
219Ericsson AB snmp 5.4.3 snmpm_user(3)