Kea  1.9.9-git
nc_remove.cc
Go to the documentation of this file.
1 // Copyright (C) 2013-2020 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 <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  }
170  else {
171  // Server list is exhausted, so fail the transaction.
173  }
174 }
175 
176 void
178  if (doOnEntry()) {
179  // Clear the request on initial transition. This allows us to reuse
180  // the request on retries if necessary.
182  }
183 
184  switch(getNextEvent()) {
185  case SERVER_SELECTED_EVT:
186  if (!getDnsUpdateRequest()) {
187  // Request hasn't been constructed yet, so build it.
188  try {
190  } catch (const std::exception& ex) {
191  // While unlikely, the build might fail if we have invalid
192  // data. Should that be the case, we need to fail the
193  // transaction.
196  .arg(getRequestId())
197  .arg(getNcr()->toText())
198  .arg(ex.what());
200  break;
201  }
202  }
203 
204  // Call sendUpdate() to initiate the async send. Note it also sets
205  // next event to NOP_EVT.
206  sendUpdate("Forward A/AAAA Remove");
207  break;
208 
209  case IO_COMPLETED_EVT: {
210  switch (getDnsUpdateStatus()) {
211  case DNSClient::SUCCESS: {
212  // We successfully received a response packet from the server.
213  // The RCODE will be based on a value-dependent RRset search,
214  // see RFC 2136 section 3.2.3/3.2.4.
215  const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
216  if ((rcode == dns::Rcode::NOERROR()) ||
217  (rcode == dns::Rcode::NXRRSET())) {
218  // We were able to remove it or it wasn't there, now we
219  // need to remove any other RRs for this FQDN.
221  } else {
222  // Per RFC4703 any other value means cease.
223  // If we get not authorized should we try the next server in
224  // the list? @todo This needs some discussion perhaps.
226  .arg(getRequestId())
227  .arg(getCurrentServer()->toText())
228  .arg(getNcr()->getFqdn())
229  .arg(rcode.getCode());
231  }
232 
233  break;
234  }
235 
236  case DNSClient::TIMEOUT:
237  case DNSClient::OTHER:
238  // We couldn't send to the current server, log it and set up
239  // to select the next server for a retry.
240  // @note For now we treat OTHER as an IO error like TIMEOUT. It
241  // is not entirely clear if this is accurate.
243  .arg(getRequestId())
244  .arg(getNcr()->getFqdn())
245  .arg(getCurrentServer()->toText());
246 
248  break;
249 
251  // A response was received but was corrupt. Retry it like an IO
252  // error.
254  .arg(getRequestId())
255  .arg(getCurrentServer()->toText())
256  .arg(getNcr()->getFqdn());
257 
259  break;
260 
261  default:
262  // Any other value and we will fail this transaction, something
263  // bigger is wrong.
266  .arg(getRequestId())
267  .arg(getDnsUpdateStatus())
268  .arg(getNcr()->getFqdn())
269  .arg(getCurrentServer()->toText());
270 
272  break;
273  } // end switch on dns_status
274 
275  break;
276  } // end case IO_COMPLETE_EVT
277 
278  default:
279  // Event is invalid.
281  "Wrong event for context: " << getContextStr());
282  }
283 }
284 
285 
286 void
288  if (doOnEntry()) {
289  // Clear the request on initial transition. This allows us to reuse
290  // the request on retries if necessary.
292  }
293 
294  switch(getNextEvent()) {
295  case UPDATE_OK_EVT:
296  case SERVER_SELECTED_EVT:
297  if (!getDnsUpdateRequest()) {
298  // Request hasn't been constructed yet, so build it.
299  try {
301  } catch (const std::exception& ex) {
302  // While unlikely, the build might fail if we have invalid
303  // data. Should that be the case, we need to fail the
304  // transaction.
307  .arg(getRequestId())
308  .arg(getNcr()->toText())
309  .arg(ex.what());
311  break;
312  }
313  }
314 
315  // Call sendUpdate() to initiate the async send. Note it also sets
316  // next event to NOP_EVT.
317  sendUpdate("Forward RR Remove");
318  break;
319 
320  case IO_COMPLETED_EVT: {
321  switch (getDnsUpdateStatus()) {
322  case DNSClient::SUCCESS: {
323  // We successfully received a response packet from the server.
324  // The RCODE will be based on a value-dependent RRset search,
325  // see RFC 2136 section 3.2.3/3.2.4.
326  const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
327  if ((rcode == dns::Rcode::NOERROR()) ||
328  (rcode == dns::Rcode::NXRRSET())) {
329  // We were able to remove them or they were not there (
330  // Rcode of NXRRSET means there are no matching RRsets).
331  // In either case, we consider it success and mark it as done.
333 
334  // If request calls for reverse update then do that next,
335  // otherwise we can process ok.
336  if (getReverseDomain()) {
338  } else {
340  }
341  } else {
342  // Per RFC4703 any other value means cease.
343  // If we get not authorized should try the next server in
344  // the list? @todo This needs some discussion perhaps.
346  .arg(getRequestId())
347  .arg(getCurrentServer()->toText())
348  .arg(getNcr()->getFqdn())
349  .arg(rcode.getCode());
351  }
352 
353  break;
354  }
355 
356  case DNSClient::TIMEOUT:
357  case DNSClient::OTHER:
358  // We couldn't send to the current server, log it and set up
359  // to select the next server for a retry.
360  // @note For now we treat OTHER as an IO error like TIMEOUT. It
361  // is not entirely clear if this is accurate.
363  .arg(getRequestId())
364  .arg(getNcr()->getFqdn())
365  .arg(getCurrentServer()->toText());
366 
367  // @note If we exhaust the IO retries for the current server
368  // due to IO failures, we will abort the remaining updates.
369  // The rational is that we are only in this state, if the remove
370  // of the forward address RR succeeded (removingFwdAddrsHandler)
371  // on the current server. Therefore we should not attempt another
372  // removal on a different server. This is perhaps a point
373  // for discussion.
374  // @todo Should we go ahead with the reverse remove?
376  break;
377 
379  // A response was received but was corrupt. Retry it like an IO
380  // error.
382  .arg(getRequestId())
383  .arg(getCurrentServer()->toText())
384  .arg(getNcr()->getFqdn());
385 
386  // If we are out of retries on this server abandon the transaction.
387  // (Same logic as the case for TIMEOUT above).
389  break;
390 
391  default:
392  // Any other value and we will fail this transaction, something
393  // bigger is wrong.
396  .arg(getRequestId())
397  .arg(getDnsUpdateStatus())
398  .arg(getNcr()->getFqdn())
399  .arg(getCurrentServer()->toText());
400 
402  break;
403  } // end switch on dns_status
404 
405  break;
406  } // end case IO_COMPLETE_EVT
407 
408  default:
409  // Event is invalid.
411  "Wrong event for context: " << getContextStr());
412  }
413 }
414 
415 
416 void
418  switch(getNextEvent()) {
419  case SELECT_SERVER_EVT:
420  // First time through for this transaction, so initialize server
421  // selection.
423  break;
424  case SERVER_IO_ERROR_EVT:
425  // We failed to communicate with current server. Attempt to select
426  // another one below.
427  break;
428  default:
429  // Event is invalid.
431  "Wrong event for context: " << getContextStr());
432  }
433 
434  // Select the next server from the list of forward servers.
435  if (selectNextServer()) {
436  // We have a server to try.
438  }
439  else {
440  // Server list is exhausted, so fail the transaction.
442  }
443 }
444 
445 
446 void
448  if (doOnEntry()) {
449  // Clear the request on initial transition. This allows us to reuse
450  // the request on retries if necessary.
452  }
453 
454  switch(getNextEvent()) {
455  case SERVER_SELECTED_EVT:
456  if (!getDnsUpdateRequest()) {
457  // Request hasn't been constructed yet, so build it.
458  try {
460  } catch (const std::exception& ex) {
461  // While unlikely, the build might fail if we have invalid
462  // data. Should that be the case, we need to fail the
463  // transaction.
465  .arg(getRequestId())
466  .arg(getNcr()->toText())
467  .arg(ex.what());
469  break;
470  }
471  }
472 
473  // Call sendUpdate() to initiate the async send. Note it also sets
474  // next event to NOP_EVT.
475  sendUpdate("Reverse Remove");
476  break;
477 
478  case IO_COMPLETED_EVT: {
479  switch (getDnsUpdateStatus()) {
480  case DNSClient::SUCCESS: {
481  // We successfully received a response packet from the server.
482  // The RCODE will be based on a value-dependent RRset search,
483  // see RFC 2136 section 3.2.3/3.2.4.
484  const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
485  if ((rcode == dns::Rcode::NOERROR()) ||
486  (rcode == dns::Rcode::NXRRSET())) {
487  // We were able to remove the reverse mapping or they were
488  // not there (Rcode of NXRRSET means there are no matching
489  // RRsets). In either case, mark it as done.
492  } else {
493  // Per RFC4703 any other value means cease.
494  // If we get not authorized should try the next server in
495  // the list? @todo This needs some discussion perhaps.
497  .arg(getRequestId())
498  .arg(getCurrentServer()->toText())
499  .arg(getNcr()->getFqdn())
500  .arg(rcode.getCode());
502  }
503 
504  break;
505  }
506 
507  case DNSClient::TIMEOUT:
508  case DNSClient::OTHER:
509  // We couldn't send to the current server, log it and set up
510  // to select the next server for a retry.
511  // @note For now we treat OTHER as an IO error like TIMEOUT. It
512  // is not entirely clear if this is accurate.
514  .arg(getRequestId())
515  .arg(getNcr()->getFqdn())
516  .arg(getCurrentServer()->toText());
517 
518  // If we are out of retries on this server, we go back and start
519  // all over on a new server.
521  break;
522 
524  // A response was received but was corrupt. Retry it like an IO
525  // error.
527  .arg(getRequestId())
528  .arg(getCurrentServer()->toText())
529  .arg(getNcr()->getFqdn());
530 
531  // If we are out of retries on this server, we go back and start
532  // all over on a new server.
534  break;
535 
536  default:
537  // Any other value and we will fail this transaction, something
538  // bigger is wrong.
541  .arg(getRequestId())
542  .arg(getDnsUpdateStatus())
543  .arg(getNcr()->getFqdn())
544  .arg(getCurrentServer()->toText());
545 
547  break;
548  } // end switch on dns_status
549 
550  break;
551  } // end case IO_COMPLETE_EVT
552 
553  default:
554  // Event is invalid.
556  "Wrong event for context: " << getContextStr());
557  }
558 }
559 
560 
561 void
563  switch(getNextEvent()) {
564  case UPDATE_OK_EVT:
566  .arg(getRequestId())
567  .arg(getNcr()->toText());
569  endModel();
570  break;
571  default:
572  // Event is invalid.
574  "Wrong event for context: " << getContextStr());
575  }
576 }
577 
578 void
580  switch(getNextEvent()) {
581  case UPDATE_FAILED_EVT:
582  case NO_MORE_SERVERS_EVT:
583  case SERVER_IO_ERROR_EVT:
586  .arg(getRequestId())
587  .arg(transactionOutcomeString());
588  endModel();
589  break;
590  default:
591  // Event is invalid.
593  "Wrong event for context: " << getContextStr());
594  }
595 }
596 
597 void
599  // Construct an empty request.
601 
602  // Content on this request is based on RFC 4703, section 5.5, paragraph 4.
603  // Construct dns::Name from NCR fqdn.
604  dns::Name fqdn(dns::Name(getNcr()->getFqdn()));
605  // First build the Prerequisite Section
606 
607  // Create an DHCID matches prerequisite RR and add it to the
608  // pre-requisite section
609  // Based on RFC 2136, section 2.4.2.
610  dns::RRsetPtr prereq(new dns::RRset(fqdn, dns::RRClass::IN(),
612  addDhcidRdata(prereq);
613  request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
614 
615  // Next build the Update Section
616 
617  // Create the FQDN/IP 'delete' RR and add it to the update section.
618  // Add the RR to update section.
619  // Based on 2136 section 2.5.4
620  dns::RRsetPtr update(new dns::RRset(fqdn, dns::RRClass::NONE(),
622  addLeaseAddressRdata(update);
623  request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
624 
625  // Set the transaction's update request to the new request.
626  setDnsUpdateRequest(request);
627 }
628 
629 void
631  // Construct an empty request.
633 
634  // Construct dns::Name from NCR fqdn.
635  dns::Name fqdn(dns::Name(getNcr()->getFqdn()));
636 
637  // Content on this request is based on RFC 4703, section 5.5, paragraph 5.
638  // First build the Prerequisite Section.
639 
640  // Now create an DHCID matches prerequisite RR.
641  // Set the RR's RData to DHCID.
642  // Add it to the pre-requisite section.
643  // Based on RFC 2136, section 2.4.2.
644  dns::RRsetPtr prereq(new dns::RRset(fqdn, dns::RRClass::IN(),
646  addDhcidRdata(prereq);
647  request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
648 
649  // Create an assertion that there are no A RRs for the FQDN.
650  // Add it to the pre-reqs.
651  // Based on RFC 2136, section 2.4.3.
652  prereq.reset(new dns::RRset(fqdn, dns::RRClass::NONE(),
653  dns::RRType::A(), dns::RRTTL(0)));
654  request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
655 
656  // Create an assertion that there are no A RRs for the FQDN.
657  // Add it to the pre-reqs.
658  // Based on RFC 2136, section 2.4.3.
659  prereq.reset(new dns::RRset(fqdn, dns::RRClass::NONE(),
661  request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
662 
663  // Next build the Update Section.
664 
665  // Create the 'delete' of all RRs for FQDN.
666  // Set the message RData to lease address.
667  // Add the RR to update section.
668  // Based on RFC 2136, section 2.5.3.
669  dns::RRsetPtr update(new dns::RRset(fqdn, dns::RRClass::ANY(),
671  request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
672 
673  // Set the transaction's update request to the new request.
674  setDnsUpdateRequest(request);
675 }
676 
677 void
679  // Construct an empty request.
681 
682  // Create the reverse IP address "FQDN".
683  std::string rev_addr = D2CfgMgr::reverseIpAddress(getNcr()->getIpAddress());
684  dns::Name rev_ip(rev_addr);
685 
686  // Content on this request is based on RFC 4703, section 5.5, paragraph 2.
687  // First build the Prerequisite Section.
688  // (Note that per RFC 4703, section 5.4, there is no need to validate
689  // DHCID RR for PTR entries.)
690 
691  // Create an assertion that the PTRDNAME in the PTR record matches the
692  // client's FQDN for the address that was released.
693  // Based on RFC 2136, section 3.2.3
694  dns::RRsetPtr prereq(new dns::RRset(rev_ip, dns::RRClass::IN(),
696  addPtrRdata(prereq);
697  request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
698 
699  // Now, build the Update section.
700 
701  // Create a delete of any RRs for the FQDN and add it to update section.
702  // Based on RFC 2136, section 3.4.2.3
703  dns::RRsetPtr update(new dns::RRset(rev_ip, dns::RRClass::ANY(),
705  request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
706 
707  // Set the transaction's update request to the new request.
708  setDnsUpdateRequest(request);
709 }
710 
711 } // namespace isc::d2
712 } // 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:316
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:33
virtual void sendUpdate(const std::string &comment="")
Send the update request to the current server.
Definition: nc_trans.cc:169
void processRemoveFailedHandler()
State handler for PROCESS_TRANS_FAILED_ST.
Definition: nc_remove.cc:579
static const RRType & DHCID()
Definition: rrtype.h:503
const isc::log::MessageID DHCP_DDNS_FORWARD_REMOVE_RRS_REJECTED
Definition: d2_messages.h:34
void buildRemoveFwdAddressRequest()
Builds a DNS request to remove a forward DNS address for a FQDN.
Definition: nc_remove.cc:598
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
const isc::log::MessageID DHCP_DDNS_FORWARD_REMOVE_ADDRS_BUILD_FAILURE
Definition: d2_messages.h:27
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:591
static const Rcode & NOERROR()
A constant object for the NOERROR Rcode (see Rcode::NOERROR_CODE).
Definition: rcode.h:220
boost::shared_ptr< D2UpdateMessage > D2UpdateMessagePtr
Pointer to the DNS Update Message.
void selectingRevServerHandler()
State handler for SELECTING_REV_SERVER_ST.
Definition: nc_remove.cc:417
void setNcrStatus(const dhcp_ddns::NameChangeStatus &status)
Sets the status of the transaction's NameChangeRequest.
Definition: nc_trans.cc:479
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:68
const isc::log::MessageID DHCP_DDNS_FORWARD_REMOVE_ADDRS_BAD_DNSCLIENT_STATUS
Definition: d2_messages.h:26
#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:62
static const int SELECTING_FWD_SERVER_ST
State in which forward DNS server selection is done.
Definition: nc_trans.h:91
std::string transactionOutcomeString() const
Returns a string version of transaction outcome.
Definition: nc_trans.cc:147
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
const dhcp_ddns::NameChangeRequestPtr & getNcr() const
Fetches the NameChangeRequest for this transaction.
Definition: nc_trans.cc:398
static const int IO_COMPLETED_EVT
Issued when a DNS update packet exchange has completed.
Definition: nc_trans.h:130
Other, unclassified error.
Definition: dns_client.h:65
#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:301
virtual ~NameRemoveTransaction()
Destructor.
Definition: nc_remove.cc:41
void addDhcidRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease client's DHCID to the given RRset.
Definition: nc_trans.cc:361
std::string getRequestId() const
Fetches the request id that identifies this transaction.
Definition: nc_trans.cc:408
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:32
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:263
const isc::log::MessageID DHCP_DDNS_FORWARD_REMOVE_RRS_RESP_CORRUPT
Definition: d2_messages.h:35
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:31
const D2UpdateMessagePtr & getDnsUpdateRequest() const
Fetches the current DNS update request packet.
Definition: nc_trans.cc:484
const isc::log::MessageID DHCP_DDNS_REVERSE_REMOVE_BUILD_FAILURE
Definition: d2_messages.h:67
boost::shared_ptr< D2CfgMgr > D2CfgMgrPtr
Defines a shared pointer to D2CfgMgr.
Definition: d2_cfg_mgr.h:334
DNSClient::Status getDnsUpdateStatus() const
Fetches the most recent DNS update status.
Definition: nc_trans.cc:489
virtual void defineStates()
Adds states defined by NameChangeTransaction to the state set.
Definition: nc_trans.cc:234
This file defines the class NameRemoveTransaction.
The RRTTL class encapsulates TTLs used in DNS resource records.
Definition: rrttl.h:55
void setReverseChangeCompleted(const bool value)
Sets the reverse change completion flag to the given value.
Definition: nc_trans.cc:306
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:66
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:61
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
std::string getContextStr() const
Convenience method which returns a string rendition of the current state and next event...
Definition: state_model.cc:443
DdnsDomainPtr & getForwardDomain()
Fetches the forward DdnsDomain.
Definition: nc_trans.cc:418
const isc::log::MessageID DHCP_DDNS_REVERSE_REMOVE_RESP_CORRUPT
Definition: d2_messages.h:70
Defines the logger used by the top-level component of kea-dhcp-ddns.
void addPtrRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease FQDN to the given RRset.
Definition: nc_trans.cc:381
virtual void verifyStates()
Validates the contents of the set of states.
Definition: nc_remove.cc:111
const D2UpdateMessagePtr & getDnsUpdateResponse() const
Fetches the most recent DNS update response packet.
Definition: nc_trans.cc:494
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:562
void buildRemoveFwdRRsRequest()
Builds a DNS request to remove all forward DNS RRs for a FQDN.
Definition: nc_remove.cc:630
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
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:64
const isc::log::MessageID DHCP_DDNS_REMOVE_SUCCEEDED
Definition: d2_messages.h:64
const isc::log::MessageID DHCP_DDNS_FORWARD_REMOVE_ADDRS_RESP_CORRUPT
Definition: d2_messages.h:30
void buildRemoveRevPtrsRequest()
Builds a DNS request to remove a reverse DNS entry for a FQDN.
Definition: nc_remove.cc:678
static const int PROCESS_TRANS_FAILED_ST
State which processes an unsuccessful transaction conclusion.
Definition: nc_trans.h:105
const DnsServerInfoPtr & getCurrentServer() const
Fetches the currently selected server.
Definition: nc_trans.cc:474
const isc::log::MessageID DHCP_DDNS_REMOVE_FAILED
Definition: d2_messages.h:63
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 and resets update attempts count.
Definition: nc_trans.cc:280
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:275
static const RRClass & NONE()
Definition: rrclass.h:325
void removingFwdRRsHandler()
State handler for REMOVING_FWD_RRS_ST.
Definition: nc_remove.cc:287
const isc::log::MessageID DHCP_DDNS_REVERSE_REMOVE_REJECTED
Definition: d2_messages.h:69
virtual void defineEvents()
Adds events defined by NameChangeTransaction to the event set.
Definition: nc_trans.cc:204
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
const dns::RRType & getAddressRRType() const
Returns the DHCP data type for the lease address.
Definition: nc_trans.cc:514
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:423
const isc::log::MessageID DHCP_DDNS_FORWARD_REMOVE_ADDRS_REJECTED
Definition: d2_messages.h:29
unsigned int getNextEvent() const
Fetches the model's next event.
Definition: state_model.cc:373
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
uint16_t getCode() const
Returns the Rcode code value.
Definition: rcode.h:106
virtual void verifyEvents()
Validates the contents of the set of events.
Definition: nc_trans.cc:219
void addLeaseAddressRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease address to the given RRset.
Definition: nc_trans.cc:339
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:177
void initServerSelection(const DdnsDomainPtr &domain)
Initializes server selection from the given DDNS domain.
Definition: nc_trans.cc:428
void readyHandler()
State handler for READY_ST.
Definition: nc_remove.cc:128
bool selectNextServer()
Selects the next server in the current server list.
Definition: nc_trans.cc:448
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:242
const isc::log::MessageID DHCP_DDNS_FORWARD_REMOVE_ADDRS_IO_ERROR
Definition: d2_messages.h:28
void removingRevPtrsHandler()
State handler for REMOVING_REV_PTRS_ST.
Definition: nc_remove.cc:447