]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2078] Moved the factory to libd2srv
authorFrancis Dupont <fdupont@isc.org>
Mon, 6 Sep 2021 18:41:40 +0000 (20:41 +0200)
committerRazvan Becheriu <razvan@isc.org>
Tue, 7 Sep 2021 09:45:43 +0000 (12:45 +0300)
src/bin/d2/dns_client.cc
src/bin/d2/dns_client.h
src/lib/d2srv/d2_tsig_key.cc
src/lib/d2srv/d2_tsig_key.h

index 5cd443db010ba700401149cc73cead71e845d4b6..77d3a09bd8c8b17ce19dd158451163e2622de5df 100644 (file)
@@ -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)) {
index 2037f3ae8ffc7e2756ddbe669cf3885498a5569d..fb2412523d78eb8705b62fec08e80c815d2b56cd 100644 (file)
 
 #include <asiodns/io_fetch.h>
 #include <d2srv/d2_tsig_key.h>
-#include <dns/tsig.h>
 
 namespace isc {
 namespace d2 {
 
-/// @brief Forward declaration of DNSclient class.
 class DNSClient;
 typedef boost::shared_ptr<DNSClient> 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
index 2d9055a833834c694955b87135c99cd4ea178ee9..57d05adaf578fa4e24fe1268c522ab6f201c5abc 100644 (file)
@@ -58,5 +58,12 @@ D2TsigKey::resetStats() {
     }
 }
 
+TSIGContextPtr
+defaultTsigContextFactory(D2TsigKeyPtr tsig_key) {
+    return (TSIGContextPtr(new TSIGContext(*tsig_key)));
+}
+
+TSIGContextFactory tsigContextFactory = &defaultTsigContextFactory;
+
 } // namespace d2
 } // namespace isc
index 2815cb0a7957e3766aae4dad645ec238643aa908..54efc47ebbc1b6e2b9310a780372bf589d8faebc 100644 (file)
@@ -8,7 +8,7 @@
 #define D2_TSIG_KEY_H
 
 #include <dns/name.h>
-#include <dns/tsigkey.h>
+#include <dns/tsig.h>
 #include <boost/shared_ptr.hpp>
 
 namespace isc {
@@ -60,6 +60,18 @@ private:
 /// @brief Type of pointer to a D2 TSIG key.
 typedef boost::shared_ptr<D2TsigKey> 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