Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SnmpMgrGetTrapEx function

[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 SnmpMgrGetTrapEx function returns outstanding trap data that the caller has not received if trap reception is enabled. In addition to the information that is returned by the SnmpMgrGetTrap function, this extended function returns the address of the transport source and the community string of the trap. This function is an element of the SNMP Management API.

Syntax


BOOL SnmpMgrGetTrapEx(
  _Out_  AsnObjectIdentifier *enterprise,
  _Out_  AsnNetworkAddress *agentAddress,
  _Out_  AsnNetworkAddress *sourceAddress,
  _Out_  AsnInteger *genericTrap,
  _Out_  AsnInteger *specificTrap,
  _Out_  AsnOctetString *community,
  _Out_  AsnTimeticks *timeStamp,
  _Out_  SnmpVarBindList *variableBindings
);

Parameters

enterprise [out]

Pointer to an AsnObjectIdentifier structure to receive the enterprise that generated the SNMP trap.

agentAddress [out]

Pointer to a variable to receive the address of the agent that generated the SNMP trap; this information is retrieved from the SNMP protocol data unit (PDU).

sourceAddress [out]

Pointer to a variable to receive the address of the agent that generated the SNMP trap; this information is retrieved from the network transport.

genericTrap [out]

Pointer to a variable to receive an indicator of the generic trap. This parameter can be one of the following values.

ValueMeaning
SNMP_GENERICTRAP_COLDSTART

The agent is initializing protocol entities on the managed mode. It may alter objects in its view.

SNMP_GENERICTRAP_WARMSTART

The agent is reinitializing itself but it will not alter objects in its view.

SNMP_GENERICTRAP_LINKDOWN

An attached interface has changed from the up state to the down state. The first variable in the variable bindings list identifies the interface.

SNMP_GENERICTRAP_LINKUP

An attached interface has changed from the down state to the up state. The first variable in the variable bindings list identifies the interface.

SNMP_GENERICTRAP_AUTHFAILURE

An SNMP entity has sent an SNMP message, but it has falsely claimed to belong to a known community.

SNMP_GENERICTRAP_EGPNEIGHLOSS

An EGP peer has changed to the down state. The first variable in the variable bindings list identifies the IP address of the EGP peer.

SNMP_GENERICTRAP_ENTERSPECIFIC

An extraordinary event has occurred. It is identified in the specificTrap parameter with an enterprise-specific value.

 

specificTrap [out]

Pointer to a variable to receive an indicator of the specific trap generated.

community [out]

Pointer to an AsnOctetString structure to receive the community string of the generated SNMP trap.

timeStamp [out]

Pointer to a variable to receive the time stamp.

variableBindings [out]

Pointer to an SnmpVarBindList structure to receive the variable bindings list.

Return value

If the function returns a trap, the return value is nonzero.

You should call the SnmpMgrGetTrapEx function repeatedly until it returns zero. The function may also return the following error codes.

Return codeDescription
SNMP_MGMTAPI_TRAP_ERRORS

Indicates that errors were encountered; traps are not accessible.

SNMP_MGMTAPI_NOTRAPS

Indicates that no traps are available.

SNMP_MEM_ALLOC_ERROR

Indicates a memory allocation error.

 

Remarks

The application must always call the SnmpMgrTrapListen function before calling the SnmpMgrGetTrapEx function. This is because the event handle that is 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 event when the SNMP Trap Service delivers a trap.

The application can also poll the SnmpMgrGetTrapEx function for traps at regular intervals. In this case, the application should repeatedly call SnmpMgrGetTrapEx until the function returns zero.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Mgmtapi.h

Library

Mgmtapi.lib

DLL

Mgmtapi.dll

See also

Simple Network Management Protocol (SNMP) Overview
SNMP Functions
SnmpMgrTrapListen
AsnOctetString
AsnObjectIdentifier
SnmpVarBindList

 

 

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.