Platform SDK: Network Management

SnmpOidCompare

The WinSNMP SnmpOidCompare function lexicographically compares two SNMP object identifiers, up to the length specified by the maxlen parameter.

SNMPAPI_STATUS SnmpOidCompare(
  smiLPCOID xOID,      // first object identifier to compare 
  smiLPCOID yOID,      // second object identifier to compare 
  smiUINT32 maxlen,    // maximum length to compare 
  smiLPINT result      // result of comparison 
);

Parameters

xOID
[in] Pointer to the first smiOID object identifier to compare. The length of the object identifier can be zero.
yOID
[in] Pointer to the second smiOID object identifier to compare. The length of the object identifier can be zero.
maxlen
[in] If not equal to zero, specifies the number of subidentifiers to compare. This parameter must be less than MAXOBJIDSIZE: 128 subidentifiers, the maximum number of components in an object identifier. For additional information, see the following Remarks section.
result
[out] Pointer to an integer variable to receive the result of the comparison. The variable can receive one of the following results.
Result Meaning
Greater than 0 xOID is greater than yOID
Equal to 0 xOID equals yOID
Less than 0 xOID is less than yOID

For additional comparison conditions, see the following Remarks section.

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 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_OID_INVALID One or both of the xOID and yOID parameters is invalid.
SNMPAPI_SIZE_INVALID The maxlen parameter is invalid. The parameter size is greater than MAXOBJIDSIZE.
SNMPAPI_OTHER_ERROR An unknown or undefined error occurred.

Remarks

A WinSNMP application can call the SnmpOidCompare function to determine whether two object identifiers have common prefixes.

If the maxlen parameter is not equal to zero, and not greater than MAXOBJIDSIZE, the value of maxlen sets the upper limit for the number of subidentifiers to compare. The maximum number of subidentifiers that the SnmpOidCompare function compares defaults to whichever is the smallest number — the maxlen parameter, or the len member of one of the smiOID structures pointed to by the xOID and yOID parameters.

If the maxlen parameter is equal to zero, the maximum number of subidentifiers that the SnmpOidCompare function compares defaults to the number that is the smaller of the len members of the two smiOID structures.

The value of the result parameter will indicate that xOID equals yOID if the two smiOID structures are lexicographically equal and one of the following occurs:

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, smiOID