[svn] commit: r3132 - in /trunk: ./ src/bin/auth/asio_link.cc src/bin/auth/auth_srv.cc src/bin/auth/auth_srv.h
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Oct 7 12:45:46 UTC 2010
Author: jinmei
Date: Thu Oct 7 12:45:45 2010
New Revision: 3132
Log:
merged trac #301
Modified:
trunk/ (props changed)
trunk/src/bin/auth/asio_link.cc
trunk/src/bin/auth/auth_srv.cc
trunk/src/bin/auth/auth_srv.h
Modified: trunk/src/bin/auth/asio_link.cc
==============================================================================
--- trunk/src/bin/auth/asio_link.cc (original)
+++ trunk/src/bin/auth/asio_link.cc Thu Oct 7 12:45:45 2010
@@ -64,24 +64,50 @@
return (asio_address_.to_string());
}
-// Note: this implementation is optimized for the case where this object
-// is created from an ASIO endpoint object in a receiving code path
-// by avoiding to make a copy of the base endpoint. For TCP it may not be
-// a big deal, but when we receive UDP packets at a high rate, the copy
-// overhead might be significant.
+/// \brief The \c TCPEndpoint class is a concrete derived class of
+/// \c IOEndpoint that represents an endpoint of a TCP connection.
+///
+/// In the current implementation, an object of this class is always
+/// instantiated within the wrapper routines. Applications are expected to
+/// get access to the object via the abstract base class, \c IOEndpoint.
+/// This design may be changed when we generalize the wrapper interface.
+///
+/// Note: this implementation is optimized for the case where this object
+/// is created from an ASIO endpoint object in a receiving code path
+/// by avoiding to make a copy of the base endpoint. For TCP it may not be
+/// a big deal, but when we receive UDP packets at a high rate, the copy
+/// overhead might be significant.
class TCPEndpoint : public IOEndpoint {
public:
+ ///
+ /// \name Constructors and Destructor
+ ///
+ //@{
+ /// \brief Constructor from a pair of address and port.
+ ///
+ /// \param address The IP address of the endpoint.
+ /// \param port The TCP port number of the endpoint.
TCPEndpoint(const IOAddress& address, const unsigned short port) :
asio_endpoint_placeholder_(
new tcp::endpoint(ip::address::from_string(address.toText()),
port)),
asio_endpoint_(*asio_endpoint_placeholder_)
{}
+
+ /// \brief Constructor from an ASIO TCP endpoint.
+ ///
+ /// This constructor is designed to be an efficient wrapper for the
+ /// corresponding ASIO class, \c tcp::endpoint.
+ ///
+ /// \param asio_endpoint The ASIO representation of the TCP endpoint.
TCPEndpoint(const tcp::endpoint& asio_endpoint) :
asio_endpoint_placeholder_(NULL), asio_endpoint_(asio_endpoint)
{}
-
+
+ /// \brief The destructor.
~TCPEndpoint() { delete asio_endpoint_placeholder_; }
+ //@}
+
virtual IOAddress getAddress() const {
return (asio_endpoint_.address());
}
@@ -90,18 +116,41 @@
const tcp::endpoint& asio_endpoint_;
};
+/// \brief The \c UDPEndpoint class is a concrete derived class of
+/// \c IOEndpoint that represents an endpoint of a UDP packet.
+///
+/// Other notes about \c TCPEndpoint applies to this class, too.
class UDPEndpoint : public IOEndpoint {
public:
+ ///
+ /// \name Constructors and Destructor.
+ ///
+ //@{
+ /// \brief Constructor from a pair of address and port.
+ ///
+ /// \param address The IP address of the endpoint.
+ /// \param port The UDP port number of the endpoint.
UDPEndpoint(const IOAddress& address, const unsigned short port) :
asio_endpoint_placeholder_(
new udp::endpoint(ip::address::from_string(address.toText()),
port)),
asio_endpoint_(*asio_endpoint_placeholder_)
{}
+
+ /// \brief Constructor from an ASIO UDP endpoint.
+ ///
+ /// This constructor is designed to be an efficient wrapper for the
+ /// corresponding ASIO class, \c udp::endpoint.
+ ///
+ /// \param asio_endpoint The ASIO representation of the UDP endpoint.
UDPEndpoint(const udp::endpoint& asio_endpoint) :
asio_endpoint_placeholder_(NULL), asio_endpoint_(asio_endpoint)
{}
+
+ /// \brief The destructor.
~UDPEndpoint() { delete asio_endpoint_placeholder_; }
+ //@}
+
virtual IOAddress getAddress() const {
return (asio_endpoint_.address());
}
@@ -124,37 +173,74 @@
protocol);
}
+/// \brief The \c TCPSocket class is a concrete derived class of
+/// \c IOSocket that represents a TCP socket.
+///
+/// In the current implementation, an object of this class is always
+/// instantiated within the wrapper routines. Applications are expected to
+/// get access to the object via the abstract base class, \c IOSocket.
+/// This design may be changed when we generalize the wrapper interface.
class TCPSocket : public IOSocket {
private:
TCPSocket(const TCPSocket& source);
TCPSocket& operator=(const TCPSocket& source);
public:
+ /// \brief Constructor from an ASIO TCP socket.
+ ///
+ /// \param socket The ASIO representation of the TCP socket.
TCPSocket(tcp::socket& socket) : socket_(socket) {}
+
virtual int getNative() const { return (socket_.native()); }
virtual int getProtocol() const { return (IPPROTO_TCP); }
private:
tcp::socket& socket_;
};
+/// \brief The \c UDPSocket class is a concrete derived class of
+/// \c IOSocket that represents a UDP socket.
+///
+/// Other notes about \c TCPSocket applies to this class, too.
class UDPSocket : public IOSocket {
private:
UDPSocket(const UDPSocket& source);
UDPSocket& operator=(const UDPSocket& source);
public:
+ /// \brief Constructor from an ASIO UDP socket.
+ ///
+ /// \param socket The ASIO representation of the UDP socket.
UDPSocket(udp::socket& socket) : socket_(socket) {}
+
virtual int getNative() const { return (socket_.native()); }
virtual int getProtocol() const { return (IPPROTO_UDP); }
private:
udp::socket& socket_;
};
+/// \brief The \c DummySocket class is a concrete derived class of
+/// \c IOSocket that is not associated with any real socket.
+///
+/// This main purpose of this class is tests, where it may be desirable to
+/// instantiate an \c IOSocket object without involving system resource
+/// allocation such as real network sockets.
class DummySocket : public IOSocket {
private:
DummySocket(const DummySocket& source);
DummySocket& operator=(const DummySocket& source);
public:
+ /// \brief Constructor from the protocol number.
+ ///
+ /// The protocol must validly identify a standard network protocol.
+ /// For example, to specify TCP \c protocol must be \c IPPROTO_TCP.
+ ///
+ /// \param protocol The network protocol number for the socket.
DummySocket(const int protocol) : protocol_(protocol) {}
+
+ /// \brief A dummy derived method of \c IOSocket::getNative().
+ ///
+ /// This version of method always returns -1 as the object is not
+ /// associated with a real (native) socket.
virtual int getNative() const { return (-1); }
+
virtual int getProtocol() const { return (protocol_); }
private:
const int protocol_;
@@ -197,8 +283,8 @@
void start() {
// Check for queued configuration commands
if (auth_server_ != NULL &&
- auth_server_->configSession()->hasQueuedMsgs()) {
- auth_server_->configSession()->checkCommand();
+ auth_server_->getConfigSession()->hasQueuedMsgs()) {
+ auth_server_->getConfigSession()->checkCommand();
}
async_read(socket_, asio::buffer(data_, TCP_MESSAGE_LENGTHSIZE),
boost::bind(&TCPClient::headerRead, this,
@@ -385,8 +471,8 @@
{
// Check for queued configuration commands
if (auth_server_ != NULL &&
- auth_server_->configSession()->hasQueuedMsgs()) {
- auth_server_->configSession()->checkCommand();
+ auth_server_->getConfigSession()->hasQueuedMsgs()) {
+ auth_server_->getConfigSession()->checkCommand();
}
if (!error && bytes_recvd > 0) {
const UDPEndpoint remote_endpoint(sender_endpoint_);
Modified: trunk/src/bin/auth/auth_srv.cc
==============================================================================
--- trunk/src/bin/auth/auth_srv.cc (original)
+++ trunk/src/bin/auth/auth_srv.cc Thu Oct 7 12:45:45 2010
@@ -215,7 +215,7 @@
}
ModuleCCSession*
-AuthSrv::configSession() const {
+AuthSrv::getConfigSession() const {
return (impl_->config_session_);
}
Modified: trunk/src/bin/auth/auth_srv.h
==============================================================================
--- trunk/src/bin/auth/auth_srv.h (original)
+++ trunk/src/bin/auth/auth_srv.h Thu Oct 7 12:45:45 2010
@@ -38,8 +38,30 @@
class IOMessage;
}
+/// \brief The implementation class for the \c AuthSrv class using the pimpl
+/// idiom.
class AuthSrvImpl;
+/// \brief The authoritative nameserver class.
+///
+/// \c AuthSrv is a concrete class that implements authoritative DNS server
+/// protocol processing.
+/// An \c AuthSrv object is primarily responsible for handling incoming DNS
+/// requests: It parses the request and dispatches subsequent processing to
+/// the corresponding module (which may be an internal library or a separate
+/// process) depending on the request type. For normal queries, the
+/// \c AuthSrv object searches configured data sources for the answer to the
+/// query, and builds a response containing the answer.
+///
+/// This class uses the "pimpl" idiom, and hides detailed implementation
+/// through the \c impl_ pointer (which points to an instance of the
+/// \c AuthSrvImpl class). An \c AuthSrv object is supposed to exist for quite
+/// a long period, and only a few \c AuthSrv objects will be created (in fact,
+/// in this current implementation there will only be one object), so the
+/// construction overhead of this approach should be acceptable.
+///
+/// The design of this class is still in flux. It's quite likely to change
+/// in future versions.
class AuthSrv {
///
/// \name Constructors, Assignment Operator and Destructor.
@@ -67,10 +89,77 @@
bool processMessage(const asio_link::IOMessage& io_message,
isc::dns::Message& message,
isc::dns::MessageRenderer& response_renderer);
- void setVerbose(bool on);
+
+ /// \brief Enable or disable verbose logging.
+ ///
+ /// This method never throws an exception.
+ ///
+ /// \param on \c true to enable verbose logging; \c false to disable
+ /// verbose logging.
+ void setVerbose(const bool on);
+
+ /// \brief Returns the logging verbosity of the \c AuthSrv object.
+ ///
+ /// This method never throws an exception.
+ ///
+ /// \return \c true if verbose logging is enabled; otherwise \c false.
bool getVerbose() const;
+
+ /// \brief Updates the data source for the \c AuthSrv object.
+ ///
+ /// This method installs or replaces the data source that the \c AuthSrv
+ /// object refers to for query processing.
+ /// Although the method name is generic, the only thing it does is to
+ /// update the data source information.
+ /// If there is a data source installed, it will be replaced with the
+ /// new one.
+ ///
+ /// In the current implementation, the SQLite data source is assumed.
+ /// The \c config parameter will simply be passed to the initialization
+ /// routine of the \c Sqlite3DataSrc class.
+ ///
+ /// On success this method returns a data \c Element (in the form of a
+ /// pointer like object) indicating the successful result,
+ /// i.e., {"result": [0]}.
+ /// Otherwise, it returns a data \c Element explaining the error:
+ /// {"result": [1, <error-description>]}.
+ ///
+ /// This method is mostly exception free (error conditions are represented
+ /// via the return value). But it may still throw a standard exception
+ /// if memory allocation fails inside the method.
+ /// When a standard exception is thrown or an implementation specific
+ /// exception is triggered and caught internally, this function provides
+ /// the strong exception guarantee: Unless everything succeeds, currently
+ /// installed data source (if any) won't be replaced.
+ ///
+ /// \param config An immutable pointer-like object to a data \c Element,
+ /// possibly containing the data source information to be used.
+ /// \return An immutable pointer-like object to a data \c Element
+ /// containing the result of the update operation.
isc::data::ConstElementPtr updateConfig(isc::data::ConstElementPtr config);
- isc::config::ModuleCCSession* configSession() const;
+
+ /// \param Returns the command and configuration session for the
+ /// \c AuthSrv.
+ ///
+ /// This method never throws an exception.
+ ///
+ /// \return A pointer to \c ModuleCCSession object stored in the
+ /// \c AuthSrv object. In this implementation it could be NULL.
+ isc::config::ModuleCCSession* getConfigSession() const;
+
+ /// \brief Set the command and configuration session for the \c AuthSrv.
+ ///
+ /// Note: this interface is tentative. We'll revisit the ASIO and session
+ /// frameworks, at which point the session will probably be passed on
+ /// construction of the server.
+ /// In the current implementation, this method is expected to be called
+ /// exactly once as part of initialization. If this method is called
+ /// multiple times, previously specified session is silently overridden.
+ ///
+ /// This method never throws an exception.
+ ///
+ /// \param config_session A pointer to \c ModuleCCSession object to receive
+ /// control commands and configuration updates.
void setConfigSession(isc::config::ModuleCCSession* config_session);
/// \brief Set or update the size (number of slots) of hot spot cache.
@@ -93,6 +182,8 @@
/// \return The current number of cache slots.
size_t getCacheSlots() const;
+ /// \brief Set the communication session with a separate process for
+ /// outgoing zone transfers.
///
/// Note: this interface is tentative. We'll revisit the ASIO and session
/// frameworks, at which point the session will probably be passed on
@@ -105,6 +196,7 @@
/// Ownership isn't transferred: the caller is responsible for keeping
/// this object to be valid while the server object is working and for
/// disconnecting the session and destroying the object when the server
+ /// is shutdown.
///
void setXfrinSession(isc::cc::AbstractSession* xfrin_session);
private:
More information about the bind10-changes
mailing list