Kea 2.7.5
isc::dns::RRClass Class Reference

The RRClass class encapsulates DNS resource record classes. More...

#include <rrclass.h>

Public Member Functions

Converter methods

We use the default copy constructor intentionally.

We use the default copy assignment operator intentionally.

const std::string toText () const
 Convert the RRClass to a string.
 
void toWire (AbstractMessageRenderer &renderer) const
 Render the RRClass in the wire format.
 
void toWire (isc::util::OutputBuffer &buffer) const
 Render the RRClass in the wire format.
 
Getter Methods
uint16_t getCode () const
 Returns the RR class code as a 16-bit unsigned integer.
 

Comparison methods

bool equals (const RRClass &other) const
 Return true iff two RRClasses are equal.
 
bool operator== (const RRClass &other) const
 Same as equals().
 
bool nequals (const RRClass &other) const
 Return true iff two RRClasses are not equal.
 
bool operator!= (const RRClass &other) const
 Same as nequals().
 
bool operator< (const RRClass &other) const
 Less-than comparison for RRClass against other.
 
static const RRClassANY ()
 
static const RRClassIN ()
 
static const RRClassCH ()
 
static const RRClassNONE ()
 

Constructors and Destructor

 RRClass (uint16_t classcode)
 Constructor from an integer class code.
 
 RRClass (const std::string &class_str)
 A valid string is one of "well-known" textual class representations such as "IN" or "CH", or in the standard format for "unknown" classes as defined in RFC3597, i.e., "CLASSnnnn".
 
 RRClass (isc::util::InputBuffer &buffer)
 Constructor from wire-format data.
 
static RRClasscreateFromText (const std::string &class_str)
 A separate factory of RRClass from text.
 

Detailed Description

The RRClass class encapsulates DNS resource record classes.

This class manages the 16-bit integer class codes in quite a straightforward way. The only non trivial task is to handle textual representations of RR classes, such as "IN", "CH", or "CLASS65534".

This class consults a helper RRParamRegistry class, which is a registry of RR related parameters and has the singleton object. This registry provides a mapping between RR class codes and their "well-known" textual representations. Parameters of RR classes defined by DNS protocol standards are automatically registered at initialization time and are ensured to be always available for applications unless the application explicitly modifies the registry.

For convenience, this class defines constant class objects corresponding to standard RR classes. These are generally referred to as the form of RRClass::{class-text}(). For example, RRClass::IN() is an RRClass object corresponding to the IN class (class code 1). Note that these constants are used through a "proxy" function. This is because they may be used to initialize another non-local (e.g. global or namespace-scope) static object as follows:

namespace foo {
const RRClass default_class = RRClass::IN();
}
The RRClass class encapsulates DNS resource record classes.
Definition rrclass.h:89

In order to ensure that the constant RRClass object has been initialized before the initialization for default_class, we need help from the proxy function.

Note to developers: same note as RRType applies.

Definition at line 89 of file rrclass.h.

Constructor & Destructor Documentation

◆ RRClass() [1/3]

isc::dns::RRClass::RRClass ( uint16_t classcode)
inlineexplicit

Constructor from an integer class code.

This constructor never throws an exception.

Parameters
classcodeAn 16-bit integer code corresponding to the RRClass.

Definition at line 100 of file rrclass.h.

Referenced by createFromText().

◆ RRClass() [2/3]

isc::dns::RRClass::RRClass ( const std::string & class_str)
explicit

A valid string is one of "well-known" textual class representations such as "IN" or "CH", or in the standard format for "unknown" classes as defined in RFC3597, i.e., "CLASSnnnn".

More precisely, the "well-known" representations are the ones stored in the RRParamRegistry registry (see the class description).

As for the format of "CLASSnnnn", "nnnn" must represent a valid 16-bit unsigned integer, which may contain leading 0's as long as it consists of at most 5 characters (inclusive). For example, "CLASS1" and "CLASS0001" are valid and represent the same class, but "CLASS65536" and "CLASS000001" are invalid. A "CLASSnnnn" representation is valid even if the corresponding class code is registered in the RRParamRegistry object. For example, both "IN" and "CLASS1" are valid and represent the same class.

All of these representations are case insensitive; "IN" and "in", and "CLASS1" and "class1" are all valid and represent the same classes, respectively.

If the given string is not recognized as a valid representation of an RR class, an exception of class InvalidRRClass will be thrown.

Parameters
class_strA string representation of the RRClass

Definition at line 26 of file rrclass.cc.

References isc::dns::RRParamRegistry::getRegistry(), and isc_throw.

+ Here is the call graph for this function:

◆ RRClass() [3/3]

isc::dns::RRClass::RRClass ( isc::util::InputBuffer & buffer)
explicit

Constructor from wire-format data.

The buffer parameter normally stores a complete DNS message containing the RRClass to be constructed. The current read position of the buffer points to the head of the class.

If the given data does not large enough to contain a 16-bit integer, an exception of class IncompleteRRClass will be thrown.

Parameters
bufferA buffer storing the wire format data.

Definition at line 35 of file rrclass.cc.

References isc_throw.

Member Function Documentation

◆ ANY()

◆ CH()

