Home
You are not currently signed in.

MIB Smithy

  1. Up to Table of Contents

Comparing OID Values

MIB Smithy SDK provide several forms for "lexicographically" comparing two object identifier values. By default, each OID value is fully compared to determine whether one OID is less than, equal to, or greater than the other. Additional options may be used to limit the number of subidentifiers compared to a specified prefix or to automatically determine if one OID represents a subtree of the other.

Syntax:

% dbcmd oidcmp ?options? oid1 oid2

Where:

dbcmd
is the name of the database;
options
are one or more optional parameters for specifying the level of comparison to be performed;
oid1
is the first object identifier value to be compared; and
oid2
is the second object identifier value to be compared

The OID values may be provided in any of the forms accepted elsewhere by the SDK (i.e., "absolute" dotted-number OID values, simple identifiers, or "relative" OID values with or without named subidentifiers). The SDK will first convert relative OIDs to absolute OIDs prior to comparison using the set of modules loaded into the named database.

Returns:

  • -1 If the compared portion of oid1 is less than that of oid2.
  • 0 If the compared portion of oid1 is equal to that of oid2.
  • 1 If the compared portion of oid1 is greater than that of oid2.

Options:

-limit count
Instructs the comparision function to do compare at most count subidentifiers of the two specified OIDs and is useful for prefix matching, similar to subtree matching but with a fixed number of subidentifiers. Note that the count is applied to the fully resolved OID values, or as much can be resolved given the available loaded MIB modules.
-nocomplain
Disables errors that may occur if one or both OID values cannot be fully resolved to one of the three root values and the two OID values do not resolve to the same unknown parent. If both resolve the same parent (such as mib-2.1.2.3 and mib-2.3.4.5 if mib-2 were undefined), no error will occur regardless of this option. However, if the two start at different points then an error will occur unless this option is specified, in which case the return value will either be a string comparison of the first identifier (if neither could be resolved) or, if one was fully resolved and the other was not, the fully-resolved OID will always be considered "greater than" the unresolved OID.
-subtree
Instructs the comparision function to do "subtree" matching. This option is similar to -limit, however the number of subidentifiers compared is automatically the same as the number of subidentifiers in the oid1 argument. Thus, specifying this option instructs the function to return 0 if oid2 is a subtree of, or equal to, oid1.

Examples

% $db oidcmp 1.3.6.1.2.1.1.1.0 1.3.6.1.2.1.1.2.0
-1
% $db oidcmp 1.3.6.1.2.1.1.2.0 1.3.6.1.2.1.1.1.0
1
% $db oidcmp -limit 2 1.3.6.1 1.3.10
0
% $db oidcmp -subtree system sysDescr
0
% $db oidcmp -subtree sysDescr system
1
% $db oidcmp -subtree 1.3.6.1 1.3.6
1
% $db oidcmp -subtree 1.3.6 1.3.6.1
0
% $db oidcmp -subtree 1.3.6 1.4.6.1
-1
  1. Up to Table of Contents