Kea 2.7.5
|
The RRType
class encapsulates DNS resource record types.
More...
#include <rrtype.h>
Public Member Functions | |
Constructors and Destructor | |
RRType (uint16_t typecode) | |
Constructor from an integer type code. | |
RRType (const std::string &typestr) | |
Constructor from a string. | |
RRType (isc::util::InputBuffer &buffer) | |
Constructor from wire-format data. | |
Converter methods | |
We use the default copy constructor intentionally. We use the default copy assignment operator intentionally. | |
const std::string | toText () const |
Convert the RRType to a string. | |
void | toWire (AbstractMessageRenderer &renderer) const |
Render the RRType in the wire format. | |
void | toWire (isc::util::OutputBuffer &buffer) const |
Render the RRType in the wire format. | |
Getter Methods | |
uint16_t | getCode () const |
Returns the RR type code as a 16-bit unsigned integer. | |
Comparison methods | |
bool | equals (const RRType &other) const |
Return true iff two RRTypes are equal. | |
bool | operator== (const RRType &other) const |
Same as equals() . | |
bool | nequals (const RRType &other) const |
Return true iff two RRTypes are not equal. | |
bool | operator!= (const RRType &other) const |
Same as nequals() . | |
bool | operator< (const RRType &other) const |
Less-than comparison for RRType against other . | |
static const RRType & | A () |
static const RRType & | NS () |
static const RRType & | SOA () |
static const RRType & | OPT () |
static const RRType & | PTR () |
static const RRType & | TXT () |
static const RRType & | AAAA () |
static const RRType & | RRSIG () |
static const RRType & | DHCID () |
static const RRType & | TKEY () |
static const RRType & | TSIG () |
static const RRType & | ANY () |
The RRType
class encapsulates DNS resource record types.
This class manages the 16-bit integer type codes in quite a straightforward way. The only non trivial task is to handle textual representations of RR types, such as "A", "AAAA", or "TYPE65534".
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 type codes and their "well-known" textual representations. Parameters of RR types 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 types. These are generally referred to as the form of RRType::{type-text}()
. For example, RRType::NS()
is an RRType
object corresponding to the NS resource record (type code 2). 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 RRType object has been initialized before the initialization for default_type
, we need help from the proxy function.
In the current implementation, the initialization of the well-known static objects is not thread safe. The same consideration as the RRParamRegistry
class applies. We may extend the implementation so that the initialization is ensured to be thread safe in a future version.
Note to developers: since it's expected that some of these constant RRType
objects are frequently used in a performance sensitive path, we define these proxy functions as inline. This makes sense only when the corresponding static objects are defined only once even if they used in different source files. Sufficiently modern compilers should meet this assumption, but if we encounter memory bloat due to this problem with particular compilers we need to revisit the design or think about workaround.
|
inlineexplicit |
|
explicit |
Constructor from a string.
A valid string is one of "well-known" textual type representations such as "A", "AAAA", or "NS", or in the standard format for "unknown" RR types as defined in RFC3597, i.e., "TYPEnnnn".
More precisely, the "well-known" representations are the ones stored in the RRParamRegistry
registry (see the class description).
As for the format of "TYPEnnnn", "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, "TYPE1" and "TYPE001" are valid and represent the same RR type, but "TYPE65536" and "TYPE000001" are invalid. A "TYPEnnnn" representation is valid even if the corresponding type code is registered in the RRParamRegistry
object. For example, both "A" and "TYPE1" are valid and represent the same RR type.
All of these representations are case insensitive; "NS" and "ns", and "TYPE1" and "type1" are all valid and represent the same RR types, respectively.
If the given string is not recognized as a valid representation of an RR type, an exception of class InvalidRRType
will be thrown.
typestr | A string representation of the RRType |
Definition at line 27 of file rrtype.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 RRType to be constructed. The current read position of the buffer points to the head of the type.
If the given data does not large enough to contain a 16-bit integer, an exception of class IncompleteRRType
will be thrown.
buffer | A buffer storing the wire format data. |
Definition at line 36 of file rrtype.cc.
References isc_throw.
|
inlinestatic |
Definition at line 279 of file rrtype.h.
Referenced by isc::d2::CheckExistsRemoveTransaction::buildRemoveFwdRRsRequest(), isc::d2::NameRemoveTransaction::buildRemoveFwdRRsRequest(), and isc::d2::NameChangeTransaction::getAddressRRType().
|
inlinestatic |
Definition at line 315 of file rrtype.h.
Referenced by isc::d2::CheckExistsRemoveTransaction::buildRemoveFwdRRsRequest(), isc::d2::NameRemoveTransaction::buildRemoveFwdRRsRequest(), and isc::d2::NameChangeTransaction::getAddressRRType().
|
inlinestatic |
Definition at line 345 of file rrtype.h.
Referenced by isc::d2::CheckExistsAddTransaction::buildAddFwdAddressRequest(), isc::d2::NameAddTransaction::buildAddFwdAddressRequest(), isc::d2::NameRemoveTransaction::buildRemoveFwdRRsRequest(), isc::d2::CheckExistsRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::NameRemoveTransaction::buildRemoveRevPtrsRequest(), and isc::d2::NameAddTransaction::buildReplaceFwdAddressRequest().
|
inlinestatic |
Definition at line 327 of file rrtype.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::d2::SimpleRemoveTransaction::buildRemoveFwdRRsRequest(), isc::d2::SimpleRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::CheckExistsAddTransaction::buildReplaceFwdAddressRequest(), isc::d2::NameAddTransaction::buildReplaceFwdAddressRequest(), isc::d2::SimpleAddTransaction::buildReplaceFwdAddressRequest(), isc::d2::CheckExistsAddTransaction::buildReplaceRevPtrsRequest(), isc::d2::NameAddTransaction::buildReplaceRevPtrsRequest(), and isc::d2::SimpleAddTransaction::buildReplaceRevPtrsRequest().
|
inline |
Return true iff two RRTypes are equal.
Two RRTypes are equal iff their type codes are equal.
This method never throws an exception.
other | the RRType object to compare against. |
Definition at line 219 of file rrtype.h.
Referenced by operator==().
|
inline |
|
inline |
Return true iff two RRTypes are not equal.
This method never throws an exception.
other | the RRType object to compare against. |
Definition at line 233 of file rrtype.h.
Referenced by operator!=().
|
inline |
|
inline |
Less-than comparison for RRType against other
.
We define the less-than relationship based on their type codes; one RRType 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 RRType 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 RRType object to compare against. |
this
RRType is less than the other
; otherwise false.
|
inline |
|
inlinestatic |
Definition at line 297 of file rrtype.h.
Referenced by isc::dns::EDNS::EDNS(), and isc::dns::MessageImpl::parseSection().
|
inlinestatic |
Definition at line 303 of file rrtype.h.
Referenced by isc::d2::CheckExistsRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::NameRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::SimpleRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::SimpleRemoveWithoutDHCIDTransaction::buildRemoveRevPtrsRequest(), isc::d2::CheckExistsAddTransaction::buildReplaceRevPtrsRequest(), isc::d2::NameAddTransaction::buildReplaceRevPtrsRequest(), isc::d2::SimpleAddTransaction::buildReplaceRevPtrsRequest(), and isc::d2::SimpleAddWithoutDHCIDTransaction::buildReplaceRevPtrsRequest().
|
inlinestatic |
Definition at line 321 of file rrtype.h.
Referenced by isc::dns::RRset::addRRsig(), and isc::dns::RRset::addRRsig().
|
inlinestatic |
Definition at line 291 of file rrtype.h.
Referenced by isc::d2::D2UpdateMessage::setZone().
const string isc::dns::RRType::toText | ( | ) | const |
Convert the RRType
to a string.
If a "well known" textual representation for the type 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" RR type in the format defined in RFC3597, i.e., "TYPEnnnn", and returns it.
If resource allocation for the string fails, a corresponding standard exception will be thrown.
RRType
. Definition at line 44 of file rrtype.cc.
References isc::dns::RRParamRegistry::getRegistry().
Referenced by isc::dns::Question::toText().
void isc::dns::RRType::toWire | ( | AbstractMessageRenderer & | renderer | ) | const |
Render the RRType
in the wire format.
This method renders the type 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 RRType is to be stored. |
Definition at line 54 of file rrtype.cc.
Referenced by isc::dns::Question::toWire(), isc::dns::BasicRRsetImpl::toWire(), and isc::dns::Question::toWire().
void isc::dns::RRType::toWire | ( | isc::util::OutputBuffer & | buffer | ) | const |
Render the RRType
in the wire format.
This method renders the type 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. |
|
inlinestatic |
Definition at line 339 of file rrtype.h.
Referenced by isc::dns::MessageImpl::parseSection(), and isc::dns::TSIGRecord::toText().