Kea: isc::dns::RRClass Class Reference

| Kea 3.2.0-git

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 RRClass & | ANY ()
static const RRClass & | IN ()
static const RRClass & | CH ()
static const RRClass & | NONE ()

## 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 RRClass * | createFromText (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();
}
isc::dns::RRClass::IN
static const RRClass & IN()
Definition rrclass.h:304
isc::dns::RRClass::RRClass
RRClass(uint16_t classcode)
Constructor from an integer class code.
Definition rrclass.h:100

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

  classcode | An 16-bit integer code corresponding to the RRClass.

Definition at line 100 of file rrclass.h.

Referenced by ANY(), CH(), createFromText(), equals(), IN(), nequals(), NONE(), operator!=(), operator<(), and operator==().

## ◆ 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_str | A 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

  buffer | A buffer storing the wire format data.

Definition at line 35 of file rrclass.cc.

References isc::util::InputBuffer::getLength(), isc::util::InputBuffer::getPosition(), isc_throw, and isc::util::InputBuffer::readUint16().

Here is the call graph for this function:

## Member Function Documentation

## ◆ ANY()

const RRClass & isc::dns::RRClass::ANY | ( |  | ) |
| inlinestatic

Definition at line 298 of file rrclass.h.

References RRClass().

Referenced by isc::d2::CheckExistsRemoveTransaction::buildRemoveFwdAddressRequest(), isc::d2::CheckExistsRemoveTransaction::buildRemoveFwdRRsRequest(), isc::d2::NameRemoveTransaction::buildRemoveFwdRRsRequest(), isc::d2::SimpleRemoveTransaction::buildRemoveFwdRRsRequest(), isc::d2::SimpleRemoveWithoutDHCIDTransaction::buildRemoveFwdRRsRequest(), isc::d2::CheckExistsRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::NameRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::SimpleRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::SimpleRemoveWithoutDHCIDTransaction::buildRemoveRevPtrsRequest(), isc::d2::CheckExistsAddTransaction::buildReplaceFwdAddressRequest(), isc::d2::NameAddTransaction::buildReplaceFwdAddressRequest(), isc::d2::SimpleAddTransaction::buildReplaceFwdAddressRequest(), isc::d2::SimpleAddWithoutDHCIDTransaction::buildReplaceFwdAddressRequest(), isc::d2::CheckExistsAddTransaction::buildReplaceRevPtrsRequest(), isc::d2::NameAddTransaction::buildReplaceRevPtrsRequest(), isc::d2::SimpleAddTransaction::buildReplaceRevPtrsRequest(), isc::d2::SimpleAddWithoutDHCIDTransaction::buildReplaceRevPtrsRequest(), isc::dns::TSIGRecord::getClass(), isc::dns::BasicRRset::getLength(), isc::dns::MessageImpl::parseSection(), isc::dns::AbstractRRset::toText(), and isc::dns::BasicRRsetImpl::toWire().

Here is the call graph for this function:

## ◆ CH()

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

Definition at line 310 of file rrclass.h.

References RRClass().

Here is the call graph for this function:

## ◆ 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_str | A 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

  other | the `RRClass` object to compare against.

Returns
  true if the two RRClasses are equal; otherwise false.

Definition at line 246 of file rrclass.h.

References RRClass().

Referenced by operator==().

Here is the call graph for this function:

## ◆ 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.

Referenced by isc::dns::EDNS::EDNS().

## ◆ IN()

const RRClass & isc::dns::RRClass::IN | ( |  | ) |
| inlinestatic

Definition at line 304 of file rrclass.h.

References RRClass().

Referenced by isc::d2::CheckExistsAddTransaction::buildAddFwdAddressRequest(), isc::d2::NameAddTransaction::buildAddFwdAddressRequest(), isc::d2::NameRemoveTransaction::buildRemoveFwdAddressRequest(), isc::d2::NameRemoveTransaction::buildRemoveFwdRRsRequest(), isc::d2::CheckExistsRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::NameRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::CheckExistsAddTransaction::buildReplaceFwdAddressRequest(), isc::d2::NameAddTransaction::buildReplaceFwdAddressRequest(), isc::d2::SimpleAddTransaction::buildReplaceFwdAddressRequest(), isc::d2::SimpleAddWithoutDHCIDTransaction::buildReplaceFwdAddressRequest(), isc::d2::CheckExistsAddTransaction::buildReplaceRevPtrsRequest(), isc::d2::NameAddTransaction::buildReplaceRevPtrsRequest(), isc::d2::SimpleAddTransaction::buildReplaceRevPtrsRequest(), isc::d2::SimpleAddWithoutDHCIDTransaction::buildReplaceRevPtrsRequest(), and isc::d2::NameChangeTransaction::prepNewRequest().

Here is the call graph for this function:

## ◆ 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

  other | the `RRClass` object to compare against.

Returns
  true if the two RRClasses are not equal; otherwise false.

Definition at line 261 of file rrclass.h.

References RRClass().

Referenced by operator!=().

Here is the call graph for this function:

## ◆ NONE()

const RRClass & isc::dns::RRClass::NONE | ( |  | ) |
| inlinestatic

Definition at line 316 of file rrclass.h.

References RRClass().

Referenced by isc::d2::CheckExistsAddTransaction::buildAddFwdAddressRequest(), isc::d2::NameAddTransaction::buildAddFwdAddressRequest(), isc::d2::CheckExistsRemoveTransaction::buildRemoveFwdAddressRequest(), isc::d2::NameRemoveTransaction::buildRemoveFwdAddressRequest(), isc::d2::CheckExistsRemoveTransaction::buildRemoveFwdRRsRequest(), isc::d2::NameRemoveTransaction::buildRemoveFwdRRsRequest(), isc::dns::BasicRRset::getLength(), isc::dns::MessageImpl::parseSection(), isc::dns::AbstractRRset::toText(), and isc::dns::BasicRRsetImpl::toWire().

Here is the call graph for this function:

## ◆ operator!=()

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

Same as `nequals()`.

Definition at line 265 of file rrclass.h.

References RRClass(), and 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

  other | the `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.

References RRClass().

Here is the call graph for this function:

## ◆ operator==()

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

Same as `equals()`.

Definition at line 251 of file rrclass.h.

References RRClass(), and 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::dns::operator<<(), and isc::dns::AbstractRRset::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

  renderer | DNS message rendering context that encapsulates the output buffer in which the RRClass is to be stored.

Definition at line 53 of file rrclass.cc.

References isc::dns::AbstractMessageRenderer::writeUint16().

Here is the call graph for this function:

## ◆ 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

  buffer | An output buffer to store the wire data.

Definition at line 48 of file rrclass.cc.

References isc::util::OutputBuffer::writeUint16().

Here is the call graph for this function:

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

- rrclass.h
- rrclass.cc