Kea 2.0.0
nc_add.cc
Go to the documentation of this file.
1// Copyright (C) 2013-2021 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
18namespace isc {
19namespace 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
47void
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
57void
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
75void
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",
101
102 defineState(PROCESS_TRANS_FAILED_ST, "PROCESS_TRANS_FAILED_ST",
104}
105
106void
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
123void
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
143void
145 switch(getNextEvent()) {
147 // First time through for this transaction, so initialize server
148 // selection.
150 break;
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 }
166 else {
167 // Server list is exhausted, so fail the transaction.
169 }
170}
171
172void
174 if (doOnEntry()) {
175 // Clear the request on initial transition. This allows us to reuse
176 // the request on retries if necessary.
178 }
179
180 switch(getNextEvent()) {
182 if (!getDnsUpdateRequest()) {
183 // Request hasn't been constructed yet, so build it.
184 try {
186 } catch (const std::exception& ex) {
187 // While unlikely, the build might fail if we have invalid
188 // data. Should that be the case, we need to fail the
189 // transaction.
191 .arg(getRequestId())
192 .arg(getNcr()->toText())
193 .arg(ex.what());
195 break;
196 }
197 }
198
199 // Call sendUpdate() to initiate the async send. Note it also sets
200 // next event to NOP_EVT.
201 sendUpdate("Forward Add");
202 break;
203
204 case IO_COMPLETED_EVT: {
205 switch (getDnsUpdateStatus()) {
206 case DNSClient::SUCCESS: {
207 // We successfully received a response packet from the server.
208 const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
209 if (rcode == dns::Rcode::NOERROR()) {
210 // We were able to add it. Mark it as done.
212
213 // If request calls for reverse update then do that next,
214 // otherwise we can process ok.
215 if (getReverseDomain()) {
217 } else {
219 }
220 } else if (rcode == dns::Rcode::YXDOMAIN()) {
221 // FQDN is in use so we need to attempt to replace
222 // forward address.
224 } else {
225 // Per RFC4703 any other value means cease.
226 // If we get not authorized should we try the next server in
227 // the list? @todo This needs some discussion perhaps.
229 .arg(getRequestId())
230 .arg(getCurrentServer()->toText())
231 .arg(getNcr()->getFqdn())
232 .arg(rcode.getCode());
234 }
235
236 break;
237 }
238
240 case DNSClient::OTHER:
241 // We couldn't send to the current server, log it and set up
242 // to select the next server for a retry.
243 // @note For now we treat OTHER as an IO error like TIMEOUT. It
244 // is not entirely clear if this is accurate.
246 .arg(getRequestId())
247 .arg(getNcr()->getFqdn())
248 .arg(getCurrentServer()->toText());
249
251 break;
252
254 // A response was received but was corrupt. Retry it like an IO
255 // error.
257 .arg(getRequestId())
258 .arg(getCurrentServer()->toText())
259 .arg(getNcr()->getFqdn());
260
262 break;
263
264 default:
265 // Any other value and we will fail this transaction, something
266 // bigger is wrong.
268 .arg(getRequestId())
269 .arg(getDnsUpdateStatus())
270 .arg(getNcr()->getFqdn())
271 .arg(getCurrentServer()->toText());
272
274 break;
275 } // end switch on dns_status
276
277 break;
278 } // end case IO_COMPLETE_EVT
279
280 default:
281 // Event is invalid.
283 "Wrong event for context: " << getContextStr());
284 }
285}
286
287void
289 if (doOnEntry()) {
290 // Clear the request on initial transition. This allows us to reuse
291 // the request on retries if necessary.
293 }
294
295 switch(getNextEvent()) {
296 case FQDN_IN_USE_EVT:
298 if (!getDnsUpdateRequest()) {
299 // Request hasn't been constructed yet, so build it.
300 try {
302 } catch (const std::exception& ex) {
303 // While unlikely, the build might fail if we have invalid
304 // data. Should that be the case, we need to fail the
305 // transaction.
307 .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 Replace");
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 const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
325 if (rcode == dns::Rcode::NOERROR()) {
326 // We were able to replace the forward mapping. Mark it as done.
328
329 // If request calls for reverse update then do that next,
330 // otherwise we can process ok.
331 if (getReverseDomain()) {
333 } else {
335 }
336 } else if (rcode == dns::Rcode::NXDOMAIN()) {
337 // FQDN is NOT in use so go back and do the forward add address.
338 // Covers the case that it was there when we tried to add it,
339 // but has since been removed per RFC 4703.
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
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 // If we are out of retries on this server, we go back and start
368 // all over on a new server.
370 break;
371
373 // A response was received but was corrupt. Retry it like an IO
374 // error.
376 .arg(getRequestId())
377 .arg(getCurrentServer()->toText())
378 .arg(getNcr()->getFqdn());
379
380 // If we are out of retries on this server, we go back and start
381 // all over on a new server.
383 break;
384
385 default:
386 // Any other value and we will fail this transaction, something
387 // bigger is wrong.
390 .arg(getRequestId())
391 .arg(getDnsUpdateStatus())
392 .arg(getNcr()->getFqdn())
393 .arg(getCurrentServer()->toText());
394
396 break;
397 } // end switch on dns_status
398
399 break;
400 } // end case IO_COMPLETE_EVT
401
402 default:
403 // Event is invalid.
405 "Wrong event for context: " << getContextStr());
406 }
407}
408
409void
411 switch(getNextEvent()) {
413 // First time through for this transaction, so initialize server
414 // selection.
416 break;
418 // We failed to communicate with current server. Attempt to select
419 // another one below.
420 break;
421 default:
422 // Event is invalid.
424 "Wrong event for context: " << getContextStr());
425 }
426
427 // Select the next server from the list of forward servers.
428 if (selectNextServer()) {
429 // We have a server to try.
431 }
432 else {
433 // Server list is exhausted, so fail the transaction.
435 }
436}
437
438
439void
441 if (doOnEntry()) {
442 // Clear the request on initial transition. This allows us to reuse
443 // the request on retries if necessary.
445 }
446
447 switch(getNextEvent()) {
449 if (!getDnsUpdateRequest()) {
450 // Request hasn't been constructed yet, so build it.
451 try {
453 } catch (const std::exception& ex) {
454 // While unlikely, the build might fail if we have invalid
455 // data. Should that be the case, we need to fail the
456 // transaction.
458 .arg(getRequestId())
459 .arg(getNcr()->toText())
460 .arg(ex.what());
462 break;
463 }
464 }
465
466 // Call sendUpdate() to initiate the async send. Note it also sets
467 // next event to NOP_EVT.
468 sendUpdate("Reverse Replace");
469 break;
470
471 case IO_COMPLETED_EVT: {
472 switch (getDnsUpdateStatus()) {
473 case DNSClient::SUCCESS: {
474 // We successfully received a response packet from the server.
475 const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
476 if (rcode == dns::Rcode::NOERROR()) {
477 // We were able to update the reverse mapping. Mark it as done.
480 } else {
481 // Per RFC4703 any other value means cease.
482 // If we get not authorized should try the next server in
483 // the list? @todo This needs some discussion perhaps.
485 .arg(getRequestId())
486 .arg(getCurrentServer()->toText())
487 .arg(getNcr()->getFqdn())
488 .arg(rcode.getCode());
490 }
491
492 break;
493 }
494
496 case DNSClient::OTHER:
497 // We couldn't send to the current server, log it and set up
498 // to select the next server for a retry.
499 // @note For now we treat OTHER as an IO error like TIMEOUT. It
500 // is not entirely clear if this is accurate.
502 .arg(getRequestId())
503 .arg(getNcr()->getFqdn())
504 .arg(getCurrentServer()->toText());
505
506 // If we are out of retries on this server, we go back and start
507 // all over on a new server.
509 break;
510
512 // A response was received but was corrupt. Retry it like an IO
513 // error.
515 .arg(getRequestId())
516 .arg(getCurrentServer()->toText())
517 .arg(getNcr()->getFqdn());
518
519 // If we are out of retries on this server, we go back and start
520 // all over on a new server.
522 break;
523
524 default:
525 // Any other value and we will fail this transaction, something
526 // bigger is wrong.
529 .arg(getRequestId())
530 .arg(getDnsUpdateStatus())
531 .arg(getNcr()->getFqdn())
532 .arg(getCurrentServer()->toText());
533
535 break;
536 } // end switch on dns_status
537
538 break;
539 } // end case IO_COMPLETE_EVT
540
541 default:
542 // Event is invalid.
544 "Wrong event for context: " << getContextStr());
545 }
546}
547
548void
550 switch(getNextEvent()) {
551 case UPDATE_OK_EVT:
553 .arg(getRequestId())
554 .arg(getNcr()->toText());
556 endModel();
557 break;
558 default:
559 // Event is invalid.
561 "Wrong event for context: " << getContextStr());
562 }
563}
564
565void
567 switch(getNextEvent()) {
572 .arg(getRequestId())
574 endModel();
575 break;
576 default:
577 // Event is invalid.
579 "Wrong event for context: " << getContextStr());
580 }
581}
582
583void
585 // Construct an empty request.
587
588 // Construct dns::Name from NCR fqdn.
589 dns::Name fqdn(dns::Name(getNcr()->getFqdn()));
590
591 // Content on this request is based on RFC 4703, section 5.3.1
592 // First build the Prerequisite Section.
593
594 // Create 'FQDN Is Not In Use' prerequisite and add it to the
595 // prerequisite section.
596 // Based on RFC 2136, section 2.4.5
599 request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
600
601 // Next build the Update Section.
602
603 // Create the TTL based on lease length.
604 dns::RRTTL lease_ttl(getNcr()->getLeaseLength());
605
606 // Create the FQDN/IP 'add' RR and add it to the to update section.
607 // Based on RFC 2136, section 2.5.1
608 dns::RRsetPtr update(new dns::RRset(fqdn, dns::RRClass::IN(),
609 getAddressRRType(), lease_ttl));
610
611 addLeaseAddressRdata(update);
612 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
613
614 // Now create the FQDN/DHCID 'add' RR and add it to update section.
615 // Based on RFC 2136, section 2.5.1
616 update.reset(new dns::RRset(fqdn, dns::RRClass::IN(),
617 dns::RRType::DHCID(), lease_ttl));
618 addDhcidRdata(update);
619 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
620
621 // Set the transaction's update request to the new request.
622 setDnsUpdateRequest(request);
623}
624
625void
627 // Construct an empty request.
629
630 // Construct dns::Name from NCR fqdn.
631 dns::Name fqdn(dns::Name(getNcr()->getFqdn()));
632
633 // Content on this request is based on RFC 4703, section 5.3.2
634 // First build the Prerequisite Section.
635
636 // Create an 'FQDN Is In Use' prerequisite and add it to the
637 // pre-requisite section.
638 // Based on RFC 2136, section 2.4.4
639 dns::RRsetPtr prereq(new dns::RRset(fqdn, dns::RRClass::ANY(),
641 request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
642
643 // Create an DHCID matches prerequisite RR and add it to the
644 // pre-requisite section.
645 // Based on RFC 2136, section 2.4.2.
646 prereq.reset(new dns::RRset(fqdn, dns::RRClass::IN(),
648 addDhcidRdata(prereq);
649 request->addRRset(D2UpdateMessage::SECTION_PREREQUISITE, prereq);
650
651 // Next build the Update Section.
652
653 // Create the TTL based on lease length.
654 dns::RRTTL lease_ttl(getNcr()->getLeaseLength());
655
656 // Create the FQDN/IP 'delete' RR and add it to the update section.
657 // Based on RFC 2136, section 2.5.2
658 dns::RRsetPtr update(new dns::RRset(fqdn, dns::RRClass::ANY(),
660 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
661
662 // Create the FQDN/IP 'add' RR and add it to the update section.
663 // Based on RFC 2136, section 2.5.1
664 update.reset(new dns::RRset(fqdn, dns::RRClass::IN(),
665 getAddressRRType(), lease_ttl));
666 addLeaseAddressRdata(update);
667 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
668
669 // Set the transaction's update request to the new request.
670 setDnsUpdateRequest(request);
671}
672
673void
675 // Construct an empty request.
677
678 // Create the reverse IP address "FQDN".
679 std::string rev_addr = D2CfgMgr::reverseIpAddress(getNcr()->getIpAddress());
680 dns::Name rev_ip(rev_addr);
681
682 // Create the TTL based on lease length.
683 dns::RRTTL lease_ttl(getNcr()->getLeaseLength());
684
685 // Content on this request is based on RFC 4703, section 5.4
686 // Reverse replacement has no prerequisites so straight on to
687 // building the Update section.
688
689 // Create the PTR 'delete' RR and add it to update section.
690 dns::RRsetPtr update(new dns::RRset(rev_ip, dns::RRClass::ANY(),
692 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
693
694 // Create the DHCID 'delete' RR and add it to the update section.
695 update.reset(new dns::RRset(rev_ip, dns::RRClass::ANY(),
697 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
698
699 // Create the FQDN/IP PTR 'add' RR, add the FQDN as the PTR Rdata
700 // then add it to update section.
701 update.reset(new dns::RRset(rev_ip, dns::RRClass::IN(),
702 dns::RRType::PTR(), lease_ttl));
703 addPtrRdata(update);
704 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
705
706 // Create the FQDN/IP PTR 'add' RR, add the DHCID Rdata
707 // then add it to update section.
708 update.reset(new dns::RRset(rev_ip, dns::RRClass::IN(),
709 dns::RRType::DHCID(), lease_ttl));
710 addDhcidRdata(update);
711 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
712
713 // Set the transaction's update request to the new request.
714 setDnsUpdateRequest(request);
715}
716
717} // namespace isc::d2
718} // 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:170
@ 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:566
virtual void defineEvents()
Adds events defined by NameAddTransaction to the event set.
Definition: nc_add.cc:48
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:44
void buildReplaceFwdAddressRequest()
Builds a DNS request to replace forward DNS entry for an FQDN.
Definition: nc_add.cc:626
virtual void verifyStates()
Validates the contents of the set of states.
Definition: nc_add.cc:107
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:288
void processAddOkHandler()
State handler for PROCESS_TRANS_OK_ST.
Definition: nc_add.cc:549
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:58
void addingFwdAddrsHandler()
State handler for ADD_FWD_ADDRS_ST.
Definition: nc_add.cc:173
void selectingRevServerHandler()
State handler for SELECTING_REV_SERVER_ST.
Definition: nc_add.cc:410
void replacingRevPtrsHandler()
State handler for REPLACING_REV_PTRS_ST.
Definition: nc_add.cc:440
void readyHandler()
State handler for READY_ST.
Definition: nc_add.cc:124
NameAddTransaction(asiolink::IOServicePtr &io_service, dhcp_ddns::NameChangeRequestPtr &ncr, DdnsDomainPtr &forward_domain, DdnsDomainPtr &reverse_domain, D2CfgMgrPtr &cfg_mgr)
Constructor.
Definition: nc_add.cc:31
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:76
void selectingFwdServerHandler()
State handler for SELECTING_FWD_SERVER_ST.
Definition: nc_add.cc:144
void buildReplaceRevPtrsRequest()
Builds a DNS request to replace a reverse DNS entry for an FQDN.
Definition: nc_add.cc:674
void buildAddFwdAddressRequest()
Builds a DNS request to add an forward DNS entry for an FQDN.
Definition: nc_add.cc:584
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:286
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:549
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:265
virtual D2UpdateMessagePtr prepNewRequest(DdnsDomainPtr domain)
Creates a new DNS update request based on the given domain.
Definition: nc_trans.cc:339
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:539
const dns::RRType & getAddressRRType() const
Returns the DHCP data type for the lease address.
Definition: nc_trans.cc:569
const dhcp_ddns::NameChangeRequestPtr & getNcr() const
Fetches the NameChangeRequest for this transaction.
Definition: nc_trans.cc:421
void initServerSelection(const DdnsDomainPtr &domain)
Initializes server selection from the given DDNS domain.
Definition: nc_trans.cc:451
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:431
virtual void defineStates()
Adds states defined by NameChangeTransaction to the state set.
Definition: nc_trans.cc:257
void addLeaseAddressRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease address to the given RRset.
Definition: nc_trans.cc:362
virtual void sendUpdate(const std::string &comment="")
Send the update request to the current server.
Definition: nc_trans.cc:192
void setForwardChangeCompleted(const bool value)
Sets the forward change completion flag to the given value.
Definition: nc_trans.cc:324
void addPtrRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease FQDN to the given RRset.
Definition: nc_trans.cc:404
bool selectNextServer()
Selects the next server in the current server list.
Definition: nc_trans.cc:463
void setNcrStatus(const dhcp_ddns::NameChangeStatus &status)
Sets the status of the transaction's NameChangeRequest.
Definition: nc_trans.cc:534
DdnsDomainPtr & getForwardDomain()
Fetches the forward DdnsDomain.
Definition: nc_trans.cc:441
virtual void verifyEvents()
Validates the contents of the set of events.
Definition: nc_trans.cc:242
void addDhcidRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease client's DHCID to the given RRset.
Definition: nc_trans.cc:384
void clearDnsUpdateRequest()
Destroys the current update request packet and resets update attempts count.
Definition: nc_trans.cc:303
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:544
void setDnsUpdateRequest(D2UpdateMessagePtr &request)
Sets the update request packet to the given packet.
Definition: nc_trans.cc:298
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:227
void setReverseChangeCompleted(const bool value)
Sets the reverse change completion flag to the given value.
Definition: nc_trans.cc:329
const DnsServerInfoPtr & getCurrentServer() const
Fetches the currently selected server.
Definition: nc_trans.cc:529
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:446
std::string transactionOutcomeString() const
Returns a string version of transaction outcome.
Definition: nc_trans.cc:170
The Name class encapsulates DNS names.
Definition: name.h:223
static const RRClass & ANY()
Definition: rrclass.h:301
static const RRClass & NONE()
Definition: rrclass.h:325
static const RRClass & IN()
Definition: rrclass.h:319
The RRTTL class encapsulates TTLs used in DNS resource records.
Definition: rrttl.h:55
static const RRType & ANY()
Definition: rrtype.h:527
static const RRType & PTR()
Definition: rrtype.h:443
static const RRType & DHCID()
Definition: rrtype.h:503
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:186
void endModel()
Conducts a normal transition to the end of the model.
Definition: state_model.cc:271
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
unsigned int getNextEvent() const
Fetches the model's next event.
Definition: state_model.cc:373
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
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
bool doOnEntry()
Checks if on entry flag is true.
Definition: state_model.cc:339
static const int START_EVT
Event issued to start the model execution.
Definition: state_model.h:295
const StatePtr getStateInternal(unsigned int value)
Fetches the state referred to by value.
Definition: state_model.cc:219
std::string getContextStr() const
Convenience method which returns a string rendition of the current state and next event.
Definition: state_model.cc:443
#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.
const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_BUILD_FAILURE
Definition: d2_messages.h:23
const isc::log::MessageID DHCP_DDNS_FORWARD_REPLACE_RESP_CORRUPT
Definition: d2_messages.h:41
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
Definition: d2_config.h:612
const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_REJECTED
Definition: d2_messages.h:25
const isc::log::MessageID DHCP_DDNS_REVERSE_REPLACE_RESP_CORRUPT
Definition: d2_messages.h:76
boost::shared_ptr< D2CfgMgr > D2CfgMgrPtr
Defines a shared pointer to D2CfgMgr.
Definition: d2_cfg_mgr.h:334
const isc::log::MessageID DHCP_DDNS_FORWARD_REPLACE_REJECTED
Definition: d2_messages.h:40
const isc::log::MessageID DHCP_DDNS_ADD_SUCCEEDED
Definition: d2_messages.h:12
const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_IO_ERROR
Definition: d2_messages.h:24
const isc::log::MessageID DHCP_DDNS_ADD_FAILED
Definition: d2_messages.h:11
const isc::log::MessageID DHCP_DDNS_FORWARD_REPLACE_BAD_DNSCLIENT_STATUS
Definition: d2_messages.h:37
isc::log::Logger d2_to_dns_logger("d2-to-dns")
Definition: d2_log.h:20
const isc::log::MessageID DHCP_DDNS_REVERSE_REPLACE_REJECTED
Definition: d2_messages.h:75
const isc::log::MessageID DHCP_DDNS_REVERSE_REPLACE_BUILD_FAILURE
Definition: d2_messages.h:73
const isc::log::MessageID DHCP_DDNS_FORWARD_REPLACE_BUILD_FAILURE
Definition: d2_messages.h:38
const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_BAD_DNSCLIENT_STATUS
Definition: d2_messages.h:22
const isc::log::MessageID DHCP_DDNS_REVERSE_REPLACE_BAD_DNSCLIENT_STATUS
Definition: d2_messages.h:72
const isc::log::MessageID DHCP_DDNS_REVERSE_REPLACE_IO_ERROR
Definition: d2_messages.h:74
const isc::log::MessageID DHCP_DDNS_FORWARD_REPLACE_IO_ERROR
Definition: d2_messages.h:39
const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_RESP_CORRUPT
Definition: d2_messages.h:26
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
Definition: ncr_msg.h:212
boost::shared_ptr< AbstractRRset > RRsetPtr
A pointer-like type pointing to an RRset object.
Definition: rrset.h:47
Defines the logger used by the top-level component of kea-lfc.
This file defines the class NameAddTransaction.