Kea  2.1.7-git
isc::dns::RRType Class Reference

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 RRTypeA ()
 
static const RRTypeA6 ()
 
static const RRTypeAAAA ()
 
static const RRTypeAFSDB ()
 
static const RRTypeANY ()
 
static const RRTypeAPL ()
 
static const RRTypeAXFR ()
 
static const RRTypeCAA ()
 
static const RRTypeCERT ()
 
static const RRTypeCNAME ()
 
static const RRTypeDHCID ()
 
static const RRTypeDLV ()
 
static const RRTypeDNAME ()
 
static const RRTypeDNSKEY ()
 
static const RRTypeDS ()
 
static const RRTypeGPOS ()
 
static const RRTypeHINFO ()
 
static const RRTypeHIP ()
 
static const RRTypeIPSECKEY ()
 
static const RRTypeISDN ()
 
static const RRTypeIXFR ()
 
static const RRTypeKEY ()
 
static const RRTypeKX ()
 
static const RRTypeL32 ()
 
static const RRTypeL64 ()
 
static const RRTypeLOC ()
 
static const RRTypeLP ()
 
static const RRTypeMAILA ()
 
static const RRTypeMAILB ()
 
static const RRTypeMB ()
 
static const RRTypeMD ()
 
static const RRTypeMF ()
 
static const RRTypeMG ()
 
static const RRTypeMINFO ()
 
static const RRTypeMR ()
 
static const RRTypeMX ()
 
static const RRTypeNAPTR ()
 
static const RRTypeNID ()
 
static const RRTypeNS ()
 
static const RRTypeNSAP ()
 
static const RRTypeNSAP_PTR ()
 
static const RRTypeNSEC ()
 
static const RRTypeNSEC3 ()
 
static const RRTypeNSEC3PARAM ()
 
static const RRTypeNull ()
 
static const RRTypeNXT ()
 
static const RRTypeOPT ()
 
static const RRTypePTR ()
 
static const RRTypePX ()
 
static const RRTypeRP ()
 
static const RRTypeRRSIG ()
 
static const RRTypeRT ()
 
static const RRTypeSIG ()
 
static const RRTypeSOA ()
 
static const RRTypeSPF ()
 
static const RRTypeSRV ()
 
static const RRTypeSSHFP ()
 
static const RRTypeTKEY ()
 
static const RRTypeTLSA ()
 
static const RRTypeTSIG ()
 
static const RRTypeTXT ()
 
static const RRTypeUNSPEC ()
 
static const RRTypeURI ()
 
static const RRTypeWKS ()
 
static const RRTypeX25 ()
 

Detailed Description

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:

namespace foo {
const RRType default_type = RRType::A();
}

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.

Definition at line 106 of file rrtype.h.

Constructor & Destructor Documentation

◆ RRType() [1/3]

isc::dns::RRType::RRType ( uint16_t  typecode)
inlineexplicit

Constructor from an integer type code.

This constructor never throws an exception.

Parameters
typecodeAn 16-bit integer code corresponding to the RRType.

Definition at line 117 of file rrtype.h.

◆ RRType() [2/3]

isc::dns::RRType::RRType ( const std::string &  typestr)
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.

Parameters
typestrA string representation of the RRType

Definition at line 28 of file rrtype.cc.

References isc_throw.

◆ RRType() [3/3]

isc::dns::RRType::RRType ( isc::util::InputBuffer buffer)
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.

Parameters
bufferA 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().

+ Here is the call graph for this function:

Member Function Documentation

◆ A()

const RRType & isc::dns::RRType::A ( )
inlinestatic

◆ A6()

const RRType & isc::dns::RRType::A6 ( )
inlinestatic

Definition at line 569 of file rrtype.h.

◆ AAAA()

const RRType & isc::dns::RRType::AAAA ( )
inlinestatic

◆ AFSDB()

const RRType & isc::dns::RRType::AFSDB ( )
inlinestatic

Definition at line 347 of file rrtype.h.

◆ ANY()

◆ APL()

const RRType & isc::dns::RRType::APL ( )
inlinestatic

Definition at line 665 of file rrtype.h.

◆ AXFR()

const RRType & isc::dns::RRType::AXFR ( )
inlinestatic

Definition at line 521 of file rrtype.h.

◆ CAA()

const RRType & isc::dns::RRType::CAA ( )
inlinestatic

Definition at line 353 of file rrtype.h.

◆ CERT()

const RRType & isc::dns::RRType::CERT ( )
inlinestatic

Definition at line 659 of file rrtype.h.

◆ CNAME()

const RRType & isc::dns::RRType::CNAME ( )
inlinestatic

Definition at line 359 of file rrtype.h.

◆ DHCID()

◆ DLV()

const RRType & isc::dns::RRType::DLV ( )
inlinestatic

Definition at line 365 of file rrtype.h.

◆ DNAME()

const RRType & isc::dns::RRType::DNAME ( )
inlinestatic

Definition at line 371 of file rrtype.h.

◆ DNSKEY()

const RRType & isc::dns::RRType::DNSKEY ( )
inlinestatic

Definition at line 377 of file rrtype.h.

◆ DS()

const RRType & isc::dns::RRType::DS ( )
inlinestatic

Definition at line 383 of file rrtype.h.

◆ equals()

bool isc::dns::RRType::equals ( const RRType other) const
inline

Return true iff two RRTypes are equal.

Two RRTypes are equal iff their type codes are equal.

This method never throws an exception.

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

Definition at line 226 of file rrtype.h.

◆ getCode()

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

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

This method never throws an exception.

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

Definition at line 211 of file rrtype.h.

◆ GPOS()

const RRType & isc::dns::RRType::GPOS ( )
inlinestatic

Definition at line 641 of file rrtype.h.

◆ HINFO()

const RRType & isc::dns::RRType::HINFO ( )
inlinestatic

Definition at line 389 of file rrtype.h.

◆ HIP()

const RRType & isc::dns::RRType::HIP ( )
inlinestatic

Definition at line 677 of file rrtype.h.

◆ IPSECKEY()

const RRType & isc::dns::RRType::IPSECKEY ( )
inlinestatic

Definition at line 671 of file rrtype.h.

◆ ISDN()

const RRType & isc::dns::RRType::ISDN ( )
inlinestatic

Definition at line 623 of file rrtype.h.

◆ IXFR()

const RRType & isc::dns::RRType::IXFR ( )
inlinestatic

Definition at line 515 of file rrtype.h.

◆ KEY()

const RRType & isc::dns::RRType::KEY ( )
inlinestatic

Definition at line 629 of file rrtype.h.

◆ KX()

const RRType & isc::dns::RRType::KX ( )
inlinestatic

Definition at line 653 of file rrtype.h.

◆ L32()

const RRType & isc::dns::RRType::L32 ( )
inlinestatic

Definition at line 695 of file rrtype.h.

◆ L64()

const RRType & isc::dns::RRType::L64 ( )
inlinestatic

Definition at line 701 of file rrtype.h.

◆ LOC()

const RRType & isc::dns::RRType::LOC ( )
inlinestatic

Definition at line 647 of file rrtype.h.

◆ LP()

const RRType & isc::dns::RRType::LP ( )
inlinestatic

Definition at line 707 of file rrtype.h.

◆ MAILA()

const RRType & isc::dns::RRType::MAILA ( )
inlinestatic

Definition at line 575 of file rrtype.h.

◆ MAILB()

const RRType & isc::dns::RRType::MAILB ( )
inlinestatic

Definition at line 713 of file rrtype.h.

◆ MB()

const RRType & isc::dns::RRType::MB ( )
inlinestatic

Definition at line 545 of file rrtype.h.

◆ MD()

const RRType & isc::dns::RRType::MD ( )
inlinestatic

Definition at line 533 of file rrtype.h.

◆ MF()

const RRType & isc::dns::RRType::MF ( )
inlinestatic

Definition at line 539 of file rrtype.h.

◆ MG()

const RRType & isc::dns::RRType::MG ( )
inlinestatic

Definition at line 551 of file rrtype.h.

◆ MINFO()

const RRType & isc::dns::RRType::MINFO ( )
inlinestatic

Definition at line 395 of file rrtype.h.

◆ MR()

const RRType & isc::dns::RRType::MR ( )
inlinestatic

Definition at line 557 of file rrtype.h.

◆ MX()

const RRType & isc::dns::RRType::MX ( )
inlinestatic

Definition at line 401 of file rrtype.h.

◆ NAPTR()

const RRType & isc::dns::RRType::NAPTR ( )
inlinestatic

Definition at line 407 of file rrtype.h.

◆ nequals()

bool isc::dns::RRType::nequals ( const RRType other) const
inline

Return true iff two RRTypes are not equal.

This method never throws an exception.

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

Definition at line 237 of file rrtype.h.

◆ NID()

const RRType & isc::dns::RRType::NID ( )
inlinestatic

Definition at line 689 of file rrtype.h.

◆ NS()

const RRType & isc::dns::RRType::NS ( )
inlinestatic

Definition at line 413 of file rrtype.h.

◆ NSAP()

const RRType & isc::dns::RRType::NSAP ( )
inlinestatic

Definition at line 605 of file rrtype.h.

◆ NSAP_PTR()

const RRType & isc::dns::RRType::NSAP_PTR ( )
inlinestatic

Definition at line 611 of file rrtype.h.

◆ NSEC()

const RRType & isc::dns::RRType::NSEC ( )
inlinestatic

Definition at line 431 of file rrtype.h.

◆ NSEC3()

const RRType & isc::dns::RRType::NSEC3 ( )
inlinestatic

Definition at line 419 of file rrtype.h.

◆ NSEC3PARAM()

const RRType & isc::dns::RRType::NSEC3PARAM ( )
inlinestatic

Definition at line 425 of file rrtype.h.

◆ Null()

const RRType & isc::dns::RRType::Null ( )
inlinestatic

Definition at line 581 of file rrtype.h.

◆ NXT()

const RRType & isc::dns::RRType::NXT ( )
inlinestatic

Definition at line 563 of file rrtype.h.

◆ operator!=()

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

Same as nequals().

Definition at line 240 of file rrtype.h.

◆ operator<()

bool isc::dns::RRType::operator< ( const RRType other) const
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.

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

Definition at line 257 of file rrtype.h.

◆ operator==()

bool isc::dns::RRType::operator== ( const RRType other) const
inline

Same as equals().

Definition at line 229 of file rrtype.h.

◆ OPT()

const RRType & isc::dns::RRType::OPT ( )
inlinestatic

◆ PTR()

◆ PX()

const RRType & isc::dns::RRType::PX ( )
inlinestatic

Definition at line 635 of file rrtype.h.

◆ RP()

const RRType & isc::dns::RRType::RP ( )
inlinestatic

Definition at line 449 of file rrtype.h.

◆ RRSIG()

const RRType & isc::dns::RRType::RRSIG ( )
inlinestatic

Definition at line 455 of file rrtype.h.

◆ RT()

const RRType & isc::dns::RRType::RT ( )
inlinestatic

Definition at line 599 of file rrtype.h.

◆ SIG()

const RRType & isc::dns::RRType::SIG ( )
inlinestatic

Definition at line 617 of file rrtype.h.

◆ SOA()

const RRType & isc::dns::RRType::SOA ( )
inlinestatic

◆ SPF()

const RRType & isc::dns::RRType::SPF ( )
inlinestatic

Definition at line 467 of file rrtype.h.

◆ SRV()

const RRType & isc::dns::RRType::SRV ( )
inlinestatic

Definition at line 509 of file rrtype.h.

◆ SSHFP()

const RRType & isc::dns::RRType::SSHFP ( )
inlinestatic

Definition at line 473 of file rrtype.h.

◆ TKEY()

const RRType & isc::dns::RRType::TKEY ( )
inlinestatic

Definition at line 479 of file rrtype.h.

◆ TLSA()

const RRType & isc::dns::RRType::TLSA ( )
inlinestatic

Definition at line 485 of file rrtype.h.

◆ toText()

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.

Returns
A string representation of the RRType.

Definition at line 45 of file rrtype.cc.

Referenced by isc::dns::operator<<(), isc::dns::Question::toText(), and isc::dns::TSIGRecord::toText().

◆ toWire() [1/2]

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.

Parameters
rendererDNS 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::TSIGRecord::getTTL(), isc::dns::AbstractRRset::toText(), isc::dns::BasicRRsetImpl::toWire(), and isc::dns::Question::toWire().

+ Here is the call graph for this function:

◆ toWire() [2/2]

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.

Parameters
bufferAn output buffer to store the wire data.

Definition at line 50 of file rrtype.cc.

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

+ Here is the call graph for this function:

◆ TSIG()

const RRType & isc::dns::RRType::TSIG ( )
inlinestatic

◆ TXT()

const RRType & isc::dns::RRType::TXT ( )
inlinestatic

Definition at line 491 of file rrtype.h.

◆ UNSPEC()

const RRType & isc::dns::RRType::UNSPEC ( )
inlinestatic

Definition at line 683 of file rrtype.h.

◆ URI()

const RRType & isc::dns::RRType::URI ( )
inlinestatic

Definition at line 719 of file rrtype.h.

References isc::util::operator<<().

+ Here is the call graph for this function:

◆ WKS()

const RRType & isc::dns::RRType::WKS ( )
inlinestatic

Definition at line 587 of file rrtype.h.

◆ X25()

const RRType & isc::dns::RRType::X25 ( )
inlinestatic

Definition at line 593 of file rrtype.h.


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