Kea 2.5.9
rrparamregistry.h
Go to the documentation of this file.
1// Copyright (C) 2010-2024 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
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
98 size_t rdata_len) const = 0;
99
113 virtual RdataPtr create(const rdata::Rdata& source) const = 0;
114
121 virtual RdataPtr create(MasterLexer& lexer, const Name* origin,
122 MasterLoader::Options options,
123 MasterLoaderCallbacks& callbacks) const = 0;
125};
126
131typedef boost::shared_ptr<AbstractRdataFactory> RdataFactoryPtr;
132} // end of namespace rdata
133
177
178private:
180 RRParamRegistry(const RRParamRegistry& orig);
183public:
203
207
208
232 void add(const std::string& type_string, uint16_t type_code,
233 const std::string& class_string, uint16_t class_code,
234 rdata::RdataFactoryPtr rdata_factory);
235
245 void add(const std::string& type_string, uint16_t type_code,
246 rdata::RdataFactoryPtr rdata_factory);
247
275 bool addType(const std::string& type_string, uint16_t type_code);
276
289 bool removeType(uint16_t type_code);
290
318 bool addClass(const std::string& class_string, uint16_t class_code);
319
332 bool removeClass(uint16_t class_code);
333
348 bool removeRdataFactory(const RRType& rrtype, const RRClass& rrclass);
349
363 bool removeRdataFactory(const RRType& rrtype);
365
369
370
387 bool textToTypeCode(const std::string& type_string,
388 uint16_t& type_code) const;
389
405 std::string codeToTypeText(uint16_t type_code) const;
406
425 bool textToClassCode(const std::string& class_string,
426 uint16_t& class_code) const;
427
443 std::string codeToClassText(uint16_t class_code) const;
445
465
466
476 rdata::RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
477 const std::string& rdata_string);
491 rdata::RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
492 isc::util::InputBuffer& buff, size_t len);
515 rdata::RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
516 const rdata::Rdata& source);
517
530 rdata::RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
531 MasterLexer& lexer, const Name* origin,
532 MasterLoader::Options options,
533 MasterLoaderCallbacks& callbacks);
535
536private:
537 boost::shared_ptr<RRParamRegistryImpl> impl_;
538};
539
540}
541}
542#endif // RRPARAMREGISTRY_H
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:303
Set of issue callbacks for a loader.
Options
Options how the parsing should work.
Definition: master_loader.h:42
The Name class encapsulates DNS names.
Definition: name.h:219
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:89
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:96
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 &buff, 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:120
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.