Kea 2.5.8
isc::dns::NameComparisonResult Class Reference

This is a supplemental class used only as a return value of Name::compare() and LabelSequence::compare(). More...

#include <name.h>

Public Types

enum  NameRelation {
  SUPERDOMAIN = 0 , SUBDOMAIN = 1 , EQUAL = 2 , COMMONANCESTOR = 3 ,
  NONE = 4
}
 The relation of two names under comparison. More...
 

Public Member Functions

Constructors and Destructor
 NameComparisonResult (int order, unsigned int nlabels, NameRelation relation)
 Constructor from a comparison tuple.
 

Getter Methods

int getOrder () const
 Returns the ordering of the comparison result.
 
unsigned int getCommonLabels () const
 Returns the number of common labels of the comparison result.
 
NameRelation getRelation () const
 Returns the NameRelation of the comparison result.
 

Detailed Description

This is a supplemental class used only as a return value of Name::compare() and LabelSequence::compare().

It encapsulate a tuple of the comparison: ordering, number of common labels, and relationship as follows:

  • ordering: relative ordering under the DNSSEC order relation
  • labels: the number of common significant labels of the two names or two label sequences being compared
  • relationship: see NameComparisonResult::NameRelation

Note that the ordering is defined for two label sequences that have no hierarchical relationship (in which case the relationship will be NONE). For example, two non absolute (or "relative") sequences "example.com" and "example.org" have no hierarchical relationship, and the former should be sorted before (i.e. "smaller") than the latter.

Definition at line 113 of file name.h.

Member Enumeration Documentation

◆ NameRelation

The relation of two names under comparison.

Its semantics for the case of name1->compare(name2) (where name1 and name2 are instances of the Name or LabelSequence class) is as follows:

  • SUPERDOMAIN: name1 properly contains name2; name2 is a proper subdomain of name1
  • SUBDOMAIN: name1 is a proper subdomain of name2
  • EQUAL: name1 and name2 are equal
  • COMMONANCESTOR: name1 and name2 share a common ancestor
  • NONE: There's no hierarchical relationship between name1 and name2

Note that there's always a hierarchical relationship between any two names since all names (not generic label sequences) are absolute and they at least share the trailing empty label. So, for example, the relationship between "com." and "net." is "commonancestor". The relationship of "NONE" can only happen for comparison between two label sequences (LabelSequence objects); usually only SUPERDOMAIN, SUBDOMAIN or EQUAL are important relationship between two names.

When two LabelSequence objects are compared, it's generally expected they are either both absolute or both non absolute; if one is absolute and the other is not, the resulting relationship will be NONE.

Enumerator
SUPERDOMAIN 
SUBDOMAIN 
EQUAL 
COMMONANCESTOR 
NONE 

Definition at line 138 of file name.h.

Constructor & Destructor Documentation

◆ NameComparisonResult()

isc::dns::NameComparisonResult::NameComparisonResult ( int  order,
unsigned int  nlabels,
NameRelation  relation 
)
inline

Constructor from a comparison tuple.

This constructor simply initializes the object in the straightforward way.

Definition at line 154 of file name.h.

Member Function Documentation

◆ getCommonLabels()

unsigned int isc::dns::NameComparisonResult::getCommonLabels ( ) const
inline

Returns the number of common labels of the comparison result.

Definition at line 166 of file name.h.

◆ getOrder()

int isc::dns::NameComparisonResult::getOrder ( ) const
inline

Returns the ordering of the comparison result.

Definition at line 164 of file name.h.

◆ getRelation()

NameRelation isc::dns::NameComparisonResult::getRelation ( ) const
inline

Returns the NameRelation of the comparison result.

Definition at line 168 of file name.h.


The documentation for this class was generated from the following file: