Kea 2.7.5
|
The Rdata
class is an abstract base class that provides a set of common interfaces to manipulate concrete RDATA objects.
More...
#include <rdata.h>
Public Member Functions | |
Converter methods | |
virtual std::string | toText () const =0 |
Convert an Rdata to a string. | |
virtual void | toWire (isc::util::OutputBuffer &buff) const =0 |
Render the Rdata in the wire format into a buffer. | |
virtual void | toWire (AbstractMessageRenderer &renderer) const =0 |
Render the Rdata in the wire format into a MessageRenderer object. | |
Comparison method | |
virtual int | compare (const Rdata &other) const =0 |
Compare two instances of Rdata . | |
virtual uint16_t | getLength () const |
Get the wire format length of an Rdata. | |
Constructors and Destructor | |
Note: The copy constructor and the assignment operator are intentionally defined as private. Concrete classes should generally specialize their own versions of these methods. | |
Rdata () | |
The default constructor. | |
virtual | ~Rdata () |
The destructor. | |
The Rdata
class is an abstract base class that provides a set of common interfaces to manipulate concrete RDATA objects.
Generally, a separate derived class directly inherited from the base Rdata
class is defined for each well known RDATA. Each of such classes will define the common logic based on the corresponding protocol standard.
Since some types of RRs are class specific and the corresponding RDATA may have different semantics (e.g. type A for class IN and type A for class CH have different representations and semantics), we separate Rdata
derived classes for such RR types in different namespaces. The namespace of types specific to a class is named the lower-cased class name; for example, RDATA of class IN-specific types are defined in the in
namespace, and RDATA of class CH-specific types are defined in the ch
namespace, and so on. The derived classes are named using the RR type name (upper cased) such as A
or AAAA
. Thus RDATA of type A RR for class IN and CH are defined as in::A
and ch::A
, respectively. Many other RR types are class independent; the derived Rdata
classes for such RR types are defined in the generic
namespace. Examples are generic::NS
and generic::SOA
.
If applications need to refer to these derived classes, it is generally recommended to prepend at least some part of the namespace because the same class name can be used in different namespaces. So, instead of doing
it is advisable to prepend at least in
from the namespace:
In many cases, however, an application doesn't have to care about such derived classes. For instance, to parse an incoming DNS message an application wouldn't have to perform type specific operation unless the application is specifically concerned about a particular type. So, this API generally handles Rdata
in a polymorphic way through a pointer or reference to this base abstract class.
|
inlineprotected |
The default constructor.
This is intentionally defined as protected
as this base class should never be instantiated (except as part of a derived class). In many cases, the derived class wouldn't define a public default constructor either, because an Rdata
object without concrete data isn't meaningful.
|
inlinevirtual |
|
pure virtual |
Compare two instances of Rdata
.
This method compares this
and the other
Rdata objects in terms of the DNSSEC sorting order as defined in RFC4034, and returns the result as an integer.
This is a pure virtual method without the definition; the actual comparison logic is specific to each derived concrete class and should be explicitly defined in the derived class.
Specific implementations of this method must confirm that this
and the other
are objects of the same concrete derived class of Rdata
. This is normally done by dynamic_cast
in the implementation. It also means if the assumption isn't met an exception of class std::bad_cast
will be thrown.
Here is an implementation choice: instead of relying on dynamic_cast
, we could first convert the data into wire-format and compare the pair as opaque data. This would be more polymorphic, but might involve significant overhead, especially for a large size of RDATA.
other | the right-hand operand to compare against. |
this
would be sorted before other
. this
is identical to other
in terms of sorting order. this
would be sorted after other
. Implemented in isc::dns::rdata::generic::Generic, isc::dns::rdata::any::TSIG, isc::dns::rdata::ch::A, isc::dns::rdata::generic::NS, isc::dns::rdata::generic::OPT, isc::dns::rdata::generic::PTR, isc::dns::rdata::generic::RRSIG, isc::dns::rdata::generic::SOA, isc::dns::rdata::generic::TKEY, isc::dns::rdata::generic::TXT, isc::dns::rdata::in::A, isc::dns::rdata::in::AAAA, and isc::dns::rdata::in::DHCID.
|
virtual |
Get the wire format length of an Rdata.
IMPLEMENTATION NOTE: Currently this base class implementation is non-optimal as it renders the wire data to a buffer and returns the buffer's length. What would perform better is to add implementations of getLength()
method to every RDATA type. This is why this method is virtual. Once all Rdata types have getLength()
implementations, this base class implementation must be removed and the method should become a pure interface.
Definition at line 43 of file rdata.cc.
References toWire().
|
pure virtual |
Convert an Rdata
to a string.
This method returns a std::string
object representing the Rdata
.
This is a pure virtual method without the definition; the actual representation is specific to each derived concrete class and should be explicitly defined in the derived class.
Rdata
. Implemented in isc::dns::rdata::generic::Generic, isc::dns::rdata::any::TSIG, isc::dns::rdata::ch::A, isc::dns::rdata::generic::NS, isc::dns::rdata::generic::OPT, isc::dns::rdata::generic::PTR, isc::dns::rdata::generic::RRSIG, isc::dns::rdata::generic::SOA, isc::dns::rdata::generic::TKEY, isc::dns::rdata::generic::TXT, isc::dns::rdata::in::A, isc::dns::rdata::in::AAAA, and isc::dns::rdata::in::DHCID.
|
pure virtual |
Render the Rdata
in the wire format into a MessageRenderer
object.
This is a pure virtual method without the definition; the actual conversion is specific to each derived concrete class and should be explicitly defined in the derived class.
renderer | DNS message rendering context that encapsulates the output buffer in which the Rdata is to be stored. |
Implemented in isc::dns::rdata::generic::Generic, isc::dns::rdata::any::TSIG, isc::dns::rdata::ch::A, isc::dns::rdata::generic::NS, isc::dns::rdata::generic::OPT, isc::dns::rdata::generic::PTR, isc::dns::rdata::generic::RRSIG, isc::dns::rdata::generic::SOA, isc::dns::rdata::generic::TKEY, isc::dns::rdata::generic::TXT, isc::dns::rdata::in::A, isc::dns::rdata::in::AAAA, and isc::dns::rdata::in::DHCID.
|
pure virtual |
Render the Rdata
in the wire format into a buffer.
This is a pure virtual method without the definition; the actual conversion is specific to each derived concrete class and should be explicitly defined in the derived class.
buff | An output buffer to store the wire data. |
Implemented in isc::dns::rdata::generic::Generic, isc::dns::rdata::any::TSIG, isc::dns::rdata::ch::A, isc::dns::rdata::generic::NS, isc::dns::rdata::generic::OPT, isc::dns::rdata::generic::PTR, isc::dns::rdata::generic::RRSIG, isc::dns::rdata::generic::SOA, isc::dns::rdata::generic::TKEY, isc::dns::rdata::generic::TXT, isc::dns::rdata::in::A, isc::dns::rdata::in::AAAA, and isc::dns::rdata::in::DHCID.
Referenced by getLength().