Kea 2.5.8
isc::dhcp::test::UnixControlClient Class Reference

Class that acts as a UnixCommandSocket client. More...

#include <unix_control_client.h>

Public Member Functions

 UnixControlClient ()
 Default constructor.
 
 ~UnixControlClient ()
 Destructor.
 
bool connectToServer (const std::string &socket_path)
 Connects to a Unix socket at the given path.
 
void disconnectFromServer ()
 Closes the Control Channel socket.
 
bool getResponse (std::string &response, const unsigned int timeout_sec=0)
 Reads the response text from the open Control Channel.
 
int selectCheck (const unsigned int timeout_sec)
 Uses select to poll the Control Channel for data waiting.
 
bool sendCommand (const std::string &command)
 Sends the given command across the open Control Channel.
 

Public Attributes

int socket_fd_
 Retains the fd of the open socket.
 

Detailed Description

Class that acts as a UnixCommandSocket client.

This class is expected to be used unit-tests that attempt to communicate with the servers that use control channel (see src/lib/config/command_mgr.h) It can connect to an open UnixCommandSocket and exchange ControlChannel commands and responses.

Definition at line 22 of file unix_control_client.h.

Constructor & Destructor Documentation

◆ UnixControlClient()

isc::dhcp::test::UnixControlClient::UnixControlClient ( )

Default constructor.

Definition at line 21 of file unix_control_client.cc.

References socket_fd_.

◆ ~UnixControlClient()

isc::dhcp::test::UnixControlClient::~UnixControlClient ( )

Destructor.

Definition at line 25 of file unix_control_client.cc.

References disconnectFromServer().

+ Here is the call graph for this function:

Member Function Documentation

◆ connectToServer()

bool isc::dhcp::test::UnixControlClient::connectToServer ( const std::string &  socket_path)

Connects to a Unix socket at the given path.

Parameters
socket_pathpathname of the socket to open
Returns
true if the connect was successful, false otherwise

Definition at line 37 of file unix_control_client.cc.

References disconnectFromServer(), and socket_fd_.

+ Here is the call graph for this function:

◆ disconnectFromServer()

void isc::dhcp::test::UnixControlClient::disconnectFromServer ( )

Closes the Control Channel socket.

Definition at line 30 of file unix_control_client.cc.

References socket_fd_.

Referenced by ~UnixControlClient(), and connectToServer().

◆ getResponse()

bool isc::dhcp::test::UnixControlClient::getResponse ( std::string &  response,
const unsigned int  timeout_sec = 0 
)

Reads the response text from the open Control Channel.

Parameters
responsevariable into which the received response should be placed.
timeout_secTimeout for receiving response in seconds.
Returns
true if data was successfully read from the socket, false otherwise

Definition at line 89 of file unix_control_client.cc.

References selectCheck(), and socket_fd_.

+ Here is the call graph for this function:

◆ selectCheck()

int isc::dhcp::test::UnixControlClient::selectCheck ( const unsigned int  timeout_sec)

Uses select to poll the Control Channel for data waiting.

Parameters
timeout_secSelect timeout in seconds
Returns
-1 on error, 0 if no data is available, 1 if data is ready

Definition at line 120 of file unix_control_client.cc.

References socket_fd_.

Referenced by getResponse().

◆ sendCommand()

bool isc::dhcp::test::UnixControlClient::sendCommand ( const std::string &  command)

Sends the given command across the open Control Channel.

Parameters
commandthe command text to execute in JSON form
Returns
true if the send succeeds, false otherwise

Definition at line 75 of file unix_control_client.cc.

References socket_fd_.

Member Data Documentation

◆ socket_fd_

int isc::dhcp::test::UnixControlClient::socket_fd_

Retains the fd of the open socket.

Definition at line 59 of file unix_control_client.h.

Referenced by UnixControlClient(), connectToServer(), disconnectFromServer(), getResponse(), selectCheck(), and sendCommand().


The documentation for this class was generated from the following files: