SnmpExtensionQuery
The
extensible agent calls the SnmpExtensionQuery function in the extension
agent DLL to resolve SNMP requests that contain variables within one or more of
the extension agent s registered MIB subtrees.
BOOL
SnmpExtensionQuery(
BYTE requestType, |
|
RFC1157VarBindList *variableBindings, |
|
AsnInteger *errorStatus, |
|
AsnInteger *errorIndex |
|
); |
|
Parameters
requestType
[in]
Specifies the SNMP request type. This parameter can be one of the following
values:
Value |
Meaning |
ASN_RFC1157_GETREQUEST |
Search and
receive a value from a specified variable. |
ASN_RFC1157_GETNEXTREQUEST |
Search and
receive a value from a variable without knowing the name of the variable. |
ASN_RFC1157_SETREQUEST |
Store a
value within a specific variable. |
variableBindings
[in/out]
Points to the variable bindings list.
errorStatus
[out] Points
to a variable in which the error status result will be returned. This parameter
can be one of the following values:
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. |
errorIndex
[out] Points
to a variable in which the error index result will be returned.
Return Values
If the function
succeeds, the return value is TRUE.
If the
function fails, the return value is FALSE.
Remarks
When the
extensible agent must resolve a Get, Get Next, or Set
command within the subtree indicated by the SnmpExtensionInit
A Get Next
command is more complicated to process because the extension agent may not
be able to resolve the requested variable binding. If the variable binding can
be resolved, the extension agent must follow the rules in RFC 1157 to either
resolve the variable bindings request or generate an error. If the extension agent
cannot resolve the variable binding, it must change the name field of
the RFC1157VarBind
It is
important to note that the extensible agent and the extension agent may need to
exchange dynamically allocated memory during a call to the SnmpExtensionQuery
function. The extensible agent dynamically allocates the object identifier in
each RFC1157VarBind 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 Get Next request. The
extension agent allocates dynamic memory for variable-length object types. The
extensible agent needs to release this memory after the object is placed in the
response.
In order to
avoid heap corruption and memory leaks, both the extensible agent and the
extension agent must use memory allocation routines that resolve to the same
heap. Extension agents should use the SnmpUtilMemAlloc function to
allocate memory and the SnmpUtilMemFree function to release memory.
These functions are located in the utility dynamic-link library SNMPAPI.DLL.
See Also
RFC1157VarBind, SnmpExtensionInit9SY827, SnmpUtilMemAlloc , SnmpUtilMemFree