[This is preliminary documentation and subject to change.]
The WinSNMP SnmpDecodeMsg function decodes an encoded SNMP message into its components. This function performs the opposite action of the WinSNMP SnmpEncodeMsg function.
SNMPAPI_STATUS SnmpDecodeMsg(
HSNMP_SESSION session, // handle to the WinSNMP session
LPHSNMP_ENTITY srcEntity, // handle to the source entity
LPHSNMP_ENTITY dstEntity, // handle to the target entity
LPHSNMP_CONTEXT context, // handle to the context
LPHSNMP_PDU pdu, // handle to the PDU
smiLPCOCTETS msgBufDesc // pointer to the message buffer
);
If the function succeeds, the return value is the number of decoded bytes. This value can be equal to, or less than, the len member of the smiOCTETS structure pointed to by the msgBufDesc parameter.
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 parameter is invalid. |
SNMPAPI_ENTITY_INVALID | One or both of the entity parameters is invalid. |
SNMPAPI_CONTEXT_INVALID | The context parameter is invalid. |
SNMPAPI_PDU_INVALID | The pdu parameter is invalid. |
SNMPAPI_OUTPUT_TRUNCATED | The output buffer length is insufficient. No output parameters were created. |
SNMPAPI_MESSAGE_INVALID | The SNMP message format in the buffer indicated by the msgBufDesc parameter is invalid. No output parameters were created. |
SNMPAPI_OTHER_ERROR | An unknown or undefined error occurred. |
The Microsoft WinSNMP implementation allocates resources to the WinSNMP manager application as a result of a successful call to the SnmpDecodeMsg function. It is recommended that the WinSNMP manager application free individual resources with the WinSNMP function that corresponds to the resource. For additional information, see Freeing WinSNMP Descriptors and WinSNMP Data Management Concepts.
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, SnmpEncodeMsg, SnmpFreeEntity, SnmpFreeContext, SnmpFreePdu, SnmpSendMsg, smiOCTETS