Platform SDK: Network Management |
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, // PDU error status, unless type is SNMP_PDU_GETBULK smiINT error_index, // PDU error index, unless type is SNMP_PDU_GETBULK 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_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 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/2000: Requires Windows 2000.
Windows 95/98: Unsupported.
Header: Declared in Winsnmp.h.
Library: Use Wsnmp32.lib.
WinSNMP API Overview, WinSNMP Functions, SnmpFreePdu, SnmpSendMsg, SnmpEncodeMsg