Platform SDK: Network Management

SnmpSetVb

The WinSNMP SnmpSetVb function changes variable binding entries in a variable bindings list. This function also appends new variable binding entries to an existing variable bindings list.

SNMPAPI_STATUS SnmpSetVb(
  HSNMP_VBL vbl,     // handle to the variable bindings list 
  smiUINT32 index,   // position of the variable binding entry
                     //   in the list 
  smiLPCOID name,    // pointer to the variable name portion
                     //   of the entry 
  smiLPCVALUE value  // pointer to the variable value portion
                     //   of the entry 
);

Parameters

vbl
[in] Handle to the variable bindings list to update.
index
[in] Specifies an unsigned long integer variable that contains the position of the variable binding entry, within the variable bindings list, if this is an update operation. If this is an append operation, this parameter must be equal to zero. For more information, see the following Remarks section.
name
[in] Pointer to an smiOID structure that represents the name of the variable to append or change. For more information, see the following Remarks section.
value
[in] Pointer to an smiVALUE structure. The structure contains the value associated with the variable specified by the name parameter.

Return Values

If the function succeeds, the return value is the position of the updated or appended variable binding entry in the variable bindings list. For additional information, see the following Remarks section.

If the function fails, the return value is SNMPAPI_FAILURE. To get extended error information, call SnmpGetLastError. The SnmpGetLastError function can return one of the following errors.

Error Code Description
SNMPAPI_NOT_INITIALIZED The SnmpStartup function did not complete successfully.
SNMPAPI_ALLOC_ERROR An error occurred during memory allocation.
SNMPAPI_VBL_INVALID The vbl parameter is invalid.
SNMPAPI_INDEX_INVALID The index parameter is invalid.
SNMPAPI_OID_INVALID The name parameter is invalid.
SNMPAPI_SYNTAX_INVALID The syntax member of the structure pointed to by the value parameter is invalid.
SNMPAPI_OTHER_ERROR An unknown or undefined error occurred.

Remarks

Valid values for the index parameter range from zero to n. The value zero indicates an append operation. The value n is the total number of variable binding entries in the variable bindings list. A WinSNMP application should call the SnmpCountVbl function before it calls SnmpSetVb to obtain the total number of variable binding entries.

If the function successfully performs an update operation, the return value equals the value of the index parameter. If the function appends a variable binding entry, the return value is n + 1.

If the name parameter is not NULL, but the value parameter is NULL, the Microsoft WinSNMP implementation initializes the new variable binding entry with the value member set to NULL and with the syntax member set to SNMP_SYNTAX_NULL.

If the index parameter is not equal to zero, and the name parameter is NULL, the Microsoft WinSNMP implementation updates only the value of the variable pointed to by the index parameter.

Requirements

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Unsupported.
  Header: Declared in Winsnmp.h.
  Library: Use Wsnmp32.lib.

See Also

WinSNMP API Overview, WinSNMP Functions, SnmpCountVbl, smiOID, smiVALUE