Kea 2.5.5
ha_impl.cc
Go to the documentation of this file.
1// Copyright (C) 2018-2023 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <ha_config_parser.h>
10#include <ha_impl.h>
11#include <ha_log.h>
12#include <asiolink/io_service.h>
13#include <cc/data.h>
15#include <dhcp/pkt4.h>
16#include <dhcp/pkt6.h>
17#include <dhcpsrv/lease.h>
18#include <stats/stats_mgr.h>
19
20using namespace isc::asiolink;
21using namespace isc::config;
22using namespace isc::data;
23using namespace isc::dhcp;
24using namespace isc::hooks;
25using namespace isc::log;
26
27namespace isc {
28namespace ha {
29
31 : config_(), services_(new HAServiceMapper()) {
32}
33
34void
35HAImpl::configure(const ConstElementPtr& input_config) {
36 config_ = HAConfigParser::parse(input_config);
37}
38
39void
41 const NetworkStatePtr& network_state,
42 const HAServerType& server_type) {
43 auto configs = config_->getAll();
44 for (auto id = 0; id < configs.size(); ++id) {
45 // Create the HA service and crank up the state machine.
46 auto service = boost::make_shared<HAService>(id, io_service, network_state,
47 configs[id], server_type);
48 for (auto peer_config : configs[id]->getAllServersConfig()) {
49 services_->map(peer_config.first, service);
50 }
51
55 break;
56 }
57 // Schedule a start of the services. This ensures we begin after
58 // the dust has settled and Kea MT mode has been firmly established.
59 io_service->post([&]() {
60 for (auto service : services_->getAll()) {
61 service->startClientAndListener();
62 }
63 });
64}
65
67 for (auto service : services_->getAll()) {
68 // Shut down the services explicitly, we need finer control
69 // than relying on destruction order.
70 service->stopClientAndListener();
71 }
72}
73
74void
76 Pkt4Ptr query4;
77 callout_handle.getArgument("query4", query4);
78
81 try {
82 // We have to unpack the query to get access into HW address which is
83 // used to load balance the packet.
84 if (callout_handle.getStatus() != CalloutHandle::NEXT_STEP_SKIP) {
85 query4->unpack();
86 }
87
88 } catch (const SkipRemainingOptionsError& ex) {
89 // An option failed to unpack but we are to attempt to process it
90 // anyway. Log it and let's hope for the best.
93 .arg(ex.what());
94
95 } catch (const std::exception& ex) {
96 // Packet parsing failed. Drop the packet.
98 .arg(query4->getRemoteAddr().toText())
99 .arg(query4->getLocalAddr().toText())
100 .arg(query4->getIface())
101 .arg(ex.what());
102
103 // Increase the statistics of parse failures and dropped packets.
104 isc::stats::StatsMgr::instance().addValue("pkt4-parse-failed",
105 static_cast<int64_t>(1));
106 isc::stats::StatsMgr::instance().addValue("pkt4-receive-drop",
107 static_cast<int64_t>(1));
108
109
110 callout_handle.setStatus(CalloutHandle::NEXT_STEP_DROP);
111 return;
112 }
113
114 // Check if we should process this query. If not, drop it.
115 if (!services_->get()->inScope(query4)) {
117 .arg(query4->getLabel());
118 callout_handle.setStatus(CalloutHandle::NEXT_STEP_DROP);
119
120 } else {
121 // We have successfully parsed the query so we have to signal
122 // to the server that it must not parse it.
123 callout_handle.setStatus(CalloutHandle::NEXT_STEP_SKIP);
124 }
125}
126
127void
129 // If the hook library is configured to not send lease updates to the
130 // partner, there is nothing to do because this whole callout is
131 // currently about sending lease updates.
132 if (!config_->get()->amSendingLeaseUpdates()) {
133 // No need to log it, because it was already logged when configuration
134 // was applied.
135 return;
136 }
137
138 Pkt4Ptr query4;
139 Lease4CollectionPtr leases4;
140 Lease4CollectionPtr deleted_leases4;
141
142 // Get all arguments available for the leases4_committed hook point.
143 // If any of these arguments is not available this is a programmatic
144 // error. An exception will be thrown which will be caught by the
145 // caller and logged.
146 callout_handle.getArgument("query4", query4);
147
148 callout_handle.getArgument("leases4", leases4);
149 callout_handle.getArgument("deleted_leases4", deleted_leases4);
150
151 // In some cases we may have no leases, e.g. DHCPNAK.
152 if (leases4->empty() && deleted_leases4->empty()) {
154 .arg(query4->getLabel());
155 return;
156 }
157
158 // Get the parking lot for this hook point. We're going to remember this
159 // pointer until we unpark the packet.
160 ParkingLotHandlePtr parking_lot = callout_handle.getParkingLotHandlePtr();
161
162 // Create a reference to the parked packet. This signals that we have a
163 // stake in unparking it.
164 parking_lot->reference(query4);
165
166 // Asynchronously send lease updates. In some cases no updates will be sent,
167 // e.g. when this server is in the partner-down state and there are no backup
168 // servers. In those cases we simply return without parking the DHCP query.
169 // The response will be sent to the client immediately.
170 try {
171 if (services_->get()->asyncSendLeaseUpdates(query4, leases4, deleted_leases4, parking_lot) == 0) {
172 // Dereference the parked packet. This releases our stake in it.
173 parking_lot->dereference(query4);
174 return;
175 }
176 } catch (...) {
177 // Make sure we dereference.
178 parking_lot->dereference(query4);
179 throw;
180 }
181
182 // The callout returns this status code to indicate to the server that it
183 // should leave the packet parked. It will be parked until each hook
184 // library with a reference, unparks the packet.
185 callout_handle.setStatus(CalloutHandle::NEXT_STEP_PARK);
186}
187
188void
190 // Always return CONTINUE.
191 callout_handle.setStatus(CalloutHandle::NEXT_STEP_CONTINUE);
192 size_t peers_to_update = 0;
193
194 // If the hook library is configured to not send lease updates to the
195 // partner, there is nothing to do because this whole callout is
196 // currently about sending lease updates.
197 if (!config_->get()->amSendingLeaseUpdates()) {
198 // No need to log it, because it was already logged when configuration
199 // was applied.
200 callout_handle.setArgument("peers_to_update", peers_to_update);
201 return;
202 }
203
204 // Get all arguments available for the lease4_server_decline hook point.
205 // If any of these arguments is not available this is a programmatic
206 // error. An exception will be thrown which will be caught by the
207 // caller and logged.
208 Pkt4Ptr query4;
209 callout_handle.getArgument("query4", query4);
210
211 Lease4Ptr lease4;
212 callout_handle.getArgument("lease4", lease4);
213
214 // Asynchronously send the lease update. In some cases no updates will be sent,
215 // e.g. when this server is in the partner-down state and there are no backup
216 // servers.
217 peers_to_update = services_->get()->asyncSendSingleLeaseUpdate(query4, lease4, 0);
218 callout_handle.setArgument("peers_to_update", peers_to_update);
219}
220
221void
223 Pkt6Ptr query6;
224 callout_handle.getArgument("query6", query6);
225
228 try {
229 // We have to unpack the query to get access into DUID which is
230 // used to load balance the packet.
231 if (callout_handle.getStatus() != CalloutHandle::NEXT_STEP_SKIP) {
232 query6->unpack();
233 }
234
235 } catch (const SkipRemainingOptionsError& ex) {
236 // An option failed to unpack but we are to attempt to process it
237 // anyway. Log it and let's hope for the best.
240 .arg(ex.what());
241
242 } catch (const std::exception& ex) {
243 // Packet parsing failed. Drop the packet.
245 .arg(query6->getRemoteAddr().toText())
246 .arg(query6->getLocalAddr().toText())
247 .arg(query6->getIface())
248 .arg(ex.what());
249
250 // Increase the statistics of parse failures and dropped packets.
251 isc::stats::StatsMgr::instance().addValue("pkt6-parse-failed",
252 static_cast<int64_t>(1));
253 isc::stats::StatsMgr::instance().addValue("pkt6-receive-drop",
254 static_cast<int64_t>(1));
255
256
257 callout_handle.setStatus(CalloutHandle::NEXT_STEP_DROP);
258 return;
259 }
260
261 // Check if we should process this query. If not, drop it.
262 if (!services_->get()->inScope(query6)) {
264 .arg(query6->getLabel());
265 callout_handle.setStatus(CalloutHandle::NEXT_STEP_DROP);
266
267 } else {
268 // We have successfully parsed the query so we have to signal
269 // to the server that it must not parse it.
270 callout_handle.setStatus(CalloutHandle::NEXT_STEP_SKIP);
271 }
272}
273
274void
276 // If the hook library is configured to not send lease updates to the
277 // partner, there is nothing to do because this whole callout is
278 // currently about sending lease updates.
279 if (!config_->get()->amSendingLeaseUpdates()) {
280 // No need to log it, because it was already logged when configuration
281 // was applied.
282 return;
283 }
284
285 Pkt6Ptr query6;
286 Lease6CollectionPtr leases6;
287 Lease6CollectionPtr deleted_leases6;
288
289 // Get all arguments available for the leases6_committed hook point.
290 // If any of these arguments is not available this is a programmatic
291 // error. An exception will be thrown which will be caught by the
292 // caller and logged.
293 callout_handle.getArgument("query6", query6);
294
295 callout_handle.getArgument("leases6", leases6);
296 callout_handle.getArgument("deleted_leases6", deleted_leases6);
297
298 // In some cases we may have no leases.
299 if (leases6->empty() && deleted_leases6->empty()) {
301 .arg(query6->getLabel());
302 return;
303 }
304
305 // Get the parking lot for this hook point. We're going to remember this
306 // pointer until we unpark the packet.
307 ParkingLotHandlePtr parking_lot = callout_handle.getParkingLotHandlePtr();
308
309 // Create a reference to the parked packet. This signals that we have a
310 // stake in unparking it.
311 parking_lot->reference(query6);
312
313 // Asynchronously send lease updates. In some cases no updates will be sent,
314 // e.g. when this server is in the partner-down state and there are no backup
315 // servers. In those cases we simply return without parking the DHCP query.
316 // The response will be sent to the client immediately.
317 try {
318 if (services_->get()->asyncSendLeaseUpdates(query6, leases6, deleted_leases6, parking_lot) == 0) {
319 // Dereference the parked packet. This releases our stake in it.
320 parking_lot->dereference(query6);
321 return;
322 }
323 } catch (...) {
324 // Make sure we dereference.
325 parking_lot->dereference(query6);
326 throw;
327 }
328
329 // The callout returns this status code to indicate to the server that it
330 // should leave the packet parked. It will be unparked until each hook
331 // library with a reference, unparks the packet.
332 callout_handle.setStatus(CalloutHandle::NEXT_STEP_PARK);
333}
334
335void
337 std::string command_name;
338 callout_handle.getArgument("name", command_name);
339 if (command_name == "status-get") {
340 // Get the response.
341 ConstElementPtr response;
342 callout_handle.getArgument("response", response);
343 if (!response || (response->getType() != Element::map)) {
344 return;
345 }
346 // Get the arguments item from the response.
347 ConstElementPtr resp_args = response->get("arguments");
348 if (!resp_args || (resp_args->getType() != Element::map)) {
349 return;
350 }
351 // Add the ha servers info to arguments.
352 ElementPtr mutable_resp_args =
353 boost::const_pointer_cast<Element>(resp_args);
354
355 // Process the status get command for each HA service.
356 auto ha_relationships = Element::createList();
357 for (auto service : services_->getAll()) {
358 auto ha_relationship = Element::createMap();
359 ConstElementPtr ha_servers = service->processStatusGet();
360 ha_relationship->set("ha-servers", ha_servers);
361 ha_relationship->set("ha-mode", Element::create(HAConfig::HAModeToString(config_->get()->getHAMode())));
362 ha_relationships->add(ha_relationship);
363 mutable_resp_args->set("high-availability", ha_relationships);
364 }
365 }
366}
367
368void
370 // Command must always be provided.
371 ConstElementPtr command;
372 callout_handle.getArgument("command", command);
373
374 // Retrieve arguments.
375 ConstElementPtr args;
376 static_cast<void>(parseCommand(args, command));
377
378 HAServicePtr service;
379 try {
380 service = getHAServiceByServerName("ha-heartbeat", args);
381
382 } catch (const std::exception& ex) {
383 // There was an error while parsing command arguments. Return an error status
384 // code to notify the user.
386 callout_handle.setArgument("response", response);
387 return;
388 }
389
390 // Command parsing was successful, so let's process the command.
391 ConstElementPtr response = service->processHeartbeat();
392 callout_handle.setArgument("response", response);
393}
394
395void
397 // Command must always be provided.
398 ConstElementPtr command;
399 callout_handle.getArgument("command", command);
400
401 // Retrieve arguments.
402 ConstElementPtr args;
403 static_cast<void>(parseCommand(args, command));
404
405 ConstElementPtr server_name;
406 unsigned int max_period_value = 0;
407
408 HAServicePtr service;
409 try {
410 // Arguments are required for the ha-sync command.
411 if (!args) {
412 isc_throw(BadValue, "arguments not found in the 'ha-sync' command");
413 }
414
415 // Arguments must be a map.
416 if (args->getType() != Element::map) {
417 isc_throw(BadValue, "arguments in the 'ha-sync' command are not a map");
418 }
419
420 // server-name is mandatory. Otherwise how can we know the server to
421 // communicate with.
422 server_name = args->get("server-name");
423 if (!server_name) {
424 isc_throw(BadValue, "'server-name' is mandatory for the 'ha-sync' command");
425 }
426
427 // server-name must obviously be a string.
428 if (server_name->getType() != Element::string) {
429 isc_throw(BadValue, "'server-name' must be a string in the 'ha-sync' command");
430 }
431
432 // max-period is optional. In fact it is optional for dhcp-disable command too.
433 ConstElementPtr max_period = args->get("max-period");
434 if (max_period) {
435 // If it is specified, it must be a positive integer.
436 if ((max_period->getType() != Element::integer) ||
437 (max_period->intValue() <= 0)) {
438 isc_throw(BadValue, "'max-period' must be a positive integer in the 'ha-sync' command");
439 }
440
441 max_period_value = static_cast<unsigned int>(max_period->intValue());
442 }
443
444 service = getHAServiceByServerName("ha-sync", args);
445
446 } catch (const std::exception& ex) {
447 // There was an error while parsing command arguments. Return an error status
448 // code to notify the user.
450 callout_handle.setArgument("response", response);
451 return;
452 }
453
454 // Command parsing was successful, so let's process the command.
455 ConstElementPtr response = service->processSynchronize(server_name->stringValue(),
456 max_period_value);
457 callout_handle.setArgument("response", response);
458}
459
460void
462 // Command must always be provided.
463 ConstElementPtr command;
464 callout_handle.getArgument("command", command);
465
466 // Retrieve arguments.
467 ConstElementPtr args;
468 static_cast<void>(parseCommand(args, command));
469
470 HAServicePtr service;
471 std::vector<std::string> scopes_vector;
472 try {
473 // Arguments must be present.
474 if (!args) {
475 isc_throw(BadValue, "arguments not found in the 'ha-scopes' command");
476 }
477
478 // Arguments must be a map.
479 if (args->getType() != Element::map) {
480 isc_throw(BadValue, "arguments in the 'ha-scopes' command are not a map");
481 }
482
483 // scopes argument is mandatory.
484 ConstElementPtr scopes = args->get("scopes");
485 if (!scopes) {
486 isc_throw(BadValue, "'scopes' is mandatory for the 'ha-scopes' command");
487 }
488
489 // It contains a list of scope names.
490 if (scopes->getType() != Element::list) {
491 isc_throw(BadValue, "'scopes' must be a list in the 'ha-scopes' command");
492 }
493
494 // Retrieve scope names from this list. The list may be empty to clear the
495 // scopes.
496 for (size_t i = 0; i < scopes->size(); ++i) {
497 ConstElementPtr scope = scopes->get(i);
498 if (!scope || scope->getType() != Element::string) {
499 isc_throw(BadValue, "scope name must be a string in the 'scopes' argument");
500 }
501 scopes_vector.push_back(scope->stringValue());
502 }
503
504 service = getHAServiceByServerName("ha-scopes", args);
505
506 } catch (const std::exception& ex) {
507 // There was an error while parsing command arguments. Return an error status
508 // code to notify the user.
510 callout_handle.setArgument("response", response);
511 return;
512 }
513
514 // Command parsing was successful, so let's process the command.
515 ConstElementPtr response = service->processScopes(scopes_vector);
516 callout_handle.setArgument("response", response);
517}
518
519void
521 // Command must always be provided.
522 ConstElementPtr command;
523 callout_handle.getArgument("command", command);
524
525 // Retrieve arguments.
526 ConstElementPtr args;
527 static_cast<void>(parseCommand(args, command));
528
529 HAServicePtr service;
530 try {
531 service = getHAServiceByServerName("ha-continue", args);
532
533 } catch (const std::exception& ex) {
534 // There was an error while parsing command arguments. Return an error status
535 // code to notify the user.
537 callout_handle.setArgument("response", response);
538 return;
539 }
540 ConstElementPtr response = service->processContinue();
541 callout_handle.setArgument("response", response);
542}
543
544void
546 // Command must always be provided.
547 ConstElementPtr command;
548 callout_handle.getArgument("command", command);
549
550 HAServicePtr service;
551 try {
552 // Retrieve arguments.
553 ConstElementPtr args;
554 static_cast<void>(parseCommandWithArgs(args, command));
555
556 ConstElementPtr cancel_op = args->get("cancel");
557 if (!cancel_op) {
558 isc_throw(BadValue, "'cancel' is mandatory for the 'ha-maintenance-notify' command");
559 }
560
561 if (cancel_op->getType() != Element::boolean) {
562 isc_throw(BadValue, "'cancel' must be a boolean in the 'ha-maintenance-notify' command");
563 }
564
565 service = getHAServiceByServerName("ha-maintenance-notify", args);
566
567 ConstElementPtr response = service->processMaintenanceNotify(cancel_op->boolValue());
568 callout_handle.setArgument("response", response);
569
570 } catch (const std::exception& ex) {
571 // There was an error while parsing command arguments. Return an error status
572 // code to notify the user.
574 callout_handle.setArgument("response", response);
575 }
576}
577
578void
580 ConstElementPtr response;
581 for (auto service : services_->getAll()) {
582 response = service->processMaintenanceStart();
583 int rcode = CONTROL_RESULT_SUCCESS;
584 static_cast<void>(parseAnswer(rcode, response));
585 if (rcode != CONTROL_RESULT_SUCCESS) {
586 break;
587 }
588 }
589 callout_handle.setArgument("response", response);
590}
591
592void
594 ConstElementPtr response;
595 for (auto service : services_->getAll()) {
596 response = service->processMaintenanceCancel();
597 }
598 callout_handle.setArgument("response", response);
599}
600
601void
603 // Command must always be provided.
604 ConstElementPtr command;
605 callout_handle.getArgument("command", command);
606
607 // Retrieve arguments.
608 ConstElementPtr args;
609 static_cast<void>(parseCommand(args, command));
610
611 HAServicePtr service;
612 try {
613 service = getHAServiceByServerName("ha-reset", args);
614
615 } catch (const std::exception& ex) {
616 // There was an error while parsing command arguments. Return an error status
617 // code to notify the user.
619 callout_handle.setArgument("response", response);
620 return;
621 }
622
623 ConstElementPtr response = service->processHAReset();
624 callout_handle.setArgument("response", response);
625}
626
627void
629 // Command must always be provided.
630 ConstElementPtr command;
631 callout_handle.getArgument("command", command);
632
633 // Retrieve arguments.
634 ConstElementPtr args;
635 static_cast<void>(parseCommand(args, command));
636
637 HAServicePtr service;
638 auto origin_value = NetworkState::HA_REMOTE_COMMAND+1;
639 try {
640 if (args) {
641 auto origin = args->get("origin");
642 if (origin) {
643 if (origin->getType() != Element::integer) {
644 isc_throw(BadValue, "'origin' must be an integer in the 'ha-sync-complete-notify' command");
645 }
646 origin_value = origin->intValue();
647 }
648 }
649
650 service = getHAServiceByServerName("ha-sync-complete-notify", args);
651
652 } catch (const std::exception& ex) {
653 // There was an error while parsing command arguments. Return an error status
654 // code to notify the user.
656 callout_handle.setArgument("response", response);
657 return;
658 }
659
660 ConstElementPtr response = service->processSyncCompleteNotify(origin_value);
661 callout_handle.setArgument("response", response);
662}
663
665HAImpl::getHAServiceByServerName(const std::string& command_name, ConstElementPtr args) const {
666 HAServicePtr service;
667 if (args) {
668 // Arguments must be a map.
669 if (args->getType() != Element::map) {
670 isc_throw(BadValue, "arguments in the '" << command_name << "' command are not a map");
671 }
672
673 auto server_name = args->get("server-name");
674
675 if (server_name) {
676 if (server_name->getType() != Element::string) {
677 isc_throw(BadValue, "'server-name' must be a string in the '" << command_name << "' command");
678 }
679 service = services_->get(server_name->stringValue());
680 if (!service) {
681 isc_throw(BadValue, server_name->stringValue() << " matches no configured"
682 << " 'server-name'");
683 }
684 }
685 }
686
687 if (!service) {
688 service = services_->get();
689 }
690
691 return (service);
692}
693
694} // end of namespace isc::ha
695} // end of namespace isc
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.
Exception thrown during option unpacking This exception is thrown when an error has occurred,...
Definition: option.h:52
static HAConfigMapperPtr parse(const data::ConstElementPtr &config)
Parses HA configuration.
static std::string HAModeToString(const HAMode &ha_mode)
Returns HA mode name.
Definition: ha_config.cc:230
void scopesHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-scopes command.
Definition: ha_impl.cc:461
void continueHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-continue command.
Definition: ha_impl.cc:520
HAConfigMapperPtr config_
Holds parsed configuration.
Definition: ha_impl.h:210
void syncCompleteNotifyHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-sync-complete-notify command.
Definition: ha_impl.cc:628
HAServicePtr getHAServiceByServerName(const std::string &command_name, data::ConstElementPtr args) const
Attempts to get an HAService by server name.
Definition: ha_impl.cc:665
HAServiceMapperPtr services_
Pointer to the high availability services (state machines).
Definition: ha_impl.h:213
void configure(const data::ConstElementPtr &input_config)
Parses configuration.
Definition: ha_impl.cc:35
~HAImpl()
Destructor.
Definition: ha_impl.cc:66
void maintenanceCancelHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-maintenance-cancel command.
Definition: ha_impl.cc:593
void haResetHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-reset command.
Definition: ha_impl.cc:602
void maintenanceNotifyHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-maintenance-notify command.
Definition: ha_impl.cc:545
void synchronizeHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-sync command.
Definition: ha_impl.cc:396
void maintenanceStartHandler(hooks::CalloutHandle &callout_handle)
Implements handler for the ha-maintenance-start command.
Definition: ha_impl.cc:579
void leases4Committed(hooks::CalloutHandle &callout_handle)
Implementation of the "leases4_committed" callout.
Definition: ha_impl.cc:128
void startServices(const asiolink::IOServicePtr &io_service, const dhcp::NetworkStatePtr &network_state, const HAServerType &server_type)
Creates high availability services using current configuration.
Definition: ha_impl.cc:40
void buffer4Receive(hooks::CalloutHandle &callout_handle)
Implementation of the "buffer4_receive" callout.
Definition: ha_impl.cc:75
void buffer6Receive(hooks::CalloutHandle &callout_handle)
Implementation of the "buffer6_receive" callout.
Definition: ha_impl.cc:222
void commandProcessed(hooks::CalloutHandle &callout_handle)
Implementation of the "command_processed" callout.
Definition: ha_impl.cc:336
HAImpl()
Constructor.
Definition: ha_impl.cc:30
void leases6Committed(hooks::CalloutHandle &callout_handle)
Implementation of the "leases6_committed" callout.
Definition: ha_impl.cc:275
void lease4ServerDecline(hooks::CalloutHandle &callout_handle)
Implementation of the "lease4_server_decline" callout.
Definition: ha_impl.cc:189
void heartbeatHandler(hooks::CalloutHandle &callout_handle)
Implements handle for the heartbeat command.
Definition: ha_impl.cc:369
Holds associations between objects and HA relationships.
Per-packet callout handle.
ParkingLotHandlePtr getParkingLotHandlePtr() const
Returns pointer to the parking lot handle for this hook point.
CalloutNextStep getStatus() const
Returns the next processing step.
void setStatus(const CalloutNextStep next)
Sets the next processing step.
void getArgument(const std::string &name, T &value) const
Get argument.
void setArgument(const std::string &name, T value)
Set argument.
static StatsMgr & instance()
Statistics Manager accessor method.
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.
void addValue(const std::string &name, const int64_t value)
Records incremental integer observation.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
Definition: macros.h:14
std::string parseCommandWithArgs(ConstElementPtr &arg, ConstElementPtr command)
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
std::string parseCommand(ConstElementPtr &arg, ConstElementPtr command)
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
ConstElementPtr parseAnswer(int &rcode, const ConstElementPtr &msg)
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:29
boost::shared_ptr< Element > ElementPtr
Definition: data.h:28
boost::shared_ptr< Lease4Collection > Lease4CollectionPtr
A shared pointer to the collection of IPv4 leases.
Definition: lease.h:500
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Definition: pkt4.h:555
boost::shared_ptr< NetworkState > NetworkStatePtr
Pointer to the NetworkState object.
boost::shared_ptr< Lease6Collection > Lease6CollectionPtr
A shared pointer to the collection of IPv6 leases.
Definition: lease.h:673
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
Definition: pkt6.h:31
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Definition: lease.h:292
const isc::log::MessageID HA_BUFFER4_RECEIVE_UNPACK_FAILED
Definition: ha_messages.h:14
const isc::log::MessageID HA_LEASES6_COMMITTED_NOTHING_TO_UPDATE
Definition: ha_messages.h:57
const isc::log::MessageID HA_BUFFER4_RECEIVE_PACKET_OPTIONS_SKIPPED
Definition: ha_messages.h:13
const isc::log::MessageID HA_BUFFER6_RECEIVE_UNPACK_FAILED
Definition: ha_messages.h:18
isc::log::Logger ha_logger("ha-hooks")
Definition: ha_log.h:17
const isc::log::MessageID HA_BUFFER6_RECEIVE_PACKET_OPTIONS_SKIPPED
Definition: ha_messages.h:17
HAServerType
Lists possible server types for which HA service is created.
const isc::log::MessageID HA_LEASES4_COMMITTED_NOTHING_TO_UPDATE
Definition: ha_messages.h:55
const isc::log::MessageID HA_BUFFER4_RECEIVE_NOT_FOR_US
Definition: ha_messages.h:12
const isc::log::MessageID HA_BUFFER6_RECEIVE_NOT_FOR_US
Definition: ha_messages.h:16
boost::shared_ptr< HAService > HAServicePtr
Pointer to the HAService class.
Definition: ha_service.h:1360
boost::shared_ptr< ParkingLotHandle > ParkingLotHandlePtr
Pointer to the parking lot handle.
Definition: parking_lots.h:381
const int DBGLVL_TRACE_BASIC
Trace basic operations.
Definition: log_dbglevels.h:69
Defines the logger used by the top-level component of kea-lfc.