16 #include <boost/foreach.hpp>
28 typedef std::vector<uint8_t> ByteAddress;
34 D2CfgContext::D2CfgContext()
43 d2_params_ = rhs.d2_params_;
44 if (rhs.forward_mgr_) {
46 forward_mgr_->setDomains(rhs.forward_mgr_->getDomains());
49 if (rhs.reverse_mgr_) {
51 reverse_mgr_->setDomains(rhs.reverse_mgr_->getDomains());
56 control_socket_ = rhs.control_socket_;
58 hooks_config_ = rhs.hooks_config_;
70 const IOAddress& ip_address = d2_params_->getIpAddress();
71 d2->set(
"ip-address", Element::create(ip_address.
toText()));
73 size_t port = d2_params_->getPort();
74 d2->set(
"port", Element::create(
static_cast<int64_t
>(port)));
76 size_t dns_server_timeout = d2_params_->getDnsServerTimeout();
77 d2->set(
"dns-server-timeout",
78 Element::create(
static_cast<int64_t
>(dns_server_timeout)));
81 d2_params_->getNcrProtocol();
82 d2->set(
"ncr-protocol",
89 ElementPtr forward_ddns = Element::createMap();
90 forward_ddns->set(
"ddns-domains", forward_mgr_->toElement());
91 d2->set(
"forward-ddns", forward_ddns);
93 ElementPtr reverse_ddns = Element::createMap();
94 reverse_ddns->set(
"ddns-domains", reverse_mgr_->toElement());
95 d2->set(
"reverse-ddns", reverse_ddns);
98 for (TSIGKeyInfoMap::const_iterator key = keys_->begin();
99 key != keys_->end(); ++key) {
100 tsig_keys->add(key->second->toElement());
102 d2->set(
"tsig-keys", tsig_keys);
104 if (!
isNull(control_socket_)) {
105 d2->set(
"control-socket", UserContext::toElement(control_socket_));
108 d2->set(
"hooks-libraries", hooks_config_.
toElement());
111 result->set(
"DhcpDdns", d2);
156 return (mgr->matchDomain(fqdn, domain));
167 return (mgr->matchDomain(reverse_address, domain));
184 << address <<
" : " << ex.
what());
190 if (!ioaddr.
isV4()) {
196 const ByteAddress bytes = ioaddr.
toBytes();
199 std::ostringstream stream;
204 const ByteAddress::const_reverse_iterator end = bytes.rend();
206 for (ByteAddress::const_reverse_iterator rit = bytes.rbegin();
210 stream << static_cast<unsigned int>(*rit) <<
".";
215 return(stream.str());
220 if (!ioaddr.
isV6()) {
225 const ByteAddress bytes = ioaddr.
toBytes();
229 std::ostringstream stream;
234 const std::string::const_reverse_iterator end = digits.rend();
236 for (std::string::const_reverse_iterator rit = digits.rbegin();
240 stream << static_cast<char>(*rit) <<
".";
245 return(stream.str());
278 ElementPtr cfg = boost::const_pointer_cast<Element>(config_set);
287 parser.
parse(ctx, cfg, check_only);
292 excuse =
"undefined configuration parsing error";
308 "Configuration check successful");
313 std::string hash = BaseCommandMgr::getHash(config);
315 params->set(
"hash", Element::create(hash));
318 "Configuration applied successfully.", params);
324 std::list<std::list<std::string>>
326 static std::list<std::list<std::string>>
const list({
328 {
"hooks-libraries",
"[]",
"parameters",
"*"},
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The IOAddress class represents an IP addresses (version agnostic)
std::string toText() const
Convert the address to a string.
bool isV6() const
Convenience function to check for an IPv6 address.
bool isV4() const
Convenience function to check for an IPv4 address.
std::vector< uint8_t > toBytes() const
Return address as set of bytes.
DHCP-DDNS Configuration Context.
virtual ~D2CfgContext()
Destructor.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
D2CfgContext()
Constructor.
Exception thrown when the error during configuration handling occurs.
virtual ~D2CfgMgr()
Destructor.
bool matchForward(const std::string &fqdn, DdnsDomainPtr &domain)
Matches a given FQDN to a forward domain.
virtual process::ConfigPtr createNewContext() override
Creates an new, blank D2CfgContext context.
static std::string reverseIpAddress(const std::string &address)
Generate a reverse order string for the given IP address.
D2CfgContextPtr getD2CfgContext()
Convenience method that returns the D2 configuration context.
bool reverseUpdatesEnabled()
Returns whether or not reverse updates are enabled.
virtual void setCfgDefaults(isc::data::ElementPtr mutable_config) override
Adds default values to the given config.
std::list< std::list< std::string > > jsonPathsToRedact() const final override
Return a list of all paths that contain passwords or secrets.
static const char * IPV6_REV_ZONE_SUFFIX
Reverse zone suffix added to IPv6 addresses for reverse lookups.
static std::string reverseV4Address(const isc::asiolink::IOAddress &ioaddr)
Generate a reverse order string for the given IP address.
bool forwardUpdatesEnabled()
Returns whether or not forward updates are enabled.
bool matchReverse(const std::string &ip_address, DdnsDomainPtr &domain)
Matches a given IP address to a reverse domain.
virtual std::string getConfigSummary(const uint32_t selection) override
Returns configuration summary in the textual format.
static std::string reverseV6Address(const isc::asiolink::IOAddress &ioaddr)
Generate a reverse order string for the given IP address.
const D2ParamsPtr & getD2Params()
Convenience method fetches the D2Params from context.
const isc::data::ConstElementPtr getControlSocketInfo()
Convenience method fetches information about control socket from context.
virtual isc::data::ConstElementPtr parse(isc::data::ConstElementPtr config, bool check_only) override
Parses configuration of the D2.
static const char * IPV4_REV_ZONE_SUFFIX
Reverse zone suffix added to IPv4 addresses for reverse lookups.
Acts as a storage vault for D2 global scalar parameters.
void parse(const D2CfgContextPtr &ctx, const isc::data::ConstElementPtr &config, bool check_only)
Parses the whole D2 configuration.
static size_t setAllDefaults(data::ElementPtr global)
Sets all defaults for D2 configuration.
Provides storage for and management of a list of DNS domains.
isc::data::ElementPtr toElement() const
Unparse a configuration object.
Base class for all configurations.
ConfigPtr & getContext()
Fetches the configuration context.
This file contains several functions and constants that are used for handling commands and responses ...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#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.
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
boost::shared_ptr< DdnsDomainListMgr > DdnsDomainListMgrPtr
Defines a pointer for DdnsDomain instances.
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
const isc::log::MessageID DHCP_DDNS_CONFIG_CHECK_FAIL
std::map< std::string, TSIGKeyInfoPtr > TSIGKeyInfoMap
Defines a map of TSIGKeyInfos, keyed by the name.
boost::shared_ptr< D2CfgContext > D2CfgContextPtr
Pointer to a configuration context.
isc::log::Logger d2_logger("dhcpddns")
Defines the logger used within D2.
boost::shared_ptr< D2Params > D2ParamsPtr
Defines a pointer for D2Params instances.
const isc::log::MessageID DHCP_DDNS_CONFIG_FAIL
boost::shared_ptr< const Element > ConstElementPtr
bool isNull(ConstElementPtr p)
Checks whether the given ElementPtr is a NULL pointer.
boost::shared_ptr< Element > ElementPtr
NameChangeFormat
Defines the list of data wire formats supported.
NameChangeProtocol
Defines the list of socket protocols supported.
std::string ncrProtocolToString(NameChangeProtocol protocol)
Function which converts NameChangeProtocol enums to text labels.
std::string ncrFormatToString(NameChangeFormat format)
Function which converts NameChangeFormat enums to text labels.
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the ConfigBase.
string encodeHex(const vector< uint8_t > &binary)
Encode binary data in the base16 ('hex') format.
Defines the logger used by the top-level component of kea-lfc.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.