45 service_ = boost::make_shared<HAService>(io_service, network_state,
65 HA_BUFFER4_RECEIVE_PACKET_OPTIONS_SKIPPED)
68 }
catch (
const std::exception& ex) {
71 .arg(query4->getRemoteAddr().toText())
72 .arg(query4->getLocalAddr().toText())
73 .arg(query4->getIface())
78 static_cast<int64_t>(1));
80 static_cast<int64_t>(1));
83 callout_handle.
setStatus(CalloutHandle::NEXT_STEP_DROP);
90 .arg(query4->getLabel());
91 callout_handle.
setStatus(CalloutHandle::NEXT_STEP_DROP);
96 callout_handle.
setStatus(CalloutHandle::NEXT_STEP_SKIP);
105 if (!
config_->amSendingLeaseUpdates()) {
122 callout_handle.
getArgument(
"deleted_leases4", deleted_leases4);
125 if (leases4->empty() && deleted_leases4->empty()) {
127 .arg(query4->getLabel());
139 if (
service_->asyncSendLeaseUpdates(query4, leases4, deleted_leases4, parking_lot) == 0) {
147 parking_lot->reference(query4);
151 callout_handle.
setStatus(CalloutHandle::NEXT_STEP_PARK);
170 HA_BUFFER6_RECEIVE_PACKET_OPTIONS_SKIPPED)
173 }
catch (
const std::exception& ex) {
176 .arg(query6->getRemoteAddr().toText())
177 .arg(query6->getLocalAddr().toText())
178 .arg(query6->getIface())
183 static_cast<int64_t>(1));
185 static_cast<int64_t>(1));
188 callout_handle.
setStatus(CalloutHandle::NEXT_STEP_DROP);
195 .arg(query6->getLabel());
196 callout_handle.
setStatus(CalloutHandle::NEXT_STEP_DROP);
201 callout_handle.
setStatus(CalloutHandle::NEXT_STEP_SKIP);
210 if (!
config_->amSendingLeaseUpdates()) {
227 callout_handle.
getArgument(
"deleted_leases6", deleted_leases6);
230 if (leases6->empty() && deleted_leases6->empty()) {
232 .arg(query6->getLabel());
244 if (
service_->asyncSendLeaseUpdates(query6, leases6, deleted_leases6, parking_lot) == 0) {
252 parking_lot->reference(query6);
256 callout_handle.
setStatus(CalloutHandle::NEXT_STEP_PARK);
261 std::string command_name;
263 if (command_name ==
"dhcp-enable") {
285 unsigned int max_period_value = 0;
294 if (args->getType() != Element::map) {
300 server_name = args->get(
"server-name");
306 if (server_name->getType() != Element::string) {
314 if ((max_period->getType() != Element::integer) ||
315 (max_period->intValue() <= 0)) {
316 isc_throw(
BadValue,
"'max-period' must be a positive integer in the 'ha-sync' command");
319 max_period_value = static_cast<unsigned int>(max_period->intValue());
322 }
catch (
const std::exception& ex) {
346 std::vector<std::string> scopes_vector;
355 if (args->getType() != Element::map) {
366 if (scopes->getType() != Element::list) {
372 for (
size_t i = 0; i < scopes->size(); ++i) {
374 if (!scope || scope->getType() != Element::string) {
377 scopes_vector.push_back(scope->stringValue());
380 }
catch (
const std::exception& ex) {
void setStatus(const CalloutNextStep next)
Sets the next processing step.
void startService(const asiolink::IOServicePtr &io_service, const dhcp::NetworkStatePtr &network_state, const HAServerType &server_type)
Creates high availability service using current configuration.
void parse(const HAConfigPtr &config_storage, const data::ConstElementPtr &config)
Parses HA configuration.
const int DBGLVL_TRACE_BASIC
Trace basic operations.
void synchronizeHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-sync command.
Configuration parser for High Availability.
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
ParkingLotHandlePtr getParkingLotHandlePtr() const
Returns pointer to the parking lot handle for this hook point.
Exception thrown during option unpacking This exception is thrown when an error has occurred,...
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
HAServicePtr service_
Pointer to the high availability service (state machine).
HAServerType
Lists possible server types for which HA service is created.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
static StatsMgr & instance()
Statistics Manager accessor method.
void buffer6Receive(hooks::CalloutHandle &callout_handle)
Implementation of the "buffer6_receive" callout.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
Per-packet callout handle.
boost::shared_ptr< Lease4Collection > Lease4CollectionPtr
A shared pointer to the collection of IPv4 leases.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
boost::shared_ptr< const Element > ConstElementPtr
void setArgument(const std::string &name, T value)
Set argument.
void scopesHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-scopes command.
void continueHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-continue command.
void addValue(const std::string &name, const int64_t value)
Records incremental integer observation.
Defines the logger used by the top-level component of kea-dhcp-ddns.
void configure(const data::ConstElementPtr &input_config)
Parases configuration.
std::string parseCommand(ConstElementPtr &arg, ConstElementPtr command)
void getArgument(const std::string &name, T &value) const
Get argument.
void leases4Committed(hooks::CalloutHandle &callout_handle)
Implementation of the "leases4_committed" callout.
This file contains several functions and constants that are used for handling commands and responses ...
HAConfigPtr config_
Holds parsed configuration.
boost::shared_ptr< Lease6Collection > Lease6CollectionPtr
A shared pointer to the collection of IPv6 leases.
boost::shared_ptr< NetworkState > NetworkStatePtr
Pointer to the NetworkState object.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
isc::log::Logger ha_logger("ha-hooks")
void buffer4Receive(hooks::CalloutHandle &callout_handle)
Implementation of the "buffer4_receive" callout.
void commandProcessed(hooks::CalloutHandle &callout_handle)
Implementation of the "command_processed" callout.
boost::shared_ptr< ParkingLotHandle > ParkingLotHandlePtr
Pointer to the parking lot handle.
void leases6Committed(hooks::CalloutHandle &callout_handle)
Implementation of the "leases6_committed" callout.
void heartbeatHandler(hooks::CalloutHandle &callout_handle)
Implements handle for the heartbeat command.
Storage for High Availability configuration.