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.");
boost::shared_ptr< D2Params > D2ParamsPtr
Defines a pointer for D2Params instances.
virtual isc::data::ConstElementPtr parse(isc::data::ConstElementPtr config, bool check_only)
Parses configuration of the D2.
boost::shared_ptr< DdnsDomainListMgr > DdnsDomainListMgrPtr
Defines a pointer for DdnsDomain instances.
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
static std::string reverseIpAddress(const std::string &address)
Generate a reverse order string for the given IP address.
static size_t setAllDefaults(data::ElementPtr global)
Sets all defaults for D2 configuration.
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
void parse(const D2CfgContextPtr &ctx, const isc::data::ConstElementPtr &config, bool check_only)
Parses the whole D2 configuration.
Base class for all configurations.
Exception thrown when the error during configuration handling occurs.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
boost::shared_ptr< Element > ElementPtr
std::map< std::string, TSIGKeyInfoPtr > TSIGKeyInfoMap
Defines a map of TSIGKeyInfos, keyed by the name.
NameChangeFormat
Defines the list of data wire formats supported.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
virtual std::string getConfigSummary(const uint32_t selection)
Returns configuration summary in the textual format.
const D2ParamsPtr & getD2Params()
Convenience method fetches the D2Params from context.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
std::string ncrProtocolToString(NameChangeProtocol protocol)
Function which converts NameChangeProtocol enums to text labels.
virtual ~D2CfgContext()
Destructor.
virtual ~D2CfgMgr()
Destructor.
D2CfgContextPtr getD2CfgContext()
Convenience method that returns the D2 configuration context.
std::vector< uint8_t > toBytes() const
Return address as set of bytes.
boost::shared_ptr< const Element > ConstElementPtr
Provides storage for and management of a list of DNS domains.
DHCP-DDNS Configuration Context.
boost::shared_ptr< D2CfgContext > D2CfgContextPtr
Pointer to a configuration context.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.
bool isV6() const
Convenience function to check for an IPv6 address.
bool isV4() const
Convenience function to check for an IPv4 address.
static std::string reverseV6Address(const isc::asiolink::IOAddress &ioaddr)
Generate a reverse order string for the given IP address.
virtual void setCfgDefaults(isc::data::ElementPtr mutable_config)
Adds default values to the given config.
static const char * IPV6_REV_ZONE_SUFFIX
Reverse zone suffix added to IPv6 addresses for reverse lookups.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
bool forwardUpdatesEnabled()
Returns whether or not forward updates are enabled.
string encodeHex(const vector< uint8_t > &binary)
Encode binary data in the base16 ('hex') format.
std::string toText() const
Convert the address to a string.
isc::log::Logger d2_logger("dhcpddns")
Defines the logger used within D2.
bool matchReverse(const std::string &ip_address, DdnsDomainPtr &domain)
Matches a given IP address to a reverse domain.
This file contains several functions and constants that are used for handling commands and responses ...
bool matchForward(const std::string &fqdn, DdnsDomainPtr &domain)
Matches a given FQDN to a forward domain.
std::string ncrFormatToString(NameChangeFormat format)
Function which converts NameChangeFormat enums to text labels.
D2CfgContext()
Constructor.
NameChangeProtocol
Defines the list of socket protocols supported.
bool reverseUpdatesEnabled()
Returns whether or not reverse updates are enabled.
The IOAddress class represents an IP addresses (version agnostic)
virtual process::ConfigPtr createNewContext()
Creates an new, blank D2CfgContext context.
static std::string reverseV4Address(const isc::asiolink::IOAddress &ioaddr)
Generate a reverse order string for the given IP address.
Acts as a storage vault for D2 global scalar parameters.
static const char * IPV4_REV_ZONE_SUFFIX
Reverse zone suffix added to IPv4 addresses for reverse lookups.
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the SrvConfig.