15 #include <boost/foreach.hpp>
27 typedef std::vector<uint8_t> ByteAddress;
33 D2CfgContext::D2CfgContext()
42 d2_params_ = rhs.d2_params_;
43 if (rhs.forward_mgr_) {
45 forward_mgr_->setDomains(rhs.forward_mgr_->getDomains());
48 if (rhs.reverse_mgr_) {
50 reverse_mgr_->setDomains(rhs.reverse_mgr_->getDomains());
55 control_socket_ = rhs.control_socket_;
57 hooks_config_ = rhs.hooks_config_;
69 const IOAddress& ip_address = d2_params_->getIpAddress();
70 d2->set(
"ip-address", Element::create(ip_address.
toText()));
72 size_t port = d2_params_->getPort();
73 d2->set(
"port", Element::create(static_cast<int64_t>(port)));
75 size_t dns_server_timeout = d2_params_->getDnsServerTimeout();
76 d2->set(
"dns-server-timeout",
77 Element::create(static_cast<int64_t>(dns_server_timeout)));
80 d2_params_->getNcrProtocol();
81 d2->set(
"ncr-protocol",
88 ElementPtr forward_ddns = Element::createMap();
89 forward_ddns->set(
"ddns-domains", forward_mgr_->toElement());
90 d2->set(
"forward-ddns", forward_ddns);
92 ElementPtr reverse_ddns = Element::createMap();
93 reverse_ddns->set(
"ddns-domains", reverse_mgr_->toElement());
94 d2->set(
"reverse-ddns", reverse_ddns);
97 for (TSIGKeyInfoMap::const_iterator key = keys_->begin();
98 key != keys_->end(); ++key) {
99 tsig_keys->add(key->second->toElement());
101 d2->set(
"tsig-keys", tsig_keys);
103 if (!
isNull(control_socket_)) {
104 d2->set(
"control-socket", UserContext::toElement(control_socket_));
107 d2->set(
"hooks-libraries", hooks_config_.
toElement());
110 result->set(
"DhcpDdns", d2);
155 return (mgr->matchDomain(fqdn, domain));
166 return (mgr->matchDomain(reverse_address, domain));
183 << address <<
" : " << ex.
what());
189 if (!ioaddr.
isV4()) {
195 const ByteAddress bytes = ioaddr.
toBytes();
198 std::ostringstream stream;
203 const ByteAddress::const_reverse_iterator end = bytes.rend();
205 for (ByteAddress::const_reverse_iterator rit = bytes.rbegin();
209 stream << static_cast<unsigned int>(*rit) <<
".";
214 return(stream.str());
219 if (!ioaddr.
isV6()) {
224 const ByteAddress bytes = ioaddr.
toBytes();
228 std::ostringstream stream;
233 const std::string::const_reverse_iterator end = digits.rend();
235 for (std::string::const_reverse_iterator rit = digits.rbegin();
239 stream << static_cast<char>(*rit) <<
".";
244 return(stream.str());
286 parser.
parse(ctx, cfg, check_only);
291 excuse =
"undefined configuration parsing error";
307 "Configuration check successful");
310 "Configuration applied successfully.");
316 std::list<std::list<std::string>>
318 static std::list<std::list<std::string>>
const list({
320 {
"hooks-libraries",
"[]",
"parameters",
"*"},
virtual process::ConfigPtr createNewContext() override
Creates an new, blank D2CfgContext context.
const isc::log::MessageID DHCP_DDNS_CONFIG_CHECK_FAIL
boost::shared_ptr< D2Params > D2ParamsPtr
Defines a pointer for D2Params instances.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
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.
virtual void setCfgDefaults(isc::data::ElementPtr mutable_config) override
Adds default values to the given config.
Base class for all configurations.
virtual std::string getConfigSummary(const uint32_t selection) override
Returns configuration summary in the textual format.
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::list< std::list< std::string > > jsonPathsToRedact() const finaloverride
Return a list of all paths that contain passwords or secrets.
std::map< std::string, TSIGKeyInfoPtr > TSIGKeyInfoMap
Defines a map of TSIGKeyInfos, keyed by the name.
NameChangeFormat
Defines the list of data wire formats supported.
const isc::log::MessageID DHCP_DDNS_CONFIG_FAIL
bool isNull(ConstElementPtr p)
Checks whether the given ElementPtr is a NULL pointer.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.
bool isV4() const
Convenience function to check for an IPv4 address.
std::vector< uint8_t > toBytes() const
Return address as set of bytes.
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.
const isc::data::ConstElementPtr getControlSocketInfo()
Convenience method fetches information about control socket from context.
isc::data::ElementPtr toElement() const
Unparse a configuration object.
D2CfgContextPtr getD2CfgContext()
Convenience method that returns the D2 configuration context.
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.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
static std::string reverseV6Address(const isc::asiolink::IOAddress &ioaddr)
Generate a reverse order string for the given IP address.
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.
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.
virtual isc::data::ConstElementPtr parse(isc::data::ConstElementPtr config, bool check_only) override
Parses configuration of the D2.
std::string ncrFormatToString(NameChangeFormat format)
Function which converts NameChangeFormat enums to text labels.
D2CfgContext()
Constructor.
The Element class represents a piece of data, used by the command channel and configuration parts...
std::string toText() const
Convert the address to a string.
NameChangeProtocol
Defines the list of socket protocols supported.
bool isV6() const
Convenience function to check for an IPv6 address.
bool reverseUpdatesEnabled()
Returns whether or not reverse updates are enabled.
The IOAddress class represents an IP addresses (version agnostic)
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 ConfigBase.