SnmpMgrGetTrap function (mgmtapi.h)
[SNMP is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions. Instead, use Windows Remote Management, which is the Microsoft implementation of WS-Man.]
The SnmpMgrGetTrap function returns outstanding trap data that the caller has not received if trap reception is enabled. This function is an element of the SNMP Management API.
In addition to the information returned by this function, the SnmpMgrGetTrapEx function returns the address of the transport source and the community string of the trap.
Syntax
BOOL SNMP_FUNC_TYPE SnmpMgrGetTrap(
[out] AsnObjectIdentifier *enterprise,
[out] AsnNetworkAddress *IPAddress,
[out] AsnInteger *genericTrap,
[out] AsnInteger *specificTrap,
[out] AsnTimeticks *timeStamp,
[out] RFC1157VarBindList *variableBindings
);
Parameters
[out] enterprise
Pointer to an AsnObjectIdentifier structure to receive the enterprise that generated the SNMP trap.
[out] IPAddress
Pointer to a variable to receive the address of the agent that generated the SNMP trap.
[out] genericTrap
Pointer to a variable to receive an indicator of the generic trap. This parameter can be one of the following values.
[out] specificTrap
Pointer to a variable to receive an indication of the specific trap generated.
[out] timeStamp
Pointer to a variable to receive the time stamp.
[out] variableBindings
Pointer to an SnmpVarBindList structure to receive the variable bindings list.
Return value
If the function returns a trap, the return value is TRUE. The code for the error can be retrieved by calling SnmpGetLastError immediately after the call.
You should call the SnmpMgrGetTrap function repeatedly until it returns FALSE (zero). The function may also return the following error codes.
Return code | Description |
---|---|
|
Indicates errors were encountered; traps are not accessible. |
|
Indicates no traps are available. |
|
Indicates a memory allocation error. |
Remarks
The application must always call the SnmpMgrTrapListen function before calling the SnmpMgrGetTrap function. This is because the event handle pointed to by the phTrapAvailable parameter of the SnmpMgrTrapListen function enables the event-driven acquisition of SNMP traps. The SNMP Management API signals an application's event when the SNMP Trap Service delivers a trap.
The application can also poll the SnmpMgrGetTrap function for traps at regular intervals. In this case, the application should repeatedly call SnmpMgrGetTrap until the function returns zero.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | mgmtapi.h |
Library | Mgmtapi.lib |
DLL | Mgmtapi.dll |