SnmpOidCompare

[This is preliminary documentation and subject to change.]

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
Pointer to the first smiOID object identifier to compare. The length of the object identifier can be zero.
yOID
Pointer to the second smiOID object identifier to compare. The length of the object identifier can be zero.
maxlen
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
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. 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 manager 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:

QuickInfo

  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.

See Also

WinSNMP Manager API Overview, WinSNMP Functions, smiOID