Kea  1.5.0
nc_remove.cc
Go to the documentation of this file.
1 // Copyright (C) 2013-2015 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 <d2/d2_log.h>
10 #include <d2/d2_cfg_mgr.h>
11 #include <d2/nc_remove.h>
12 
13 #include <boost/function.hpp>
14 #include <boost/bind.hpp>
15 
16 namespace isc {
17 namespace d2 {
18 
19 
20 // NameRemoveTransaction states
24 
25 // NameRemoveTransaction events
26 // Currently NameRemoveTransaction does not define any events.
27 
31  DdnsDomainPtr& forward_domain,
32  DdnsDomainPtr& reverse_domain,
33  D2CfgMgrPtr& cfg_mgr)
34  : NameChangeTransaction(io_service, ncr, forward_domain, reverse_domain,
35  cfg_mgr) {
36  if (ncr->getChangeType() != isc::dhcp_ddns::CHG_REMOVE) {
38  "NameRemoveTransaction, request type must be CHG_REMOVE");
39  }
40 }
41 
43 }
44 
45 void
47  // Call superclass impl first.
49 
50  // Define NameRemoveTransaction events.
51  // Currently NameRemoveTransaction does not define any events.
52  // defineEvent(TBD_EVENT, "TBD_EVT");
53 }
54 
55 void
57  // Call superclass implementation first to verify its events. These are
58  // events common to all transactions, and they must be defined.
59  // SELECT_SERVER_EVT
60  // SERVER_SELECTED_EVT
61  // SERVER_IO_ERROR_EVT
62  // NO_MORE_SERVERS_EVT
63  // IO_COMPLETED_EVT
64  // UPDATE_OK_EVT
65  // UPDATE_FAILED_EVT
67 
68  // Verify NameRemoveTransaction events by attempting to fetch them.
69  // Currently NameRemoveTransaction does not define any events.
70  // getEvent(TBD_EVENT);
71 }
72 
73 void
75  // Call superclass impl first.
77 
78  // Define NameRemoveTransaction states.
79  defineState(READY_ST, "READY_ST",
80  boost::bind(&NameRemoveTransaction::readyHandler, this));
81 
82  defineState(SELECTING_FWD_SERVER_ST, "SELECTING_FWD_SERVER_ST",
84  this));
85 
86  defineState(SELECTING_REV_SERVER_ST, "SELECTING_REV_SERVER_ST",
88  this));
89 
90  defineState(REMOVING_FWD_ADDRS_ST, "REMOVING_FWD_ADDRS_ST",
92  this));
93 
94  defineState(REMOVING_FWD_RRS_ST, "REMOVING_FWD_RRS_ST",
96  this));
97 
98  defineState(REMOVING_REV_PTRS_ST, "REMOVING_REV_PTRS_ST",
100  this));
101 
102  defineState(PROCESS_TRANS_OK_ST, "PROCESS_TRANS_OK_ST",
104  this));
105 
106  defineState(PROCESS_TRANS_FAILED_ST, "PROCESS_TRANS_FAILED_ST",
108  this));
109 }
110 
111 void
113  // Call superclass implementation first to verify its states. These are
114  // states common to all transactions, and they must be defined.
115  // READY_ST
116  // SELECTING_FWD_SERVER_ST
117  // SELECTING_REV_SERVER_ST
118  // PROCESS_TRANS_OK_ST
119  // PROCESS_TRANS_FAILED_ST
121 
122  // Verify NameRemoveTransaction states by attempting to fetch them.
126 }
127 
128 void
130  switch(getNextEvent()) {
131  case START_EVT:
132  if (getForwardDomain()) {
133  // Request includes a forward change, do that first.
135  } else {
136  // Reverse change only, transition accordingly.
138  }
139 
140  break;
141  default:
142  // Event is invalid.
144  "Wrong event for context: " << getContextStr());
145  }
146 }
147 
148 void
150  switch(getNextEvent()) {
151  case SELECT_SERVER_EVT:
152  // First time through for this transaction, so initialize server
153  // selection.
155  break;
156  case SERVER_IO_ERROR_EVT:
157  // We failed to communicate with current server. Attempt to select
158  // another one below.
159  break;
160  default:
161  // Event is invalid.
163  "Wrong event for context: " << getContextStr());
164  }
165 
166  // Select the next server from the list of forward servers.
167  if (selectNextServer()) {
168  // We have a server to try.
170  }
171  else {
172  // Server list is exhausted, so fail the transaction.
174  }
175 }
176 
177 void
179  if (doOnEntry()) {
180  // Clear the request on initial transition. This allows us to reuse
181  // the request on retries if necessary.
183  }
184 
185  switch(getNextEvent()) {
186  case SERVER_SELECTED_EVT:
187  if (!getDnsUpdateRequest()) {
188  // Request hasn't been constructed yet, so build it.
189  try {
191  } catch (const std::exception& ex) {
192  // While unlikely, the build might fail if we have invalid
193  // data. Should that be the case, we need to fail the
194  // transaction.
196  DHCP_DDNS_FORWARD_REMOVE_ADDRS_BUILD_FAILURE)
197  .arg(getRequestId())
198  .arg(getNcr()->toText())
199  .arg(ex.what());
201  break;
202  }
203  }
204 
205  // Call sendUpdate() to initiate the async send. Note it also sets
206  // next event to NOP_EVT.
207  sendUpdate("Forward A/AAAA Remove");
208  break;
209 
210  case IO_COMPLETED_EVT: {
211  switch (getDnsUpdateStatus()) {
212  case DNSClient::SUCCESS: {
213  // We successfully received a response packet from the server.
214  // The RCODE will be based on a value-dependent RRset search,
215  // see RFC 2136 section 3.2.3/3.2.4.
216  const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
217  if ((rcode == dns::Rcode::NOERROR()) ||
218  (rcode == dns::Rcode::NXRRSET())) {
219  // We were able to remove it or it wasn't there, now we
220  // need to remove any other RRs for this FQDN.
222  } else {
223  // Per RFC4703 any other value means cease.
224  // If we get not authorized should we try the next server in
225  // the list? @todo This needs some discussion perhaps.
226  LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_REMOVE_ADDRS_REJECTED)
227  .arg(getRequestId())
228  .arg(getCurrentServer()->toText())
229  .arg(getNcr()->getFqdn())
230  .arg(rcode.getCode());
232  }
233 
234  break;
235  }
236 
237  case DNSClient::TIMEOUT:
238  case DNSClient::OTHER:
239  // We couldn't send to the current server, log it and set up
240  // to select the next server for a retry.
241  // @note For now we treat OTHER as an IO error like TIMEOUT. It
242  // is not entirely clear if this is accurate.
243  LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_REMOVE_ADDRS_IO_ERROR)
244  .arg(getRequestId())
245  .arg(getNcr()->getFqdn())
246  .arg(getCurrentServer()->toText());
247 
249  break;
250 
252  // A response was received but was corrupt. Retry it like an IO
253  // error.
254  LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_REMOVE_ADDRS_RESP_CORRUPT)
255  .arg(getRequestId())
256  .arg(getCurrentServer()->toText())
257  .arg(getNcr()->getFqdn());
258 
260  break;
261 
262  default:
263  // Any other value and we will fail this transaction, something
264  // bigger is wrong.
266  DHCP_DDNS_FORWARD_REMOVE_ADDRS_BAD_DNSCLIENT_STATUS)
267  .arg(getRequestId())
268  .arg(getDnsUpdateStatus())
269  .arg(getNcr()->getFqdn())
270  .arg(getCurrentServer()->toText());
271 
273  break;
274  } // end switch on dns_status
275 
276  break;
277  } // end case IO_COMPLETE_EVT
278 
279  default:
280  // Event is invalid.
282  "Wrong event for context: " << getContextStr());
283  }
284 }
285 
286 
287 void
289  if (doOnEntry()) {
290  // Clear the request on initial transition. This allows us to reuse
291  // the request on retries if necessary.
293  }
294 
295  switch(getNextEvent()) {
296  case UPDATE_OK_EVT:
297  case SERVER_SELECTED_EVT:
298  if (!getDnsUpdateRequest()) {
299  // Request hasn't been constructed yet, so build it.
300  try {
302  } catch (const std::exception& ex) {
303  // While unlikely, the build might fail if we have invalid
304  // data. Should that be the case, we need to fail the
305  // transaction.
307  DHCP_DDNS_FORWARD_REMOVE_RRS_BUILD_FAILURE)
308  .arg(getRequestId())
309  .arg(getNcr()->toText())
310  .arg(ex.what());
312  break;
313  }
314  }
315 
316  // Call sendUpdate() to initiate the async send. Note it also sets
317  // next event to NOP_EVT.
318  sendUpdate("Forward RR Remove");
319  break;
320 
321  case IO_COMPLETED_EVT: {
322  switch (getDnsUpdateStatus()) {
323  case DNSClient::SUCCESS: {
324  // We successfully received a response packet from the server.
325  // The RCODE will be based on a value-dependent RRset search,
326  // see RFC 2136 section 3.2.3/3.2.4.
327  const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
328  if ((rcode == dns::Rcode::NOERROR()) ||
329  (rcode == dns::Rcode::NXRRSET())) {
330  // We were able to remove them or they were not there (
331  // Rcode of NXRRSET means there are no matching RRsets).
332  // In either case, we consider it success and mark it as done.
334 
335  // If request calls for reverse update then do that next,
336  // otherwise we can process ok.
337  if (getReverseDomain()) {
339  } else {
341  }
342  } else {
343  // Per RFC4703 any other value means cease.
344  // If we get not authorized should try the next server in
345  // the list? @todo This needs some discussion perhaps.
346  LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_REMOVE_RRS_REJECTED)
347  .arg(getRequestId())
348  .arg(getCurrentServer()->toText())
349  .arg(getNcr()->getFqdn())
350  .arg(rcode.getCode());
352  }
353 
354  break;
355  }
356 
357  case DNSClient::TIMEOUT:
358  case DNSClient::OTHER:
359  // We couldn't send to the current server, log it and set up
360  // to select the next server for a retry.
361  // @note For now we treat OTHER as an IO error like TIMEOUT. It
362  // is not entirely clear if this is accurate.
363  LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_REMOVE_RRS_IO_ERROR)
364  .arg(getRequestId())
365  .arg(getNcr()->getFqdn())
366  .arg(getCurrentServer()->toText());
367 
368  // @note If we exhaust the IO retries for the current server
369  // due to IO failures, we will abort the remaining updates.
370  // The rational is that we are only in this state, if the remove
371  // of the forward address RR succeeded (removingFwdAddrsHandler)
372  // on the current server. Therefore we should not attempt another
373  // removal on a different server. This is perhaps a point
374  // for discussion.
375  // @todo Should we go ahead with the reverse remove?
377  break;
378 
380  // A response was received but was corrupt. Retry it like an IO
381  // error.
382  LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_REMOVE_RRS_RESP_CORRUPT)
383  .arg(getRequestId())
384  .arg(getCurrentServer()->toText())
385  .arg(getNcr()->getFqdn());
386 
387  // If we are out of retries on this server abandon the transaction.
388  // (Same logic as the case for TIMEOUT above).
390  break;
391 
392  default:
393  // Any other value and we will fail this transaction, something
394  // bigger is wrong.
396  DHCP_DDNS_FORWARD_REMOVE_RRS_BAD_DNSCLIENT_STATUS)
397  .arg(getRequestId())
398  .arg(getDnsUpdateStatus())
399  .arg(getNcr()->getFqdn())
400  .arg(getCurrentServer()->toText());
401 
403  break;
404  } // end switch on dns_status
405 
406  break;
407  } // end case IO_COMPLETE_EVT
408 
409  default:
410  // Event is invalid.
412  "Wrong event for context: " << getContextStr());
413  }
414 }
415 
416 
417 void
419  switch(getNextEvent()) {
420  case SELECT_SERVER_EVT:
421  // First time through for this transaction, so initialize server
422  // selection.
424  break;
425  case SERVER_IO_ERROR_EVT:
426  // We failed to communicate with current server. Attempt to select
427  // another one below.
428  break;
429  default:
430  // Event is invalid.
432  "Wrong event for context: " << getContextStr());
433  }
434 
435  // Select the next server from the list of forward servers.
436  if (selectNextServer()) {
437  // We have a server to try.
439  }
440  else {
441  // Server list is exhausted, so fail the transaction.
443  }
444 }
445 
446 
447 void
449  if (doOnEntry()) {
450  // Clear the request on initial transition. This allows us to reuse
451  // the request on retries if necessary.
453  }
454 
455  switch(getNextEvent()) {
456  case SERVER_SELECTED_EVT:
457  if (!getDnsUpdateRequest()) {
458  // Request hasn't been constructed yet, so build it.
459  try {
461  } catch (const std::exception& ex) {
462  // While unlikely, the build might fail if we have invalid
463  // data. Should that be the case, we need to fail the
464  // transaction.
465  LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_REVERSE_REMOVE_BUILD_FAILURE)
466  .arg(getRequestId())
467  .arg(getNcr()->toText())
468  .arg(ex.what());
470  break;
471  }
472  }
473 
474  // Call sendUpdate() to initiate the async send. Note it also sets
475  // next event to NOP_EVT.
476  sendUpdate("Reverse Remove");
477  break;
478 
479  case IO_COMPLETED_EVT: {
480  switch (getDnsUpdateStatus()) {
481  case DNSClient::SUCCESS: {
482  // We successfully received a response packet from the server.
483  // The RCODE will be based on a value-dependent RRset search,
484  // see RFC 2136 section 3.2.3/3.2.4.
485  const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
486  if ((rcode == dns::Rcode::NOERROR()) ||
487  (rcode == dns::Rcode::NXRRSET())) {
488  // We were able to remove the reverse mapping or they were
489  // not there (Rcode of NXRRSET means there are no matching
490  // RRsets). In either case, mark it as done.
493  } else {
494  // Per RFC4703 any other value means cease.
495  // If we get not authorized should try the next server in
496  // the list? @todo This needs some discussion perhaps.
497  LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_REVERSE_REMOVE_REJECTED)
498  .arg(getRequestId())
499  .arg(getCurrentServer()->toText())
500  .arg(getNcr()->getFqdn())
501  .arg(rcode.getCode());
503  }
504 
505  break;
506  }
507 
508  case DNSClient::TIMEOUT:
509  case DNSClient::OTHER:
510  // We couldn't send to the current server, log it and set up
511  // to select the next server for a retry.
512  // @note For now we treat OTHER as an IO error like TIMEOUT. It
513  // is not entirely clear if this is accurate.
514  LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_REVERSE_REMOVE_IO_ERROR)
515  .arg(getRequestId())
516  .arg(getNcr()->getFqdn())
517  .arg(getCurrentServer()->toText());
518 
519  // If we are out of retries on this server, we go back and start
520  // all over on a new server.
522  break;
523 
525  // A response was received but was corrupt. Retry it like an IO
526  // error.
527  LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_REVERSE_REMOVE_RESP_CORRUPT)
528  .arg(getRequestId())
529  .arg(getCurrentServer()->toText())
530  .arg(getNcr()->getFqdn());
531 
532  // If we are out of retries on this server, we go back and start
533  // all over on a new server.
535  break;
536 
537  default:
538  // Any other value and we will fail this transaction, something
539  // bigger is wrong.
541  DHCP_DDNS_REVERSE_REMOVE_BAD_DNSCLIENT_STATUS)
542  .arg(getRequestId())
543  .arg(getDnsUpdateStatus())
544  .arg(getNcr()->getFqdn())
545  .arg(getCurrentServer()->toText());
546 
548  break;
549  } // end switch on dns_status
550 
551  break;
552  } // end case IO_COMPLETE_EVT
553 
554  default:
555  // Event is invalid.
557  "Wrong event for context: " << getContextStr());
558  }
559 }
560 
561 
562 void
564  switch(getNextEvent()) {
565  case UPDATE_OK_EVT:
566  LOG_INFO(d2_to_dns_logger, DHCP_DDNS_REMOVE_SUCCEEDED)
567  .arg(getRequestId())
568  .arg(getNcr()->toText());
570  endModel();
571  break;
572  default:
573  // Event is invalid.
575  "Wrong event for context: " << getContextStr());
576  }
577 }
578 
579 void
581  switch(getNextEvent()) {
582  case UPDATE_FAILED_EVT:
583  case NO_MORE_SERVERS_EVT:
584  case SERVER_IO_ERROR_EVT:
586  LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_REMOVE_FAILED)
587  .arg(getRequestId())
588  .arg(transactionOutcomeString());
589  endModel();
590  break;
591  default:
592  // Event is invalid.
594  "Wrong event for context: " << getContextStr());
595  }
596 }
597 
598 void
600  // Construct an empty request.
602 
603  // Content on this request is based on RFC 4703, section 5.5, paragraph 4.
604  // Construct dns::Name from NCR fqdn.
605  dns::Name fqdn(dns::Name(getNcr()->getFqdn()));
606  // First build the Prerequisite Section
607 
608  // Create an DHCID matches prerequisite RR and add it to the
609  // pre-requisite section
610  // Based on RFC 2136, section 2.4.2.
611  dns::RRsetPtr prereq(new dns::RRset(fqdn, dns::RRClass::IN(),
613  addDhcidRdata(prereq);
614  request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
615 
616  // Next build the Update Section
617 
618  // Create the FQDN/IP 'delete' RR and add it to the update section.
619  // Add the RR to update section.
620  // Based on 2136 section 2.5.4
621  dns::RRsetPtr update(new dns::RRset(fqdn, dns::RRClass::NONE(),
623  addLeaseAddressRdata(update);
624  request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
625 
626  // Set the transaction's update request to the new request.
627  setDnsUpdateRequest(request);
628 }
629 
630 void
632  // Construct an empty request.
634 
635  // Construct dns::Name from NCR fqdn.
636  dns::Name fqdn(dns::Name(getNcr()->getFqdn()));
637 
638  // Content on this request is based on RFC 4703, section 5.5, paragraph 5.
639  // First build the Prerequisite Section.
640 
641  // Now create an DHCID matches prerequisite RR.
642  // Set the RR's RData to DHCID.
643  // Add it to the pre-requisite section.
644  // Based on RFC 2136, section 2.4.2.
645  dns::RRsetPtr prereq(new dns::RRset(fqdn, dns::RRClass::IN(),
647  addDhcidRdata(prereq);
648  request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
649 
650  // Create an assertion that there are no A RRs for the FQDN.
651  // Add it to the pre-reqs.
652  // Based on RFC 2136, section 2.4.3.
653  prereq.reset(new dns::RRset(fqdn, dns::RRClass::NONE(),
654  dns::RRType::A(), dns::RRTTL(0)));
655  request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
656 
657  // Create an assertion that there are no A RRs for the FQDN.
658  // Add it to the pre-reqs.
659  // Based on RFC 2136, section 2.4.3.
660  prereq.reset(new dns::RRset(fqdn, dns::RRClass::NONE(),
662  request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
663 
664  // Next build the Update Section.
665 
666  // Create the 'delete' of all RRs for FQDN.
667  // Set the message RData to lease address.
668  // Add the RR to update section.
669  // Based on RFC 2136, section 2.5.3.
670  dns::RRsetPtr update(new dns::RRset(fqdn, dns::RRClass::ANY(),
672  request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
673 
674  // Set the transaction's update request to the new request.
675  setDnsUpdateRequest(request);
676 }
677 
678 void
680  // Construct an empty request.
682 
683  // Create the reverse IP address "FQDN".
684  std::string rev_addr = D2CfgMgr::reverseIpAddress(getNcr()->getIpAddress());
685  dns::Name rev_ip(rev_addr);
686 
687  // Content on this request is based on RFC 4703, section 5.5, paragraph 2.
688  // First build the Prerequisite Section.
689  // (Note that per RFC 4703, section 5.4, there is no need to validate
690  // DHCID RR for PTR entries.)
691 
692  // Create an assertion that the PTRDNAME in the PTR record matches the
693  // client's FQDN for the address that was released.
694  // Based on RFC 2136, section 3.2.3
695  dns::RRsetPtr prereq(new dns::RRset(rev_ip, dns::RRClass::IN(),
697  addPtrRdata(prereq);
698  request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
699 
700  // Now, build the Update section.
701 
702  // Create a delete of any RRs for the FQDN and add it to update section.
703  // Based on RFC 2136, section 3.4.2.3
704  dns::RRsetPtr update(new dns::RRset(rev_ip, dns::RRClass::ANY(),
706  request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
707 
708  // Set the transaction's update request to the new request.
709  setDnsUpdateRequest(request);
710 }
711 
712 } // namespace isc::d2
713 } // namespace isc
isc::util::StateModel::defineState
void defineState(unsigned int value, const std::string &label, StateHandler handler, const StatePausing &state_pausing=STATE_PAUSE_NEVER)
Adds an state value and associated label to the set of states.
Definition: state_model.cc:194
isc::dns::RRClass::ANY
static const RRClass & ANY()
Definition: rrclass.h:313
LOG_ERROR
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
Definition: macros.h:32
isc::d2::NameChangeTransaction::getRequestId
std::string getRequestId() const
Fetches the request id that identifies this transaction.
Definition: nc_trans.cc:408
isc::d2::NameChangeTransaction::getForwardDomain
DdnsDomainPtr & getForwardDomain()
Fetches the forward DdnsDomain.
Definition: nc_trans.cc:418
isc::d2::NameRemoveTransaction::~NameRemoveTransaction
virtual ~NameRemoveTransaction()
Destructor.
Definition: nc_remove.cc:42
isc::d2::D2CfgMgrPtr
boost::shared_ptr< D2CfgMgr > D2CfgMgrPtr
Defines a shared pointer to D2CfgMgr.
Definition: d2_cfg_mgr.h:297
isc::dns::RRType::A
static const RRType & A()
Definition: rrtype.h:677
isc::dns::RRClass::IN
static const RRClass & IN()
Definition: rrclass.h:325
isc::dns::RRsetPtr
boost::shared_ptr< AbstractRRset > RRsetPtr
A pointer-like type pointing to an RRset object.
Definition: rrset.h:47
isc::d2::NameChangeTransaction::SERVER_SELECTED_EVT
static const int SERVER_SELECTED_EVT
Issued when a server has been selected.
Definition: nc_trans.h:116
isc::d2::NameRemoveTransaction::buildRemoveFwdRRsRequest
void buildRemoveFwdRRsRequest()
Builds a DNS request to remove all forward DNS RRs for a FQDN.
Definition: nc_remove.cc:631
isc::d2::NameChangeTransaction::PROCESS_TRANS_FAILED_ST
static const int PROCESS_TRANS_FAILED_ST
State which processes an unsuccessful transaction conclusion.
Definition: nc_trans.h:105
isc::d2::NameChangeTransaction::setReverseChangeCompleted
void setReverseChangeCompleted(const bool value)
Sets the reverse change completion flag to the given value.
Definition: nc_trans.cc:306
isc::util::StateModel::transition
void transition(unsigned int state, unsigned int event)
Sets up the model to transition into given state with a given event.
Definition: state_model.cc:256
isc::d2::NameChangeTransaction::setDnsUpdateRequest
void setDnsUpdateRequest(D2UpdateMessagePtr &request)
Sets the update request packet to the given packet.
Definition: nc_trans.cc:275
isc::util::StateModel::doOnEntry
bool doOnEntry()
Checks if on entry flag is true.
Definition: state_model.cc:317
isc::d2::NameRemoveTransaction::processRemoveOkHandler
void processRemoveOkHandler()
State handler for PROCESS_TRANS_OK_ST.
Definition: nc_remove.cc:563
isc::d2::NameChangeTransaction::READY_ST
static const int READY_ST
State from which a transaction is started.
Definition: nc_trans.h:83
isc::d2::NameChangeTransaction::getReverseDomain
DdnsDomainPtr & getReverseDomain()
Fetches the reverse DdnsDomain.
Definition: nc_trans.cc:423
isc::dns::Rcode::NXRRSET
static const Rcode & NXRRSET()
A constant object for the NXRRSET Rcode (see Rcode::NXRRSET_CODE).
Definition: rcode.h:268
isc::dhcp_ddns::NameChangeRequestPtr
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
Definition: ncr_msg.h:212
isc::d2::NameChangeTransaction::verifyEvents
virtual void verifyEvents()
Validates the contents of the set of events.
Definition: nc_trans.cc:219
isc::d2::NameChangeTransaction::transactionOutcomeString
std::string transactionOutcomeString() const
Returns a string version of transaction outcome.
Definition: nc_trans.cc:147
isc::d2::NameRemoveTransaction::selectingFwdServerHandler
void selectingFwdServerHandler()
State handler for SELECTING_FWD_SERVER_ST.
Definition: nc_remove.cc:149
isc::dns::RRType::PTR
static const RRType & PTR()
Definition: rrtype.h:569
isc::dns::Rcode::NOERROR
static const Rcode & NOERROR()
A constant object for the NOERROR Rcode (see Rcode::NOERROR_CODE).
Definition: rcode.h:220
isc::d2::NameRemoveTransaction::verifyStates
virtual void verifyStates()
Validates the contents of the set of states.
Definition: nc_remove.cc:112
isc::d2::NameChangeTransaction::NO_MORE_SERVERS_EVT
static const int NO_MORE_SERVERS_EVT
Issued when there are no more servers from which to select.
Definition: nc_trans.h:125
isc::d2::NameRemoveTransaction::buildRemoveRevPtrsRequest
void buildRemoveRevPtrsRequest()
Builds a DNS request to remove a reverse DNS entry for a FQDN.
Definition: nc_remove.cc:679
isc::d2::NameRemoveTransaction::removingFwdRRsHandler
void removingFwdRRsHandler()
State handler for REMOVING_FWD_RRS_ST.
Definition: nc_remove.cc:288
isc::dhcp_ddns::CHG_REMOVE
@ CHG_REMOVE
Definition: ncr_msg.h:48
isc::dhcp_ddns::ST_FAILED
@ ST_FAILED
Definition: ncr_msg.h:56
isc::d2::NameChangeTransaction::addPtrRdata
void addPtrRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease FQDN to the given RRset.
Definition: nc_trans.cc:381
isc::d2::NameChangeTransaction::getDnsUpdateStatus
DNSClient::Status getDnsUpdateStatus() const
Fetches the most recent DNS update status.
Definition: nc_trans.cc:489
isc::d2::NameChangeTransaction::defineEvents
virtual void defineEvents()
Adds events defined by NameChangeTransaction to the event set.
Definition: nc_trans.cc:204
nc_remove.h
isc::d2::NameChangeTransaction::selectNextServer
bool selectNextServer()
Selects the next server in the current server list.
Definition: nc_trans.cc:448
isc::d2::NameRemoveTransaction::NameRemoveTransaction
NameRemoveTransaction(asiolink::IOServicePtr &io_service, dhcp_ddns::NameChangeRequestPtr &ncr, DdnsDomainPtr &forward_domain, DdnsDomainPtr &reverse_domain, D2CfgMgrPtr &cfg_mgr)
Event sent when replace attempt to fails with address not in use.
Definition: nc_remove.cc:29
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
isc::d2::NameChangeTransaction::sendUpdate
virtual void sendUpdate(const std::string &comment="")
Send the update request to the current server.
Definition: nc_trans.cc:169
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition: exceptions/exceptions.h:192
isc::d2::NameChangeTransaction::clearDnsUpdateRequest
void clearDnsUpdateRequest()
Destroys the current update request packet and resets update attempts count.
Definition: nc_trans.cc:280
isc::d2::NameRemoveTransaction::defineStates
virtual void defineStates()
Adds states defined by NameRemoveTransaction to the state set.
Definition: nc_remove.cc:74
isc::d2::NameRemoveTransaction::REMOVING_REV_PTRS_ST
static const int REMOVING_REV_PTRS_ST
State that attempts to remove reverse PTR records.
Definition: nc_remove.h:62
d2_cfg_mgr.h
isc::d2::NameChangeTransaction::SELECT_SERVER_EVT
static const int SELECT_SERVER_EVT
Issued when a server needs to be selected.
Definition: nc_trans.h:113
isc::d2::NameRemoveTransaction::buildRemoveFwdAddressRequest
void buildRemoveFwdAddressRequest()
Builds a DNS request to remove a forward DNS address for a FQDN.
Definition: nc_remove.cc:599
isc::dns::Rcode::getCode
uint16_t getCode() const
Returns the Rcode code value.
Definition: rcode.h:106
isc::dns::Name
The Name class encapsulates DNS names.
Definition: name.h:223
isc::d2::DNSClient::OTHER
@ OTHER
Other, unclassified error.
Definition: dns_client.h:65
isc::d2::NameChangeTransaction::UPDATE_OK_EVT
static const int UPDATE_OK_EVT
Issued when the attempted update successfully completed.
Definition: nc_trans.h:135
isc::dns::RRClass::NONE
static const RRClass & NONE()
Definition: rrclass.h:307
isc::d2::NameRemoveTransaction::removingFwdAddrsHandler
void removingFwdAddrsHandler()
State handler for REMOVING_FWD_ADDRS_ST.
Definition: nc_remove.cc:178
isc::d2::D2UpdateMessage::SECTION_PREREQUISITE
@ SECTION_PREREQUISITE
Definition: d2_update_message.h:119
isc::util::StateModel::getContextStr
std::string getContextStr() const
Convenience method which returns a string rendition of the current state and next event.
Definition: state_model.cc:390
isc::d2::DNSClient::INVALID_RESPONSE
@ INVALID_RESPONSE
Response received but invalid.
Definition: dns_client.h:64
isc::d2::NameChangeTransaction::addLeaseAddressRdata
void addLeaseAddressRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease address to the given RRset.
Definition: nc_trans.cc:339
isc::d2::NameChangeTransaction::prepNewRequest
virtual D2UpdateMessagePtr prepNewRequest(DdnsDomainPtr domain)
Creates a new DNS update request based on the given domain.
Definition: nc_trans.cc:316
isc::d2::DNSClient::SUCCESS
@ SUCCESS
Response received and is ok.
Definition: dns_client.h:61
isc::d2::NameChangeTransaction::getDnsUpdateResponse
const D2UpdateMessagePtr & getDnsUpdateResponse() const
Fetches the most recent DNS update response packet.
Definition: nc_trans.cc:494
isc::dns::RRType::DHCID
static const RRType & DHCID()
Definition: rrtype.h:629
isc::d2::NameChangeTransaction::initServerSelection
void initServerSelection(const DdnsDomainPtr &domain)
Initializes server selection from the given DDNS domain.
Definition: nc_trans.cc:428
isc::d2::NameRemoveTransaction::readyHandler
void readyHandler()
State handler for READY_ST.
Definition: nc_remove.cc:129
isc::d2::NameChangeTransaction::UPDATE_FAILED_EVT
static const int UPDATE_FAILED_EVT
Issued when the attempted update fails to complete.
Definition: nc_trans.h:141
isc::d2::NameRemoveTransaction::processRemoveFailedHandler
void processRemoveFailedHandler()
State handler for PROCESS_TRANS_FAILED_ST.
Definition: nc_remove.cc:580
isc::d2::NameChangeTransaction::PROCESS_TRANS_OK_ST
static const int PROCESS_TRANS_OK_ST
State which processes successful transaction conclusion.
Definition: nc_trans.h:102
isc::dns::RRTTL
The RRTTL class encapsulates TTLs used in DNS resource records.
Definition: rrttl.h:55
isc::d2::NameChangeTransaction
Embodies the "life-cycle" required to carry out a DDNS update.
Definition: nc_trans.h:77
isc::d2::D2UpdateMessage::SECTION_UPDATE
@ SECTION_UPDATE
Definition: d2_update_message.h:120
isc::dns::RRType::ANY
static const RRType & ANY()
Definition: rrtype.h:389
isc::d2::NameChangeTransaction::verifyStates
virtual void verifyStates()
Validates the contents of the set of states.
Definition: nc_trans.cc:242
isc::d2::NameRemoveTransaction::removingRevPtrsHandler
void removingRevPtrsHandler()
State handler for REMOVING_REV_PTRS_ST.
Definition: nc_remove.cc:448
isc::d2::DNSClient::TIMEOUT
@ TIMEOUT
No response, timeout.
Definition: dns_client.h:62
isc::d2::NameChangeTransaction::getCurrentServer
const DnsServerInfoPtr & getCurrentServer() const
Fetches the currently selected server.
Definition: nc_trans.cc:474
isc::d2::NameRemoveTransaction::verifyEvents
virtual void verifyEvents()
Validates the contents of the set of events.
Definition: nc_remove.cc:56
isc::dhcp_ddns::ST_COMPLETED
@ ST_COMPLETED
Definition: ncr_msg.h:55
isc::d2::NameChangeTransaction::getNcr
const dhcp_ddns::NameChangeRequestPtr & getNcr() const
Fetches the NameChangeRequest for this transaction.
Definition: nc_trans.cc:398
isc::d2::d2_to_dns_logger
isc::log::Logger d2_to_dns_logger("d2-to-dns")
Definition: d2_log.h:20
isc::util::StateModel::endModel
void endModel()
Conducts a normal transition to the end of the model.
Definition: state_model.cc:262
isc::d2::NameRemoveTransaction::selectingRevServerHandler
void selectingRevServerHandler()
State handler for SELECTING_REV_SERVER_ST.
Definition: nc_remove.cc:418
isc::dns::RRset
The RRset class is a concrete derived class of BasicRRset which contains a pointer to an additional R...
Definition: rrset.h:847
isc::d2::D2CfgMgr::reverseIpAddress
static std::string reverseIpAddress(const std::string &address)
Generate a reverse order string for the given IP address.
Definition: d2_cfg_mgr.cc:159
isc::d2::NameChangeTransaction::setNcrStatus
void setNcrStatus(const dhcp_ddns::NameChangeStatus &status)
Sets the status of the transaction's NameChangeRequest.
Definition: nc_trans.cc:479
isc::d2::NameRemoveTransaction::REMOVING_FWD_ADDRS_ST
static const int REMOVING_FWD_ADDRS_ST
State that attempts to remove specific forward address record.
Definition: nc_remove.h:56
isc::util::StateModel::getNextEvent
unsigned int getNextEvent() const
Fetches the model's next event.
Definition: state_model.cc:346
isc::util::StateModel::START_EVT
static const int START_EVT
Event issued to start the model execution.
Definition: state_model.h:292
isc::d2::NameRemoveTransaction::REMOVING_FWD_RRS_ST
static const int REMOVING_FWD_RRS_ST
State that attempts to remove any other forward RRs for the DHCID.
Definition: nc_remove.h:59
isc::d2::NameChangeTransaction::retryTransition
void retryTransition(const int fail_to_state)
Determines the state and next event based on update attempts.
Definition: nc_trans.cc:263
isc::d2::NameChangeTransaction::addDhcidRdata
void addDhcidRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease client's DHCID to the given RRset.
Definition: nc_trans.cc:361
isc::d2::NameChangeTransaction::defineStates
virtual void defineStates()
Adds states defined by NameChangeTransaction to the state set.
Definition: nc_trans.cc:234
isc::dns::RRType::AAAA
static const RRType & AAAA()
Definition: rrtype.h:467
isc::d2::NameChangeTransaction::getAddressRRType
const dns::RRType & getAddressRRType() const
Returns the DHCP data type for the lease address.
Definition: nc_trans.cc:514
isc::d2::NameRemoveTransactionError
Thrown if the NameRemoveTransaction encounters a general error.
Definition: nc_remove.h:18
isc::d2::NameChangeTransaction::getDnsUpdateRequest
const D2UpdateMessagePtr & getDnsUpdateRequest() const
Fetches the current DNS update request packet.
Definition: nc_trans.cc:484
isc::d2::NameChangeTransaction::SERVER_IO_ERROR_EVT
static const int SERVER_IO_ERROR_EVT
Issued when an update fails due to an IO error.
Definition: nc_trans.h:119
isc::d2::NameChangeTransaction::setForwardChangeCompleted
void setForwardChangeCompleted(const bool value)
Sets the forward change completion flag to the given value.
Definition: nc_trans.cc:301
isc::d2::DdnsDomainPtr
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
Definition: d2_config.h:586
isc::d2::D2UpdateMessagePtr
boost::shared_ptr< D2UpdateMessage > D2UpdateMessagePtr
Pointer to the DNS Update Message.
Definition: d2_update_message.h:70
isc::d2::NameChangeTransaction::SELECTING_FWD_SERVER_ST
static const int SELECTING_FWD_SERVER_ST
State in which forward DNS server selection is done.
Definition: nc_trans.h:91
isc::d2::NameChangeTransaction::SELECTING_REV_SERVER_ST
static const int SELECTING_REV_SERVER_ST
State in which reverse DNS server selection is done.
Definition: nc_trans.h:99
LOG_INFO
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
Definition: macros.h:20
d2_log.h
isc::d2::NameChangeTransaction::IO_COMPLETED_EVT
static const int IO_COMPLETED_EVT
Issued when a DNS update packet exchange has completed.
Definition: nc_trans.h:130
isc::dns::Rcode
DNS Response Codes (RCODEs) class.
Definition: rcode.h:40
isc::d2::NameRemoveTransaction::defineEvents
virtual void defineEvents()
Adds events defined by NameRemoveTransaction to the event set.
Definition: nc_remove.cc:46
isc::util::StateModel::getState
const StatePtr getState(unsigned int value)
Fetches the state referred to by value.
Definition: state_model.cc:211