Managing Traps and Notifications
The WinSNMP application must register to receive traps and notifications by calling the SnmpRegister function with SNMPAPI_ON. The application can unregister and disable traps and notifications by calling the function with SNMPAPI_OFF.
Several options are available when the application calls SnmpRegister. The application can register or unregister for the following traps and notifications:
- One type of trap or notification
- All traps and notifications
- All sources of trap and notification requests
- Traps and notifications from all management entities
- Traps and notifications for every context
To register and receive a predefined trap or notification type, the application must define an object identifier (an smiOID structure) for each predefined type. The structure must contain a pattern-matching sequence for the type of trap or notification. RFC 1907, "Management Information Base for Version 2 of the Simple Network Management Protocol (SNMPv2)," defines trap and notification object identifiers.
To retrieve outstanding trap data and notifications for a WinSNMP session, a WinSNMP application must call the SnmpRecvMsg function with the session handle returned by the SnmpCreateSession function.
For more information, see Sending SNMP Messages and Receiving SNMP Messages. For additional information about allocation and deallocation of resources for traps and notifications, see Allocating WinSNMP Memory Objects.