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) {
138 renderer.setTruncated();
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);
420 BasicRdataIterator(
const std::vector<rdata::ConstRdataPtr>& datavector) :
424 ~BasicRdataIterator() {}
427 virtual void first() {
432 virtual void next() {
446 virtual bool isLast()
const {
455 std::vector<rdata::ConstRdataPtr>::const_iterator
it_;
The Name class encapsulates DNS names.
The BasicRRset class is a concrete derived class of AbstractRRset that defines a straightforward RRse...
virtual const Name & getName() const =0
Returns the owner name of the RRset.
The RdataIterator class is an abstract base class that provides an interface for accessing RDATA obje...
This encapsulates the actual implementation of the BasicRRset class.
void skip(size_t len)
Insert a specified length of gap at the end of the buffer.
virtual uint16_t getLength() const
Get the wire format length of the BasicRRset.
vector< ConstRdataPtr > rdatalist_
boost::shared_ptr< const Rdata > ConstRdataPtr
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 ...
The Rdata class is an abstract base class that provides a set of common interfaces to manipulate conc...
virtual RdataIteratorPtr getRdataIterator() const
Return an iterator to go through all RDATA stored in the BasicRRset.
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.
virtual const RRClass & getClass() const =0
Returns the RR Class of the RRset.
virtual unsigned int getRRsigDataCount() const
Returns the number of RRSIG records associated with the RRset.
void trim(size_t len)
Trim the specified length of data from the end of the internal buffer.
void toWire(AbstractMessageRenderer &renderer) const
Render the RRTTL in the wire format.
virtual unsigned int getRdataCount() const
Returns the number of Rdata objects contained in the RRset.
The RRClass class encapsulates DNS resource record classes.
void writeUint16(uint16_t data)
Write an unsigned 16-bit integer in host byte order into the internal buffer in network byte order...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
virtual std::string toText() const =0
Convert the RRset to a string.
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.
void toWire(AbstractMessageRenderer &renderer) const
Render the RRType in the wire format.
The RRTTL class encapsulates TTLs used in DNS resource records.
virtual RdataIteratorPtr getRdataIterator() const =0
Return an iterator to go through all RDATA stored in the RRset.
void toWire(AbstractMessageRenderer &renderer) const
Render the RRClass in the wire format.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
A standard DNS module exception that is thrown if an RRset object does not contain any RDATA where re...
virtual const RRTTL & getTTL() const =0
Returns the TTL of the RRset.
Defines the logger used by the top-level component of kea-dhcp-ddns.
The AbstractRRset class is an abstract base class that models a DNS RRset.
virtual unsigned int toWire(AbstractMessageRenderer &renderer) const
Render the RRset in the wire format with name compression and truncation handling.
std::vector< rdata::ConstRdataPtr >::const_iterator it_
Iterator used to retrieve data.
const std::vector< rdata::ConstRdataPtr > * datavector_
Vector containing data.
ostream & operator<<(ostream &os, const AbstractRRset &rrset)
Insert the RRset as a string into stream.
The RRType class encapsulates DNS resource record types.
size_t getLength() const
Return the length of data written in the internal buffer.
boost::shared_ptr< RdataIterator > RdataIteratorPtr
A pointer-like type point to an RdataIterator object.
virtual const RRType & getType() const =0
Returns the RR Type of the RRset.
boost::shared_ptr< AbstractRRset > RRsetPtr
A pointer-like type pointing to an RRset object.
BasicRRsetImpl(const Name &name, const RRClass &rrclass, const RRType &rrtype, const RRTTL &ttl)
virtual size_t getLengthLimit() const =0
Return the maximum length of rendered data that can fit in the corresponding DNS message without trun...
virtual uint16_t getLength() const
Get the wire format length of the RRset.
void toWire(AbstractMessageRenderer &renderer) const
Render the Name in the wire format with compression.