Kea 2.7.6
|
The RRTTL
class encapsulates TTLs used in DNS resource records.
More...
#include <rrttl.h>
Public Member Functions | |
Converter methods | |
const std::string | toText () const |
Convert the RRTTL to a string. | |
void | toWire (AbstractMessageRenderer &renderer) const |
Render the RRTTL in the wire format. | |
void | toWire (isc::util::OutputBuffer &buff) const |
Render the RRTTL in the wire format. | |
Getter Methods | |
uint32_t | getValue () const |
Returns the TTL value as a 32-bit unsigned integer. | |
Comparison methods | |
Comparison between two | |
bool | equals (const RRTTL &other) const |
Return true iff two RRTTLs are equal. | |
bool | operator== (const RRTTL &other) const |
Same as equals() . | |
bool | nequals (const RRTTL &other) const |
Return true iff two RRTTLs are not equal. | |
bool | operator!= (const RRTTL &other) const |
Same as nequals() . | |
bool | leq (const RRTTL &other) const |
Less-than or equal comparison for RRTTL against other . | |
bool | operator<= (const RRTTL &other) const |
Same as leq() | |
bool | geq (const RRTTL &other) const |
Greater-than or equal comparison for RRTTL against other . | |
bool | operator>= (const RRTTL &other) const |
Same as geq() | |
bool | lthan (const RRTTL &other) const |
Less-than comparison for RRTTL against other . | |
bool | operator< (const RRTTL &other) const |
Same as lthan() | |
bool | gthan (const RRTTL &other) const |
Greater-than comparison for RRTTL against other . | |
bool | operator> (const RRTTL &other) const |
Same as gthan() | |
Protocol constants | |
static const RRTTL & | MAX_TTL () |
The TTL of the max allowable value, per RFC2181 Section 8. | |
Constructors, Factory and Destructor | |
Note: We use the default copy constructor and the default copy assignment operator intentionally. | |
RRTTL (uint32_t ttlval) | |
Constructor from an integer TTL value. | |
RRTTL (const std::string &ttlstr) | |
Constructor from a string. | |
RRTTL (isc::util::InputBuffer &buff) | |
Constructor from wire-format data. | |
static RRTTL * | createFromText (const std::string &ttlstr) |
A separate factory of RRTTL from text. | |
The RRTTL
class encapsulates TTLs used in DNS resource records.
This is a straightforward class; an RRTTL
object simply maintains a 32-bit unsigned integer corresponding to the TTL value. The main purpose of this class is to provide convenient interfaces to convert a textual representation into the integer TTL value and vice versa, and to handle wire-format representations.
|
inlineexplicit |
Constructor from an integer TTL value.
This constructor never throws an exception.
ttlval | An 32-bit integer of the RRTTL. |
Definition at line 64 of file rrttl.h.
Referenced by createFromText().
|
explicit |
Constructor from a string.
It accepts either a decimal number, specifying number of seconds. Or, it can be given a sequence of numbers and units, like "2H" (meaning two hours), "1W3D" (one week and 3 days). The allowed units are W (week), D (day), H (hour), M (minute) and S (second). They can be also specified in lower-case. No further restrictions are checked (so they can be specified in arbitrary order and even things like "1D1D" can be used to specify two days).
ttlstr | A string representation of the RRTTL . |
InvalidRRTTL | in case the string is not recognized as valid TTL representation. |
Definition at line 168 of file rrttl.cc.
References isc_throw.
|
explicit |
Constructor from wire-format data.
The buffer
parameter normally stores a complete DNS message containing the RRTTL 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 IncompleteRRTTL
will be thrown.
buff | A buffer storing the wire format data. |
Definition at line 184 of file rrttl.cc.
References isc::util::InputBuffer::getLength(), isc::util::InputBuffer::getPosition(), isc_throw, and isc::util::InputBuffer::readUint32().
|
static |
A separate factory of RRTTL 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.
If the given text represents a valid RRTTL, it returns a pointer to a new RRTTL object. If the given text does not represent a valid RRTTL, it returns null..
One main purpose of this function is to minimize the overhead when the given text does not represent a valid RR TTL. 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 InvalidRRTTL
exception.
ttlstr | A string representation of the RRTTL . |
Definition at line 176 of file rrttl.cc.
References RRTTL().
|
inline |
|
inline |
|
inline |
Returns the TTL value as a 32-bit unsigned integer.
This method never throws an exception.
Definition at line 173 of file rrttl.h.
Referenced by isc::dns::EDNS::EDNS(), and isc::dns::createEDNSFromRR().
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
const string isc::dns::RRTTL::toText | ( | ) | const |
Convert the RRTTL
to a string.
This version of implementation simply converts the TTL value into the numeric textual representation. We may introduce more human-readable format depending on the context in future versions.
If resource allocation in rendering process fails, a corresponding standard exception will be thrown.
RRTTL
. Definition at line 192 of file rrttl.cc.
Referenced by isc::dns::operator<<(), and isc::dns::AbstractRRset::toText().
void isc::dns::RRTTL::toWire | ( | AbstractMessageRenderer & | renderer | ) | const |
Render the RRTTL
in the wire format.
This method renders the TTL value 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 RRTTL is to be stored. |
Definition at line 204 of file rrttl.cc.
References isc::dns::AbstractMessageRenderer::writeUint32().
Referenced by isc::dns::BasicRRsetImpl::toWire().
void isc::dns::RRTTL::toWire | ( | isc::util::OutputBuffer & | buff | ) | const |
Render the RRTTL
in the wire format.
This method renders the TTL value in network byte order into the buffer
.
If resource allocation in rendering process fails, a corresponding standard exception will be thrown.
buff | An output buffer to store the wire data. |
Definition at line 199 of file rrttl.cc.
References isc::util::OutputBuffer::writeUint32().