Kea  2.1.7-git
rdata.h
Go to the documentation of this file.
1 // Copyright (C) 2010-2015 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 RDATA_H
8 #define RDATA_H 1
9 
10 #include <dns/master_lexer.h>
11 #include <dns/master_loader.h>
13 
14 #include <dns/exceptions.h>
15 
16 #include <boost/shared_ptr.hpp>
17 
18 #include <stdint.h>
19 
20 namespace isc {
21 namespace util {
22 class InputBuffer;
23 class OutputBuffer;
24 }
25 namespace dns {
26 class AbstractMessageRenderer;
27 class RRType;
28 class RRClass;
29 class Name;
30 
31 namespace rdata {
32 
38 public:
39  InvalidRdataLength(const char* file, size_t line, const char* what) :
40  DNSTextError(file, line, what) {}
41 };
42 
48 public:
49  InvalidRdataText(const char* file, size_t line, const char* what) :
50  DNSTextError(file, line, what) {}
51 };
52 
59 public:
60  CharStringTooLong(const char* file, size_t line, const char* what) :
61  DNSTextError(file, line, what) {}
62 };
63 
64 // Forward declaration to define RdataPtr.
65 class Rdata;
66 
71 typedef boost::shared_ptr<Rdata> RdataPtr;
72 typedef boost::shared_ptr<const Rdata> ConstRdataPtr;
73 
76 const size_t MAX_RDLENGTH = 65535;
77 
80 const unsigned int MAX_CHARSTRING_LEN = 255;
81 
123 class Rdata {
130 
131 protected:
139  Rdata() {}
140 private:
141  Rdata(const Rdata& source);
142  void operator=(const Rdata& source);
143 public:
145  virtual ~Rdata() {};
147 
151 
152  virtual std::string toText() const = 0;
162 
170  virtual void toWire(isc::util::OutputBuffer& buffer) const = 0;
171 
181  virtual void toWire(AbstractMessageRenderer& renderer) const = 0;
183 
187 
188  virtual int compare(const Rdata& other) const = 0;
216 
230  virtual uint16_t getLength() const;
231 };
232 
233 namespace generic {
234 
242 struct GenericImpl;
243 
249 class Generic : public Rdata {
250 public:
254 
255  explicit Generic(const std::string& rdata_string);
269 
291  Generic(isc::util::InputBuffer& buffer, size_t rdata_len);
292 
295  Generic(MasterLexer& lexer, const Name* name,
296  MasterLoader::Options options, MasterLoaderCallbacks& callbacks);
297 
300  virtual ~Generic();
308  Generic(const Generic& source);
309 
317  Generic& operator=(const Generic& source);
319 
323 
324  virtual std::string toText() const;
334 
344  virtual void toWire(isc::util::OutputBuffer& buffer) const;
345 
356  virtual void toWire(AbstractMessageRenderer& renderer) const;
358 
362 
363  virtual int compare(const Rdata& other) const;
386 
387 private:
388  GenericImpl* constructFromLexer(MasterLexer& lexer);
389 
390  GenericImpl* impl_;
391 };
392 
407 std::ostream& operator<<(std::ostream& os, const Generic& rdata);
408 } // end of namespace "generic"
409 
410 //
411 // Non class-member functions related to Rdata
412 //
413 
441 
442 RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
453  const std::string& rdata_string);
454 
476 RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
477  isc::util::InputBuffer& buffer, size_t len);
478 
492 RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
493  const Rdata& source);
494 
536 RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
537  MasterLexer& lexer, const Name* origin,
538  MasterLoader::Options options,
539  MasterLoaderCallbacks& callbacks);
540 
542 
573 int compareNames(const Name& n1, const Name& n2);
574 
575 } // end of namespace "rdata"
576 }
577 }
578 #endif // RDATA_H
579 
580 // Local Variables:
581 // mode: c++
582 // End:
The Name class encapsulates DNS names.
Definition: name.h:223
const unsigned int MAX_CHARSTRING_LEN
The maximum allowable length of character-string containing in RDATA as defined in RFC1035...
Definition: rdata.h:80
const size_t MAX_RDLENGTH
Possible maximum length of RDATA, which is the maximum unsigned 16 bit value.
Definition: rdata.h:76
InvalidRdataLength(const char *file, size_t line, const char *what)
Definition: rdata.h:39
Base class for all sorts of text parse errors.
boost::shared_ptr< const Rdata > ConstRdataPtr
Definition: rdata.h:72
The Rdata class is an abstract base class that provides a set of common interfaces to manipulate conc...
Definition: rdata.h:123
std::ostream & operator<<(std::ostream &os, const CSVRow &row)
Overrides standard output stream operator for CSVRow object.
Definition: csv_file.cc:100
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.
Definition: rdata.cc:56
The generic::Generic class represents generic "unknown" RDATA.
Definition: rdata.h:249
The RRClass class encapsulates DNS resource record classes.
Definition: rrclass.h:98
Options
Options how the parsing should work.
Definition: master_loader.h:39
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
InvalidRdataText(const char *file, size_t line, const char *what)
Definition: rdata.h:49
A standard DNS module exception that is thrown if RDATA parser fails to recognize a given textual rep...
Definition: rdata.h:47
A standard DNS module exception that is thrown if RDATA parser encounters an invalid or inconsistent ...
Definition: rdata.h:37
virtual ~Rdata()
The destructor.
Definition: rdata.h:145
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition: buffer.h:294
Defines the logger used by the top-level component of kea-lfc.
int compareNames(const Name &n1, const Name &n2)
Gives relative ordering of two names in terms of DNSSEC RDATA ordering.
Definition: rdata.cc:181
The RRType class encapsulates DNS resource record types.
Definition: rrtype.h:106
A standard DNS module exception that is thrown if RDATA parser encounters a character-string (as defi...
Definition: rdata.h:58
Rdata()
The default constructor.
Definition: rdata.h:139
The InputBuffer class is a buffer abstraction for manipulating read-only data.
Definition: buffer.h:81
Tokenizer for parsing DNS master files.
Definition: master_lexer.h:301
Set of issue callbacks for a loader.
boost::shared_ptr< Rdata > RdataPtr
The RdataPtr type is a pointer-like type, pointing to an object of some concrete derived class of Rda...
CharStringTooLong(const char *file, size_t line, const char *what)
Definition: rdata.h:60