Kea 3.2.1-git
rdataclass.h
Go to the documentation of this file.
1// Copyright (C) 2010-2026 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef DNS_RDATACLASS_H
8#define DNS_RDATACLASS_H
9
10#include <dns/master_loader.h>
11#include <dns/name.h>
12#include <dns/rdata.h>
13#include <dns/rrttl.h>
14#include <dns/rrtype.h>
15#include <dns/serial.h>
16#include <util/buffer.h>
17
18#include <boost/shared_ptr.hpp>
19
20#include <memory>
21#include <stdint.h>
22#include <string>
23#include <vector>
24
25namespace isc {
26namespace dns {
27
28class Name;
29class MasterLexer;
32
33namespace rdata {
34namespace any {
35
36struct TSIGImpl;
37
44class TSIG : public Rdata {
45public:
46 explicit TSIG(const std::string& type_str);
47 TSIG(isc::util::InputBuffer& buffer, size_t rdata_len);
48 TSIG(const TSIG& other);
50 MasterLexer& lexer, const Name* name,
52 virtual std::string toText() const;
53 virtual void toWire(isc::util::OutputBuffer& buffer) const;
54 virtual void toWire(AbstractMessageRenderer& renderer) const;
55 virtual int compare(const Rdata& other) const;
56
82 TSIG(const Name& algorithm, uint64_t time_signed, uint16_t fudge,
83 uint16_t mac_size, const void* mac, uint16_t original_id,
84 uint16_t error, uint16_t other_len, const void* other_data);
85
95 TSIG& operator=(const TSIG& source);
96
99
103 const Name& getAlgorithm() const;
104
110 uint64_t getTimeSigned() const;
111
115 uint16_t getFudge() const;
116
120 uint16_t getMACSize() const;
121
134 const void* getMAC() const;
135
139 uint16_t getOriginalID() const;
140
144 uint16_t getError() const;
145
149 uint16_t getOtherLen() const;
150
156 const void* getOtherData() const;
157private:
158 std::unique_ptr<TSIGImpl> constructFromLexer(MasterLexer& lexer, const Name* origin);
159
160 std::unique_ptr<TSIGImpl> impl_;
161};
162
163} // end of namespace "any"
164
165namespace ch {
166
167class A : public Rdata {
168public:
169 explicit A(const std::string& type_str);
170 A(isc::util::InputBuffer& buffer, size_t rdata_len);
171 A(const A& other);
173 MasterLexer& lexer, const Name* name,
174 MasterLoader::Options options, MasterLoaderCallbacks& callbacks);
175 virtual std::string toText() const;
176 virtual void toWire(isc::util::OutputBuffer& buffer) const;
177 virtual void toWire(AbstractMessageRenderer& renderer) const;
178 virtual int compare(const Rdata& other) const;
179};
180
181} // end of namespace "ch"
182
183namespace generic {
184namespace detail {
185
206inline Name
207createNameFromLexer(MasterLexer& lexer, const Name* origin) {
208 const MasterToken::StringRegion& str_region =
210 return (Name(str_region.beg, str_region.len, origin));
211}
212
213template<class Type, uint16_t typeCode>
214class TXTLikeImpl;
215
216} // namespace detail
217
218class NS : public Rdata {
219public:
220 explicit NS(const std::string& type_str);
221 NS(isc::util::InputBuffer& buffer, size_t rdata_len);
222 NS(const NS& other);
224 MasterLexer& lexer, const Name* name,
225 MasterLoader::Options options, MasterLoaderCallbacks& callbacks);
226 virtual std::string toText() const;
227 virtual void toWire(isc::util::OutputBuffer& buffer) const;
228 virtual void toWire(AbstractMessageRenderer& renderer) const;
229 virtual int compare(const Rdata& other) const;
230
233 explicit NS(const Name& nsname) : nsname_(nsname) {
234 }
235
238 const Name& getNSName() const;
239private:
240 Name nsname_;
241};
242
243struct OPTImpl;
244
245class OPT : public Rdata {
246public:
247 explicit OPT(const std::string& type_str);
248 OPT(isc::util::InputBuffer& buffer, size_t rdata_len);
249 OPT(const OPT& other);
251 MasterLexer& lexer, const Name* name,
252 MasterLoader::Options options, MasterLoaderCallbacks& callbacks);
253 virtual std::string toText() const;
254 virtual void toWire(isc::util::OutputBuffer& buffer) const;
255 virtual void toWire(AbstractMessageRenderer& renderer) const;
256 virtual int compare(const Rdata& other) const;
257
258 // The default constructor makes sense for OPT as it can be empty.
260 OPT& operator=(const OPT& source);
262
265 class PseudoRR {
266 public:
271 PseudoRR(uint16_t code,
272 boost::shared_ptr<std::vector<uint8_t> >& data);
273
275 uint16_t getCode() const;
276
280 const uint8_t* getData() const;
281
284 uint16_t getLength() const;
285
286 private:
287 uint16_t code_;
288 boost::shared_ptr<std::vector<uint8_t>> data_;
289 };
290
299 void appendPseudoRR(uint16_t code, const uint8_t* data, uint16_t length);
300
307 const std::vector<PseudoRR>& getPseudoRRs() const;
308
309private:
310 std::unique_ptr<OPTImpl> impl_;
311};
312
313class PTR : public Rdata {
314public:
315 explicit PTR(const std::string& type_str);
316 PTR(isc::util::InputBuffer& buffer, size_t rdata_len);
317 PTR(const PTR& other);
319 MasterLexer& lexer, const Name* name,
320 MasterLoader::Options options, MasterLoaderCallbacks& callbacks);
321 virtual std::string toText() const;
322 virtual void toWire(isc::util::OutputBuffer& buffer) const;
323 virtual void toWire(AbstractMessageRenderer& renderer) const;
324 virtual int compare(const Rdata& other) const;
325
329 explicit PTR(const Name& ptr_name) : ptr_name_(ptr_name) {
330 }
331
334 const Name& getPTRName() const;
335private:
336 Name ptr_name_;
337};
338
339struct RRSIGImpl;
340
347class RRSIG : public Rdata {
348public:
349 explicit RRSIG(const std::string& type_str);
350 RRSIG(isc::util::InputBuffer& buffer, size_t rdata_len);
351 RRSIG(const RRSIG& other);
353 MasterLexer& lexer, const Name* name,
354 MasterLoader::Options options, MasterLoaderCallbacks& callbacks);
355 virtual std::string toText() const;
356 virtual void toWire(isc::util::OutputBuffer& buffer) const;
357 virtual void toWire(AbstractMessageRenderer& renderer) const;
358 virtual int compare(const Rdata& other) const;
359
360 RRSIG& operator=(const RRSIG& source);
362
363 // specialized methods
364 const RRType& typeCovered() const;
365private:
366 // helper function for string and lexer constructors
367 std::unique_ptr<RRSIGImpl> constructFromLexer(MasterLexer& lexer, const Name* origin);
368
369 std::unique_ptr<RRSIGImpl> impl_;
370};
371
372class SOA : public Rdata {
373public:
374 explicit SOA(const std::string& type_str);
375 SOA(isc::util::InputBuffer& buffer, size_t rdata_len);
376 SOA(const SOA& other);
378 MasterLexer& lexer, const Name* name,
379 MasterLoader::Options options, MasterLoaderCallbacks& callbacks);
380 virtual std::string toText() const;
381 virtual void toWire(isc::util::OutputBuffer& buffer) const;
382 virtual void toWire(AbstractMessageRenderer& renderer) const;
383 virtual int compare(const Rdata& other) const;
384
385 SOA(const Name& mname, const Name& rname, uint32_t serial,
386 uint32_t refresh, uint32_t retry, uint32_t expire,
387 uint32_t minimum);
388
391
393 uint32_t getMinimum() const;
394private:
397 Name mname_;
398 Name rname_;
400 uint8_t numdata_[20];
401};
402
403struct TKEYImpl;
404
411class TKEY : public Rdata {
412public:
413 explicit TKEY(const std::string& type_str);
414 TKEY(isc::util::InputBuffer& buffer, size_t rdata_len);
415 TKEY(const TKEY& other);
417 MasterLexer& lexer, const Name* name,
418 MasterLoader::Options options, MasterLoaderCallbacks& callbacks);
419 virtual std::string toText() const;
420 virtual void toWire(isc::util::OutputBuffer& buffer) const;
421 virtual void toWire(AbstractMessageRenderer& renderer) const;
422 virtual int compare(const Rdata& other) const;
423
444 TKEY(const Name& algorithm, uint32_t inception, uint32_t expire,
445 uint16_t mode, uint16_t error, uint16_t key_len,
446 const void* key, uint16_t other_len, const void* other_data);
447
457 TKEY& operator=(const TKEY& source);
458
461
465 const Name& getAlgorithm() const;
466
470 uint32_t getInception() const;
471
473 std::string getInceptionDate() const;
474
478 uint32_t getExpire() const;
479
481 std::string getExpireDate() const;
482
486 uint16_t getMode() const;
487
491 uint16_t getError() const;
492
496 uint16_t getKeyLen() const;
497
501 const void* getKey() const;
502
506 uint16_t getOtherLen() const;
507
513 const void* getOtherData() const;
514
516 static const uint16_t GSS_API_MODE;
517
518private:
519 std::unique_ptr<TKEYImpl> constructFromLexer(MasterLexer& lexer, const Name* origin);
520
521 std::unique_ptr<TKEYImpl> impl_;
522};
523
524class TXT : public Rdata {
525public:
526 explicit TXT(const std::string& type_str);
527 TXT(isc::util::InputBuffer& buffer, size_t rdata_len);
528 TXT(const TXT& other);
530 MasterLexer& lexer, const Name* name,
531 MasterLoader::Options options, MasterLoaderCallbacks& callbacks);
532 virtual std::string toText() const;
533 virtual void toWire(isc::util::OutputBuffer& buffer) const;
534 virtual void toWire(AbstractMessageRenderer& renderer) const;
535 virtual int compare(const Rdata& other) const;
536
537 TXT& operator=(const TXT& source);
539
540private:
542 std::unique_ptr<TXTImpl> impl_;
543};
544} // namespace generic
545
546
547namespace in {
548
549class A : public Rdata {
550public:
551 explicit A(const std::string& type_str);
552 A(isc::util::InputBuffer& buffer, size_t rdata_len);
553 A(const A& other);
555 MasterLexer& lexer, const Name* name,
556 MasterLoader::Options options, MasterLoaderCallbacks& callbacks);
557 virtual std::string toText() const;
558 virtual void toWire(isc::util::OutputBuffer& buffer) const;
559 virtual void toWire(AbstractMessageRenderer& renderer) const;
560 virtual int compare(const Rdata& other) const;
561private:
562 uint32_t addr_; // raw IPv4 address (network byte order)
563};
564
565class AAAA : public Rdata {
566public:
567 explicit AAAA(const std::string& type_str);
568 AAAA(isc::util::InputBuffer& buffer, size_t rdata_len);
569 AAAA(const AAAA& other);
571 MasterLexer& lexer, const Name* name,
572 MasterLoader::Options options, MasterLoaderCallbacks& callbacks);
573 virtual std::string toText() const;
574 virtual void toWire(isc::util::OutputBuffer& buffer) const;
575 virtual void toWire(AbstractMessageRenderer& renderer) const;
576 virtual int compare(const Rdata& other) const;
577private:
578 uint8_t addr_[16]; // raw IPv6 address (network byte order)
579};
580
587class DHCID : public Rdata {
588public:
589 explicit DHCID(const std::string& type_str);
590 DHCID(isc::util::InputBuffer& buffer, size_t rdata_len);
591 DHCID(const DHCID& other);
593 MasterLexer& lexer, const Name* name,
594 MasterLoader::Options options, MasterLoaderCallbacks& callbacks);
595 virtual std::string toText() const;
596 virtual void toWire(isc::util::OutputBuffer& buffer) const;
597 virtual void toWire(AbstractMessageRenderer& renderer) const;
598 virtual int compare(const Rdata& other) const;
599
603 const std::vector<uint8_t>& getDigest() const;
604
605private:
606 // helper for string and lexer constructors
607 void constructFromLexer(MasterLexer& lexer);
608
613 std::vector<uint8_t> digest_;
614};
615
616} // end of namespace "in"
617} // end of namespace "rdata"
618} // end of namespace "dns"
619} // end of namespace "isc"
620#endif // DNS_RDATACLASS_H
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
Tokenizer for parsing DNS master files.
const MasterToken & getNextToken(Options options=NONE)
Parse and return another token from the input.
Set of issue callbacks for a loader.
Options
Options how the parsing should work.
@ STRING
A single string.
const StringRegion & getStringRegion() const
Return the value of a string-variant token.
The Name class encapsulates DNS names.
Definition name.h:219
The RRType class encapsulates DNS resource record types.
Definition rrtype.h:96
This class defines DNS serial numbers and serial arithmetic.
Definition serial.h:41
Rdata()
The default constructor.
Definition rdata.h:136
TSIG(isc::util::InputBuffer &buffer, size_t rdata_len)
TSIG(const Name &algorithm, uint64_t time_signed, uint16_t fudge, uint16_t mac_size, const void *mac, uint16_t original_id, uint16_t error, uint16_t other_len, const void *other_data)
Constructor from RDATA field parameters.
uint16_t getOriginalID() const
Return the value of the Original ID field.
uint16_t getError() const
Return the value of the Error field.
virtual std::string toText() const
Convert an Rdata to a string.
TSIG & operator=(const TSIG &source)
Assignment operator.
~TSIG()
The destructor.
virtual void toWire(AbstractMessageRenderer &renderer) const
Render the Rdata in the wire format into a MessageRenderer object.
TSIG(const TSIG &other)
TSIG(MasterLexer &lexer, const Name *name, MasterLoader::Options options, MasterLoaderCallbacks &callbacks)
const Name & getAlgorithm() const
Return the algorithm name.
uint16_t getOtherLen() const
Return the value of the Other Len field.
TSIG(const std::string &type_str)
const void * getOtherData() const
Return the value of the Other Data field.
virtual int compare(const Rdata &other) const
Compare two instances of Rdata.
const void * getMAC() const
Return the value of the MAC field.
uint16_t getFudge() const
Return the value of the Fudge field.
virtual void toWire(isc::util::OutputBuffer &buffer) const
Render the Rdata in the wire format into a buffer.
uint16_t getMACSize() const
Return the value of the MAC Size field.
uint64_t getTimeSigned() const
Return the value of the Time Signed field.
A(MasterLexer &lexer, const Name *name, MasterLoader::Options options, MasterLoaderCallbacks &callbacks)
A(const A &other)
A(const std::string &type_str)
virtual void toWire(isc::util::OutputBuffer &buffer) const
Render the Rdata in the wire format into a buffer.
virtual int compare(const Rdata &other) const
Compare two instances of Rdata.
virtual void toWire(AbstractMessageRenderer &renderer) const
Render the Rdata in the wire format into a MessageRenderer object.
A(isc::util::InputBuffer &buffer, size_t rdata_len)
virtual std::string toText() const
Convert an Rdata to a string.
virtual std::string toText() const
Convert an Rdata to a string.
NS(MasterLexer &lexer, const Name *name, MasterLoader::Options options, MasterLoaderCallbacks &callbacks)
virtual void toWire(isc::util::OutputBuffer &buffer) const
Render the Rdata in the wire format into a buffer.
NS(isc::util::InputBuffer &buffer, size_t rdata_len)
virtual int compare(const Rdata &other) const
Compare two instances of Rdata.
NS(const std::string &type_str)
virtual void toWire(AbstractMessageRenderer &renderer) const
Render the Rdata in the wire format into a MessageRenderer object.
const Name & getNSName() const
Specialized methods.
NS(const Name &nsname)
Specialized constructor.
Definition rdataclass.h:233
const uint8_t * getData() const
Return the option data of this pseudo RR.
uint16_t getLength() const
Return the length of the option data of this pseudo RR.
uint16_t getCode() const
Return the option code of this pseudo RR.
PseudoRR(uint16_t code, boost::shared_ptr< std::vector< uint8_t > > &data)
Constructor.
virtual void toWire(isc::util::OutputBuffer &buffer) const
Render the Rdata in the wire format into a buffer.
virtual std::string toText() const
Convert an Rdata to a string.
void appendPseudoRR(uint16_t code, const uint8_t *data, uint16_t length)
Append a pseudo RR (option) in this OPT RR.
virtual int compare(const Rdata &other) const
Compare two instances of Rdata.
OPT & operator=(const OPT &source)
const std::vector< PseudoRR > & getPseudoRRs() const
Return a vector of the pseudo RRs (options) in this OPT RR.
OPT(MasterLexer &lexer, const Name *name, MasterLoader::Options options, MasterLoaderCallbacks &callbacks)
virtual void toWire(AbstractMessageRenderer &renderer) const
Render the Rdata in the wire format into a MessageRenderer object.
OPT(isc::util::InputBuffer &buffer, size_t rdata_len)
OPT(const std::string &type_str)
virtual std::string toText() const
Convert an Rdata to a string.
PTR(const std::string &type_str)
virtual void toWire(AbstractMessageRenderer &renderer) const
Render the Rdata in the wire format into a MessageRenderer object.
PTR(isc::util::InputBuffer &buffer, size_t rdata_len)
PTR(MasterLexer &lexer, const Name *name, MasterLoader::Options options, MasterLoaderCallbacks &callbacks)
virtual int compare(const Rdata &other) const
Compare two instances of Rdata.
const Name & getPTRName() const
Specialized methods.
PTR(const Name &ptr_name)
Specialized constructor.
Definition rdataclass.h:329
virtual void toWire(isc::util::OutputBuffer &buffer) const
Render the Rdata in the wire format into a buffer.
const RRType & typeCovered() const
virtual void toWire(isc::util::OutputBuffer &buffer) const
Render the Rdata in the wire format into a buffer.
virtual std::string toText() const
Convert an Rdata to a string.
RRSIG(const std::string &type_str)
virtual int compare(const Rdata &other) const
Compare two instances of Rdata.
RRSIG(MasterLexer &lexer, const Name *name, MasterLoader::Options options, MasterLoaderCallbacks &callbacks)
RRSIG & operator=(const RRSIG &source)
virtual void toWire(AbstractMessageRenderer &renderer) const
Render the Rdata in the wire format into a MessageRenderer object.
RRSIG(isc::util::InputBuffer &buffer, size_t rdata_len)
SOA(const std::string &type_str)
Serial getSerial() const
Returns the serial stored in the SOA.
SOA(const Name &mname, const Name &rname, uint32_t serial, uint32_t refresh, uint32_t retry, uint32_t expire, uint32_t minimum)
SOA(isc::util::InputBuffer &buffer, size_t rdata_len)
virtual std::string toText() const
Convert an Rdata to a string.
virtual int compare(const Rdata &other) const
Compare two instances of Rdata.
virtual void toWire(AbstractMessageRenderer &renderer) const
Render the Rdata in the wire format into a MessageRenderer object.
virtual void toWire(isc::util::OutputBuffer &buffer) const
Render the Rdata in the wire format into a buffer.
uint32_t getMinimum() const
brief Returns the minimum TTL field value of the SOA.
SOA(MasterLexer &lexer, const Name *name, MasterLoader::Options options, MasterLoaderCallbacks &callbacks)
const Name & getAlgorithm() const
Return the algorithm name.
virtual void toWire(isc::util::OutputBuffer &buffer) const
Render the Rdata in the wire format into a buffer.
virtual int compare(const Rdata &other) const
Compare two instances of Rdata.
TKEY & operator=(const TKEY &source)
Assignment operator.
uint32_t getInception() const
Return the value of the Inception field as a number.
uint16_t getMode() const
Return the value of the Mode field.
virtual void toWire(AbstractMessageRenderer &renderer) const
Render the Rdata in the wire format into a MessageRenderer object.
std::string getInceptionDate() const
Return the value of the Inception field as a string.
virtual std::string toText() const
Convert an Rdata to a string.
TKEY(isc::util::InputBuffer &buffer, size_t rdata_len)
uint32_t getExpire() const
Return the value of the Expire field as a number.
static const uint16_t GSS_API_MODE
The GSS_API constant for the Mode field.
Definition rdataclass.h:516
const void * getKey() const
Return the value of the Key field.
std::string getExpireDate() const
Return the value of the Expire field as a string.
TKEY(const std::string &type_str)
uint16_t getOtherLen() const
Return the value of the Other Len field.
TKEY(MasterLexer &lexer, const Name *name, MasterLoader::Options options, MasterLoaderCallbacks &callbacks)
uint16_t getError() const
Return the value of the Error field.
TKEY(const Name &algorithm, uint32_t inception, uint32_t expire, uint16_t mode, uint16_t error, uint16_t key_len, const void *key, uint16_t other_len, const void *other_data)
Constructor from RDATA field parameters.
uint16_t getKeyLen() const
Return the value of the Key Len field.
const void * getOtherData() const
Return the value of the Other Data field.
virtual int compare(const Rdata &other) const
Compare two instances of Rdata.
TXT(MasterLexer &lexer, const Name *name, MasterLoader::Options options, MasterLoaderCallbacks &callbacks)
virtual std::string toText() const
Convert an Rdata to a string.
virtual void toWire(AbstractMessageRenderer &renderer) const
Render the Rdata in the wire format into a MessageRenderer object.
TXT & operator=(const TXT &source)
TXT(const std::string &type_str)
virtual void toWire(isc::util::OutputBuffer &buffer) const
Render the Rdata in the wire format into a buffer.
TXT(isc::util::InputBuffer &buffer, size_t rdata_len)
rdata::TXTLikeImpl class represents the TXT-like RDATA for TXT and SPF types.
Definition txt_like.h:31
virtual void toWire(AbstractMessageRenderer &renderer) const
Render the Rdata in the wire format into a MessageRenderer object.
AAAA(isc::util::InputBuffer &buffer, size_t rdata_len)
AAAA(MasterLexer &lexer, const Name *name, MasterLoader::Options options, MasterLoaderCallbacks &callbacks)
virtual int compare(const Rdata &other) const
Compare two instances of Rdata.
AAAA(const AAAA &other)
virtual std::string toText() const
Convert an Rdata to a string.
virtual void toWire(isc::util::OutputBuffer &buffer) const
Render the Rdata in the wire format into a buffer.
AAAA(const std::string &type_str)
A(const std::string &type_str)
A(isc::util::InputBuffer &buffer, size_t rdata_len)
virtual void toWire(AbstractMessageRenderer &renderer) const
Render the Rdata in the wire format into a MessageRenderer object.
virtual int compare(const Rdata &other) const
Compare two instances of Rdata.
A(const A &other)
A(MasterLexer &lexer, const Name *name, MasterLoader::Options options, MasterLoaderCallbacks &callbacks)
virtual void toWire(isc::util::OutputBuffer &buffer) const
Render the Rdata in the wire format into a buffer.
virtual std::string toText() const
Convert an Rdata to a string.
virtual int compare(const Rdata &other) const
Compare two instances of Rdata.
virtual void toWire(isc::util::OutputBuffer &buffer) const
Render the Rdata in the wire format into a buffer.
DHCID(isc::util::InputBuffer &buffer, size_t rdata_len)
virtual std::string toText() const
Convert an Rdata to a string.
DHCID(const DHCID &other)
DHCID(const std::string &type_str)
virtual void toWire(AbstractMessageRenderer &renderer) const
Render the Rdata in the wire format into a MessageRenderer object.
const std::vector< uint8_t > & getDigest() const
Return the digest.
DHCID(MasterLexer &lexer, const Name *name, MasterLoader::Options options, MasterLoaderCallbacks &callbacks)
The InputBuffer class is a buffer abstraction for manipulating read-only data.
Definition buffer.h:81
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition buffer.h:346
Name createNameFromLexer(MasterLexer &lexer, const Name *origin)
Construct a Name object using a master lexer and optional origin.
Definition rdataclass.h:207
Defines the logger used by the top-level component of kea-lfc.
A simple representation of a range of a string.
size_t len
The length of the string in bytes.
const char * beg
The start address of the string.