Kea 1.5.0
nc_add.cc
Go to the documentation of this file.
1// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <d2/d2_log.h>
10#include <d2/d2_cfg_mgr.h>
11#include <d2/nc_add.h>
12
13#include <boost/function.hpp>
14#include <boost/bind.hpp>
15
16#include <util/buffer.h>
17#include <dns/rdataclass.h>
18
19namespace isc {
20namespace d2 {
21
22// NameAddTransaction states
26
27// NameAddTransaction events
30
34 DdnsDomainPtr& forward_domain,
35 DdnsDomainPtr& reverse_domain,
36 D2CfgMgrPtr& cfg_mgr)
37 : NameChangeTransaction(io_service, ncr, forward_domain, reverse_domain,
38 cfg_mgr) {
39 if (ncr->getChangeType() != isc::dhcp_ddns::CHG_ADD) {
41 "NameAddTransaction, request type must be CHG_ADD");
42 }
43}
44
46}
47
48void
50 // Call superclass impl first.
52
53 // Define NameAddTransaction events.
54 defineEvent(FQDN_IN_USE_EVT, "FQDN_IN_USE_EVT");
55 defineEvent(FQDN_NOT_IN_USE_EVT, "FQDN_NOT_IN_USE_EVT");
56}
57
58void
60 // Call superclass implementation first to verify its events. These are
61 // events common to all transactions, and they must be defined.
62 // SELECT_SERVER_EVT
63 // SERVER_SELECTED_EVT
64 // SERVER_IO_ERROR_EVT
65 // NO_MORE_SERVERS_EVT
66 // IO_COMPLETED_EVT
67 // UPDATE_OK_EVT
68 // UPDATE_FAILED_EVT
70
71 // Verify NameAddTransaction events by attempting to fetch them.
74}
75
76void
78 // Call superclass impl first.
80
81 // Define NameAddTransaction states.
82 defineState(READY_ST, "READY_ST",
83 boost::bind(&NameAddTransaction::readyHandler, this));
84
85 defineState(SELECTING_FWD_SERVER_ST, "SELECTING_FWD_SERVER_ST",
87
88 defineState(SELECTING_REV_SERVER_ST, "SELECTING_REV_SERVER_ST",
90
91 defineState(ADDING_FWD_ADDRS_ST, "ADDING_FWD_ADDRS_ST",
93
94 defineState(REPLACING_FWD_ADDRS_ST, "REPLACING_FWD_ADDRS_ST",
96
97 defineState(REPLACING_REV_PTRS_ST, "REPLACING_REV_PTRS_ST",
99
100 defineState(PROCESS_TRANS_OK_ST, "PROCESS_TRANS_OK_ST",
101 boost::bind(&NameAddTransaction::processAddOkHandler, this));
102
103 defineState(PROCESS_TRANS_FAILED_ST, "PROCESS_TRANS_FAILED_ST",
105
106}
107void
109 // Call superclass implementation first to verify its states. These are
110 // states common to all transactions, and they must be defined.
111 // READY_ST
112 // SELECTING_FWD_SERVER_ST
113 // SELECTING_REV_SERVER_ST
114 // PROCESS_TRANS_OK_ST
115 // PROCESS_TRANS_FAILED_ST
117
118 // Verify NameAddTransaction states by attempting to fetch them.
122}
123
124void
126 switch(getNextEvent()) {
127 case START_EVT:
128 if (getForwardDomain()) {
129 // Request includes a forward change, do that first.
131 } else {
132 // Reverse change only, transition accordingly.
134 }
135
136 break;
137 default:
138 // Event is invalid.
140 "Wrong event for context: " << getContextStr());
141 }
142}
143
144void
146 switch(getNextEvent()) {
148 // First time through for this transaction, so initialize server
149 // selection.
151 break;
153 // We failed to communicate with current server. Attempt to select
154 // another one below.
155 break;
156 default:
157 // Event is invalid.
159 "Wrong event for context: " << getContextStr());
160 }
161
162 // Select the next server from the list of forward servers.
163 if (selectNextServer()) {
164 // We have a server to try.
166 }
167 else {
168 // Server list is exhausted, so fail the transaction.
170 }
171}
172
173void
175 if (doOnEntry()) {
176 // Clear the request on initial transition. This allows us to reuse
177 // the request on retries if necessary.
179 }
180
181 switch(getNextEvent()) {
183 if (!getDnsUpdateRequest()) {
184 // Request hasn't been constructed yet, so build it.
185 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.
191 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_ADD_BUILD_FAILURE)
192 .arg(getRequestId())
193 .arg(getNcr()->toText())
194 .arg(ex.what());
196 break;
197 }
198 }
199
200 // Call sendUpdate() to initiate the async send. Note it also sets
201 // next event to NOP_EVT.
202 sendUpdate("Forward Add");
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 const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
210 if (rcode == dns::Rcode::NOERROR()) {
211 // We were able to add it. Mark it as done.
213
214 // If request calls for reverse update then do that next,
215 // otherwise we can process ok.
216 if (getReverseDomain()) {
218 } else {
220 }
221 } else if (rcode == dns::Rcode::YXDOMAIN()) {
222 // FQDN is in use so we need to attempt to replace
223 // forward address.
225 } else {
226 // Per RFC4703 any other value means cease.
227 // If we get not authorized should we try the next server in
228 // the list? @todo This needs some discussion perhaps.
229 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_ADD_REJECTED)
230 .arg(getRequestId())
231 .arg(getCurrentServer()->toText())
232 .arg(getNcr()->getFqdn())
233 .arg(rcode.getCode());
235 }
236
237 break;
238 }
239
241 case DNSClient::OTHER:
242 // We couldn't send to the current server, log it and set up
243 // to select the next server for a retry.
244 // @note For now we treat OTHER as an IO error like TIMEOUT. It
245 // is not entirely clear if this is accurate.
246 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_ADD_IO_ERROR)
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.
257 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_ADD_RESP_CORRUPT)
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.
268 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_ADD_BAD_DNSCLIENT_STATUS)
269 .arg(getRequestId())
270 .arg(getDnsUpdateStatus())
271 .arg(getNcr()->getFqdn())
272 .arg(getCurrentServer()->toText());
273
275 break;
276 } // end switch on dns_status
277
278 break;
279 } // end case IO_COMPLETE_EVT
280
281 default:
282 // Event is invalid.
284 "Wrong event for context: " << getContextStr());
285 }
286}
287
288void
290 if (doOnEntry()) {
291 // Clear the request on initial transition. This allows us to reuse
292 // the request on retries if necessary.
294 }
295
296 switch(getNextEvent()) {
297 case FQDN_IN_USE_EVT:
299 if (!getDnsUpdateRequest()) {
300 // Request hasn't been constructed yet, so build it.
301 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.
307 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_REPLACE_BUILD_FAILURE)
308 .arg(getRequestId())
309 .arg(getNcr()->toText())
310 .arg(ex.what());
312 break;
313 }
314 }
315
316 // Call sendUpdate() to initiate the async send. Note it also sets
317 // next event to NOP_EVT.
318 sendUpdate("Forward Replace");
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 const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
326 if (rcode == dns::Rcode::NOERROR()) {
327 // We were able to replace the forward mapping. Mark it as done.
329
330 // If request calls for reverse update then do that next,
331 // otherwise we can process ok.
332 if (getReverseDomain()) {
334 } else {
336 }
337 } else if (rcode == dns::Rcode::NXDOMAIN()) {
338 // FQDN is NOT in use so go back and do the forward add address.
339 // Covers the case that it was there when we tried to add it,
340 // but has since been removed per RFC 4703.
342 } else {
343 // Per RFC4703 any other value means cease.
344 // If we get not authorized should try the next server in
345 // the list? @todo This needs some discussion perhaps.
346 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_REPLACE_REJECTED)
347 .arg(getRequestId())
348 .arg(getCurrentServer()->toText())
349 .arg(getNcr()->getFqdn())
350 .arg(rcode.getCode());
352 }
353
354 break;
355 }
356
358 case DNSClient::OTHER:
359 // We couldn't send to the current server, log it and set up
360 // to select the next server for a retry.
361 // @note For now we treat OTHER as an IO error like TIMEOUT. It
362 // is not entirely clear if this is accurate.
363 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_REPLACE_IO_ERROR)
364 .arg(getRequestId())
365 .arg(getNcr()->getFqdn())
366 .arg(getCurrentServer()->toText());
367
368 // If we are out of retries on this server, we go back and start
369 // all over on a new server.
371 break;
372
374 // A response was received but was corrupt. Retry it like an IO
375 // error.
376 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_REPLACE_RESP_CORRUPT)
377 .arg(getRequestId())
378 .arg(getCurrentServer()->toText())
379 .arg(getNcr()->getFqdn());
380
381 // If we are out of retries on this server, we go back and start
382 // all over on a new server.
384 break;
385
386 default:
387 // Any other value and we will fail this transaction, something
388 // bigger is wrong.
390 DHCP_DDNS_FORWARD_REPLACE_BAD_DNSCLIENT_STATUS)
391 .arg(getRequestId())
392 .arg(getDnsUpdateStatus())
393 .arg(getNcr()->getFqdn())
394 .arg(getCurrentServer()->toText());
395
397 break;
398 } // end switch on dns_status
399
400 break;
401 } // end case IO_COMPLETE_EVT
402
403 default:
404 // Event is invalid.
406 "Wrong event for context: " << getContextStr());
407 }
408}
409
410void
412 switch(getNextEvent()) {
414 // First time through for this transaction, so initialize server
415 // selection.
417 break;
419 // We failed to communicate with current server. Attempt to select
420 // another one below.
421 break;
422 default:
423 // Event is invalid.
425 "Wrong event for context: " << getContextStr());
426 }
427
428 // Select the next server from the list of forward servers.
429 if (selectNextServer()) {
430 // We have a server to try.
432 }
433 else {
434 // Server list is exhausted, so fail the transaction.
436 }
437}
438
439
440void
442 if (doOnEntry()) {
443 // Clear the request on initial transition. This allows us to reuse
444 // the request on retries if necessary.
446 }
447
448 switch(getNextEvent()) {
450 if (!getDnsUpdateRequest()) {
451 // Request hasn't been constructed yet, so build it.
452 try {
454 } catch (const std::exception& ex) {
455 // While unlikely, the build might fail if we have invalid
456 // data. Should that be the case, we need to fail the
457 // transaction.
458 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_REVERSE_REPLACE_BUILD_FAILURE)
459 .arg(getRequestId())
460 .arg(getNcr()->toText())
461 .arg(ex.what());
463 break;
464 }
465 }
466
467 // Call sendUpdate() to initiate the async send. Note it also sets
468 // next event to NOP_EVT.
469 sendUpdate("Reverse Replace");
470 break;
471
472 case IO_COMPLETED_EVT: {
473 switch (getDnsUpdateStatus()) {
474 case DNSClient::SUCCESS: {
475 // We successfully received a response packet from the server.
476 const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
477 if (rcode == dns::Rcode::NOERROR()) {
478 // We were able to update the reverse mapping. Mark it as done.
481 } else {
482 // Per RFC4703 any other value means cease.
483 // If we get not authorized should try the next server in
484 // the list? @todo This needs some discussion perhaps.
485 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_REVERSE_REPLACE_REJECTED)
486 .arg(getRequestId())
487 .arg(getCurrentServer()->toText())
488 .arg(getNcr()->getFqdn())
489 .arg(rcode.getCode());
491 }
492
493 break;
494 }
495
497 case DNSClient::OTHER:
498 // We couldn't send to the current server, log it and set up
499 // to select the next server for a retry.
500 // @note For now we treat OTHER as an IO error like TIMEOUT. It
501 // is not entirely clear if this is accurate.
502 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_REVERSE_REPLACE_IO_ERROR)
503 .arg(getRequestId())
504 .arg(getNcr()->getFqdn())
505 .arg(getCurrentServer()->toText());
506
507 // If we are out of retries on this server, we go back and start
508 // all over on a new server.
510 break;
511
513 // A response was received but was corrupt. Retry it like an IO
514 // error.
515 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_REVERSE_REPLACE_RESP_CORRUPT)
516 .arg(getRequestId())
517 .arg(getCurrentServer()->toText())
518 .arg(getNcr()->getFqdn());
519
520 // If we are out of retries on this server, we go back and start
521 // all over on a new server.
523 break;
524
525 default:
526 // Any other value and we will fail this transaction, something
527 // bigger is wrong.
529 DHCP_DDNS_REVERSE_REPLACE_BAD_DNSCLIENT_STATUS)
530 .arg(getRequestId())
531 .arg(getDnsUpdateStatus())
532 .arg(getNcr()->getFqdn())
533 .arg(getCurrentServer()->toText());
534
536 break;
537 } // end switch on dns_status
538
539 break;
540 } // end case IO_COMPLETE_EVT
541
542 default:
543 // Event is invalid.
545 "Wrong event for context: " << getContextStr());
546 }
547}
548
549void
551 switch(getNextEvent()) {
552 case UPDATE_OK_EVT:
553 LOG_INFO(d2_to_dns_logger, DHCP_DDNS_ADD_SUCCEEDED)
554 .arg(getRequestId())
555 .arg(getNcr()->toText());
557 endModel();
558 break;
559 default:
560 // Event is invalid.
562 "Wrong event for context: " << getContextStr());
563 }
564}
565
566void
568 switch(getNextEvent()) {
572 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_ADD_FAILED)
573 .arg(getRequestId())
575 endModel();
576 break;
577 default:
578 // Event is invalid.
580 "Wrong event for context: " << getContextStr());
581 }
582}
583
584void
586 // Construct an empty request.
588
589 // Construct dns::Name from NCR fqdn.
590 dns::Name fqdn(dns::Name(getNcr()->getFqdn()));
591
592 // Content on this request is based on RFC 4703, section 5.3.1
593 // First build the Prerequisite Section.
594
595 // Create 'FQDN Is Not In Use' prerequisite and add it to the
596 // prerequisite section.
597 // Based on RFC 2136, section 2.4.5
600 request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
601
602 // Next build the Update Section.
603
604 // Create the TTL based on lease length.
605 dns::RRTTL lease_ttl(getNcr()->getLeaseLength());
606
607 // Create the FQDN/IP 'add' RR and add it to the to update section.
608 // Based on RFC 2136, section 2.5.1
609 dns::RRsetPtr update(new dns::RRset(fqdn, dns::RRClass::IN(),
610 getAddressRRType(), lease_ttl));
611
612 addLeaseAddressRdata(update);
613 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
614
615 // Now create the FQDN/DHCID 'add' RR and add it to update section.
616 // Based on RFC 2136, section 2.5.1
617 update.reset(new dns::RRset(fqdn, dns::RRClass::IN(),
618 dns::RRType::DHCID(), lease_ttl));
619 addDhcidRdata(update);
620 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
621
622 // Set the transaction's update request to the new request.
623 setDnsUpdateRequest(request);
624}
625
626void
628 // Construct an empty request.
630
631 // Construct dns::Name from NCR fqdn.
632 dns::Name fqdn(dns::Name(getNcr()->getFqdn()));
633
634 // Content on this request is based on RFC 4703, section 5.3.2
635 // First build the Prerequisite Section.
636
637 // Create an 'FQDN Is In Use' prerequisite and add it to the
638 // pre-requisite section.
639 // Based on RFC 2136, section 2.4.4
640 dns::RRsetPtr prereq(new dns::RRset(fqdn, dns::RRClass::ANY(),
642 request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
643
644 // Create an DHCID matches prerequisite RR and add it to the
645 // pre-requisite section.
646 // Based on RFC 2136, section 2.4.2.
647 prereq.reset(new dns::RRset(fqdn, dns::RRClass::IN(),
649 addDhcidRdata(prereq);
650 request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
651
652 // Next build the Update Section.
653
654 // Create the TTL based on lease length.
655 dns::RRTTL lease_ttl(getNcr()->getLeaseLength());
656
657 // Create the FQDN/IP 'delete' RR and add it to the update section.
658 // Based on RFC 2136, section 2.5.2
659 dns::RRsetPtr update(new dns::RRset(fqdn, dns::RRClass::ANY(),
661 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
662
663 // Create the FQDN/IP 'add' RR and add it to the update section.
664 // Based on RFC 2136, section 2.5.1
665 update.reset(new dns::RRset(fqdn, dns::RRClass::IN(),
666 getAddressRRType(), lease_ttl));
667 addLeaseAddressRdata(update);
668 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
669
670 // Set the transaction's update request to the new request.
671 setDnsUpdateRequest(request);
672}
673
674void
676 // Construct an empty request.
678
679 // Create the reverse IP address "FQDN".
680 std::string rev_addr = D2CfgMgr::reverseIpAddress(getNcr()->getIpAddress());
681 dns::Name rev_ip(rev_addr);
682
683 // Create the TTL based on lease length.
684 dns::RRTTL lease_ttl(getNcr()->getLeaseLength());
685
686 // Content on this request is based on RFC 4703, section 5.4
687 // Reverse replacement has no prerequisites so straight on to
688 // building the Update section.
689
690 // Create the PTR 'delete' RR and add it to update section.
691 dns::RRsetPtr update(new dns::RRset(rev_ip, dns::RRClass::ANY(),
693 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
694
695 // Create the DHCID 'delete' RR and add it to the update section.
696 update.reset(new dns::RRset(rev_ip, dns::RRClass::ANY(),
698 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
699
700 // Create the FQDN/IP PTR 'add' RR, add the FQDN as the PTR Rdata
701 // then add it to update section.
702 update.reset(new dns::RRset(rev_ip, dns::RRClass::IN(),
703 dns::RRType::PTR(), lease_ttl));
704 addPtrRdata(update);
705 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
706
707 // Create the FQDN/IP PTR 'add' RR, add the DHCID Rdata
708 // then add it to update section.
709 update.reset(new dns::RRset(rev_ip, dns::RRClass::IN(),
710 dns::RRType::DHCID(), lease_ttl));
711 addDhcidRdata(update);
712 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
713
714 // Set the transaction's update request to the new request.
715 setDnsUpdateRequest(request);
716}
717
718} // namespace isc::d2
719} // namespace isc
static std::string reverseIpAddress(const std::string &address)
Generate a reverse order string for the given IP address.
Definition: d2_cfg_mgr.cc:159
@ TIMEOUT
No response, timeout.
Definition: dns_client.h:62
@ OTHER
Other, unclassified error.
Definition: dns_client.h:65
@ INVALID_RESPONSE
Response received but invalid.
Definition: dns_client.h:64
@ SUCCESS
Response received and is ok.
Definition: dns_client.h:61
Thrown if the NameAddTransaction encounters a general error.
Definition: nc_add.h:19
void processAddFailedHandler()
State handler for PROCESS_TRANS_FAILED_ST.
Definition: nc_add.cc:567
virtual void defineEvents()
Adds events defined by NameAddTransaction to the event set.
Definition: nc_add.cc:49
static const int ADDING_FWD_ADDRS_ST
State that attempts to add forward address records.
Definition: nc_add.h:57
virtual ~NameAddTransaction()
Destructor.
Definition: nc_add.cc:45
void buildReplaceFwdAddressRequest()
Builds a DNS request to replace forward DNS entry for an FQDN.
Definition: nc_add.cc:627
virtual void verifyStates()
Validates the contents of the set of states.
Definition: nc_add.cc:108
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
void replacingFwdAddrsHandler()
State handler for REPLACING_FWD_ADDRS_ST.
Definition: nc_add.cc:289
void processAddOkHandler()
State handler for PROCESS_TRANS_OK_ST.
Definition: nc_add.cc:550
static const int REPLACING_FWD_ADDRS_ST
State that attempts to replace forward address records.
Definition: nc_add.h:60
virtual void verifyEvents()
Validates the contents of the set of events.
Definition: nc_add.cc:59
void addingFwdAddrsHandler()
State handler for ADD_FWD_ADDRS_ST.
Definition: nc_add.cc:174
void selectingRevServerHandler()
State handler for SELECTING_REV_SERVER_ST.
Definition: nc_add.cc:411
void replacingRevPtrsHandler()
State handler for REPLACING_REV_PTRS_ST.
Definition: nc_add.cc:441
void readyHandler()
State handler for READY_ST.
Definition: nc_add.cc:125
NameAddTransaction(asiolink::IOServicePtr &io_service, dhcp_ddns::NameChangeRequestPtr &ncr, DdnsDomainPtr &forward_domain, DdnsDomainPtr &reverse_domain, D2CfgMgrPtr &cfg_mgr)
Constructor.
Definition: nc_add.cc:32
static const int FQDN_IN_USE_EVT
Event sent when an add attempt fails with address in use.
Definition: nc_add.h:68
virtual void defineStates()
Adds states defined by NameAddTransaction to the state set.
Definition: nc_add.cc:77
void selectingFwdServerHandler()
State handler for SELECTING_FWD_SERVER_ST.
Definition: nc_add.cc:145
void buildReplaceRevPtrsRequest()
Builds a DNS request to replace a reverse DNS entry for an FQDN.
Definition: nc_add.cc:675
void buildAddFwdAddressRequest()
Builds a DNS request to add an forward DNS entry for an FQDN.
Definition: nc_add.cc:585
static const int REPLACING_REV_PTRS_ST
State that attempts to replace reverse PTR records.
Definition: nc_add.h:63
Embodies the "life-cycle" required to carry out a DDNS update.
Definition: nc_trans.h:77
static const int SELECTING_FWD_SERVER_ST
State in which forward DNS server selection is done.
Definition: nc_trans.h:91
void retryTransition(const int fail_to_state)
Determines the state and next event based on update attempts.
Definition: nc_trans.cc:263
static const int PROCESS_TRANS_FAILED_ST
State which processes an unsuccessful transaction conclusion.
Definition: nc_trans.h:105
static const int READY_ST
State from which a transaction is started.
Definition: nc_trans.h:83
const D2UpdateMessagePtr & getDnsUpdateResponse() const
Fetches the most recent DNS update response packet.
Definition: nc_trans.cc:494
static const int PROCESS_TRANS_OK_ST
State which processes successful transaction conclusion.
Definition: nc_trans.h:102
static const int UPDATE_OK_EVT
Issued when the attempted update successfully completed.
Definition: nc_trans.h:135
virtual void verifyStates()
Validates the contents of the set of states.
Definition: nc_trans.cc:242
virtual D2UpdateMessagePtr prepNewRequest(DdnsDomainPtr domain)
Creates a new DNS update request based on the given domain.
Definition: nc_trans.cc:316
static const int UPDATE_FAILED_EVT
Issued when the attempted update fails to complete.
Definition: nc_trans.h:141
const D2UpdateMessagePtr & getDnsUpdateRequest() const
Fetches the current DNS update request packet.
Definition: nc_trans.cc:484
const dns::RRType & getAddressRRType() const
Returns the DHCP data type for the lease address.
Definition: nc_trans.cc:514
const dhcp_ddns::NameChangeRequestPtr & getNcr() const
Fetches the NameChangeRequest for this transaction.
Definition: nc_trans.cc:398
void initServerSelection(const DdnsDomainPtr &domain)
Initializes server selection from the given DDNS domain.
Definition: nc_trans.cc:428
static const int IO_COMPLETED_EVT
Issued when a DNS update packet exchange has completed.
Definition: nc_trans.h:130
static const int SELECT_SERVER_EVT
Issued when a server needs to be selected.
Definition: nc_trans.h:113
static const int SERVER_IO_ERROR_EVT
Issued when an update fails due to an IO error.
Definition: nc_trans.h:119
std::string getRequestId() const
Fetches the request id that identifies this transaction.
Definition: nc_trans.cc:408
virtual void defineStates()
Adds states defined by NameChangeTransaction to the state set.
Definition: nc_trans.cc:234
void addLeaseAddressRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease address to the given RRset.
Definition: nc_trans.cc:339
virtual void sendUpdate(const std::string &comment="")
Send the update request to the current server.
Definition: nc_trans.cc:169
void setForwardChangeCompleted(const bool value)
Sets the forward change completion flag to the given value.
Definition: nc_trans.cc:301
void addPtrRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease FQDN to the given RRset.
Definition: nc_trans.cc:381
bool selectNextServer()
Selects the next server in the current server list.
Definition: nc_trans.cc:448
void setNcrStatus(const dhcp_ddns::NameChangeStatus &status)
Sets the status of the transaction's NameChangeRequest.
Definition: nc_trans.cc:479
DdnsDomainPtr & getForwardDomain()
Fetches the forward DdnsDomain.
Definition: nc_trans.cc:418
virtual void verifyEvents()
Validates the contents of the set of events.
Definition: nc_trans.cc:219
void addDhcidRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease client's DHCID to the given RRset.
Definition: nc_trans.cc:361
void clearDnsUpdateRequest()
Destroys the current update request packet and resets update attempts count.
Definition: nc_trans.cc:280
static const int SELECTING_REV_SERVER_ST
State in which reverse DNS server selection is done.
Definition: nc_trans.h:99
DNSClient::Status getDnsUpdateStatus() const
Fetches the most recent DNS update status.
Definition: nc_trans.cc:489
void setDnsUpdateRequest(D2UpdateMessagePtr &request)
Sets the update request packet to the given packet.
Definition: nc_trans.cc:275
static const int NO_MORE_SERVERS_EVT
Issued when there are no more servers from which to select.
Definition: nc_trans.h:125
virtual void defineEvents()
Adds events defined by NameChangeTransaction to the event set.
Definition: nc_trans.cc:204
void setReverseChangeCompleted(const bool value)
Sets the reverse change completion flag to the given value.
Definition: nc_trans.cc:306
const DnsServerInfoPtr & getCurrentServer() const
Fetches the currently selected server.
Definition: nc_trans.cc:474
static const int SERVER_SELECTED_EVT
Issued when a server has been selected.
Definition: nc_trans.h:116
DdnsDomainPtr & getReverseDomain()
Fetches the reverse DdnsDomain.
Definition: nc_trans.cc:423
std::string transactionOutcomeString() const
Returns a string version of transaction outcome.
Definition: nc_trans.cc:147
The Name class encapsulates DNS names.
Definition: name.h:223
static const RRClass & ANY()
Definition: rrclass.h:313
static const RRClass & NONE()
Definition: rrclass.h:307
static const RRClass & IN()
Definition: rrclass.h:325
The RRTTL class encapsulates TTLs used in DNS resource records.
Definition: rrttl.h:55
static const RRType & ANY()
Definition: rrtype.h:389
static const RRType & PTR()
Definition: rrtype.h:569
static const RRType & DHCID()
Definition: rrtype.h:629
The RRset class is a concrete derived class of BasicRRset which contains a pointer to an additional R...
Definition: rrset.h:847
DNS Response Codes (RCODEs) class.
Definition: rcode.h:40
static const Rcode & NOERROR()
A constant object for the NOERROR Rcode (see Rcode::NOERROR_CODE).
Definition: rcode.h:220
static const Rcode & NXDOMAIN()
A constant object for the NXDOMAIN Rcode (see Rcode::NXDOMAIN_CODE).
Definition: rcode.h:238
uint16_t getCode() const
Returns the Rcode code value.
Definition: rcode.h:106
static const Rcode & YXDOMAIN()
A constant object for the YXDOMAIN Rcode (see Rcode::YXDOMAIN_CODE).
Definition: rcode.h:256
const EventPtr & getEvent(unsigned int value)
Fetches the event referred to by value.
Definition: state_model.cc:184
void endModel()
Conducts a normal transition to the end of the model.
Definition: state_model.cc:262
void defineState(unsigned int value, const std::string &label, StateHandler handler, const StatePausing &state_pausing=STATE_PAUSE_NEVER)
Adds an state value and associated label to the set of states.
Definition: state_model.cc:194
const StatePtr getState(unsigned int value)
Fetches the state referred to by value.
Definition: state_model.cc:211
unsigned int getNextEvent() const
Fetches the model's next event.
Definition: state_model.cc:346
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:168
void transition(unsigned int state, unsigned int event)
Sets up the model to transition into given state with a given event.
Definition: state_model.cc:256
bool doOnEntry()
Checks if on entry flag is true.
Definition: state_model.cc:317
static const int START_EVT
Event issued to start the model execution.
Definition: state_model.h:292
std::string getContextStr() const
Convenience method which returns a string rendition of the current state and next event.
Definition: state_model.cc:390
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
Definition: macros.h:32
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
Definition: macros.h:20
boost::shared_ptr< D2UpdateMessage > D2UpdateMessagePtr
Pointer to the DNS Update Message.
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
Definition: d2_config.h:586
boost::shared_ptr< D2CfgMgr > D2CfgMgrPtr
Defines a shared pointer to D2CfgMgr.
Definition: d2_cfg_mgr.h:297
isc::log::Logger d2_to_dns_logger("d2-to-dns")
Definition: d2_log.h:20
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
Definition: ncr_msg.h:214
boost::shared_ptr< AbstractRRset > RRsetPtr
A pointer-like type pointing to an RRset object.
Definition: rrset.h:53
Defines the logger used by the top-level component of kea-dhcp-ddns.
This file defines the class NameAddTransaction.