const RRClass & isc::dns::RRClass::CH ( )
inlinestatic

Definition at line 310 of file rrclass.h.

◆ createFromText()

RRClass * isc::dns::RRClass::createFromText ( const std::string & class_str)
static

A separate factory of RRClass from text.

This static method is similar to the constructor that takes a string object, but works as a factory and reports parsing failure in the form of the return value. Normally the constructor version should suffice, but in some cases the caller may have to expect mixture of valid and invalid input, and may want to minimize the overhead of possible exception handling. This version is provided for such purpose.

For the format of the class_str argument, see the RRClass(const std::string&) constructor.

If the given text represents a valid RRClass, it returns a pointer to a new RRClass object. If the given text does not represent a valid RRClass, it returns null.

One main purpose of this function is to minimize the overhead when the given text does not represent a valid RR class. For this reason this function intentionally omits the capability of delivering a detailed reason for the parse failure, such as in the want() string when exception is thrown from the constructor (it will internally require a creation of string object, which is relatively expensive). If such detailed information is necessary, the constructor version should be used to catch the resulting exception.

This function never throws the InvalidRRClass exception.

Parameters
class_strA string representation of the RRClass.
Returns
A new RRClass object for the given text or a null value.

Definition at line 58 of file rrclass.cc.

References RRClass(), and isc::dns::RRParamRegistry::getRegistry().

+ Here is the call graph for this function:

◆ equals()

bool isc::dns::RRClass::equals ( const RRClass & other) const
inline

Return true iff two RRClasses are equal.

Two RRClasses are equal iff their class codes are equal.

This method never throws an exception.

Parameters
otherthe RRClass object to compare against.
Returns
true if the two RRClasses are equal; otherwise false.

Definition at line 246 of file rrclass.h.

Referenced by operator==().

◆ getCode()

uint16_t isc::dns::RRClass::getCode ( ) const
inline

Returns the RR class code as a 16-bit unsigned integer.

This method never throws an exception.

Returns
An 16-bit integer code corresponding to the RRClass.

Definition at line 229 of file rrclass.h.

◆ IN()

◆ nequals()

bool isc::dns::RRClass::nequals ( const RRClass & other) const
inline

Return true iff two RRClasses are not equal.

This method never throws an exception.

Parameters
otherthe RRClass object to compare against.
Returns
true if the two RRClasses are not equal; otherwise false.

Definition at line 261 of file rrclass.h.

Referenced by operator!=().

◆ NONE()

◆ operator!=()

bool isc::dns::RRClass::operator!= ( const RRClass & other) const
inline

Same as nequals().

Definition at line 265 of file rrclass.h.

References nequals().

+ Here is the call graph for this function:

◆ operator<()

bool isc::dns::RRClass::operator< ( const RRClass & other) const
inline

Less-than comparison for RRClass against other.

We define the less-than relationship based on their class codes; one RRClass is less than the other iff the code of the former is less than that of the other as unsigned integers. The relationship is meaningless in terms of DNS protocol; the only reason we define this method is that RRClass objects can be stored in STL containers without requiring user-defined less-than relationship. We therefore don't define other comparison operators.

This method never throws an exception.

Parameters
otherthe RRClass object to compare against.
Returns
true if this RRClass is less than the other; otherwise false.

Definition at line 284 of file rrclass.h.

◆ operator==()

bool isc::dns::RRClass::operator== ( const RRClass & other) const
inline

Same as equals().

Definition at line 251 of file rrclass.h.

References equals().

+ Here is the call graph for this function:

◆ toText()

const string isc::dns::RRClass::toText ( ) const

Convert the RRClass to a string.

If a "well known" textual representation for the class code is registered in the RR parameter registry (see the class description), that will be used as the return value of this method. Otherwise, this method creates a new string for an "unknown" class in the format defined in RFC3597, i.e., "CLASSnnnn", and returns it.

If resource allocation for the string fails, a corresponding standard exception will be thrown.

Returns
A string representation of the RRClass.

Definition at line 43 of file rrclass.cc.

References isc::dns::RRParamRegistry::getRegistry().

Referenced by isc::d2::D2Zone::toText(), and isc::dns::Question::toText().

+ Here is the call graph for this function:

◆ toWire() [1/2]

void isc::dns::RRClass::toWire ( AbstractMessageRenderer & renderer) const

Render the RRClass in the wire format.

This method renders the class code in network byte order via renderer, which encapsulates output buffer and other rendering contexts.

If resource allocation in rendering process fails, a corresponding standard exception will be thrown.

Parameters
rendererDNS message rendering context that encapsulates the output buffer in which the RRClass is to be stored.

Definition at line 53 of file rrclass.cc.

Referenced by isc::dns::Question::toWire(), isc::dns::BasicRRsetImpl::toWire(), and isc::dns::Question::toWire().

◆ toWire() [2/2]

void isc::dns::RRClass::toWire ( isc::util::OutputBuffer & buffer) const

Render the RRClass in the wire format.

This method renders the class code in network byte order into the buffer.

If resource allocation in rendering process fails, a corresponding standard exception will be thrown.

Parameters
bufferAn output buffer to store the wire data.

Definition at line 48 of file rrclass.cc.


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