mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 14:35:29 +00:00
[1784] introduced a base interface class for DNSService for subsequent tests.
Only some part of portconfig need to be adjusted; others will still use the derived class directly.
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
#include <util/buffer.h>
|
#include <util/buffer.h>
|
||||||
|
|
||||||
#include <asiodns/dns_server.h>
|
#include <asiodns/dns_server.h>
|
||||||
|
#include <asiodns/dns_service.h>
|
||||||
#include <asiodns/dns_lookup.h>
|
#include <asiodns/dns_lookup.h>
|
||||||
#include <asiodns/dns_answer.h>
|
#include <asiodns/dns_answer.h>
|
||||||
#include <asiolink/io_message.h>
|
#include <asiolink/io_message.h>
|
||||||
|
@@ -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
|
/// This class is defined mainly for test code so it can use a faked/mock
|
||||||
/// a given IOService. This class is mainly intended to hold all the
|
/// version of a derived class and test scenarios that would involve
|
||||||
/// logic that is shared between the authoritative and the recursive
|
/// \c DNSService without actually instantiating the real service class.
|
||||||
/// server implementations. As such, it handles asio, including config
|
///
|
||||||
/// updates (through the 'Checkinprovider'), and listening sockets.
|
/// It doesn't intend to be a customization for other purposes - we generally
|
||||||
class DNSService {
|
/// 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,7 +191,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 addServerUDPFromFD(int fd, int af,
|
virtual void addServerUDPFromFD(int fd, int af,
|
||||||
ServerFlag options = SERVER_DEFAULT);
|
ServerFlag options = SERVER_DEFAULT);
|
||||||
|
|
||||||
/// \brief Remove all servers from the service
|
/// \brief Remove all servers from the service
|
||||||
|
@@ -84,7 +84,7 @@ namespace {
|
|||||||
vector<string> current_sockets;
|
vector<string> current_sockets;
|
||||||
|
|
||||||
void
|
void
|
||||||
setAddresses(DNSService& service, const AddressList& addresses) {
|
setAddresses(DNSServiceBase& service, const AddressList& addresses) {
|
||||||
service.clearServers();
|
service.clearServers();
|
||||||
BOOST_FOREACH(const string& token, current_sockets) {
|
BOOST_FOREACH(const string& token, current_sockets) {
|
||||||
socketRequestor().releaseSocket(token);
|
socketRequestor().releaseSocket(token);
|
||||||
@@ -118,7 +118,7 @@ setAddresses(DNSService& service, const AddressList& addresses) {
|
|||||||
void
|
void
|
||||||
installListenAddresses(const AddressList& newAddresses,
|
installListenAddresses(const AddressList& newAddresses,
|
||||||
AddressList& addressStore,
|
AddressList& addressStore,
|
||||||
isc::asiodns::DNSService& service)
|
isc::asiodns::DNSServiceBase& service)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
LOG_DEBUG(logger, DBG_TRACE_BASIC, SRVCOMM_SET_LISTEN);
|
LOG_DEBUG(logger, DBG_TRACE_BASIC, SRVCOMM_SET_LISTEN);
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
namespace isc {
|
namespace isc {
|
||||||
namespace asiodns {
|
namespace asiodns {
|
||||||
class DNSService;
|
class DNSServiceBase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,10 +120,14 @@ parseAddresses(isc::data::ConstElementPtr addresses,
|
|||||||
void
|
void
|
||||||
installListenAddresses(const AddressList& newAddresses,
|
installListenAddresses(const AddressList& newAddresses,
|
||||||
AddressList& addressStore,
|
AddressList& addressStore,
|
||||||
asiodns::DNSService& dnsService);
|
asiodns::DNSServiceBase& dnsService);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// mode: c++
|
||||||
|
// End:
|
||||||
|
Reference in New Issue
Block a user