 |
Kea
1.5.0
|
Go to the documentation of this file.
13 #include <boost/shared_ptr.hpp>
14 #include <boost/foreach.hpp>
32 AbstractRRset::addRdata(
const Rdata& rdata) {
33 addRdata(
createRdata(getType(), getClass(), rdata));
37 AbstractRRset::toText()
const {
45 if (getClass() != RRClass::ANY() &&
50 s += getName().toText() +
" " + getTTL().toText() +
" " +
51 getClass().toText() +
" " + getType().toText() +
"\n";
56 s += getName().toText() +
" " + getTTL().toText() +
" " +
57 getClass().toText() +
" " + getType().toText() +
" " +
58 it->getCurrent().toText() +
"\n";
60 }
while (!it->isLast());
63 s += getRRsig()->toText();
75 rrsetToWire(
const AbstractRRset& rrset, T& output,
const size_t limit) {
81 if (rrset.
getClass() != RRClass::ANY() &&
92 output.writeUint16(0);
100 const size_t pos0 = output.getLength();
101 assert(pos0 < 65536);
108 const size_t pos = output.getLength();
109 output.skip(
sizeof(uint16_t));
110 it->getCurrent().toWire(output);
111 output.writeUint16At(output.getLength() - pos -
sizeof(uint16_t), pos);
113 if (limit > 0 && output.getLength() > limit) {
115 output.trim(output.getLength() - pos0);
121 }
while (!it->isLast());
130 return (rrsetToWire<OutputBuffer>(*
this, buffer, 0));
135 const unsigned int rrs_written = rrsetToWire<AbstractMessageRenderer>(
137 if (getRdataCount() > rrs_written) {
140 return (rrs_written);
148 return (getType() == other.
getType() &&
149 getName() == other.
getName() &&
183 if (rdatalist_.empty()) {
195 ttl_.toWire(renderer);
206 const size_t pos0 = renderer.
getLength();
207 assert(pos0 < 65536);
212 ttl_.toWire(renderer);
215 renderer.
skip(
sizeof(uint16_t));
216 rdata->toWire(renderer);
220 if (limit > 0 && renderer.
getLength() > limit) {
237 BasicRRset::~BasicRRset() {
243 impl_->rdatalist_.push_back(rdata);
247 BasicRRset::addRdata(
const Rdata& rdata) {
248 AbstractRRset::addRdata(rdata);
252 BasicRRset::addRdata(
const std::string& rdata_str) {
253 addRdata(
createRdata(getType(), getClass(), rdata_str));
257 BasicRRset::getRdataCount()
const {
258 return (impl_->rdatalist_.size());
262 BasicRRset::getName()
const {
263 return (impl_->name_);
267 BasicRRset::getClass()
const {
268 return (impl_->rrclass_);
272 BasicRRset::getType()
const {
273 return (impl_->rrtype_);
277 BasicRRset::getTTL()
const {
278 return (impl_->ttl_);
282 BasicRRset::setTTL(
const RRTTL& ttl) {
287 BasicRRset::toText()
const {
288 return (AbstractRRset::toText());
292 BasicRRset::getLength()
const {
298 if (getClass() != RRClass::ANY() &&
305 length += getName().getLength();
319 rrlen += getName().getLength();
324 rrlen += it->getCurrent().getLength();
326 assert(length + rrlen < 65536);
330 }
while (!it->isLast());
337 return (AbstractRRset::toWire(buffer));
342 const unsigned int rrs_written = impl_->toWire(renderer,
344 if (impl_->rdatalist_.size() > rrs_written) {
347 return (rrs_written);
362 return (rrsig_->getRdataCount());
373 const uint16_t rrsigs_length = rrsig_->getLength();
376 assert(length + rrsigs_length < 65536);
377 length += rrsigs_length;
387 return (rrs_written);
391 rrs_written += rrsig_->toWire(buffer);
394 return (rrs_written);
401 return (rrs_written);
405 rrs_written += rrsig_->toWire(renderer);
412 return (rrs_written);
418 BasicRdataIterator() {}
420 BasicRdataIterator(
const std::vector<rdata::ConstRdataPtr>& datavector) :
421 datavector_(&datavector), it_(datavector_->begin())
423 ~BasicRdataIterator() {}
424 virtual void first() { it_ = datavector_->begin(); }
425 virtual void next() { ++it_; }
426 virtual const rdata::Rdata& getCurrent()
const {
return (**it_); }
427 virtual bool isLast()
const {
return (it_ == datavector_->end()); }
429 const std::vector<rdata::ConstRdataPtr>* datavector_;
430 std::vector<rdata::ConstRdataPtr>::const_iterator it_;
virtual const RRTTL & getTTL() const =0
Returns the TTL of the RRset.
size_t getLength() const
Return the length of data written in the internal buffer.
A standard DNS module exception that is thrown if an RRset object does not contain any RDATA where re...
virtual RdataIteratorPtr getRdataIterator() const =0
Return an iterator to go through all RDATA stored in the RRset.
boost::shared_ptr< AbstractRRset > RRsetPtr
A pointer-like type pointing to an RRset object.
The AbstractRRset class is an abstract base class that models a DNS RRset.
void toWire(AbstractMessageRenderer &renderer) const
Render the RRClass in the wire format.
The Rdata class is an abstract base class that provides a set of common interfaces to manipulate conc...
The BasicRRset class is a concrete derived class of AbstractRRset that defines a straightforward RRse...
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
virtual uint16_t getLength() const
Get the wire format length of the BasicRRset.
virtual RdataIteratorPtr getRdataIterator() const
Return an iterator to go through all RDATA stored in the BasicRRset.
Defines the logger used by the top-level component of kea-dhcp-ddns.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
vector< ConstRdataPtr > rdatalist_
virtual unsigned int getRRsigDataCount() const
Returns the number of RRSIG records associated with the RRset.
virtual unsigned int getRdataCount() const
Returns the number of Rdata objects contained in the RRset.
The Name class encapsulates DNS names.
The RdataIterator class is an abstract base class that provides an interface for accessing RDATA obje...
virtual void setTruncated()=0
Mark the renderer to indicate truncation has occurred while rendering.
virtual unsigned int toWire(AbstractMessageRenderer &renderer) const
Render the RRset in the wire format with name compression and truncation handling.
ostream & operator<<(ostream &os, const AbstractRRset &rrset)
Insert the RRset as a string into stream.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
void writeUint16(uint16_t data)
Write an unsigned 16-bit integer in host byte order into the internal buffer in network byte order.
void toWire(AbstractMessageRenderer &renderer) const
Render the Name in the wire format with compression.
void skip(size_t len)
Insert a specified length of gap at the end of the buffer.
void trim(size_t len)
Trim the specified length of data from the end of the internal buffer.
The RRTTL class encapsulates TTLs used in DNS resource records.
virtual const Name & getName() const =0
Returns the owner name of the RRset.
virtual unsigned int toWire(AbstractMessageRenderer &renderer) const
Render the RRset in the wire format with name compression and truncation handling.
void toWire(AbstractMessageRenderer &renderer) const
Render the RRType in the wire format.
boost::shared_ptr< RdataIterator > RdataIteratorPtr
A pointer-like type point to an RdataIterator object.
virtual uint16_t getLength() const
Get the wire format length of the RRset.
virtual const RRClass & getClass() const =0
Returns the RR Class of the RRset.
void writeUint16At(uint16_t data, size_t pos)
Write an unsigned 16-bit integer in host byte order at the specified position of the internal buffer ...
void toWire(AbstractMessageRenderer &renderer) const
Render the RRTTL in the wire format.
boost::shared_ptr< const Rdata > ConstRdataPtr
virtual size_t getLengthLimit() const =0
Return the maximum length of rendered data that can fit in the corresponding DNS message without trun...
RdataPtr createRdata(const RRType &rrtype, const RRClass &rrclass, const std::string &rdata_string)
Create RDATA of a given pair of RR type and class from a string.
The RRType class encapsulates DNS resource record types.
This encapsulates the actual implementation of the BasicRRset class.
The RRClass class encapsulates DNS resource record classes.
BasicRRsetImpl(const Name &name, const RRClass &rrclass, const RRType &rrtype, const RRTTL &ttl)
virtual std::string toText() const =0
Convert the RRset to a string.
virtual const RRType & getType() const =0
Returns the RR Type of the RRset.