Kea 2.5.5
rrparamregistry.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 RRPARAMREGISTRY_H
8#define RRPARAMREGISTRY_H 1
9
10#include <string>
11
12#include <stdint.h>
13
14#include <boost/shared_ptr.hpp>
15
16#include <dns/exceptions.h>
17
18#include <dns/rdata.h>
19
20namespace isc {
21namespace dns {
22
23// forward declarations
24struct RRParamRegistryImpl;
25
31public:
32 RRTypeExists(const char* file, size_t line, const char* what) :
33 isc::dns::Exception(file, line, what) {}
34};
35
41public:
42 RRClassExists(const char* file, size_t line, const char* what) :
43 isc::dns::Exception(file, line, what) {}
44};
45
46namespace rdata {
61
62protected:
68public:
72
76
77
85 virtual RdataPtr create(const std::string& rdata_str) const = 0;
86
97 virtual RdataPtr create(isc::util::InputBuffer& buffer, size_t rdata_len) const = 0;
98
112 virtual RdataPtr create(const rdata::Rdata& source) const = 0;
113
120 virtual RdataPtr create(MasterLexer& lexer, const Name* origin,
121 MasterLoader::Options options,
122 MasterLoaderCallbacks& callbacks) const = 0;
124};
125
130typedef boost::shared_ptr<AbstractRdataFactory> RdataFactoryPtr;
131} // end of namespace rdata
132
176
177private:
179 RRParamRegistry(const RRParamRegistry& orig);
182public:
202
206
207
231 void add(const std::string& type_string, uint16_t type_code,
232 const std::string& class_string, uint16_t class_code,
233 rdata::RdataFactoryPtr rdata_factory);
234
244 void add(const std::string& type_string, uint16_t type_code,
245 rdata::RdataFactoryPtr rdata_factory);
246
274 bool addType(const std::string& type_string, uint16_t type_code);
275
288 bool removeType(uint16_t type_code);
289
317 bool addClass(const std::string& class_string, uint16_t class_code);
318
331 bool removeClass(uint16_t class_code);
332
347 bool removeRdataFactory(const RRType& rrtype, const RRClass& rrclass);
348
362 bool removeRdataFactory(const RRType& rrtype);
364
368
369
386 bool textToTypeCode(const std::string& type_string,
387 uint16_t& type_code) const;
388
404 std::string codeToTypeText(uint16_t type_code) const;
405
424 bool textToClassCode(const std::string& class_string,
425 uint16_t& class_code) const;
426
442 std::string codeToClassText(uint16_t class_code) const;
444
464
465
475 rdata::RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
476 const std::string& rdata_string);
490 rdata::RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
491 isc::util::InputBuffer& buffer, size_t len);
514 rdata::RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
515 const rdata::Rdata& source);
516
529 rdata::RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
530 MasterLexer& lexer, const Name* origin,
531 MasterLoader::Options options,
532 MasterLoaderCallbacks& callbacks);
534
535private:
536 RRParamRegistryImpl* impl_;
537};
538
539}
540}
541#endif // RRPARAMREGISTRY_H
542
543// Local Variables:
544// mode: c++
545// End:
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
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
A standard DNS module exception that is thrown if a new RR class is being registered with a different...
RRClassExists(const char *file, size_t line, const char *what)
The RRClass class encapsulates DNS resource record classes.
Definition: rrclass.h:98
The RRParamRegistry class represents a registry of parameters to manipulate DNS resource records (RRs...
rdata::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.
bool removeType(uint16_t type_code)
Remove mappings between RR type code and textual representation for a given type.
bool textToTypeCode(const std::string &type_string, uint16_t &type_code) const
Convert a textual representation of an RR type to the corresponding 16-bit integer code.
bool textToClassCode(const std::string &class_string, uint16_t &class_code) const
Convert a textual representation of an RR class to the corresponding 16-bit integer code.
std::string codeToClassText(uint16_t class_code) const
Convert class code into its textual representation.
std::string codeToTypeText(uint16_t type_code) const
Convert type code into its textual representation.
bool addClass(const std::string &class_string, uint16_t class_code)
Add mappings between RR class code and textual representation.
static RRParamRegistry & getRegistry()
Return the singleton instance of RRParamRegistry.
bool addType(const std::string &type_string, uint16_t type_code)
Add mappings between RR type code and textual representation.
bool removeRdataFactory(const RRType &rrtype, const RRClass &rrclass)
Remove registered RDATA factory for the given pair of RRType and RRClass.
void add(const std::string &type_string, uint16_t type_code, const std::string &class_string, uint16_t class_code, rdata::RdataFactoryPtr rdata_factory)
Add a set of parameters for a pair of RR type and class.
bool removeClass(uint16_t class_code)
Remove mappings between RR class code and textual representation for a given class.
A standard DNS module exception that is thrown if a new RR type is being registered with a different ...
RRTypeExists(const char *file, size_t line, const char *what)
The RRType class encapsulates DNS resource record types.
Definition: rrtype.h:106
The AbstractRdataFactory class is an abstract base class to encapsulate a set of Rdata factory method...
virtual RdataPtr create(const std::string &rdata_str) const =0
Create RDATA from a string.
virtual RdataPtr create(const rdata::Rdata &source) const =0
Create RDATA from another Rdata object of the same type.
virtual RdataPtr create(isc::util::InputBuffer &buffer, size_t rdata_len) const =0
Create RDATA from wire-format data.
AbstractRdataFactory()
The default constructor.
virtual RdataPtr create(MasterLexer &lexer, const Name *origin, MasterLoader::Options options, MasterLoaderCallbacks &callbacks) const =0
Create RDATA using MasterLexer.
virtual ~AbstractRdataFactory()
The destructor.
The Rdata class is an abstract base class that provides a set of common interfaces to manipulate conc...
Definition: rdata.h:123
The InputBuffer class is a buffer abstraction for manipulating read-only data.
Definition: buffer.h:81
boost::shared_ptr< AbstractRdataFactory > RdataFactoryPtr
The RdataFactoryPtr type is a pointer-like type, pointing to an object of some concrete derived class...
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.
The RRParamRegistryImpl class is the actual implementation of RRParamRegistry.