class DNSAnswer;
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:
/// \brief Flags for optional server properties.
///
/// variants. As we see need for more such properties, a compound
/// form of flags (i.e., a single value generated by bitwise OR'ed
/// 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 {
SERVER_DEFAULT = 0, ///< The default flag (no particular property)
SERVER_SYNC_OK = 1 ///< The server can act in the "synchronous" mode.
///< 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
///
DNSLookup* lookup, DNSAnswer* answer);
/// \brief The destructor.
- ~DNSService();
+ virtual ~DNSService();
//@}
/// \brief Add another server to the service
/// \throw isc::InvalidParameter if af is neither AF_INET nor AF_INET6.
/// \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.
- void addServerTCPFromFD(int fd, int af);
+ virtual void addServerTCPFromFD(int fd, int af);
/// \brief Add another UDP server to the service from already opened
/// file descriptor
/// \throw isc::InvalidParameter if af is neither AF_INET nor AF_INET6.
/// \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.
- 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
void clearServers();