Kea 2.7.6
|
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. | |
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:
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.
|
inlineexplicit |
Constructor from an integer class code.
This constructor never throws an exception.
classcode | An 16-bit integer code corresponding to the RRClass. |
Definition at line 100 of file rrclass.h.
Referenced by createFromText().
|
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.
class_str | A string representation of the RRClass |
Definition at line 26 of file rrclass.cc.
References isc::dns::RRParamRegistry::getRegistry(), and isc_throw.
|
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.
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().
|
inlinestatic |
Definition at line 298 of file rrclass.h.
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().
|
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.
class_str | A string representation of the RRClass . |
Definition at line 58 of file rrclass.cc.
References RRClass(), and isc::dns::RRParamRegistry::getRegistry().
|
inline |
Return true iff two RRClasses are equal.
Two RRClasses are equal iff their class codes are equal.
This method never throws an exception.
other | the RRClass object to compare against. |
Definition at line 246 of file rrclass.h.
Referenced by operator==().
|
inline |
Returns the RR class code as a 16-bit unsigned integer.
This method never throws an exception.
Definition at line 229 of file rrclass.h.
Referenced by isc::dns::EDNS::EDNS().
|
inlinestatic |
Definition at line 304 of file rrclass.h.
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().
|
inline |
Return true iff two RRClasses are not equal.
This method never throws an exception.
other | the RRClass object to compare against. |
Definition at line 261 of file rrclass.h.
Referenced by operator!=().
|
inlinestatic |
Definition at line 316 of file rrclass.h.
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().
|
inline |
|
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.
other | the RRClass object to compare against. |
this
RRClass is less than the other
; otherwise false.
|
inline |
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.
RRClass
. Definition at line 43 of file rrclass.cc.
References isc::dns::RRParamRegistry::getRegistry().
Referenced by isc::dns::operator<<(), isc::d2::D2Zone::toText(), isc::dns::AbstractRRset::toText(), and isc::dns::Question::toText().
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.
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().
Referenced by isc::dns::BasicRRsetImpl::toWire(), isc::dns::Question::toWire(), and isc::dns::Question::toWire().
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.
buffer | An output buffer to store the wire data. |
Definition at line 48 of file rrclass.cc.
References isc::util::OutputBuffer::writeUint16().