From: Francis Dupont Date: Mon, 6 Sep 2021 18:41:40 +0000 (+0200) Subject: [#2078] Moved the factory to libd2srv X-Git-Tag: Kea-2.0.0~140 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ddb97c80befa1a8ebd47c8cdd45025e4cc47b77;p=thirdparty%2Fkea.git [#2078] Moved the factory to libd2srv --- diff --git a/src/bin/d2/dns_client.cc b/src/bin/d2/dns_client.cc index 5cd443db01..77d3a09bd8 100644 --- a/src/bin/d2/dns_client.cc +++ b/src/bin/d2/dns_client.cc @@ -207,7 +207,7 @@ DNSClientImpl::doUpdate(asiolink::IOService& io_service, // pointer. Message marshalling uses non-null context is the indicator // that TSIG should be used. if (tsig_key) { - tsig_context_ = DNSClient::factory(tsig_key); + tsig_context_ = tsigContextFactory(tsig_key); tsig_key_name_ = tsig_key->getKeyName().toText(); } else { tsig_context_.reset(); @@ -262,14 +262,6 @@ DNSClientImpl::incrStats(const std::string& stat, bool update_key) { } } -TSIGContextPtr -DNSClient::defaultFactory(D2TsigKeyPtr tsig_key) { - return (TSIGContextPtr(new TSIGContext(*tsig_key))); -} - -DNSClient::TSIGContextFactory -DNSClient::factory = &DNSClient::defaultFactory; - DNSClient::DNSClient(D2UpdateMessagePtr& response_placeholder, Callback* callback, const DNSClient::Protocol proto) : impl_(new DNSClientImpl(response_placeholder, callback, proto)) { diff --git a/src/bin/d2/dns_client.h b/src/bin/d2/dns_client.h index 2037f3ae8f..fb2412523d 100644 --- a/src/bin/d2/dns_client.h +++ b/src/bin/d2/dns_client.h @@ -14,12 +14,10 @@ #include #include -#include namespace isc { namespace d2 { -/// @brief Forward declaration of DNSclient class. class DNSClient; typedef boost::shared_ptr DNSClientPtr; @@ -85,18 +83,6 @@ public: virtual void operator()(DNSClient::Status status) = 0; }; - /// @brief TSIGContext factory type. - typedef dns::TSIGContextPtr (*TSIGContextFactory)(D2TsigKeyPtr); - - /// @brief The TSIGContext factory. - static TSIGContextFactory factory; - - /// @brief Default TSIGContext factory. - /// - /// @param tsig_key a D2 TSIG key. - /// @return a pointer to a TSIG context. - static dns::TSIGContextPtr defaultFactory(D2TsigKeyPtr tsig_key); - /// @brief Constructor. /// /// @param response_placeholder Message object pointer which will be updated diff --git a/src/lib/d2srv/d2_tsig_key.cc b/src/lib/d2srv/d2_tsig_key.cc index 2d9055a833..57d05adaf5 100644 --- a/src/lib/d2srv/d2_tsig_key.cc +++ b/src/lib/d2srv/d2_tsig_key.cc @@ -58,5 +58,12 @@ D2TsigKey::resetStats() { } } +TSIGContextPtr +defaultTsigContextFactory(D2TsigKeyPtr tsig_key) { + return (TSIGContextPtr(new TSIGContext(*tsig_key))); +} + +TSIGContextFactory tsigContextFactory = &defaultTsigContextFactory; + } // namespace d2 } // namespace isc diff --git a/src/lib/d2srv/d2_tsig_key.h b/src/lib/d2srv/d2_tsig_key.h index 2815cb0a79..54efc47ebb 100644 --- a/src/lib/d2srv/d2_tsig_key.h +++ b/src/lib/d2srv/d2_tsig_key.h @@ -8,7 +8,7 @@ #define D2_TSIG_KEY_H #include -#include +#include #include namespace isc { @@ -60,6 +60,18 @@ private: /// @brief Type of pointer to a D2 TSIG key. typedef boost::shared_ptr D2TsigKeyPtr; +/// @brief TSIGContext factory type. +typedef dns::TSIGContextPtr (*TSIGContextFactory)(D2TsigKeyPtr); + +/// @brief The TSIGContext factory. +extern TSIGContextFactory tsigContextFactory; + +/// @brief Default TSIGContext factory. +/// +/// @param tsig_key a D2 TSIG key. +/// @return a pointer to a TSIG context. +dns::TSIGContextPtr defaultTsigContextFactory(D2TsigKeyPtr tsig_key); + } // namespace d2 } // namespace isc