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