About SnmpExtensionInit

At startup time, the SNMP service or master agent reads from the registry a list of the extension-agent DLLs that need to be loaded. After successfully loading an SNMP extension agent, the master agent calls the SnmpExtensionInit function that is defined in the DLL to supply the extension agent with startup data, and to have the extension agent register an OID to initialize the SNMP service.

The SnmpExtensionInit function must return TRUE if initialization was successful and FALSE if initialization failed. In case of initialization failure, the SNMP service will not register the extension agent; the failure of the extension agent to start will be recorded in an event log.

The SnmpExtensionInit function causes an extension agent to register an event to notify the master agent when to send a trap to the manager. For example, if the MIB-II extension agent returns an event that is associated with a timer, the master agent starts calling the SnmpExtensionTrap function of the extension agent periodically, inducing the extension agent to check the status of each of its links. If the status of any link has changed since the last time the SnmpExtensionTrap function was called, the extension agent informs the master agent that a LINKUP or LINKDOWN trap must be sent.

When calling the SnmpExtensionInit function of the extension agent, the master agent passes a time-zero reference, which the extension agent can use later to determine its uptime. The extension agent requires the uptime to implement various MIBs, and to have the master agent send a trap on its behalf. In order to calculate the length of the uptime, the extension agent subtracts dwTimeZeroReference from the value that is returned from the system call to the GetTickCount function.

After registering a MIB subtree with the SNMP service, the extension agent must free the memory that is allocated to the OID and that is passed back to the master agent (a static variable works best because there is no SnmpExtensionCleanup routine). The master agent then calls SnmpExtensionInitEx, if it is implemented to discover if the extension agent has any further subtrees to support. This function is called until it returns FALSE, indicating that the extension agent has given the master agent all of its subtree OIDs. The master agent lexicographically sorts each of the OIDs that is returned and creates a table of reference for incoming requests for variables.

The SnmpExtensionInit function has the following parameters:

  • A time value that identifies the number of centiseconds that have elapsed since the SNMP service has started. The extension agent stores this value and subtracts it from the current system time. Make sure that the dwTimeZeroReference parameter is set to zero prior to initialization.
  • An event handle through which the extension agent communicates traps to the master agent. If the extension agent does not need to send traps, the value of this handle (hPollForTrapEvent) is set to NULL.
  • An OID representing the first or only subtree the extension agent supports.

See Also

Extension-Agent Architecture

 Last updated on Saturday, April 10, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.