Kea  2.1.7-git
nc_add.cc
Go to the documentation of this file.
1 // Copyright (C) 2013-2022 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_add.h>
10 #include <d2srv/d2_cfg_mgr.h>
11 #include <d2srv/d2_log.h>
12 
13 #include <util/buffer.h>
14 #include <dns/rdataclass.h>
15 
16 #include <functional>
17 
18 namespace isc {
19 namespace d2 {
20 
21 // NameAddTransaction states
25 
26 // NameAddTransaction events
29 
33  DdnsDomainPtr& forward_domain,
34  DdnsDomainPtr& reverse_domain,
35  D2CfgMgrPtr& cfg_mgr)
36  : NameChangeTransaction(io_service, ncr, forward_domain, reverse_domain,
37  cfg_mgr) {
38  if (ncr->getChangeType() != isc::dhcp_ddns::CHG_ADD) {
40  "NameAddTransaction, request type must be CHG_ADD");
41  }
42 }
43 
45 }
46 
47 void
49  // Call superclass impl first.
51 
52  // Define NameAddTransaction events.
53  defineEvent(FQDN_IN_USE_EVT, "FQDN_IN_USE_EVT");
54  defineEvent(FQDN_NOT_IN_USE_EVT, "FQDN_NOT_IN_USE_EVT");
55 }
56 
57 void
59  // Call superclass implementation first to verify its events. These are
60  // events common to all transactions, and they must be defined.
61  // SELECT_SERVER_EVT
62  // SERVER_SELECTED_EVT
63  // SERVER_IO_ERROR_EVT
64  // NO_MORE_SERVERS_EVT
65  // IO_COMPLETED_EVT
66  // UPDATE_OK_EVT
67  // UPDATE_FAILED_EVT
69 
70  // Verify NameAddTransaction events by attempting to fetch them.
73 }
74 
75 void
77  // Call superclass impl first.
79 
80  // Define NameAddTransaction states.
81  defineState(READY_ST, "READY_ST",
82  std::bind(&NameAddTransaction::readyHandler, this));
83 
84  defineState(SELECTING_FWD_SERVER_ST, "SELECTING_FWD_SERVER_ST",
86 
87  defineState(SELECTING_REV_SERVER_ST, "SELECTING_REV_SERVER_ST",
89 
90  defineState(ADDING_FWD_ADDRS_ST, "ADDING_FWD_ADDRS_ST",
92 
93  defineState(REPLACING_FWD_ADDRS_ST, "REPLACING_FWD_ADDRS_ST",
95 
96  defineState(REPLACING_REV_PTRS_ST, "REPLACING_REV_PTRS_ST",
98 
99  defineState(PROCESS_TRANS_OK_ST, "PROCESS_TRANS_OK_ST",
100  std::bind(&NameAddTransaction::processAddOkHandler, this));
101 
102  defineState(PROCESS_TRANS_FAILED_ST, "PROCESS_TRANS_FAILED_ST",
104 }
105 
106 void
108  // Call superclass implementation first to verify its states. These are
109  // states common to all transactions, and they must be defined.
110  // READY_ST
111  // SELECTING_FWD_SERVER_ST
112  // SELECTING_REV_SERVER_ST
113  // PROCESS_TRANS_OK_ST
114  // PROCESS_TRANS_FAILED_ST
116 
117  // Verify NameAddTransaction states by attempting to fetch them.
121 }
122 
123 void
125  switch(getNextEvent()) {
126  case START_EVT:
127  if (getForwardDomain()) {
128  // Request includes a forward change, do that first.
130  } else {
131  // Reverse change only, transition accordingly.
133  }
134 
135  break;
136  default:
137  // Event is invalid.
139  "Wrong event for context: " << getContextStr());
140  }
141 }
142 
143 void
145  switch(getNextEvent()) {
146  case SELECT_SERVER_EVT:
147  // First time through for this transaction, so initialize server
148  // selection.
150  break;
151  case SERVER_IO_ERROR_EVT:
152  // We failed to communicate with current server. Attempt to select
153  // another one below.
154  break;
155  default:
156  // Event is invalid.
158  "Wrong event for context: " << getContextStr());
159  }
160 
161  // Select the next server from the list of forward servers.
162  if (selectNextServer()) {
163  // We have a server to try.
165  } else {
166  // Server list is exhausted, so fail the transaction.
168  }
169 }
170 
171 void
173  if (doOnEntry()) {
174  // Clear the update attempts count on initial transition.
176  }
177 
178  switch(getNextEvent()) {
179  case SERVER_SELECTED_EVT:
180  try {
183  } catch (const std::exception& ex) {
184  // While unlikely, the build might fail if we have invalid
185  // data. Should that be the case, we need to fail the
186  // transaction.
188  .arg(getRequestId())
189  .arg(getNcr()->toText())
190  .arg(ex.what());
192  break;
193  }
194 
195  // Call sendUpdate() to initiate the async send. Note it also sets
196  // next event to NOP_EVT.
197  sendUpdate("Forward Add");
198  break;
199 
200  case IO_COMPLETED_EVT: {
201  switch (getDnsUpdateStatus()) {
202  case DNSClient::SUCCESS: {
203  // We successfully received a response packet from the server.
204  const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
205  if (rcode == dns::Rcode::NOERROR()) {
206  // We were able to add it. Mark it as done.
208 
209  // If request calls for reverse update then do that next,
210  // otherwise we can process ok.
211  if (getReverseDomain()) {
213  } else {
215  }
216  } else if (rcode == dns::Rcode::YXDOMAIN()) {
217  // FQDN is in use so we need to attempt to replace
218  // forward address.
220  } else {
221  // Per RFC4703 any other value means cease.
222  // If we get not authorized should we try the next server in
223  // the list? @todo This needs some discussion perhaps.
225  .arg(getRequestId())
226  .arg(getCurrentServer()->toText())
227  .arg(getNcr()->getFqdn())
228  .arg(rcode.getCode());
230  }
231 
232  break;
233  }
234 
235  case DNSClient::TIMEOUT:
236  case DNSClient::OTHER:
237  // We couldn't send to the current server, log it and set up
238  // to select the next server for a retry.
239  // @note For now we treat OTHER as an IO error like TIMEOUT. It
240  // is not entirely clear if this is accurate.
242  .arg(getRequestId())
243  .arg(getNcr()->getFqdn())
244  .arg(getCurrentServer()->toText());
245 
247  break;
248 
250  // A response was received but was corrupt. Retry it like an IO
251  // error.
253  .arg(getRequestId())
254  .arg(getCurrentServer()->toText())
255  .arg(getNcr()->getFqdn());
256 
258  break;
259 
260  default:
261  // Any other value and we will fail this transaction, something
262  // bigger is wrong.
264  .arg(getRequestId())
265  .arg(getDnsUpdateStatus())
266  .arg(getNcr()->getFqdn())
267  .arg(getCurrentServer()->toText());
268 
270  break;
271  } // end switch on dns_status
272 
273  break;
274  } // end case IO_COMPLETE_EVT
275 
276  default:
277  // Event is invalid.
279  "Wrong event for context: " << getContextStr());
280  }
281 }
282 
283 void
285  if (doOnEntry()) {
286  // Clear the update attempts count on initial transition.
288  }
289 
290  switch(getNextEvent()) {
291  case FQDN_IN_USE_EVT:
292  case SERVER_SELECTED_EVT:
293  try {
296  } catch (const std::exception& ex) {
297  // While unlikely, the build might fail if we have invalid
298  // data. Should that be the case, we need to fail the
299  // transaction.
301  .arg(getRequestId())
302  .arg(getNcr()->toText())
303  .arg(ex.what());
305  break;
306  }
307 
308  // Call sendUpdate() to initiate the async send. Note it also sets
309  // next event to NOP_EVT.
310  sendUpdate("Forward Replace");
311  break;
312 
313  case IO_COMPLETED_EVT: {
314  switch (getDnsUpdateStatus()) {
315  case DNSClient::SUCCESS: {
316  // We successfully received a response packet from the server.
317  const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
318  if (rcode == dns::Rcode::NOERROR()) {
319  // We were able to replace the forward mapping. Mark it as done.
321 
322  // If request calls for reverse update then do that next,
323  // otherwise we can process ok.
324  if (getReverseDomain()) {
326  } else {
328  }
329  } else if (rcode == dns::Rcode::NXDOMAIN()) {
330  // FQDN is NOT in use so go back and do the forward add address.
331  // Covers the case that it was there when we tried to add it,
332  // but has since been removed per RFC 4703.
334  } else {
335  // Per RFC4703 any other value means cease.
336  // If we get not authorized should try the next server in
337  // the list? @todo This needs some discussion perhaps.
339  .arg(getRequestId())
340  .arg(getCurrentServer()->toText())
341  .arg(getNcr()->getFqdn())
342  .arg(rcode.getCode());
344  }
345 
346  break;
347  }
348 
349  case DNSClient::TIMEOUT:
350  case DNSClient::OTHER:
351  // We couldn't send to the current server, log it and set up
352  // to select the next server for a retry.
353  // @note For now we treat OTHER as an IO error like TIMEOUT. It
354  // is not entirely clear if this is accurate.
356  .arg(getRequestId())
357  .arg(getNcr()->getFqdn())
358  .arg(getCurrentServer()->toText());
359 
360  // If we are out of retries on this server, we go back and start
361  // all over on a new server.
363  break;
364 
366  // A response was received but was corrupt. Retry it like an IO
367  // error.
369  .arg(getRequestId())
370  .arg(getCurrentServer()->toText())
371  .arg(getNcr()->getFqdn());
372 
373  // If we are out of retries on this server, we go back and start
374  // all over on a new server.
376  break;
377 
378  default:
379  // Any other value and we will fail this transaction, something
380  // bigger is wrong.
383  .arg(getRequestId())
384  .arg(getDnsUpdateStatus())
385  .arg(getNcr()->getFqdn())
386  .arg(getCurrentServer()->toText());
387 
389  break;
390  } // end switch on dns_status
391 
392  break;
393  } // end case IO_COMPLETE_EVT
394 
395  default:
396  // Event is invalid.
398  "Wrong event for context: " << getContextStr());
399  }
400 }
401 
402 void
404  switch(getNextEvent()) {
405  case SELECT_SERVER_EVT:
406  // First time through for this transaction, so initialize server
407  // selection.
409  break;
410  case SERVER_IO_ERROR_EVT:
411  // We failed to communicate with current server. Attempt to select
412  // another one below.
413  break;
414  default:
415  // Event is invalid.
417  "Wrong event for context: " << getContextStr());
418  }
419 
420  // Select the next server from the list of forward servers.
421  if (selectNextServer()) {
422  // We have a server to try.
424  } else {
425  // Server list is exhausted, so fail the transaction.
427  }
428 }
429 
430 
431 void
433  if (doOnEntry()) {
434  // Clear the update attempts count on initial transition.
436  }
437 
438  switch(getNextEvent()) {
439  case SERVER_SELECTED_EVT:
440  try {
443  } catch (const std::exception& ex) {
444  // While unlikely, the build might fail if we have invalid
445  // data. Should that be the case, we need to fail the
446  // transaction.
448  .arg(getRequestId())
449  .arg(getNcr()->toText())
450  .arg(ex.what());
452  break;
453  }
454 
455  // Call sendUpdate() to initiate the async send. Note it also sets
456  // next event to NOP_EVT.
457  sendUpdate("Reverse Replace");
458  break;
459 
460  case IO_COMPLETED_EVT: {
461  switch (getDnsUpdateStatus()) {
462  case DNSClient::SUCCESS: {
463  // We successfully received a response packet from the server.
464  const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
465  if (rcode == dns::Rcode::NOERROR()) {
466  // We were able to update the reverse mapping. Mark it as done.
469  } else {
470  // Per RFC4703 any other value means cease.
471  // If we get not authorized should try the next server in
472  // the list? @todo This needs some discussion perhaps.
474  .arg(getRequestId())
475  .arg(getCurrentServer()->toText())
476  .arg(getNcr()->getFqdn())
477  .arg(rcode.getCode());
479  }
480 
481  break;
482  }
483 
484  case DNSClient::TIMEOUT:
485  case DNSClient::OTHER:
486  // We couldn't send to the current server, log it and set up
487  // to select the next server for a retry.
488  // @note For now we treat OTHER as an IO error like TIMEOUT. It
489  // is not entirely clear if this is accurate.
491  .arg(getRequestId())
492  .arg(getNcr()->getFqdn())
493  .arg(getCurrentServer()->toText());
494 
495  // If we are out of retries on this server, we go back and start
496  // all over on a new server.
498  break;
499 
501  // A response was received but was corrupt. Retry it like an IO
502  // error.
504  .arg(getRequestId())
505  .arg(getCurrentServer()->toText())
506  .arg(getNcr()->getFqdn());
507 
508  // If we are out of retries on this server, we go back and start
509  // all over on a new server.
511  break;
512 
513  default:
514  // Any other value and we will fail this transaction, something
515  // bigger is wrong.
518  .arg(getRequestId())
519  .arg(getDnsUpdateStatus())
520  .arg(getNcr()->getFqdn())
521  .arg(getCurrentServer()->toText());
522 
524  break;
525  } // end switch on dns_status
526 
527  break;
528  } // end case IO_COMPLETE_EVT
529 
530  default:
531  // Event is invalid.
533  "Wrong event for context: " << getContextStr());
534  }
535 }
536 
537 void
539  switch(getNextEvent()) {
540  case UPDATE_OK_EVT:
542  .arg(getRequestId())
543  .arg(getNcr()->toText());
545  endModel();
546  break;
547  default:
548  // Event is invalid.
550  "Wrong event for context: " << getContextStr());
551  }
552 }
553 
554 void
556  switch(getNextEvent()) {
557  case UPDATE_FAILED_EVT:
558  case NO_MORE_SERVERS_EVT:
561  .arg(getRequestId())
562  .arg(transactionOutcomeString());
563  endModel();
564  break;
565  default:
566  // Event is invalid.
568  "Wrong event for context: " << getContextStr());
569  }
570 }
571 
572 void
574  // Construct an empty request.
576 
577  // Construct dns::Name from NCR fqdn.
578  dns::Name fqdn(dns::Name(getNcr()->getFqdn()));
579 
580  // Content on this request is based on RFC 4703, section 5.3.1
581  // First build the Prerequisite Section.
582 
583  // Create 'FQDN Is Not In Use' prerequisite and add it to the
584  // prerequisite section.
585  // Based on RFC 2136, section 2.4.5
586  dns::RRsetPtr prereq(new dns::RRset(fqdn, dns::RRClass::NONE(),
588  request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
589 
590  // Next build the Update Section.
591 
592  // Create the TTL based on lease length.
593  dns::RRTTL lease_ttl(getNcr()->getLeaseLength());
594 
595  // Create the FQDN/IP 'add' RR and add it to the to update section.
596  // Based on RFC 2136, section 2.5.1
597  dns::RRsetPtr update(new dns::RRset(fqdn, dns::RRClass::IN(),
598  getAddressRRType(), lease_ttl));
599 
600  addLeaseAddressRdata(update);
601  request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
602 
603  // Now create the FQDN/DHCID 'add' RR and add it to update section.
604  // Based on RFC 2136, section 2.5.1
605  update.reset(new dns::RRset(fqdn, dns::RRClass::IN(),
606  dns::RRType::DHCID(), lease_ttl));
607  addDhcidRdata(update);
608  request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
609 
610  // Set the transaction's update request to the new request.
611  setDnsUpdateRequest(request);
612 }
613 
614 void
616  // Construct an empty request.
618 
619  // Construct dns::Name from NCR fqdn.
620  dns::Name fqdn(dns::Name(getNcr()->getFqdn()));
621 
622  // Content on this request is based on RFC 4703, section 5.3.2
623  // First build the Prerequisite Section.
624 
625  // Create an 'FQDN Is In Use' prerequisite and add it to the
626  // pre-requisite section.
627  // Based on RFC 2136, section 2.4.4
628  dns::RRsetPtr prereq(new dns::RRset(fqdn, dns::RRClass::ANY(),
630  request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
631 
632  // Create an DHCID matches prerequisite RR and add it to the
633  // pre-requisite section.
634  // Based on RFC 2136, section 2.4.2.
635  prereq.reset(new dns::RRset(fqdn, dns::RRClass::IN(),
637  addDhcidRdata(prereq);
638  request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
639 
640  // Next build the Update Section.
641 
642  // Create the TTL based on lease length.
643  dns::RRTTL lease_ttl(getNcr()->getLeaseLength());
644 
645  // Create the FQDN/IP 'delete' RR and add it to the update section.
646  // Based on RFC 2136, section 2.5.2
647  dns::RRsetPtr update(new dns::RRset(fqdn, dns::RRClass::ANY(),
649  request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
650 
651  // Create the FQDN/IP 'add' RR and add it to the update section.
652  // Based on RFC 2136, section 2.5.1
653  update.reset(new dns::RRset(fqdn, dns::RRClass::IN(),
654  getAddressRRType(), lease_ttl));
655  addLeaseAddressRdata(update);
656  request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
657 
658  // Set the transaction's update request to the new request.
659  setDnsUpdateRequest(request);
660 }
661 
662 void
664  // Construct an empty request.
666 
667  // Create the reverse IP address "FQDN".
668  std::string rev_addr = D2CfgMgr::reverseIpAddress(getNcr()->getIpAddress());
669  dns::Name rev_ip(rev_addr);
670 
671  // Create the TTL based on lease length.
672  dns::RRTTL lease_ttl(getNcr()->getLeaseLength());
673 
674  // Content on this request is based on RFC 4703, section 5.4
675  // Reverse replacement has no prerequisites so straight on to
676  // building the Update section.
677 
678  // Create the PTR 'delete' RR and add it to update section.
679  dns::RRsetPtr update(new dns::RRset(rev_ip, dns::RRClass::ANY(),
681  request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
682 
683  // Create the DHCID 'delete' RR and add it to the update section.
684  update.reset(new dns::RRset(rev_ip, dns::RRClass::ANY(),
686  request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
687 
688  // Create the FQDN/IP PTR 'add' RR, add the FQDN as the PTR Rdata
689  // then add it to update section.
690  update.reset(new dns::RRset(rev_ip, dns::RRClass::IN(),
691  dns::RRType::PTR(), lease_ttl));
692  addPtrRdata(update);
693  request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
694 
695  // Create the FQDN/IP PTR 'add' RR, add the DHCID Rdata
696  // then add it to update section.
697  update.reset(new dns::RRset(rev_ip, dns::RRClass::IN(),
698  dns::RRType::DHCID(), lease_ttl));
699  addDhcidRdata(update);
700  request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
701 
702  // Set the transaction's update request to the new request.
703  setDnsUpdateRequest(request);
704 }
705 
706 } // namespace isc::d2
707 } // 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
virtual void defineStates()
Adds states defined by NameAddTransaction to the state set.
Definition: nc_add.cc:76
virtual void sendUpdate(const std::string &comment="")
Send the update request to the current server.
Definition: nc_trans.cc:192
const isc::log::MessageID DHCP_DDNS_REVERSE_REPLACE_RESP_CORRUPT
Definition: d2_messages.h:77
static const RRType & DHCID()
Definition: rrtype.h:503
static const int PROCESS_TRANS_OK_ST
State which processes successful transaction conclusion.
Definition: nc_trans.h:102
static const int FQDN_NOT_IN_USE_EVT
Event sent when replace attempt to fails with address not in use.
Definition: nc_add.h:71
const isc::log::MessageID DHCP_DDNS_REVERSE_REPLACE_REJECTED
Definition: d2_messages.h:76
virtual void verifyEvents()
Validates the contents of the set of events.
Definition: nc_add.cc:58
std::string getContextStr() const
Convenience method which returns a string rendition of the current state and next event...
Definition: state_model.cc:443
void replacingFwdAddrsHandler()
State handler for REPLACING_FWD_ADDRS_ST.
Definition: nc_add.cc:284
void defineEvent(unsigned int value, const std::string &label)
Adds an event value and associated label to the set of events.
Definition: state_model.cc:170
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
const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_BUILD_FAILURE
Definition: d2_messages.h:24
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
This file defines the class NameAddTransaction.
const isc::log::MessageID DHCP_DDNS_FORWARD_REPLACE_IO_ERROR
Definition: d2_messages.h:40
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 setNcrStatus(const dhcp_ddns::NameChangeStatus &status)
Sets the status of the transaction&#39;s NameChangeRequest.
Definition: nc_trans.cc:538
void selectingFwdServerHandler()
State handler for SELECTING_FWD_SERVER_ST.
Definition: nc_add.cc:144
const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_BAD_DNSCLIENT_STATUS
Definition: d2_messages.h:23
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
static const Rcode & YXDOMAIN()
A constant object for the YXDOMAIN Rcode (see Rcode::YXDOMAIN_CODE).
Definition: rcode.h:256
static const int ADDING_FWD_ADDRS_ST
State that attempts to add forward address records.
Definition: nc_add.h:57
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
Definition: macros.h:32
static const int REPLACING_FWD_ADDRS_ST
State that attempts to replace forward address records.
Definition: nc_add.h:60
const isc::log::MessageID DHCP_DDNS_ADD_SUCCEEDED
Definition: d2_messages.h:12
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
const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_REJECTED
Definition: d2_messages.h:26
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
void replacingRevPtrsHandler()
State handler for REPLACING_REV_PTRS_ST.
Definition: nc_add.cc:432
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.
virtual ~NameAddTransaction()
Destructor.
Definition: nc_add.cc:44
const isc::log::MessageID DHCP_DDNS_REVERSE_REPLACE_IO_ERROR
Definition: d2_messages.h:75
void setForwardChangeCompleted(const bool value)
Sets the forward change completion flag to the given value.
Definition: nc_trans.cc:328
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 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
void addingFwdAddrsHandler()
State handler for ADD_FWD_ADDRS_ST.
Definition: nc_add.cc:172
void processAddFailedHandler()
State handler for PROCESS_TRANS_FAILED_ST.
Definition: nc_add.cc:555
bool doOnEntry()
Checks if on entry flag is true.
Definition: state_model.cc:339
const isc::log::MessageID DHCP_DDNS_REVERSE_REPLACE_BUILD_FAILURE
Definition: d2_messages.h:74
const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_IO_ERROR
Definition: d2_messages.h:25
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
static const int FQDN_IN_USE_EVT
Event sent when an add attempt fails with address in use.
Definition: nc_add.h:68
const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_RESP_CORRUPT
Definition: d2_messages.h:27
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
void selectingRevServerHandler()
State handler for SELECTING_REV_SERVER_ST.
Definition: nc_add.cc:403
void processAddOkHandler()
State handler for PROCESS_TRANS_OK_ST.
Definition: nc_add.cc:538
virtual void defineEvents()
Adds events defined by NameAddTransaction to the event set.
Definition: nc_add.cc:48
static const Rcode & NXDOMAIN()
A constant object for the NXDOMAIN Rcode (see Rcode::NXDOMAIN_CODE).
Definition: rcode.h:238
Response received and is ok.
Definition: dns_client.h:59
static const int REPLACING_REV_PTRS_ST
State that attempts to replace reverse PTR records.
Definition: nc_add.h:63
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
const isc::log::MessageID DHCP_DDNS_FORWARD_REPLACE_BAD_DNSCLIENT_STATUS
Definition: d2_messages.h:38
DdnsDomainPtr & getForwardDomain()
Fetches the forward DdnsDomain.
Definition: nc_trans.cc:445
NameAddTransaction(asiolink::IOServicePtr &io_service, dhcp_ddns::NameChangeRequestPtr &ncr, DdnsDomainPtr &forward_domain, DdnsDomainPtr &reverse_domain, D2CfgMgrPtr &cfg_mgr)
Constructor.
Definition: nc_add.cc:31
const isc::log::MessageID DHCP_DDNS_FORWARD_REPLACE_REJECTED
Definition: d2_messages.h:41
virtual void verifyStates()
Validates the contents of the set of states.
Definition: nc_add.cc:107
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
void buildReplaceRevPtrsRequest()
Builds a DNS request to replace a reverse DNS entry for an FQDN.
Definition: nc_add.cc:663
const isc::log::MessageID DHCP_DDNS_FORWARD_REPLACE_BUILD_FAILURE
Definition: d2_messages.h:39
static const int NO_MORE_SERVERS_EVT
Issued when there are no more servers from which to select.
Definition: nc_trans.h:125
std::string getRequestId() const
Fetches the request id that identifies this transaction.
Definition: nc_trans.cc:435
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
static const int PROCESS_TRANS_FAILED_ST
State which processes an unsuccessful transaction conclusion.
Definition: nc_trans.h:105
void buildAddFwdAddressRequest()
Builds a DNS request to add an forward DNS entry for an FQDN.
Definition: nc_add.cc:573
const isc::log::MessageID DHCP_DDNS_REVERSE_REPLACE_BAD_DNSCLIENT_STATUS
Definition: d2_messages.h:73
std::string transactionOutcomeString() const
Returns a string version of transaction outcome.
Definition: nc_trans.cc:170
void buildReplaceFwdAddressRequest()
Builds a DNS request to replace forward DNS entry for an FQDN.
Definition: nc_add.cc:615
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
const isc::log::MessageID DHCP_DDNS_ADD_FAILED
Definition: d2_messages.h:11
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
void readyHandler()
State handler for READY_ST.
Definition: nc_add.cc:124
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 EventPtr & getEvent(unsigned int value)
Fetches the event referred to by value.
Definition: state_model.cc:186
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
const isc::log::MessageID DHCP_DDNS_FORWARD_REPLACE_RESP_CORRUPT
Definition: d2_messages.h:42
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
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
bool selectNextServer()
Selects the next server in the current server list.
Definition: nc_trans.cc:467
virtual void verifyStates()
Validates the contents of the set of states.
Definition: nc_trans.cc:265
Thrown if the NameAddTransaction encounters a general error.
Definition: nc_add.h:19