[svn] commit: r2358 - /branches/trac167/src/bin/auth/main.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Jun 30 18:15:47 UTC 2010
Author: each
Date: Wed Jun 30 18:15:46 2010
New Revision: 2358
Log:
addressed review comments
Modified:
branches/trac167/src/bin/auth/main.cc
Modified: branches/trac167/src/bin/auth/main.cc
==============================================================================
--- branches/trac167/src/bin/auth/main.cc (original)
+++ branches/trac167/src/bin/auth/main.cc Wed Jun 30 18:15:46 2010
@@ -239,7 +239,7 @@
class TCPServer {
public:
- TCPServer(io_service& io_service, int af, short port) :
+ TCPServer(io_service& io_service, int af, uint16_t port) :
io_service_(io_service), acceptor_(io_service_),
listening_(new TCPClient(io_service_))
{
@@ -258,7 +258,7 @@
listening_, placeholders::error));
}
- TCPServer(io_service& io_service, asio::ip::address addr, short port) :
+ TCPServer(io_service& io_service, asio::ip::address addr, uint16_t port) :
io_service_(io_service), acceptor_(io_service_),
listening_(new TCPClient(io_service_))
{
@@ -299,7 +299,7 @@
class UDPServer {
public:
- UDPServer(io_service& io_service, int af, short port) :
+ UDPServer(io_service& io_service, int af, uint16_t port) :
io_service_(io_service),
socket_(io_service, af == AF_INET6 ? udp::v6() : udp::v4()),
response_buffer_(0),
@@ -317,7 +317,7 @@
startReceive();
}
- UDPServer(io_service& io_service, asio::ip::address addr, short port) :
+ UDPServer(io_service& io_service, asio::ip::address addr, uint16_t port) :
io_service_(io_service),
socket_(io_service, addr.is_v6() ? udp::v6() : udp::v4()),
response_buffer_(0),
@@ -403,7 +403,14 @@
AuthSrv* srv UNUSED_PARAM)
{
ServerSet servers;
- short portnum = boost::lexical_cast<short>(port);
+ uint16_t portnum;
+
+ try {
+ portnum = boost::lexical_cast<uint16_t>(port);
+ } catch (const std::exception& ex) {
+ isc_throw(FatalError, "[b10-auth] Invalid port number '"
+ << port << "'");
+ }
if (address != NULL) {
asio::ip::address addr = asio::ip::address::from_string(address);
@@ -418,8 +425,13 @@
"[b10-auth] Error: -6 conflicts with " << addr);
}
- servers.udp4_server = new UDPServer(io_service_, addr, portnum);
- servers.tcp4_server = new TCPServer(io_service_, addr, portnum);
+ if (addr.is_v4()) {
+ servers.udp4_server = new UDPServer(io_service_, addr, portnum);
+ servers.tcp4_server = new TCPServer(io_service_, addr, portnum);
+ } else {
+ servers.udp6_server = new UDPServer(io_service_, addr, portnum);
+ servers.tcp6_server = new TCPServer(io_service_, addr, portnum);
+ }
} else {
if (use_ipv4) {
servers.udp4_server = new UDPServer(io_service_, AF_INET, portnum);
More information about the bind10-changes
mailing list