}
}
-void Dhcp4to6Ipc::handler() {
+void Dhcp4to6Ipc::handler(int /* fd */) {
Dhcp4to6Ipc& ipc = Dhcp4to6Ipc::instance();
Pkt6Ptr pkt;
///
/// The handler processes the DHCPv4-query DHCPv6 packet and
/// sends the DHCPv4-response DHCPv6 packet back to the DHCPv6 server
- static void handler();
+ static void handler(int /* fd */);
};
} // namespace isc
}
}
-void Dhcp6to4Ipc::handler() {
+void Dhcp6to4Ipc::handler(int /* fd */) {
Dhcp6to4Ipc& ipc = Dhcp6to4Ipc::instance();
Pkt6Ptr pkt;
/// @brief On receive handler
///
/// The handler sends the DHCPv6 packet back to the remote address
- static void handler();
+ static void handler(int /* fd */);
/// @param client_port UDP port where all responses are sent to.
/// Not zero is mostly useful for testing purposes.
// run by an explicit call IOService ready in kea-dhcp<n> code.
// We are registerin the socket only to interrupt main-thread
// select().
- IfaceMgr::instance().addExternalSocket(tcp_native_fd, 0);
+ IfaceMgr::instance().addExternalSocket(tcp_native_fd,
+ boost::bind(&HAService::socketReadyHandler, this, _1)
+ );
}
// If ec.value() == boost::asio::error::already_connected, we should already
return (true);
}
+void
+HAService::socketReadyHandler(int tcp_native_fd) {
+ std::cout << "HAService::socketReadyHandler - ready socket:" << tcp_native_fd << std::endl;
+ // If the socket is not usable/or in a transaction
+ // we'll unregister it
+ // if (socket bad) /{
+ // IfaceMgr::instance().deleteExternalSocket(tcp_native_fd, 0);
+ // }
+}
+
void
HAService::clientCloseHandler(int tcp_native_fd) {
if (tcp_native_fd >= 0) {
/// error we want Connection logic to process it.
bool clientConnectHandler(const boost::system::error_code& ec, int tcp_native_fd);
+ /// @brief IfaceMgr external socket ready callback handler
+ ///
+ /// IfaceMgr invokes this call back when a registered socket has been
+ /// flagged as ready to read. It is installed by the invocation to
+ /// register the socket with IfaceMgr made in @ref clientConnectHandler.
+ ///
+ /// @todo add logic to determine if the
+ /// socket is involved in an ongoing transcation or not. If not, it
+ /// will be unregistered from IfaceMgr.
+ ///
+ /// @param tcp_native_fd socket descriptor of the ready socket
+ void socketReadyHandler(int tcp_native_fd);
+
/// @brief HttpClient close callback handler
///
/// Passed into HttpClient calls to allow unregistration of client's
// layer access without integrating any specific features
// in IfaceMgr
if (s.callback_) {
- s.callback_();
+ s.callback_(s.socket_);
}
return (Pkt4Ptr());
// layer access without integrating any specific features
// in IfaceMgr
if (s.callback_) {
- s.callback_();
+ s.callback_(s.socket_);
}
return (Pkt4Ptr());
// layer access without integrating any specific features
// in IfaceMgr
if (s.callback_) {
- s.callback_();
+ s.callback_(s.socket_);
}
return (Pkt6Ptr());
// layer access without integrating any specific features
// in IfaceMgr
if (s.callback_) {
- s.callback_();
+ s.callback_(s.socket_);
}
return (Pkt6Ptr());
class IfaceMgr : public boost::noncopyable {
public:
/// Defines callback used when data is received over external sockets.
- typedef boost::function<void ()> SocketCallback;
+ /// @param fd socket descriptor of the ready socket
+ typedef boost::function<void (int fd)> SocketCallback;
/// Keeps callback information for external sockets.
struct SocketCallbackInfo {
int pipefd[2];
EXPECT_TRUE(pipe(pipefd) == 0);
EXPECT_NO_THROW(ifacemgr->addExternalSocket(pipefd[0],
- [&callback_ok](){ callback_ok = true; }));
+ [&callback_ok](int /* fd */){ callback_ok = true; }));
// Let's create a second pipe and register it as well
int secondpipe[2];
EXPECT_TRUE(pipe(secondpipe) == 0);
EXPECT_NO_THROW(ifacemgr->addExternalSocket(secondpipe[0],
- [&callback2_ok](){ callback2_ok = true; }));
+ [&callback2_ok](int /* fd */){ callback2_ok = true; }));
// Verify a call with no data and normal external sockets works ok.
Pkt4Ptr pkt4;
int pipefd[2];
EXPECT_TRUE(pipe(pipefd) == 0);
EXPECT_NO_THROW(ifacemgr->addExternalSocket(pipefd[0],
- [&callback_ok](){ callback_ok = true; }));
+ [&callback_ok](int /* fd*/){ callback_ok = true; }));
// Let's create a second pipe and register it as well
int secondpipe[2];
EXPECT_TRUE(pipe(secondpipe) == 0);
EXPECT_NO_THROW(ifacemgr->addExternalSocket(secondpipe[0],
- [&callback2_ok](){ callback2_ok = true; }));
+ [&callback2_ok](int /*fd */){ callback2_ok = true; }));
// Verify a call with no data and normal external sockets works ok.
Pkt6Ptr pkt6;
volatile bool callback_ok;
volatile bool callback2_ok;
-void my_callback(void) {
+void my_callback(int /* fd */) {
callback_ok = true;
}
-void my_callback2(void) {
+void my_callback2(int /* fd */) {
callback2_ok = true;
}