Kea
1.9.9-git
|
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. More... | |
RRType (const std::string &typestr) | |
Constructor from a string. More... | |
RRType (isc::util::InputBuffer &buffer) | |
Constructor from wire-format data. More... | |
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. More... | |
void | toWire (AbstractMessageRenderer &renderer) const |
Render the RRType in the wire format. More... | |
void | toWire (isc::util::OutputBuffer &buffer) const |
Render the RRType in the wire format. More... | |
Getter Methods | |
uint16_t | getCode () const |
Returns the RR type code as a 16-bit unsigned integer. More... | |
Comparison methods | |
bool | equals (const RRType &other) const |
Return true iff two RRTypes are equal. More... | |
bool | operator== (const RRType &other) const |
Same as equals() . More... | |
bool | nequals (const RRType &other) const |
Return true iff two RRTypes are not equal. More... | |
bool | operator!= (const RRType &other) const |
Same as nequals() . More... | |
bool | operator< (const RRType &other) const |
Less-than comparison for RRType against other . More... | |
Static Public Member Functions | |
static const RRType & | A () |
static const RRType & | A6 () |
static const RRType & | AAAA () |
static const RRType & | AFSDB () |
static const RRType & | ANY () |
static const RRType & | APL () |
static const RRType & | AXFR () |
static const RRType & | CAA () |
static const RRType & | CERT () |
static const RRType & | CNAME () |
static const RRType & | DHCID () |
static const RRType & | DLV () |
static const RRType & | DNAME () |
static const RRType & | DNSKEY () |
static const RRType & | DS () |
static const RRType & | GPOS () |
static const RRType & | HINFO () |
static const RRType & | HIP () |
static const RRType & | IPSECKEY () |
static const RRType & | ISDN () |
static const RRType & | IXFR () |
static const RRType & | KEY () |
static const RRType & | KX () |
static const RRType & | L32 () |
static const RRType & | L64 () |
static const RRType & | LOC () |
static const RRType & | LP () |
static const RRType & | MAILA () |
static const RRType & | MAILB () |
static const RRType & | MB () |
static const RRType & | MD () |
static const RRType & | MF () |
static const RRType & | MG () |
static const RRType & | MINFO () |
static const RRType & | MR () |
static const RRType & | MX () |
static const RRType & | NAPTR () |
static const RRType & | NID () |
static const RRType & | NS () |
static const RRType & | NSAP () |
static const RRType & | NSAP_PTR () |
static const RRType & | NSEC () |
static const RRType & | NSEC3 () |
static const RRType & | NSEC3PARAM () |
static const RRType & | Null () |
static const RRType & | NXT () |
static const RRType & | OPT () |
static const RRType & | PTR () |
static const RRType & | PX () |
static const RRType & | RP () |
static const RRType & | RRSIG () |
static const RRType & | RT () |
static const RRType & | SIG () |
static const RRType & | SOA () |
static const RRType & | SPF () |
static const RRType & | SRV () |
static const RRType & | SSHFP () |
static const RRType & | TKEY () |
static const RRType & | TLSA () |
static const RRType & | TSIG () |
static const RRType & | TXT () |
static const RRType & | UNSPEC () |
static const RRType & | URI () |
static const RRType & | WKS () |
static const RRType & | X25 () |
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 28 of file rrtype.cc.
References 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 37 of file rrtype.cc.
References isc::util::InputBuffer::getLength(), isc::util::InputBuffer::getPosition(), isc_throw, and isc::util::InputBuffer::readUint16().
|
inlinestatic |
Definition at line 341 of file rrtype.h.
Referenced by isc::d2::NameRemoveTransaction::buildRemoveFwdRRsRequest(), and isc::d2::NameChangeTransaction::getAddressRRType().
|
inlinestatic |
Definition at line 497 of file rrtype.h.
Referenced by isc::d2::NameRemoveTransaction::buildRemoveFwdRRsRequest(), and isc::d2::NameChangeTransaction::getAddressRRType().
|
inlinestatic |
|
inlinestatic |
Definition at line 503 of file rrtype.h.
Referenced by isc::d2::NameAddTransaction::buildAddFwdAddressRequest(), isc::d2::NameRemoveTransaction::buildRemoveFwdAddressRequest(), isc::d2::SimpleRemoveTransaction::buildRemoveFwdRRsRequest(), isc::d2::NameRemoveTransaction::buildRemoveFwdRRsRequest(), isc::d2::SimpleRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::SimpleAddTransaction::buildReplaceFwdAddressRequest(), isc::d2::NameAddTransaction::buildReplaceFwdAddressRequest(), isc::d2::SimpleAddTransaction::buildReplaceRevPtrsRequest(), and isc::d2::NameAddTransaction::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 226 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 237 of file rrtype.h.
Referenced by operator!=().
|
inlinestatic |
|
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 437 of file rrtype.h.
Referenced by isc::dns::EDNS::EDNS(), and isc::dns::MessageImpl::parseSection().
|
inlinestatic |
Definition at line 443 of file rrtype.h.
Referenced by isc::d2::SimpleRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::NameRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::SimpleAddTransaction::buildReplaceRevPtrsRequest(), and isc::d2::NameAddTransaction::buildReplaceRevPtrsRequest().
|
inlinestatic |
Definition at line 455 of file rrtype.h.
Referenced by isc::dns::RRset::addRRsig().
|
inlinestatic |
Definition at line 461 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 45 of file rrtype.cc.
Referenced by isc::dns::operator<<(), isc::dns::Question::toText(), and isc::dns::TSIGRecord::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 55 of file rrtype.cc.
References isc::dns::AbstractMessageRenderer::writeUint16().
Referenced by 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. |
Definition at line 50 of file rrtype.cc.
References isc::util::OutputBuffer::writeUint16().
|
inlinestatic |
Definition at line 335 of file rrtype.h.
Referenced by isc::dns::MessageImpl::parseSection(), and isc::dns::TSIGRecord::toText().