SnmpMgrRequest 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 SnmpMgrRequest function requests the specified operation be performed with the specified agent. This function is an element of the SNMP Management API.

Syntax

SNMPAPI SNMP_FUNC_TYPE SnmpMgrRequest(
  [in]      LPSNMP_MGR_SESSION session,
  [in]      BYTE               requestType,
  [in, out] RFC1157VarBindList *variableBindings,
  [out]     AsnInteger         *errorStatus,
  [out]     AsnInteger         *errorIndex
);

Parameters

[in] session

Pointer to an internal structure that specifies the session that will perform the request.

Applications should not specify the LPSNMP_MGR_SESSION pointer returned by this function in a different thread. You can specify a pointer returned by SnmpMgrOpen, but only if the calls to SnmpMgrOpen and SnmpMgrRequest originate in the context of the same thread.

[in] requestType

Specifies the SNMP request type. This parameter can be one of the following values defined by SNMPv1.

Value Meaning
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.
 

Note that PDU request types have been renamed. For additional information, see SNMP Variable Types and Request PDU Types.

[in, out] variableBindings

Pointer to the variable bindings list.

Note  The SnmpVarBind array pointed to by the SnmpVarBindList structure must be allocated using the SnmpUtilMemAlloc function.
 

[out] errorStatus

Pointer to a variable in which the error status result will be returned. This parameter can be one of the following values defined by SNMPv1.

Value Meaning
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.

[out] errorIndex

Pointer to a variable in which the error index result will be returned.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is NULL. To get extended error information, call GetLastError, which may return one of the following error codes.

Return code Description
SNMP_MGMTAPI_TIMEOUT
The request timed-out.
SNMP_MGMTAPI_SELECT_FDERRORS
Unexpected error file descriptors indicated by the Windows Sockets select function.

Remarks

Retries and time-outs are supplied to the SnmpMgrOpen function. Each variable in the variable bindings list must be initialized to type ASN_NULL for Get and Get Next requests.

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

See also

SNMP Functions

Simple Network Management Protocol (SNMP) Overview

SnmpMgrClose

SnmpMgrOpen