7 #ifndef D2_CLIENT_MGR_H 8 #define D2_CLIENT_MGR_H 19 #include <boost/algorithm/string.hpp> 20 #include <boost/shared_ptr.hpp> 21 #include <boost/noncopyable.hpp> 153 void analyzeFqdn(
const bool client_s,
const bool client_n,
bool& server_s,
154 bool& server_n)
const;
174 const bool trailing_dot =
true)
const;
190 std::string
qualifyName(
const std::string& partial_name,
191 const bool trailing_dot)
const;
426 boost::shared_ptr<asiolink::IOService> private_io_service_;
433 int registered_select_fd_;
439 bool server_s =
false;
440 bool server_n =
false;
441 analyzeFqdn(fqdn.getFlag(T::FLAG_S), fqdn.getFlag(T::FLAG_N),
445 fqdn_resp.resetFlags();
448 fqdn_resp.setFlag(T::FLAG_S, server_s);
449 fqdn_resp.setFlag(T::FLAG_N, server_n);
452 fqdn_resp.setFlag(T::FLAG_O, (fqdn.getFlag(T::FLAG_S) != server_s));
458 bool& forward,
bool& reverse) {
459 forward = fqdn_resp.getFlag(T::FLAG_S);
460 reverse = !(fqdn_resp.getFlag(T::FLAG_N));
470 fqdn.getDomainName().empty()) {
471 fqdn_resp.setDomainName(
"", T::PARTIAL);
474 std::string client_name = fqdn.getDomainName();
476 if (d2_client_config_->getHostnameSanitizer()) {
485 std::vector<std::string> labels;
486 boost::algorithm::split(labels, raw_name, boost::is_any_of(
"."));
487 std::stringstream ss;
488 for (
auto label = labels.begin(); label != labels.end(); ++label ) {
489 if (label != labels.begin()) {
493 ss << d2_client_config_->getHostnameSanitizer()->scrub(*label);
496 client_name = ss.str();
500 if (fqdn.getDomainNameType() == T::PARTIAL) {
501 fqdn_resp.setDomainName(
qualifyName(client_name,
true), T::FULL);
504 fqdn_resp.setDomainName(client_name, T::FULL);
std::string generateFqdn(const asiolink::IOAddress &address, const bool trailing_dot=true) const
Builds a FQDN based on the configuration and given IP address.
The Name class encapsulates DNS names.
Defines the D2ClientConfig class.
bool amSending() const
Returns true if the sender is in send mode, false otherwise.
std::string qualifyName(const std::string &partial_name, const bool trailing_dot) const
Adds a qualifying suffix to a given domain name.
void adjustFqdnFlags(const T &fqdn, T &fqdn_resp)
Set server FQDN flags based on configuration and a given FQDN.
This file defines abstract classes for exchanging NameChangeRequests.
~D2ClientMgr()
Destructor.
void startSender(D2ClientErrorHandler error_handler, isc::asiolink::IOService &io_service)
Enables sending NameChangeRequests to kea-dhcp-ddns.
Result
Defines the outcome of an asynchronous NCR send.
virtual void operator()(const dhcp_ddns::NameChangeSender::Result result, dhcp_ddns::NameChangeRequestPtr &ncr)
Function operator implementing the NCR sender callback.
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
void sendRequest(dhcp_ddns::NameChangeRequestPtr &ncr)
Send the given NameChangeRequests to kea-dhcp-ddns.
The IOService class is a wrapper for the ASIO io_service class.
boost::function< void(const dhcp_ddns::NameChangeSender::Result result, dhcp_ddns::NameChangeRequestPtr &ncr)> D2ClientErrorHandler
Defines the type for D2 IO error handler.
boost::shared_ptr< D2ClientMgr > D2ClientMgrPtr
Defines a pointer for D2ClientMgr instances.
void analyzeFqdn(const bool client_s, const bool client_n, bool &server_s, bool &server_n) const
Determines server flags based on configuration and client flags.
bool ddnsEnabled()
Convenience method for checking if DHCP-DDNS is enabled.
std::string toRawText(bool omit_final_dot=false) const
Convert the LabelSequence to a string without escape sequences.
void clearQueue()
Removes all NCRs queued for transmission.
const D2ClientConfigPtr & getD2ClientConfig() const
Fetches the DHCP-DDNS configuration pointer.
void adjustDomainName(const T &fqdn, T &fqdn_resp)
Set server FQDN name based on configuration and a given FQDN.
const dhcp_ddns::NameChangeRequestPtr & peekAt(const size_t index) const
Returns the nth NCR queued for transmission.
void invokeClientErrorHandler(const dhcp_ddns::NameChangeSender::Result result, dhcp_ddns::NameChangeRequestPtr &ncr)
Calls the client's error handler.
boost::shared_ptr< NameChangeSender > NameChangeSenderPtr
Defines a smart pointer to an instance of a sender.
Abstract class for defining application layer send callbacks.
Defines the logger used by the top-level component of kea-dhcp-ddns.
D2ClientMgr isolates Kea from the details of being a D2 client.
void getUpdateDirections(const T &fqdn_resp, bool &forward, bool &reverse)
Get directional update flags based on server FQDN flags.
void suspendUpdates()
Suspends sending requests.
Abstract interface for sending NameChangeRequests.
D2ClientMgr()
Constructor.
int getSelectFd()
Fetches the sender's select-fd.
The IOAddress class represents an IP addresses (version agnostic)
int getRegisteredSelectFd()
Fetches the select-fd that is currently registered.
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
void runReadyIO()
Processes sender IO events.
size_t getQueueMaxSize() const
Returns the maximum number of NCRs allowed in the queue.
void setD2ClientConfig(D2ClientConfigPtr &new_config)
Updates the DHCP-DDNS client configuration to the given value.
void stopSender()
Disables sending NameChangeRequests to kea-dhcp-ddns.
size_t getQueueSize() const
Returns the number of NCRs queued for transmission.