 |
Kea
1.5.0
|
Go to the documentation of this file.
15 #include <boost/foreach.hpp>
27 typedef std::vector<uint8_t> ByteAddress;
33 D2CfgContext::D2CfgContext()
41 d2_params_ = rhs.d2_params_;
42 if (rhs.forward_mgr_) {
44 forward_mgr_->setDomains(rhs.forward_mgr_->getDomains());
47 if (rhs.reverse_mgr_) {
49 reverse_mgr_->setDomains(rhs.reverse_mgr_->getDomains());
64 const IOAddress& ip_address = d2_params_->getIpAddress();
65 d2->set(
"ip-address", Element::create(ip_address.
toText()));
67 size_t port = d2_params_->getPort();
68 d2->set(
"port", Element::create(
static_cast<int64_t
>(port)));
70 size_t dns_server_timeout = d2_params_->getDnsServerTimeout();
71 d2->set(
"dns-server-timeout",
72 Element::create(
static_cast<int64_t
>(dns_server_timeout)));
75 d2_params_->getNcrProtocol();
76 d2->set(
"ncr-protocol",
83 ElementPtr forward_ddns = Element::createMap();
84 forward_ddns->set(
"ddns-domains", forward_mgr_->toElement());
85 d2->set(
"forward-ddns", forward_ddns);
87 ElementPtr reverse_ddns = Element::createMap();
88 reverse_ddns->set(
"ddns-domains", reverse_mgr_->toElement());
89 d2->set(
"reverse-ddns", reverse_ddns);
92 for (TSIGKeyInfoMap::const_iterator key = keys_->begin();
93 key != keys_->end(); ++key) {
94 tsig_keys->add(key->second->toElement());
96 d2->set(
"tsig-keys", tsig_keys);
99 result->set(
"DhcpDdns", d2);
144 return (mgr->matchDomain(fqdn, domain));
155 return (mgr->matchDomain(reverse_address, domain));
172 << address <<
" : " << ex.
what());
178 if (!ioaddr.
isV4()) {
184 const ByteAddress bytes = ioaddr.
toBytes();
187 std::ostringstream stream;
192 const ByteAddress::const_reverse_iterator end = bytes.rend();
194 for (ByteAddress::const_reverse_iterator rit = bytes.rbegin();
198 stream << static_cast<unsigned int>(*rit) <<
".";
203 return(stream.str());
208 if (!ioaddr.
isV6()) {
213 const ByteAddress bytes = ioaddr.
toBytes();
217 std::ostringstream stream;
222 const std::string::const_reverse_iterator end = digits.rend();
224 for (std::string::const_reverse_iterator rit = digits.rbegin();
228 stream << static_cast<char>(*rit) <<
".";
233 return(stream.str());
261 ElementPtr cfg = boost::const_pointer_cast<Element>(config_set);
270 parser.
parse(ctx, cfg, check_only);
275 excuse =
"undefined configuration parsing error";
291 "Configuration check successful");
294 "Configuration applied successfully.");
Base class for all configurations.
Acts as a storage vault for D2 global scalar parameters.
boost::shared_ptr< DdnsDomainListMgr > DdnsDomainListMgrPtr
Defines a pointer for DdnsDomain instances.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
isc::log::Logger d2_logger("dhcpddns")
Defines the logger used within D2.
The IOAddress class represents an IP addresses (version agnostic)
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
Provides storage for and management of a list of DNS domains.
virtual isc::data::ConstElementPtr parse(isc::data::ConstElementPtr config, bool check_only)
Parses configuration of the D2.
bool isV6() const
Convenience function to check for an IPv6 address.
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
static std::string reverseV6Address(const isc::asiolink::IOAddress &ioaddr)
Generate a reverse order string for the given IP address.
std::vector< uint8_t > toBytes() const
Return address as set of bytes.
This is a base class for exceptions thrown from the DNS library module.
const D2ParamsPtr & getD2Params()
Convenience method fetches the D2Params from context.
Exception thrown when the error during configuration handling occurs.
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the SrvConfig.
Defines the logger used by the top-level component of kea-dhcp-ddns.
bool matchReverse(const std::string &ip_address, DdnsDomainPtr &domain)
Matches a given IP address to a reverse domain.
static std::string reverseV4Address(const isc::asiolink::IOAddress &ioaddr)
Generate a reverse order string for the given IP address.
D2CfgContextPtr getD2CfgContext()
Convenience method that returns the D2 configuration context.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
virtual process::ConfigPtr createNewContext()
Creates an new, blank D2CfgContext context.
virtual void setCfgDefaults(isc::data::ElementPtr mutable_config)
Adds default values to the given config.
boost::shared_ptr< D2Params > D2ParamsPtr
Defines a pointer for D2Params instances.
static size_t setAllDefaults(data::ElementPtr global)
Sets all defaults for D2 configuration.
virtual ~D2CfgMgr()
Destructor.
virtual ~D2CfgContext()
Destructor.
bool matchForward(const std::string &fqdn, DdnsDomainPtr &domain)
Matches a given FQDN to a forward domain.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
std::string toText() const
Convert the address to a string.
D2CfgContext()
Constructor.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.
static const char * IPV4_REV_ZONE_SUFFIX
Reverse zone suffix added to IPv4 addresses for reverse lookups.
std::map< std::string, TSIGKeyInfoPtr > TSIGKeyInfoMap
Defines a map of TSIGKeyInfos, keyed by the name.
bool forwardUpdatesEnabled()
Returns whether or not forward updates are enabled.
DHCP-DDNS Configuration Context.
std::string ncrProtocolToString(NameChangeProtocol protocol)
Function which converts NameChangeProtocol enums to text labels.
string encodeHex(const vector< uint8_t > &binary)
Encode binary data in the base16 ('hex') format.
static std::string reverseIpAddress(const std::string &address)
Generate a reverse order string for the given IP address.
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< const Element > ConstElementPtr
virtual std::string getConfigSummary(const uint32_t selection)
Returns configuration summary in the textual format.
boost::shared_ptr< D2CfgContext > D2CfgContextPtr
Pointer to a configuration context.
bool reverseUpdatesEnabled()
Returns whether or not reverse updates are enabled.
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
bool isV4() const
Convenience function to check for an IPv4 address.
void parse(const D2CfgContextPtr &ctx, const isc::data::ConstElementPtr &config, bool check_only)
Parses the whole D2 configuration.
std::string ncrFormatToString(NameChangeFormat format)
Function which converts NameChangeFormat enums to text labels.
static const char * IPV6_REV_ZONE_SUFFIX
Reverse zone suffix added to IPv6 addresses for reverse lookups.
NameChangeFormat
Defines the list of data wire formats supported.
NameChangeProtocol
Defines the list of socket protocols supported.