19#include <boost/pointer_cast.hpp> 
   56            boost::dynamic_pointer_cast<CtrlAgentController>(
 
   58        controller->registerCommands();
 
   68    } 
catch (
const std::exception& ex) {
 
   76                  "Process run method failed: " << ex.what());
 
   82            boost::dynamic_pointer_cast<CtrlAgentController>(
 
   84        controller->deregisterCommands();
 
   85    } 
catch (
const std::exception&) {
 
 
   93CtrlAgentProcess::runIO() {
 
  107                                      "Control Agent is shutting down"));
 
 
  128            ctx = boost::dynamic_pointer_cast<CtrlAgentCfgContext>(base_ctx);
 
  137            server_address = 
IOAddress(ctx->getHttpHost());
 
  141                      << 
" to IP address:" << e.
what());
 
  144        uint16_t server_port = ctx->getHttpPort();
 
  147        auto it = sockets_.find(std::make_pair(server_address, server_port));
 
  148        if (it != sockets_.end()) {
 
  149            auto listener = it->second->listener_;
 
  152                if (listener->getTlsContext()) {
 
  153                    if (ctx->getTrustAnchor().empty()) {
 
  156                            .arg(server_address.
toText())
 
  159                                  "Can not switch from HTTPS to HTTP sockets using the same address and port.");
 
  163                        TlsContext::configure(tls_context,
 
  165                                              ctx->getTrustAnchor(),
 
  168                                              ctx->getCertRequired());
 
  170                        it->second->config_->setAuthConfig(ctx->getAuthConfig());
 
  171                        it->second->config_->setHttpHeaders(ctx->getHttpHeaders());
 
  172                        listener->setTlsContext(tls_context);
 
  174                            .arg(server_address.
toText())
 
  178                    if (!ctx->getTrustAnchor().empty()) {
 
  181                            .arg(server_address.
toText())
 
  184                                  "Can not switch from HTTP to HTTPS sockets using the same address and port.");
 
  187                        it->second->config_->setAuthConfig(ctx->getAuthConfig());
 
  188                        it->second->config_->setHttpHeaders(ctx->getHttpHeaders());
 
  190                            .arg(server_address.
toText())
 
  196            it->second->usable_ = 
true;
 
  201            bool use_https = 
false;
 
  203            if (!ctx->getCertFile().empty()) {
 
  204                TlsContext::configure(tls_context,
 
  206                                      ctx->getTrustAnchor(),
 
  209                                      ctx->getCertRequired());
 
  231            http_listener->start();
 
  234            socket_info->config_ = ctx;
 
  235            socket_info->listener_ = http_listener;
 
  237            sockets_[std::make_pair(server_address, server_port)] = socket_info;
 
  242                  .arg(server_address.
toText())
 
  246                    .arg(server_address.
toText())
 
  251        auto copy = sockets_;
 
  253            if (
data.second->usable_) {
 
  257                data.second->usable_ = 
false;
 
  260                data.second->listener_->stop();
 
  261                auto it2 = sockets_.find(std::make_pair(
data.second->config_->getHttpHost(),
 
  262                                                       data.second->config_->getHttpPort()));
 
  263                if (it2 != sockets_.end()) {
 
  277    } 
catch (
const std::exception& ex) {
 
  278        std::ostringstream err;
 
  279        err << 
"Error initializing hooks: " 
 
  289    for (
auto const& 
data : sockets_) {
 
  290        data.second->listener_->stop();
 
 
  303    return (boost::dynamic_pointer_cast<CtrlAgentCfgMgr>(
getCfgMgr()));
 
 
  310        auto it = sockets_.find(std::make_pair(info->config_->getHttpHost(), info->config_->getHttpPort()));
 
  311        if (it != sockets_.end()) {
 
  312            return (it->second->listener_);
 
  314    } 
else if (sockets_.size()) {
 
  315        return (sockets_.begin()->second->listener_);
 
 
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown when an unexpected error condition occurs.
Ctrl Agent Configuration Manager.
static process::DControllerBasePtr & instance()
Static singleton instance method.
bool isListening() const
Checks if the process is listening to the HTTP requests.
isc::http::ConstHttpListenerPtr getHttpListener(HttpSocketInfoPtr info=HttpSocketInfoPtr()) const
Returns a const pointer to the HTTP listener.
virtual isc::data::ConstElementPtr shutdown(isc::data::ConstElementPtr args)
Initiates the process's shutdown process.
virtual ~CtrlAgentProcess()
Destructor.
CtrlAgentProcess(const char *name, const asiolink::IOServicePtr &io_service)
Constructor.
virtual void init()
Initialize the Control Agent process.
CtrlAgentCfgMgrPtr getCtrlAgentCfgMgr()
Returns a pointer to the configuration manager.
virtual isc::data::ConstElementPtr configure(isc::data::ConstElementPtr config_set, bool check_only=false)
Processes the given configuration.
void closeCommandSockets()
Close http control sockets.
virtual void run()
Implements the process's event loop.
HTTP response creator factory for Control Agent.
The IOAddress class represents an IP addresses (version agnostic)
std::string toText() const
Convert the address to a string.
An exception that is thrown if an error occurs within the IO module.
static IOServiceMgr & instance()
Access the IOServiceMgr singleton instance.
void pollIOServices()
Poll IOService objects.
Exception thrown if the process encountered an operational error.
void setShutdownFlag(bool value)
Sets the process shut down flag to the given value.
DProcessBase(const char *app_name, asiolink::IOServicePtr io_service, DCfgMgrBasePtr cfg_mgr)
Constructor.
void stopIOService()
Convenience method for stopping IOservice processing.
bool shouldShutdown() const
Checks if the process has been instructed to shut down.
asiolink::IOServicePtr & getIOService()
Fetches the controller's IOService.
DCfgMgrBasePtr & getCfgMgr()
Fetches the process's configuration manager.
static bool shouldEnforceSecurity()
Indicates security checks should be enforced.
This file contains several functions and constants that are used for handling commands and responses ...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
#define LOG_FATAL(LOGGER, MESSAGE)
Macro to conveniently test fatal output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
const isc::log::MessageID CTRL_AGENT_HTTPS_SERVICE_UPDATED
boost::shared_ptr< CtrlAgentCfgContext > CtrlAgentCfgContextPtr
Pointer to a configuration context.
const isc::log::MessageID CTRL_AGENT_HTTP_SERVICE_REUSE_FAILED
const isc::log::MessageID CTRL_AGENT_HTTP_SERVICE_UPDATED
const isc::log::MessageID CTRL_AGENT_HTTP_SERVICE_STARTED
const isc::log::MessageID CTRL_AGENT_STARTED
isc::log::Logger agent_logger("ctrl-agent")
Control Agent logger.
boost::shared_ptr< CtrlAgentCfgMgr > CtrlAgentCfgMgrPtr
Defines a shared pointer to CtrlAgentCfgMgr.
boost::shared_ptr< CtrlAgentController > CtrlAgentControllerPtr
boost::shared_ptr< HttpSocketInfo > HttpSocketInfoPtr
Pointer to a HttpSocketInfo object.
const isc::log::MessageID CTRL_AGENT_HTTPS_SERVICE_STARTED
const isc::log::MessageID CTRL_AGENT_RUN_EXIT
const isc::log::MessageID CTRL_AGENT_SECURITY_CHECKS_DISABLED
const isc::log::MessageID CTRL_AGENT_HTTPS_SERVICE_REUSE_FAILED
const isc::log::MessageID CTRL_AGENT_IS_DEPRECATED
const isc::log::MessageID CTRL_AGENT_FAILED
boost::shared_ptr< TlsContext > TlsContextPtr
The type of shared pointers to TlsContext objects.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
ConstElementPtr parseAnswer(int &rcode, const ConstElementPtr &msg)
Parses a standard config/command level answer and returns arguments or text status code.
constexpr long TIMEOUT_AGENT_IDLE_CONNECTION_TIMEOUT
Timeout for the idle connection to be closed.
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
Creates a standard config/command level answer message.
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
constexpr long TIMEOUT_AGENT_RECEIVE_COMMAND
Timeout for the Control Agent to receive command over the RESTful interface.
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< const HttpListener > ConstHttpListenerPtr
Pointer to the const HttpListener.
boost::shared_ptr< HttpListener > HttpListenerPtr
Pointer to the HttpListener.
boost::shared_ptr< HttpResponseCreatorFactory > HttpResponseCreatorFactoryPtr
Pointer to the HttpResponseCreatorFactory.
const int DBGLVL_START_SHUT
This is given a value of 0 as that is the level selected if debugging is enabled without giving a lev...
boost::shared_ptr< DCfgMgrBase > DCfgMgrBasePtr
Defines a shared pointer to DCfgMgrBase.
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the ConfigBase.
Defines the logger used by the top-level component of kea-lfc.
Structure used to store HTTP/HTTPS connection data.
HTTP request timeout value.