Platform SDK: Network Management

SnmpSetPduData

The WinSNMP SnmpSetPduData function updates selected data fields in the specified SNMP protocol data unit (PDU).

SNMPAPI_STATUS SnmpSetPduData(
  HSNMP_PDU PDU,                 // handle to the PDU 
  const smiINT *PDU_type,        // pointer to the PDU type 
  const smiINT32 *request_id,    // pointer to the PDU request identifier
  const smiINT *non_repeaters,   // valid only for an
                                 //   SNMP_PDU_GETBULK request 
  const smiINT *max_repetitions, // valid only for an
                                 //   SNMP_PDU_GETBULK request 
  const HSNMP_VBL *varbindlist   // handle to variable bindings list
);

Parameters

PDU
[in] Handle to an SNMP PDU.
PDU_type
[in] Pointer to a variable with a value to update the PDU_type field of the specified PDU. This parameter can also be NULL.
request_id
[in] Pointer to a variable with a value to update the request_id field of the specified PDU. This parameter can also be NULL.
non_repeaters
[in] If the PDU_type parameter is equal to SNMP_PDU_GETBULK, this parameter points to a variable with a value to update the non_repeaters field of the specified PDU. The Microsoft WinSNMP implementation ignores this parameter for other PDU types. This parameter can also be NULL.
max_repetitions
[in] If the PDU_type parameter is equal to SNMP_PDU_GETBULK, this parameter points to a variable with a value to update the max_repetitions field of the specified PDU. The implementation ignores this parameter for other PDU types. This parameter can also be NULL.
varbindlist
[in] Pointer to a variable with a value that updates the handle to the variable bindings list field of the specified PDU. This parameter can also be NULL.

Return Values

If the function succeeds, the return value is SNMPAPI_SUCCESS.

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_PDU_INVALID The PDU type is invalid.
SNMPAPI_VBL_INVALID The variable bindings list is invalid.
SNMPAPI_NOOP All input parameters are NULL. The SNMP operation was not performed.
SNMPAPI_OTHER_ERROR An unknown or undefined error occurred.

Remarks

All parameters of the SnmpSetPduData function are required. However, all parameters, except the PDU parameter, can be NULL. If the WinSNMP application passes NULL in a parameter, SnmpSetPduData does not update the corresponding field in the PDU. Because SnmpSetPduData passes parameters as pointers to values, an application can still update a PDU field with NULL.

The value of one PDU field can be valid alone, but may be invalidated in combination with values for other fields. The implementation validates the PDU and the other message elements when the application calls the SnmpSendMsg or the SnmpEncodeMsg functions. The implementation rejects invalid PDUs.

The only type of trap PDU you can update with a call to the SnmpSetPduData function is an SNMPv2C trap PDU.

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, SnmpSendMsg, SnmpEncodeMsg