[This is preliminary documentation and subject to change.]
The WinSNMP SnmpCreatePdu function creates and initializes an SNMP protocol data unit (PDU).
HSNMP_PDU SnmpCreatePdu(
HSNMP_SESSION session, // handle to the WinSNMP session
smiINT PDU_type, // PDU type
smiINT32 request_id, // PDU request identifier
smiINT error_status, // valid only for SNMP_PDU_GETBULK requests
smiINT error_index, // valid only for SNMP_PDU_GETBULK requests
HSNMP_VBL varbindlist // handle to the variable bindings list
);
Value | Meaning |
---|---|
SNMP_PDU_GET | Search and retrieve a value from a specified SNMP variable. |
SNMP_PDU_GETNEXT | Search and retrieve the value of an SNMP variable without knowing the exact name of the variable. |
SNMP_PDU_RESPONSE | Reply to an SNMP_PDU_GET or an SNMP_PDU_GETNEXT request. |
SNMP_PDU_SET | Store a value in a specified SNMP variable. |
SNMP_PDU_V1TRAP | Alerts the management system to an extraordinary event under the SNMP version 1 (SNMPv1) framework. This type is obsolete in SNMP version 2C (SNMPv2C). |
SNMP_PDU_GETBULK | Search and retrieve multiple values with a single request. |
SNMP_PDU_TRAP | Alerts the management system to an event under SNMPv2C. |
If the function succeeds, the return value is the handle to a new SNMP PDU.
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_SESSION_INVALID | The session handle is invalid. |
SNMPAPI_PDU_INVALID | The PDU type is invalid. |
SNMPAPI_VBL_INVALID | The variable bindings list is invalid. |
SNMPAPI_OTHER_ERROR | An unknown or undefined error occurred. |
A WinSNMP manager application must create a PDU before it calls the SnmpSendMsg or the SnmpEncodeMsg functions.
All of the parameters of the SnmpCreatePdu function are required. However, all parameters, except the session parameter, can be NULL. In this instance, the new PDU has the following default values.
Field | Contents |
---|---|
PDU_type | SNMP_PDU_GETNEXT |
request_id | The implementation generates a numeric value. |
error_status | SNMP_ERROR_NOERROR |
error_index | 0 |
varbindlist | NULL |
The application must call the SnmpFreePdu function to release the resources that the SnmpCreatePdu function allocates for the new PDU.
Windows NT: Requires version 5.0 or later. Available as a redistributable for Windows NT 4.0.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in winsnmp.h.
Import Library: Use wsnmp32.lib.
WinSNMP Manager API Overview, WinSNMP Functions, SnmpFreePdu, SnmpSendMsg, SnmpEncodeMsg