|
@@ -63,11 +63,10 @@ convertAddr(const std::string& address) {
|
|
|
class DNSServiceImpl {
|
|
|
public:
|
|
|
DNSServiceImpl(IOService& io_service, const char& port,
|
|
|
- const asio::ip::address* v4addr,
|
|
|
- const asio::ip::address* v6addr,
|
|
|
- SimpleCallback* checkin, DNSLookup* lookup,
|
|
|
- DNSAnswer* answer,
|
|
|
- const UDPVersion param_flags);
|
|
|
+ const asio::ip::address* v4addr,
|
|
|
+ const asio::ip::address* v6addr,
|
|
|
+ SimpleCallback* checkin, DNSLookup* lookup,
|
|
|
+ DNSAnswer* answe);
|
|
|
|
|
|
IOService& io_service_;
|
|
|
|
|
@@ -87,9 +86,7 @@ public:
|
|
|
servers_.push_back(server);
|
|
|
}
|
|
|
|
|
|
- void addServer(uint16_t port, const asio::ip::address& address,
|
|
|
- const UDPVersion param_flags)
|
|
|
- {
|
|
|
+ void addServer(uint16_t port, const asio::ip::address& address) {
|
|
|
try {
|
|
|
dlog(std::string("Initialize TCP server at ") +
|
|
|
address.to_string() + ":" +
|
|
@@ -102,29 +99,10 @@ public:
|
|
|
dlog(std::string("Initialize UDP server at ") +
|
|
|
address.to_string() + ":" +
|
|
|
boost::lexical_cast<std::string>(port));
|
|
|
- // Use param_flags to generate diff UDPServers.
|
|
|
- switch (param_flags) {
|
|
|
- case SYNC_: {
|
|
|
- SyncUDPServerPtr syncUdpServer(
|
|
|
- new SyncUDPServer(io_service_.get_io_service(), address,
|
|
|
- port, checkin_, lookup_, answer_));
|
|
|
- (*syncUdpServer)();
|
|
|
- servers_.push_back(syncUdpServer);
|
|
|
- break;
|
|
|
- }
|
|
|
- case ASYNC_: {
|
|
|
- UDPServerPtr udpServer(
|
|
|
- new UDPServer(io_service_.get_io_service(), address, port,
|
|
|
- checkin_, lookup_, answer_));
|
|
|
- (*udpServer)();
|
|
|
- servers_.push_back(udpServer);
|
|
|
- break;
|
|
|
- }
|
|
|
- default:
|
|
|
- // If neither async UDPServer nor sync UDNServer, it throws.
|
|
|
- isc_throw(IOError, "Bad UDPServer Version!");
|
|
|
- break;
|
|
|
- }
|
|
|
+ UDPServerPtr udpServer(new UDPServer(io_service_.get_io_service(),
|
|
|
+ address, port, checkin_, lookup_, answer_));
|
|
|
+ (*udpServer)();
|
|
|
+ servers_.push_back(udpServer);
|
|
|
} catch (const asio::system_error& err) {
|
|
|
// We need to catch and convert any ASIO level exceptions.
|
|
|
// This can happen for unavailable address, binding a privilege port
|
|
@@ -133,9 +111,7 @@ public:
|
|
|
err.what());
|
|
|
}
|
|
|
}
|
|
|
- void addServer(const char& port, const asio::ip::address& address,
|
|
|
- const UDPVersion param_flags)
|
|
|
- {
|
|
|
+ void addServer(const char& port, const asio::ip::address& address) {
|
|
|
uint16_t portnum;
|
|
|
try {
|
|
|
// XXX: SunStudio with stlport4 doesn't reject some invalid
|
|
@@ -151,7 +127,7 @@ public:
|
|
|
isc_throw(IOError, "Invalid port number '" << &port << "': " <<
|
|
|
ex.what());
|
|
|
}
|
|
|
- addServer(portnum, address, param_flags);
|
|
|
+ addServer(portnum, address);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -161,8 +137,7 @@ DNSServiceImpl::DNSServiceImpl(IOService& io_service,
|
|
|
const asio::ip::address* const v6addr,
|
|
|
SimpleCallback* checkin,
|
|
|
DNSLookup* lookup,
|
|
|
- DNSAnswer* answer,
|
|
|
- const UDPVersion param_flags):
|
|
|
+ DNSAnswer* answer) :
|
|
|
io_service_(io_service),
|
|
|
checkin_(checkin),
|
|
|
lookup_(lookup),
|
|
@@ -170,10 +145,10 @@ DNSServiceImpl::DNSServiceImpl(IOService& io_service,
|
|
|
{
|
|
|
|
|
|
if (v4addr) {
|
|
|
- addServer(port, *v4addr, param_flags);
|
|
|
+ addServer(port, *v4addr);
|
|
|
}
|
|
|
if (v6addr) {
|
|
|
- addServer(port, *v6addr, param_flags);
|
|
|
+ addServer(port, *v6addr);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -181,12 +156,12 @@ DNSService::DNSService(IOService& io_service,
|
|
|
const char& port, const char& address,
|
|
|
SimpleCallback* checkin,
|
|
|
DNSLookup* lookup,
|
|
|
- DNSAnswer* answer,
|
|
|
- const UDPVersion param_flags) :
|
|
|
+ DNSAnswer* answer) :
|
|
|
impl_(new DNSServiceImpl(io_service, port, NULL, NULL, checkin, lookup,
|
|
|
- answer,param_flags)), io_service_(io_service)
|
|
|
+ answer)),
|
|
|
+ io_service_(io_service)
|
|
|
{
|
|
|
- addServer(port, &address, param_flags);
|
|
|
+ addServer(port, &address);
|
|
|
}
|
|
|
|
|
|
DNSService::DNSService(IOService& io_service,
|
|
@@ -194,8 +169,7 @@ DNSService::DNSService(IOService& io_service,
|
|
|
const bool use_ipv4, const bool use_ipv6,
|
|
|
SimpleCallback* checkin,
|
|
|
DNSLookup* lookup,
|
|
|
- DNSAnswer* answer,
|
|
|
- const UDPVersion param_flags) :
|
|
|
+ DNSAnswer* answer) :
|
|
|
impl_(NULL), io_service_(io_service)
|
|
|
{
|
|
|
const asio::ip::address v4addr_any =
|
|
@@ -205,13 +179,13 @@ DNSService::DNSService(IOService& io_service,
|
|
|
asio::ip::address(asio::ip::address_v6::any());
|
|
|
const asio::ip::address* const v6addrp = use_ipv6 ? &v6addr_any : NULL;
|
|
|
impl_ = new DNSServiceImpl(io_service, port, v4addrp, v6addrp, checkin,
|
|
|
- lookup, answer, param_flags);
|
|
|
+ lookup, answer);
|
|
|
}
|
|
|
|
|
|
DNSService::DNSService(IOService& io_service, SimpleCallback* checkin,
|
|
|
- DNSLookup* lookup, DNSAnswer *answer,const UDPVersion param_flags) :
|
|
|
+ DNSLookup* lookup, DNSAnswer *answer) :
|
|
|
impl_(new DNSServiceImpl(io_service, *"0", NULL, NULL, checkin, lookup,
|
|
|
- answer, param_flags)), io_service_(io_service)
|
|
|
+ answer)), io_service_(io_service)
|
|
|
{
|
|
|
}
|
|
|
|
|
@@ -220,17 +194,13 @@ DNSService::~DNSService() {
|
|
|
}
|
|
|
|
|
|
void
|
|
|
-DNSService::addServer(const char& port, const std::string& address,
|
|
|
- UDPVersion param_flags)
|
|
|
-{
|
|
|
- impl_->addServer(port, convertAddr(address), param_flags);
|
|
|
+DNSService::addServer(const char& port, const std::string& address) {
|
|
|
+ impl_->addServer(port, convertAddr(address));
|
|
|
}
|
|
|
|
|
|
void
|
|
|
-DNSService::addServer(uint16_t port, const std::string& address,
|
|
|
- UDPVersion param_flags)
|
|
|
-{
|
|
|
- impl_->addServer(port, convertAddr(address), param_flags);
|
|
|
+DNSService::addServer(uint16_t port, const std::string& address) {
|
|
|
+ impl_->addServer(port, convertAddr(address));
|
|
|
}
|
|
|
|
|
|
void DNSService::addServerTCPFromFD(int fd, int af) {
|
|
@@ -246,6 +216,8 @@ void DNSService::addServerUDPFromFD(int fd, int af,
|
|
|
} else if (ASYNC_ == param_flags) {
|
|
|
impl_->addServerFromFD<DNSServiceImpl::UDPServerPtr, UDPServer>(
|
|
|
fd, af);
|
|
|
+ } else {
|
|
|
+ isc_throw(IOError, "Bad UDPServer Version!");
|
|
|
}
|
|
|
}
|
|
|
|