21#include <boost/algorithm/string.hpp>
22#include <boost/shared_ptr.hpp>
23#include <boost/noncopyable.hpp>
164 void analyzeFqdn(
const bool client_s,
const bool client_n,
bool& server_s,
165 bool& server_n,
const DdnsParams& ddns_params)
const;
188 const bool trailing_dot =
true)
const;
209 std::string
qualifyName(
const std::string& partial_name,
211 const bool trailing_dot)
const;
457 boost::shared_ptr<asiolink::IOService> private_io_service_;
464 int registered_select_fd_;
470 bool server_s =
false;
471 bool server_n =
false;
472 analyzeFqdn(fqdn.getFlag(T::FLAG_S), fqdn.getFlag(T::FLAG_N),
473 server_s, server_n, ddns_params);
476 fqdn_resp.resetFlags();
479 fqdn_resp.setFlag(T::FLAG_S, server_s);
480 fqdn_resp.setFlag(T::FLAG_N, server_n);
483 fqdn_resp.setFlag(T::FLAG_O, (fqdn.getFlag(T::FLAG_S) != server_s));
489 bool& forward,
bool& reverse) {
490 forward = fqdn_resp.getFlag(T::FLAG_S);
491 reverse = !(fqdn_resp.getFlag(T::FLAG_N));
501 fqdn.getDomainName().empty()) {
502 fqdn_resp.setDomainName(
"", T::PARTIAL);
505 std::string client_name = fqdn.getDomainName();
516 std::vector<std::string> labels;
517 boost::algorithm::split(labels, raw_name, boost::is_any_of(
"."));
518 std::stringstream ss;
520 for (
auto const& label : labels) {
527 ss << sanitizer->scrub(label);
530 std::string clean_name = ss.str();
531 if (clean_name.empty() || clean_name ==
".") {
535 client_name = clean_name;
539 if (fqdn.getDomainNameType() == T::PARTIAL) {
540 if (client_name.back() ==
'.') {
543 client_name.pop_back();
546 fqdn_resp.setDomainName(
qualifyName(client_name, ddns_params,
true), T::FULL);
548 fqdn_resp.setDomainName(client_name, T::FULL);
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
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).
ReplaceClientNameMode
Defines the client name replacement modes.
void invokeClientErrorHandler(const dhcp_ddns::NameChangeSender::Result result, dhcp_ddns::NameChangeRequestPtr &ncr)
Calls the client's error handler.
std::string generateFqdn(const asiolink::IOAddress &address, const DdnsParams &ddns_params, const bool trailing_dot=true) const
Builds a FQDN based on the configuration and given IP address.
void analyzeFqdn(const bool client_s, const bool client_n, bool &server_s, bool &server_n, const DdnsParams &ddns_params) const
Determines server flags based on configuration and client flags.
bool ddnsEnabled()
Convenience method for checking if DHCP-DDNS is enabled.
const D2ClientConfigPtr & getD2ClientConfig() const
Fetches the DHCP-DDNS configuration pointer.
void getUpdateDirections(const T &fqdn_resp, bool &forward, bool &reverse)
Get directional update flags based on server FQDN flags.
void stop()
Stop the sender.
void suspendUpdates()
Suspends sending requests.
int getRegisteredSelectFd()
Fetches the select-fd that is currently registered.
void adjustDomainName(const T &fqdn, T &fqdn_resp, const DdnsParams &ddns_params)
Set server FQDN name based on configuration and a given FQDN.
void sendRequest(dhcp_ddns::NameChangeRequestPtr &ncr)
Send the given NameChangeRequests to kea-dhcp-ddns.
size_t getQueueSize() const
Returns the number of NCRs queued for transmission.
void clearQueue()
Removes all NCRs queued for transmission.
void stopSender()
Disables sending NameChangeRequests to kea-dhcp-ddns.
void setD2ClientConfig(D2ClientConfigPtr &new_config)
Updates the DHCP-DDNS client configuration to the given value.
bool amSending() const
Returns true if the sender is in send mode, false otherwise.
int getSelectFd()
Fetches the sender's select-fd.
void runReadyIO()
Processes sender IO events.
void adjustFqdnFlags(const T &fqdn, T &fqdn_resp, const DdnsParams &ddns_params)
Set server FQDN flags based on configuration and a given FQDN.
~D2ClientMgr()
Destructor.
D2ClientMgr()
Constructor.
size_t getQueueMaxSize() const
Returns the maximum number of NCRs allowed in the queue.
virtual void operator()(const dhcp_ddns::NameChangeSender::Result result, dhcp_ddns::NameChangeRequestPtr &ncr)
Function operator implementing the NCR sender callback.
const dhcp_ddns::NameChangeRequestPtr & peekAt(const size_t index) const
Returns the nth NCR queued for transmission.
std::string qualifyName(const std::string &partial_name, const DdnsParams &ddns_params, const bool trailing_dot) const
Adds a qualifying suffix to a given domain name.
void startSender(D2ClientErrorHandler error_handler, const isc::asiolink::IOServicePtr &io_service)
Enables sending NameChangeRequests to kea-dhcp-ddns.
Convenience container for conveying DDNS behavioral parameters It is intended to be created per Packe...
D2ClientConfig::ReplaceClientNameMode getReplaceClientNameMode() const
Returns how Kea should handle the domain-name supplied by the client.
isc::util::str::StringSanitizerPtr getHostnameSanitizer() const
Returns a regular expression string sanitizer.
Exception thrown when host name sanitizing reduces the domain name to an empty string.
FQDNScrubbedEmpty(const char *file, size_t line, const char *what)
Abstract class for defining application layer send callbacks.
Abstract interface for sending NameChangeRequests.
Result
Defines the outcome of an asynchronous NCR send.
The Name class encapsulates DNS names.
std::string toRawText(bool omit_final_dot=false) const
Convert the LabelSequence to a string without escape sequences.
Defines the D2ClientConfig class.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
boost::shared_ptr< NameChangeSender > NameChangeSenderPtr
Defines a smart pointer to an instance of a sender.
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
boost::shared_ptr< D2ClientMgr > D2ClientMgrPtr
Defines a pointer for D2ClientMgr instances.
std::function< void(const dhcp_ddns::NameChangeSender::Result result, dhcp_ddns::NameChangeRequestPtr &ncr)> D2ClientErrorHandler
Defines the type for D2 IO error handler.
std::unique_ptr< StringSanitizer > StringSanitizerPtr
Type representing the pointer to the StringSanitizer.
Defines the logger used by the top-level component of kea-lfc.
This file defines abstract classes for exchanging NameChangeRequests.