snmpm_user(3)

NAME
snmpm_user - Behaviour module for the SNMP manager user.

DESCRIPTION

This module defines the behaviour of the manager user. A snmpm_user compliant module must export the following functions:

    • handle_error/3

    • handle_agent/5

    • handle_pdu/4

    • handle_trap/3

    • handle_inform/3

    • handle_report/3

    • handle_invalid_result/2

The semantics of them and their exact signatures are explained below.

Some of the function has no defined return value (void()), they can of course return anything. But the functions that do have specified return value(s) must adhere to this. None of the functions can use exit of throw to return.

If the manager is not configured to use any particular transport domain, the behaviour handle_agent/5 will for backwards copmpatibility reasons be called with the old IpAddr and PortNumber arguments

DATA TYPES

ip_address() :: inet:ip_address().
port_number() :: inet:port_number().
snmp_gen_info() :: {ErrorStatus :: atom(), ErrorIndex :: pos_integer(), Varbinds :: [snmp:varbind()]}.

    General error information (does not have to indicate an error)..
snmp_v1_trap_info() :: {Enteprise :: snmp:oid(), Generic :: integer(), Spec :: integer(), Timestamp :: integer(), Varbinds :: [snmp:varbind()]}.

    Trap related information.

CALLBACKS

handle_agent(Domain, Address, Type, SnmpInfo, UserData)

    This function is called when a message is received from an unknown agent.

    Note that this will always be the default user that is called.

    For more info about the agent_config(), see snmpm:register_agent/3.

    The arguments Type and SnmpInfo relates in the following way: pdu
        SnmpPduInfo (see handle_pdu/4 for more info).
    trap
        SnmpTrapInfo (see handle_trap/3 for more info).
    report
        SnmpReportInfo (see handle_report/3 for more info).
    inform
        SnmpInformInfo (see handle_inform/3 for more info).

    The only user which would return {register, UserId, TargetName, AgentConfig} is the default user.
handle_error(ReqId, Reason, UserData)

    This function is called when the manager needs to communicate an "asynchronous" error to the user: e.g. failure to send an asynchronous message (i.e. encoding error), a received message was discarded due to security error, the manager failed to generate a response message to a received inform-request, or when receiving an unexpected PDU from an agent (could be an expired async request).

    If ReqId is less then 0, it means that this information was not available to the manager (that info was never retrieved before the message was discarded).

    For SnmpInfo see handle_agent below.

    When Reason is {failed_processing_message, {securityError, SecurityError, Opts}}, the Opts proplist may contain a sec_data entry with USM security parameters from the received message. In particular, when SecurityError is usmStatsUnknownEngineIDs, the sec_data proplist contains msgAuthoritativeEngineID and msgUserName, which can be used for SNMPv3 USM EngineID discovery (RFC 3414, Section 4).

    Note that there is a special case when the value of ReqId has the value of the atom netif. This means that the NetIF process has suffered a "fatal" error and been restarted. With possible loss of traffic!
handle_inform(TargetName, SnmpInform, UserData)

    Handle a inform message.

    For more info about the agent_config(), see snmpm:register_agent/3.

    The only user which would return {register, UserId, TargetName2, AgentConfig} is the default user.

    If the inform request behaviour configuration option is set to user or {user, integer()}, the response (acknowledgment) to this inform-request will be sent when this function returns.
handle_invalid_result(In, Out)

    If any of the other callback functions crashes (exit, throw or a plain crash) or return an invalid result (if a valid return has been specified), this function is called. The purpose is to allow the user handle this error (for instance to issue an error report).

    IN reprecents the function called (and its arguments). OUT represents the unexpected/invalid result.
handle_pdu(TargetName, ReqId, SnmpResponse, UserData)

    Handle the reply to an asynchronous request, such as async_get, async_get_next or async_set.

    It could also be a late reply to a synchronous request.

    ReqId is returned by the asynchronous request function.
handle_report(TargetName, SnmpReport, UserData)

    Handle a report message.

    For more info about the agent_config(), see snmpm:register_agent/3.

    The only user which would return {register, UserId, TargetName2, AgentConfig} is the default user.
handle_trap(TargetName, SnmpTrapInfo, UserData)

    Handle a trap/notification message from an agent.

    For more info about the agent_config(), see snmpm:register_agent/3.

    The only user which would return {register, UserId, TargetName2, agent_info()} is the default user.