SnmpExtensionQuery

Other versions of this page are also available for the following:

Windows Mobile Not SupportedWindows Embedded CE Supported

8/28/2008

This function is called by the Microsoft SNMP service to resolve SNMP requests that contain variables within one or more of the SNMP extension agent's registered MIB subtrees. This function is an element of the SNMP Extension Agent API.

Syntax

BOOL SnmpExtensionQuery( 
  BYTE bPduType, 
  SnmpVarBindList pVarBindList, 
  AsnInteger32 pErrorStatus, 
  AsnInteger32 pErrorIndex 
);

Parameters

  • bPduType
    [in] Specifies the SNMP version 1 (SNMPv1) PDU request type. This parameter can be one of the following values.

    Value Description

    SNMP_PDU_GET

    Retrieve the value or values of the specified variables.

    SNMP_PDU_GETNEXT

    Retrieve the value or values of the lexicographic successor of the specified variable.

    SNMP_PDU_SET

    Write a value within a specific variable.

  • pVarBindList
    [in, out] Pointer to the variable bindings list.
  • pErrorStatus
    [out] Pointer to a variable in which the result of the error status will be returned. This parameter can be one of the following values defined by SNMPv1

    Value Description

    SNMP_ERRORSTATUS_NOERROR

    The agent reports that no errors occurred during transmission.

    SNMP_ERRORSTATUS_TOOBIG

    The agent could not place the results of the requested operation into a single SNMP message.

    SNMP_ERRORSTATUS_NOSUCHNAME

    The requested operation identified an unknown variable.

    SNMP_ERRORSTATUS_BADVALUE

    The requested operation tried to change a variable but it specified either a syntax or value error.

    SNMP_ERRORSTATUS_READONLY

    The requested operation tried to change a variable that was not allowed to change according to the community profile of the variable.

    SNMP_ERRORSTATUS_GENERR

    An error other than one of those listed here occurred during the requested operation.

  • pErrorIndex
    [out] Pointer to a variable in which the error index result will be returned.

Return Value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE.

Remarks

When the SNMP service receives an SNMP PDU request, it calls the SnmpExtensionQuery function to process the request. The extension agent must follow the rules in RFC 1157 to either resolve the variable bindings or generate an error.

If the extension agent cannot resolve the variable bindings on a Get Next request, it must change the name field of the SnmpVarBind structure to the value of the object identifier immediately following that of the currently supported MIB subtree view. For example, if the extension agent supports view .1.3.6.1.4.1.77.1, a Get Next request on .1.3.6.1.4.1.77.1.5.1 would result in a modified name field of .1.3.6.1.4.1.77.2. This signals the SNMP service to continue the attempt to resolve the variable bindings with other extension agents.

It is important to note that the SNMP service and the extension agent may need to exchange dynamically allocated memory during a call to the SnmpExtensionQuery function. The service dynamically allocates the object identifier in each SnmpVarBind structure it passes to the extension agent. However, the extension agent must release this memory in order to replace the object identifier when it processes a GetNext request. The extension agent allocates dynamic memory for variable-length object types. The SNMP service releases this memory after the object is placed in the response PDU.

In order to avoid heap corruption and memory leaks, both the SNMP service and the extension agent must use memory allocation routines that resolve to the same heap. The extension agent must use the SnmpUtilMemAlloc function to allocate memory that it passes to the SNMP service. It must use the SnmpUtilMemFree function to release the memory the service passes back to the extension agent. These functions are located in the utility dynamic-link library SNMPAPI.DLL.

Requirements

Header snmp.h
Library snmp.lib
Windows Embedded CE Windows CE 3.0 and later

See Also

Reference

SnmpVarBind
SnmpExtensionInit
SnmpUtilMemAlloc
SnmpUtilMemFree