Platform SDK: Network Management |
The WinSNMP SnmpOidToStr function converts the internal binary representation of an SNMP object identifier to its dotted numeric string format, for example, to "1.2.3.4.5.6".
SNMPAPI_STATUS SnmpOidToStr( smiLPCOID srcOID, // object identifier to convert smiUINT32 size, // buffer size for string LPSTR string // pointer to buffer for converted string // object identifier );
If the function succeeds, the return value is the length, in bytes, of the string that the WinSNMP application writes to the string parameter. The return value includes a null-terminating byte. This value may be less than or equal to the value of the size parameter, but it may not be greater.
If the function fails, the return value is SNMPAPI_FAILURE. To get extended error information, call SnmpGetLastError specifying a NULL value in its session parameter. 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_SIZE_INVALID | The size parameter is invalid. This parameter cannot be equal to zero; it must indicate the size of the buffer pointed to by the string parameter. |
SNMPAPI_OID_INVALID | The srcOID parameter is invalid. For additional information, see the following Remarks section. |
SNMPAPI_OUTPUT_TRUNCATED | The output buffer length is insufficient. |
SNMPAPI_OTHER_ERROR | An unknown or undefined error occurred. |
It is recommended that a WinSNMP application specify, with the size parameter, a string buffer of MAXOBJIDSTRSIZE length (1408 bytes). This ensures that the output buffer is large enough to hold the converted string. Because the converted string is usually less than MAXOBJIDSTRSIZE, the WinSNMP application can copy the converted string to a smaller buffer. The application can then reuse or free the memory that it allocated for the initial buffer. For additional information, see WinSNMP Data Management Concepts.
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Unsupported.
Header: Declared in Winsnmp.h.
Library: Use Wsnmp32.lib.
WinSNMP API Overview, WinSNMP Functions, SnmpStrToOid, smiOID