Kea 2.5.5
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
20namespace isc {
21namespace util {
22class InputBuffer;
23class OutputBuffer;
24}
25namespace dns {
26class AbstractMessageRenderer;
27class RRType;
28class RRClass;
29class Name;
30
31namespace rdata {
32
38public:
39 InvalidRdataLength(const char* file, size_t line, const char* what) :
40 DNSTextError(file, line, what) {}
41};
42
48public:
49 InvalidRdataText(const char* file, size_t line, const char* what) :
50 DNSTextError(file, line, what) {}
51};
52
59public:
60 CharStringTooLong(const char* file, size_t line, const char* what) :
61 DNSTextError(file, line, what) {}
62};
63
64// Forward declaration to define RdataPtr.
65class Rdata;
66
71typedef boost::shared_ptr<Rdata> RdataPtr;
72typedef boost::shared_ptr<const Rdata> ConstRdataPtr;
73
76const size_t MAX_RDLENGTH = 65535;
77
80const unsigned int MAX_CHARSTRING_LEN = 255;
81
123class Rdata {
130
131protected:
139 Rdata() {}
140private:
141 Rdata(const Rdata& source);
142 void operator=(const Rdata& source);
143public:
145 virtual ~Rdata() {};
147
151
152
161 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
214 virtual int compare(const Rdata& other) const = 0;
216
230 virtual uint16_t getLength() const;
231};
232
233namespace generic {
234
242struct GenericImpl;
243
249class Generic : public Rdata {
250public:
254
255
268 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
333 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
384 virtual int compare(const Rdata& other) const;
386
387private:
388 GenericImpl* constructFromLexer(MasterLexer& lexer);
389
390 GenericImpl* impl_;
391};
392
407std::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
452RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
453 const std::string& rdata_string);
454
476RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
477 isc::util::InputBuffer& buffer, size_t len);
478
492RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
493 const Rdata& source);
494
536RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
537 MasterLexer& lexer, const Name* origin,
538 MasterLoader::Options options,
539 MasterLoaderCallbacks& callbacks);
540
542
573int 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:
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
Base class for all sorts of text parse errors.
Tokenizer for parsing DNS master files.
Definition: master_lexer.h:301
Set of issue callbacks for a loader.
Options
Options how the parsing should work.
Definition: master_loader.h:39
The Name class encapsulates DNS names.
Definition: name.h:223
The RRClass class encapsulates DNS resource record classes.
Definition: rrclass.h:98
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
CharStringTooLong(const char *file, size_t line, const char *what)
Definition: rdata.h:60
A standard DNS module exception that is thrown if RDATA parser encounters an invalid or inconsistent ...
Definition: rdata.h:37
InvalidRdataLength(const char *file, size_t line, const char *what)
Definition: rdata.h:39
A standard DNS module exception that is thrown if RDATA parser fails to recognize a given textual rep...
Definition: rdata.h:47
InvalidRdataText(const char *file, size_t line, const char *what)
Definition: rdata.h:49
The Rdata class is an abstract base class that provides a set of common interfaces to manipulate conc...
Definition: rdata.h:123
virtual std::string toText() const =0
Convert an Rdata to a string.
virtual void toWire(isc::util::OutputBuffer &buffer) const =0
Render the Rdata in the wire format into a buffer.
virtual ~Rdata()
The destructor.
Definition: rdata.h:145
Rdata()
The default constructor.
Definition: rdata.h:139
virtual int compare(const Rdata &other) const =0
Compare two instances of Rdata.
virtual void toWire(AbstractMessageRenderer &renderer) const =0
Render the Rdata in the wire format into a MessageRenderer object.
virtual uint16_t getLength() const
Get the wire format length of an Rdata.
Definition: rdata.cc:45
The generic::Generic class represents generic "unknown" RDATA.
Definition: rdata.h:249
virtual ~Generic()
The destructor.
Definition: rdata.cc:314
Generic & operator=(const Generic &source)
The assignment operator.
Definition: rdata.cc:326
Generic(const std::string &rdata_string)
Constructor from a string.
Definition: rdata.cc:280
virtual std::string toText() const
Convert an generic::Generic object to a string.
Definition: rdata.cc:352
virtual void toWire(isc::util::OutputBuffer &buffer) const
Render the generic::Generic in the wire format into a buffer.
Definition: rdata.cc:364
virtual int compare(const Rdata &other) const
Compare two instances of generic::Generic objects.
Definition: rdata.cc:394
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:294
std::ostream & operator<<(std::ostream &os, const Generic &rdata)
Insert the name as a string into stream.
Definition: rdata.cc:401
int compareNames(const Name &n1, const Name &n2)
Gives relative ordering of two names in terms of DNSSEC RDATA ordering.
Definition: rdata.cc:181
boost::shared_ptr< const Rdata > ConstRdataPtr
Definition: rdata.h:72
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
const size_t MAX_RDLENGTH
Possible maximum length of RDATA, which is the maximum unsigned 16 bit value.
Definition: rdata.h:76
const unsigned int MAX_CHARSTRING_LEN
The maximum allowable length of character-string containing in RDATA as defined in RFC1035,...
Definition: rdata.h:80
boost::shared_ptr< Rdata > RdataPtr
The RdataPtr type is a pointer-like type, pointing to an object of some concrete derived class of Rda...
Defines the logger used by the top-level component of kea-lfc.