|
@@ -27,14 +27,25 @@ class DNSLookup;
|
|
class DNSAnswer;
|
|
class DNSAnswer;
|
|
class DNSServiceImpl;
|
|
class DNSServiceImpl;
|
|
|
|
|
|
-/// \brief Handle DNS Queries
|
|
|
|
|
|
+/// \brief A base class for common \c DNSService interfaces.
|
|
///
|
|
///
|
|
-/// DNSService is the service that handles DNS queries and answers with
|
|
|
|
-/// a given IOService. This class is mainly intended to hold all the
|
|
|
|
-/// logic that is shared between the authoritative and the recursive
|
|
|
|
-/// server implementations. As such, it handles asio, including config
|
|
|
|
-/// updates (through the 'Checkinprovider'), and listening sockets.
|
|
|
|
-class DNSService {
|
|
|
|
|
|
+/// This class is defined mainly for test code so it can use a faked/mock
|
|
|
|
+/// version of a derived class and test scenarios that would involve
|
|
|
|
+/// \c DNSService without actually instantiating the real service class.
|
|
|
|
+///
|
|
|
|
+/// It doesn't intend to be a customization for other purposes - we generally
|
|
|
|
+/// expect non test code only use \c DNSService directly.
|
|
|
|
+/// For this reason most of the detailed description are given in the
|
|
|
|
+/// \c DNSService class. See that for further details of specific methods
|
|
|
|
+/// and class behaviors.
|
|
|
|
+class DNSServiceBase {
|
|
|
|
+protected:
|
|
|
|
+ /// \brief Default constructor.
|
|
|
|
+ ///
|
|
|
|
+ /// This is protected so this class couldn't be accidentally instantiated
|
|
|
|
+ /// directly, even if there were no pure virtual functions.
|
|
|
|
+ DNSServiceBase() {}
|
|
|
|
+
|
|
public:
|
|
public:
|
|
/// \brief Flags for optional server properties.
|
|
/// \brief Flags for optional server properties.
|
|
///
|
|
///
|
|
@@ -43,6 +54,10 @@ public:
|
|
/// variants. As we see need for more such properties, a compound
|
|
/// variants. As we see need for more such properties, a compound
|
|
/// form of flags (i.e., a single value generated by bitwise OR'ed
|
|
/// form of flags (i.e., a single value generated by bitwise OR'ed
|
|
/// multiple flag values) will be allowed.
|
|
/// multiple flag values) will be allowed.
|
|
|
|
+ ///
|
|
|
|
+ /// Note: the description is given here because it's used in the method
|
|
|
|
+ /// signature. It essentially belongs to the derived \c DNSService
|
|
|
|
+ /// class.
|
|
enum ServerFlag {
|
|
enum ServerFlag {
|
|
SERVER_DEFAULT = 0, ///< The default flag (no particular property)
|
|
SERVER_DEFAULT = 0, ///< The default flag (no particular property)
|
|
SERVER_SYNC_OK = 1 ///< The server can act in the "synchronous" mode.
|
|
SERVER_SYNC_OK = 1 ///< The server can act in the "synchronous" mode.
|
|
@@ -60,6 +75,26 @@ public:
|
|
///< information given by the client.
|
|
///< information given by the client.
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ /// \brief The destructor.
|
|
|
|
+ virtual ~DNSServiceBase() {}
|
|
|
|
+
|
|
|
|
+ virtual void addServerTCPFromFD(int fd, int af) = 0;
|
|
|
|
+ virtual void addServerUDPFromFD(int fd, int af,
|
|
|
|
+ ServerFlag options = SERVER_DEFAULT) = 0;
|
|
|
|
+ virtual void clearServers() = 0;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+/// \brief Handle DNS Queries
|
|
|
|
+///
|
|
|
|
+/// DNSService is the service that handles DNS queries and answers with
|
|
|
|
+/// a given IOService. This class is mainly intended to hold all the
|
|
|
|
+/// logic that is shared between the authoritative and the recursive
|
|
|
|
+/// server implementations. As such, it handles asio, including config
|
|
|
|
+/// updates (through the 'Checkinprovider'), and listening sockets.
|
|
|
|
+class DNSService : public DNSServiceBase {
|
|
|
|
+public:
|
|
|
|
+ using DNSServiceBase::ServerFlag;
|
|
|
|
+
|
|
///
|
|
///
|
|
/// \name Constructors and Destructor
|
|
/// \name Constructors and Destructor
|
|
///
|
|
///
|
|
@@ -110,7 +145,7 @@ public:
|
|
DNSLookup* lookup, DNSAnswer* answer);
|
|
DNSLookup* lookup, DNSAnswer* answer);
|
|
|
|
|
|
/// \brief The destructor.
|
|
/// \brief The destructor.
|
|
- ~DNSService();
|
|
|
|
|
|
+ virtual ~DNSService();
|
|
//@}
|
|
//@}
|
|
|
|
|
|
/// \brief Add another server to the service
|
|
/// \brief Add another server to the service
|
|
@@ -137,7 +172,7 @@ public:
|
|
/// \throw isc::InvalidParameter if af is neither AF_INET nor AF_INET6.
|
|
/// \throw isc::InvalidParameter if af is neither AF_INET nor AF_INET6.
|
|
/// \throw isc::asiolink::IOError when a low-level error happens, like the
|
|
/// \throw isc::asiolink::IOError when a low-level error happens, like the
|
|
/// fd is not a valid descriptor or it can't be listened on.
|
|
/// fd is not a valid descriptor or it can't be listened on.
|
|
- void addServerTCPFromFD(int fd, int af);
|
|
|
|
|
|
+ virtual void addServerTCPFromFD(int fd, int af);
|
|
|
|
|
|
/// \brief Add another UDP server to the service from already opened
|
|
/// \brief Add another UDP server to the service from already opened
|
|
/// file descriptor
|
|
/// file descriptor
|
|
@@ -156,8 +191,8 @@ public:
|
|
/// \throw isc::InvalidParameter if af is neither AF_INET nor AF_INET6.
|
|
/// \throw isc::InvalidParameter if af is neither AF_INET nor AF_INET6.
|
|
/// \throw isc::asiolink::IOError when a low-level error happens, like the
|
|
/// \throw isc::asiolink::IOError when a low-level error happens, like the
|
|
/// fd is not a valid descriptor or it can't be listened on.
|
|
/// fd is not a valid descriptor or it can't be listened on.
|
|
- void addServerUDPFromFD(int fd, int af,
|
|
|
|
- ServerFlag options = SERVER_DEFAULT);
|
|
|
|
|
|
+ virtual void addServerUDPFromFD(int fd, int af,
|
|
|
|
+ ServerFlag options = SERVER_DEFAULT);
|
|
|
|
|
|
/// \brief Remove all servers from the service
|
|
/// \brief Remove all servers from the service
|
|
void clearServers();
|
|
void clearServers();
|