Kea: simple_add_without_dhcid.cc Source File

| Kea 3.2.0-git

simple_add_without_dhcid.cc
Go to the documentation of this file.
1// Copyright (C) 2023-2024 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/simple_add_without_dhcid.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// SimpleAddWithoutDHCIDTransaction states
22const int SimpleAddWithoutDHCIDTransaction::REPLACING_FWD_ADDRS_ST;
23const int SimpleAddWithoutDHCIDTransaction::REPLACING_REV_PTRS_ST;
24
25// SimpleAddWithoutDHCIDTransaction events
26const int SimpleAddWithoutDHCIDTransaction::FQDN_IN_USE_EVT;
27const int SimpleAddWithoutDHCIDTransaction::FQDN_NOT_IN_USE_EVT;
28
29SimpleAddWithoutDHCIDTransaction::
30 SimpleAddWithoutDHCIDTransaction(asiolink::IOServicePtr& io_service,
31 dhcp_ddns::NameChangeRequestPtr& ncr,
32 DdnsDomainPtr& forward_domain,
33 DdnsDomainPtr& reverse_domain,
34 D2CfgMgrPtr& cfg_mgr)
35 : NameChangeTransaction(io_service, ncr, forward_domain, reverse_domain,
36 cfg_mgr) {
37 if (ncr->getChangeType() != isc::dhcp_ddns::CHG_ADD) {
38 isc_throw (SimpleAddWithoutDHCIDTransactionError,
39 "SimpleAddWithoutDHCIDTransaction, request type must be CHG_ADD");
40 }
41}
42
43SimpleAddWithoutDHCIDTransaction::~SimpleAddWithoutDHCIDTransaction(){
44}
45
46void
47SimpleAddWithoutDHCIDTransaction::defineEvents() {
48 // Call superclass impl first.
49 NameChangeTransaction::defineEvents();
50
51 // Define SimpleAddWithoutDHCIDTransaction events.
52 defineEvent(FQDN_IN_USE_EVT, "FQDN_IN_USE_EVT");
53 defineEvent(FQDN_NOT_IN_USE_EVT, "FQDN_NOT_IN_USE_EVT");
54}
55
56void
57SimpleAddWithoutDHCIDTransaction::verifyEvents() {
58 // Call superclass implementation first to verify its events. These are
59 // events common to all transactions, and they must be defined.
60 // SELECT_SERVER_EVT
61 // SERVER_SELECTED_EVT
62 // SERVER_IO_ERROR_EVT
63 // NO_MORE_SERVERS_EVT
64 // IO_COMPLETED_EVT
65 // UPDATE_OK_EVT
66 // UPDATE_FAILED_EVT
67 NameChangeTransaction::verifyEvents();
68
69 // Verify SimpleAddWithoutDHCIDTransaction events by attempting to fetch them.
70 getEvent(FQDN_IN_USE_EVT);
71 getEvent(FQDN_NOT_IN_USE_EVT);
72}
73
74void
75SimpleAddWithoutDHCIDTransaction::defineStates() {
76 // Call superclass impl first.
77 NameChangeTransaction::defineStates();
78
79 // Define SimpleAddWithoutDHCIDTransaction states.
80 defineState(READY_ST, "READY_ST",
81 std::bind(&SimpleAddWithoutDHCIDTransaction::readyHandler, this));
82
83 defineState(SELECTING_FWD_SERVER_ST, "SELECTING_FWD_SERVER_ST",
84 std::bind(&SimpleAddWithoutDHCIDTransaction::selectingFwdServerHandler, this));
85
86 defineState(SELECTING_REV_SERVER_ST, "SELECTING_REV_SERVER_ST",
87 std::bind(&SimpleAddWithoutDHCIDTransaction::selectingRevServerHandler, this));
88
89 defineState(REPLACING_FWD_ADDRS_ST, "REPLACING_FWD_ADDRS_ST",
90 std::bind(&SimpleAddWithoutDHCIDTransaction::replacingFwdAddrsHandler, this));
91
92 defineState(REPLACING_REV_PTRS_ST, "REPLACING_REV_PTRS_ST",
93 std::bind(&SimpleAddWithoutDHCIDTransaction::replacingRevPtrsHandler, this));
94
95 defineState(PROCESS_TRANS_OK_ST, "PROCESS_TRANS_OK_ST",
96 std::bind(&SimpleAddWithoutDHCIDTransaction::processAddOkHandler, this));
97
98 defineState(PROCESS_TRANS_FAILED_ST, "PROCESS_TRANS_FAILED_ST",
99 std::bind(&SimpleAddWithoutDHCIDTransaction::processAddFailedHandler, this));
100}
101
102void
103SimpleAddWithoutDHCIDTransaction::verifyStates() {
104 // Call superclass implementation first to verify its states. These are
105 // states common to all transactions, and they must be defined.
106 // READY_ST
107 // SELECTING_FWD_SERVER_ST
108 // SELECTING_REV_SERVER_ST
109 // PROCESS_TRANS_OK_ST
110 // PROCESS_TRANS_FAILED_ST
111 NameChangeTransaction::verifyStates();
112
113 // Verify SimpleAddWithoutDHCIDTransaction states by attempting to fetch them.
114 getStateInternal(REPLACING_FWD_ADDRS_ST);
115 getStateInternal(REPLACING_REV_PTRS_ST);
116}
117
118void
119SimpleAddWithoutDHCIDTransaction::readyHandler() {
120 switch(getNextEvent()) {
121 case START_EVT:
122 if (getForwardDomain()) {
123 // Request includes a forward change, do that first.
124 transition(SELECTING_FWD_SERVER_ST, SELECT_SERVER_EVT);
125 } else {
126 // Reverse change only, transition accordingly.
127 transition(SELECTING_REV_SERVER_ST, SELECT_SERVER_EVT);
128 }
129
130 break;
131 default:
132 // Event is invalid.
133 isc_throw(SimpleAddWithoutDHCIDTransactionError,
134 "Wrong event for context: " << getContextStr());
135 }
136}
137
138void
139SimpleAddWithoutDHCIDTransaction::selectingFwdServerHandler() {
140 switch(getNextEvent()) {
141 case SELECT_SERVER_EVT:
142 // First time through for this transaction, so initialize server
143 // selection.
144 initServerSelection(getForwardDomain());
145 break;
146 case SERVER_IO_ERROR_EVT:
147 // We failed to communicate with current server. Attempt to select
148 // another one below.
149 break;
150 default:
151 // Event is invalid.
152 isc_throw(SimpleAddWithoutDHCIDTransactionError,
153 "Wrong event for context: " << getContextStr());
154 }
155
156 // Select the next server from the list of forward servers.
157 if (selectNextServer()) {
158 // We have a server to try.
159 transition(REPLACING_FWD_ADDRS_ST, SERVER_SELECTED_EVT);
160 }
161 else {
162 // Server list is exhausted, so fail the transaction.
163 transition(PROCESS_TRANS_FAILED_ST, NO_MORE_SERVERS_EVT);
164 }
165}
166
167void
168SimpleAddWithoutDHCIDTransaction::replacingFwdAddrsHandler() {
169 if (doOnEntry()) {
170 // Clear the update attempts count on initial transition.
171 clearUpdateAttempts();
172 }
173
174 switch(getNextEvent()) {
175 case SERVER_SELECTED_EVT:
176 try {
177 clearDnsUpdateRequest();
178 buildReplaceFwdAddressRequest();
179 } catch (const std::exception& ex) {
180 // While unlikely, the build might fail if we have invalid
181 // data. Should that be the case, we need to fail the
182 // transaction.
183 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_ADD_BUILD_FAILURE)
184 .arg(getRequestId())
185 .arg(getNcr()->toText())
186 .arg(ex.what());
187 transition(PROCESS_TRANS_FAILED_ST, UPDATE_FAILED_EVT);
188 break;
189 }
190
191 // Call sendUpdate() to initiate the async send. Note it also sets
192 // next event to NOP_EVT.
193 sendUpdate("Forward Add");
194 break;
195
196 case IO_COMPLETED_EVT: {
197 switch (getDnsUpdateStatus()) {
198 case DNSClient::SUCCESS: {
199 // We successfully received a response packet from the server.
200 const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
201 if (rcode == dns::Rcode::NOERROR()) {
202 // We were able to add it. Mark it as done.
203 setForwardChangeCompleted(true);
204
205 // If request calls for reverse update then do that next,
206 // otherwise we can process ok.
207 if (getReverseDomain()) {
208 transition(SELECTING_REV_SERVER_ST, SELECT_SERVER_EVT);
209 } else {
210 transition(PROCESS_TRANS_OK_ST, UPDATE_OK_EVT);
211 }
212 } else {
213 // Any other value means cease. Really shouldn't happen.
214 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_ADD_REJECTED)
215 .arg(getRequestId())
216 .arg(getCurrentServer()->toText())
217 .arg(getNcr()->getFqdn())
218 .arg(rcode.getCode());
219 transition(PROCESS_TRANS_FAILED_ST, UPDATE_FAILED_EVT);
220 }
221
222 break;
223 }
224
225 case DNSClient::TIMEOUT:
226 // No response from the server, log it and set up
227 // to select the next server for a retry.
228 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_ADD_TIMEOUT)
229 .arg(getRequestId())
230 .arg(getNcr()->getFqdn())
231 .arg(getCurrentServer()->toText());
232
233 retryTransition(SELECTING_FWD_SERVER_ST);
234 break;
235
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 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_ADD_IO_ERROR)
240 .arg(getRequestId())
241 .arg(getNcr()->getFqdn())
242 .arg(getCurrentServer()->toText());
243
244 retryTransition(SELECTING_FWD_SERVER_ST);
245 break;
246
247 case DNSClient::INVALID_RESPONSE:
248 // A response was received but was corrupt. Retry it like an IO
249 // error.
250 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_ADD_RESP_CORRUPT)
251 .arg(getRequestId())
252 .arg(getCurrentServer()->toText())
253 .arg(getNcr()->getFqdn());
254
255 retryTransition(SELECTING_FWD_SERVER_ST);
256 break;
257
258 default:
259 // Any other value and we will fail this transaction, something
260 // bigger is wrong.
261 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_FORWARD_ADD_BAD_DNSCLIENT_STATUS)
262 .arg(getRequestId())
263 .arg(getDnsUpdateStatus())
264 .arg(getNcr()->getFqdn())
265 .arg(getCurrentServer()->toText());
266
267 transition(PROCESS_TRANS_FAILED_ST, UPDATE_FAILED_EVT);
268 break;
269 } // end switch on dns_status
270
271 break;
272 } // end case IO_COMPLETE_EVT
273
274 default:
275 // Event is invalid.
276 isc_throw(SimpleAddWithoutDHCIDTransactionError,
277 "Wrong event for context: " << getContextStr());
278 }
279}
280
281void
282SimpleAddWithoutDHCIDTransaction::selectingRevServerHandler() {
283 switch(getNextEvent()) {
284 case SELECT_SERVER_EVT:
285 // First time through for this transaction, so initialize server
286 // selection.
287 initServerSelection(getReverseDomain());
288 break;
289 case SERVER_IO_ERROR_EVT:
290 // We failed to communicate with current server. Attempt to select
291 // another one below.
292 break;
293 default:
294 // Event is invalid.
295 isc_throw(SimpleAddWithoutDHCIDTransactionError,
296 "Wrong event for context: " << getContextStr());
297 }
298
299 // Select the next server from the list of forward servers.
300 if (selectNextServer()) {
301 // We have a server to try.
302 transition(REPLACING_REV_PTRS_ST, SERVER_SELECTED_EVT);
303 }
304 else {
305 // Server list is exhausted, so fail the transaction.
306 transition(PROCESS_TRANS_FAILED_ST, NO_MORE_SERVERS_EVT);
307 }
308}
309
310
311void
312SimpleAddWithoutDHCIDTransaction::replacingRevPtrsHandler() {
313 if (doOnEntry()) {
314 // Clear the update attempts count on initial transition.
315 clearUpdateAttempts();
316 }
317
318 switch(getNextEvent()) {
319 case SERVER_SELECTED_EVT:
320 try {
321 clearDnsUpdateRequest();
322 buildReplaceRevPtrsRequest();
323 } catch (const std::exception& ex) {
324 // While unlikely, the build might fail if we have invalid
325 // data. Should that be the case, we need to fail the
326 // transaction.
327 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_REVERSE_REPLACE_BUILD_FAILURE)
328 .arg(getRequestId())
329 .arg(getNcr()->toText())
330 .arg(ex.what());
331 transition(PROCESS_TRANS_FAILED_ST, UPDATE_FAILED_EVT);
332 break;
333 }
334
335 // Call sendUpdate() to initiate the async send. Note it also sets
336 // next event to NOP_EVT.
337 sendUpdate("Reverse Replace");
338 break;
339
340 case IO_COMPLETED_EVT: {
341 switch (getDnsUpdateStatus()) {
342 case DNSClient::SUCCESS: {
343 // We successfully received a response packet from the server.
344 const dns::Rcode& rcode = getDnsUpdateResponse()->getRcode();
345 if (rcode == dns::Rcode::NOERROR()) {
346 // We were able to update the reverse mapping. Mark it as done.
347 setReverseChangeCompleted(true);
348 transition(PROCESS_TRANS_OK_ST, UPDATE_OK_EVT);
349 } else {
350 // Per RFC4703 any other value means cease.
351 // If we get not authorized should try the next server in
352 // the list? @todo This needs some discussion perhaps.
353 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_REVERSE_REPLACE_REJECTED)
354 .arg(getRequestId())
355 .arg(getCurrentServer()->toText())
356 .arg(getNcr()->getFqdn())
357 .arg(rcode.getCode());
358 transition(PROCESS_TRANS_FAILED_ST, UPDATE_FAILED_EVT);
359 }
360
361 break;
362 }
363
364 case DNSClient::TIMEOUT:
365 // No response from the server, log it and set up
366 // to select the next server for a retry.
367 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_REVERSE_REPLACE_TIMEOUT)
368 .arg(getRequestId())
369 .arg(getNcr()->getFqdn())
370 .arg(getCurrentServer()->toText());
371
372 // If we are out of retries on this server, we go back and start
373 // all over on a new server.
374 retryTransition(SELECTING_REV_SERVER_ST);
375 break;
376
377 case DNSClient::OTHER:
378 // We couldn't send to the current server, log it and set up
379 // to select the next server for a retry.
380 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_REVERSE_REPLACE_IO_ERROR)
381 .arg(getRequestId())
382 .arg(getNcr()->getFqdn())
383 .arg(getCurrentServer()->toText());
384
385 // If we are out of retries on this server, we go back and start
386 // all over on a new server.
387 retryTransition(SELECTING_REV_SERVER_ST);
388 break;
389
390 case DNSClient::INVALID_RESPONSE:
391 // A response was received but was corrupt. Retry it like an IO
392 // error.
393 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_REVERSE_REPLACE_RESP_CORRUPT)
394 .arg(getRequestId())
395 .arg(getCurrentServer()->toText())
396 .arg(getNcr()->getFqdn());
397
398 // If we are out of retries on this server, we go back and start
399 // all over on a new server.
400 retryTransition(SELECTING_REV_SERVER_ST);
401 break;
402
403 default:
404 // Any other value and we will fail this transaction, something
405 // bigger is wrong.
406 LOG_ERROR(d2_to_dns_logger,
407 DHCP_DDNS_REVERSE_REPLACE_BAD_DNSCLIENT_STATUS)
408 .arg(getRequestId())
409 .arg(getDnsUpdateStatus())
410 .arg(getNcr()->getFqdn())
411 .arg(getCurrentServer()->toText());
412
413 transition(PROCESS_TRANS_FAILED_ST, UPDATE_FAILED_EVT);
414 break;
415 } // end switch on dns_status
416
417 break;
418 } // end case IO_COMPLETE_EVT
419
420 default:
421 // Event is invalid.
422 isc_throw(SimpleAddWithoutDHCIDTransactionError,
423 "Wrong event for context: " << getContextStr());
424 }
425}
426
427void
428SimpleAddWithoutDHCIDTransaction::processAddOkHandler() {
429 switch(getNextEvent()) {
430 case UPDATE_OK_EVT:
431 LOG_INFO(d2_to_dns_logger, DHCP_DDNS_ADD_SUCCEEDED)
432 .arg(getRequestId())
433 .arg(getNcr()->toText());
434 setNcrStatus(dhcp_ddns::ST_COMPLETED);
435 endModel();
436 break;
437 default:
438 // Event is invalid.
439 isc_throw(SimpleAddWithoutDHCIDTransactionError,
440 "Wrong event for context: " << getContextStr());
441 }
442}
443
444void
445SimpleAddWithoutDHCIDTransaction::processAddFailedHandler() {
446 switch(getNextEvent()) {
447 case UPDATE_FAILED_EVT:
448 case NO_MORE_SERVERS_EVT:
449 setNcrStatus(dhcp_ddns::ST_FAILED);
450 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_ADD_FAILED)
451 .arg(getRequestId())
452 .arg(transactionOutcomeString());
453 endModel();
454 break;
455 default:
456 // Event is invalid.
457 isc_throw(SimpleAddWithoutDHCIDTransactionError,
458 "Wrong event for context: " << getContextStr());
459 }
460}
461
462void
463SimpleAddWithoutDHCIDTransaction::buildReplaceFwdAddressRequest() {
464 // Construct an empty request.
465 D2UpdateMessagePtr request = prepNewRequest(getForwardDomain());
466
467 // Construct dns::Name from NCR fqdn.
468 dns::Name fqdn(dns::Name(getNcr()->getFqdn()));
469
470 // There are no prerequisites.
471
472 // Build the Update Section. First we delete any pre-existing
473 // FQDN/IP RR. Then we add new one.
474
475 // Create the FQDN/IP 'delete' RR and add it to update section.
476 dns::RRsetPtr update(new dns::RRset(fqdn, dns::RRClass::ANY(),
477 getAddressRRType(), dns::RRTTL(0)));
478
479 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
480
481 // Now make the new RRs.
482 // Create the TTL based on lease length.
483 dns::RRTTL lease_ttl(getNcr()->getLeaseLength());
484
485 // Create the FQDN/IP 'add' RR and add it to the to update section.
486 // Based on RFC 2136, section 2.5.1
487 update.reset(new dns::RRset(fqdn, dns::RRClass::IN(),
488 getAddressRRType(), lease_ttl));
489
490 addLeaseAddressRdata(update);
491 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
492
493 // Set the transaction's update request to the new request.
494 setDnsUpdateRequest(request);
495}
496
497void
498SimpleAddWithoutDHCIDTransaction::buildReplaceRevPtrsRequest() {
499 // Construct an empty request.
500 D2UpdateMessagePtr request = prepNewRequest(getReverseDomain());
501
502 // Create the reverse IP address "FQDN".
503 std::string rev_addr = D2CfgMgr::reverseIpAddress(getNcr()->getIpAddress());
504 dns::Name rev_ip(rev_addr);
505
506 // Create the TTL based on lease length.
507 dns::RRTTL lease_ttl(getNcr()->getLeaseLength());
508
509 // There are no prerequisites.
510
511 // Create the FQDN/IP PTR 'delete' RR for this IP and add it to
512 // the update section.
513 dns::RRsetPtr update(new dns::RRset(rev_ip, dns::RRClass::ANY(),
514 dns::RRType::PTR(), dns::RRTTL(0)));
515 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
516
517 // Create the FQDN/IP PTR 'add' RR, add the FQDN as the PTR Rdata
518 // then add it to update section.
519 update.reset(new dns::RRset(rev_ip, dns::RRClass::IN(),
520 dns::RRType::PTR(), lease_ttl));
521 addPtrRdata(update);
522 request->addRRset(D2UpdateMessage::SECTION_UPDATE, update);
523
524 // Set the transaction's update request to the new request.
525 setDnsUpdateRequest(request);
526}
527
528} // namespace isc::d2
529} // namespace isc
buffer.h
isc::d2::D2CfgMgr::reverseIpAddress
static std::string reverseIpAddress(const std::string &address)
Generate a reverse order string for the given IP address.
Definition d2_cfg_mgr.cc:183
isc::d2::D2UpdateMessage::SECTION_UPDATE
@ SECTION_UPDATE
Definition d2_update_message.h:120
isc::d2::DNSClient::TIMEOUT
@ TIMEOUT
No response, timeout.
Definition dns_client.h:60
isc::d2::DNSClient::OTHER
@ OTHER
Other, unclassified error.
Definition dns_client.h:63
isc::d2::DNSClient::INVALID_RESPONSE
@ INVALID_RESPONSE
Response received but invalid.
Definition dns_client.h:62
isc::d2::DNSClient::SUCCESS
@ SUCCESS
Response received and is ok.
Definition dns_client.h:59
isc::d2::NameChangeTransaction::SELECTING_FWD_SERVER_ST
static const int SELECTING_FWD_SERVER_ST
State in which forward DNS server selection is done.
Definition nc_trans.h:91
isc::d2::NameChangeTransaction::retryTransition
void retryTransition(const int fail_to_state)
Determines the state and next event based on update attempts.
Definition nc_trans.cc:286
isc::d2::NameChangeTransaction::PROCESS_TRANS_FAILED_ST
static const int PROCESS_TRANS_FAILED_ST
State which processes an unsuccessful transaction conclusion.
Definition nc_trans.h:105
isc::d2::NameChangeTransaction::READY_ST
static const int READY_ST
State from which a transaction is started.
Definition nc_trans.h:83
isc::d2::NameChangeTransaction::getDnsUpdateResponse
const D2UpdateMessagePtr & getDnsUpdateResponse() const
Fetches the most recent DNS update response packet.
Definition nc_trans.cc:553
isc::d2::NameChangeTransaction::PROCESS_TRANS_OK_ST
static const int PROCESS_TRANS_OK_ST
State which processes successful transaction conclusion.
Definition nc_trans.h:102
isc::d2::NameChangeTransaction::UPDATE_OK_EVT
static const int UPDATE_OK_EVT
Issued when the attempted update successfully completed.
Definition nc_trans.h:135
isc::d2::NameChangeTransaction::verifyStates
virtual void verifyStates()
Validates the contents of the set of states.
Definition nc_trans.cc:265
isc::d2::NameChangeTransaction::prepNewRequest
virtual D2UpdateMessagePtr prepNewRequest(DdnsDomainPtr domain)
Creates a new DNS update request based on the given domain.
Definition nc_trans.cc:343
isc::d2::NameChangeTransaction::NameChangeTransaction
NameChangeTransaction(asiolink::IOServicePtr &io_service, dhcp_ddns::NameChangeRequestPtr &ncr, DdnsDomainPtr &forward_domain, DdnsDomainPtr &reverse_domain, D2CfgMgrPtr &cfg_mgr)
Constructor.
Definition nc_trans.cc:69
isc::d2::NameChangeTransaction::UPDATE_FAILED_EVT
static const int UPDATE_FAILED_EVT
Issued when the attempted update fails to complete.
Definition nc_trans.h:141
isc::d2::NameChangeTransaction::getAddressRRType
const dns::RRType & getAddressRRType() const
Returns the DHCP data type for the lease address.
Definition nc_trans.cc:573
isc::d2::NameChangeTransaction::getNcr
const dhcp_ddns::NameChangeRequestPtr & getNcr() const
Fetches the NameChangeRequest for this transaction.
Definition nc_trans.cc:425
isc::d2::NameChangeTransaction::initServerSelection
void initServerSelection(const DdnsDomainPtr &domain)
Initializes server selection from the given DDNS domain.
Definition nc_trans.cc:455
isc::d2::NameChangeTransaction::IO_COMPLETED_EVT
static const int IO_COMPLETED_EVT
Issued when a DNS update packet exchange has completed.
Definition nc_trans.h:130
isc::d2::NameChangeTransaction::SELECT_SERVER_EVT
static const int SELECT_SERVER_EVT
Issued when a server needs to be selected.
Definition nc_trans.h:113
isc::d2::NameChangeTransaction::SERVER_IO_ERROR_EVT
static const int SERVER_IO_ERROR_EVT
Issued when an update fails due to an IO error.
Definition nc_trans.h:119
isc::d2::NameChangeTransaction::getRequestId
std::string getRequestId() const
Fetches the request id that identifies this transaction.
Definition nc_trans.cc:435
isc::d2::NameChangeTransaction::defineStates
virtual void defineStates()
Adds states defined by NameChangeTransaction to the state set.
Definition nc_trans.cc:257
isc::d2::NameChangeTransaction::addLeaseAddressRdata
void addLeaseAddressRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease address to the given RRset.
Definition nc_trans.cc:366
isc::d2::NameChangeTransaction::sendUpdate
virtual void sendUpdate(const std::string &comment="")
Send the update request to the current server.
Definition nc_trans.cc:192
isc::d2::NameChangeTransaction::setForwardChangeCompleted
void setForwardChangeCompleted(const bool value)
Sets the forward change completion flag to the given value.
Definition nc_trans.cc:328
isc::d2::NameChangeTransaction::addPtrRdata
void addPtrRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease FQDN to the given RRset.
Definition nc_trans.cc:408
isc::d2::NameChangeTransaction::selectNextServer
bool selectNextServer()
Selects the next server in the current server list.
Definition nc_trans.cc:467
isc::d2::NameChangeTransaction::setNcrStatus
void setNcrStatus(const dhcp_ddns::NameChangeStatus &status)
Sets the status of the transaction's NameChangeRequest.
Definition nc_trans.cc:538
isc::d2::NameChangeTransaction::getForwardDomain
DdnsDomainPtr & getForwardDomain()
Fetches the forward DdnsDomain.
Definition nc_trans.cc:445
isc::d2::NameChangeTransaction::verifyEvents
virtual void verifyEvents()
Validates the contents of the set of events.
Definition nc_trans.cc:242
isc::d2::NameChangeTransaction::clearDnsUpdateRequest
void clearDnsUpdateRequest()
Destroys the current update request packet.
Definition nc_trans.cc:303
isc::d2::NameChangeTransaction::clearUpdateAttempts
void clearUpdateAttempts()
Resets the update attempts count.
Definition nc_trans.cc:308
isc::d2::NameChangeTransaction::SELECTING_REV_SERVER_ST
static const int SELECTING_REV_SERVER_ST
State in which reverse DNS server selection is done.
Definition nc_trans.h:99
isc::d2::NameChangeTransaction::getDnsUpdateStatus
DNSClient::Status getDnsUpdateStatus() const
Fetches the most recent DNS update status.
Definition nc_trans.cc:548
isc::d2::NameChangeTransaction::setDnsUpdateRequest
void setDnsUpdateRequest(D2UpdateMessagePtr &request)
Sets the update request packet to the given packet.
Definition nc_trans.cc:298
isc::d2::NameChangeTransaction::NO_MORE_SERVERS_EVT
static const int NO_MORE_SERVERS_EVT
Issued when there are no more servers from which to select.
Definition nc_trans.h:125
isc::d2::NameChangeTransaction::defineEvents
virtual void defineEvents()
Adds events defined by NameChangeTransaction to the event set.
Definition nc_trans.cc:227
isc::d2::NameChangeTransaction::setReverseChangeCompleted
void setReverseChangeCompleted(const bool value)
Sets the reverse change completion flag to the given value.
Definition nc_trans.cc:333
isc::d2::NameChangeTransaction::getCurrentServer
const DnsServerInfoPtr & getCurrentServer() const
Fetches the currently selected server.
Definition nc_trans.cc:533
isc::d2::NameChangeTransaction::SERVER_SELECTED_EVT
static const int SERVER_SELECTED_EVT
Issued when a server has been selected.
Definition nc_trans.h:116
isc::d2::NameChangeTransaction::getReverseDomain
DdnsDomainPtr & getReverseDomain()
Fetches the reverse DdnsDomain.
Definition nc_trans.cc:450
isc::d2::NameChangeTransaction::transactionOutcomeString
std::string transactionOutcomeString() const
Returns a string version of transaction outcome.
Definition nc_trans.cc:170
isc::d2::SimpleAddWithoutDHCIDTransactionError
Thrown if the SimpleAddWithoutDHCIDTransaction encounters a general error.
Definition simple_add_without_dhcid.h:19
isc::d2::SimpleAddWithoutDHCIDTransaction::replacingRevPtrsHandler
void replacingRevPtrsHandler()
State handler for REPLACING_REV_PTRS_ST.
Definition simple_add_without_dhcid.cc:312
isc::d2::SimpleAddWithoutDHCIDTransaction::FQDN_NOT_IN_USE_EVT
static const int FQDN_NOT_IN_USE_EVT
Event sent when replace attempt fails with address not in use.
Definition simple_add_without_dhcid.h:65
isc::d2::SimpleAddWithoutDHCIDTransaction::defineStates
virtual void defineStates()
Adds states defined by SimpleAddWithoutDHCID to the state set.
Definition simple_add_without_dhcid.cc:75
isc::d2::SimpleAddWithoutDHCIDTransaction::SimpleAddWithoutDHCIDTransaction
SimpleAddWithoutDHCIDTransaction(asiolink::IOServicePtr &io_service, dhcp_ddns::NameChangeRequestPtr &ncr, DdnsDomainPtr &forward_domain, DdnsDomainPtr &reverse_domain, D2CfgMgrPtr &cfg_mgr)
Constructor.
Definition simple_add_without_dhcid.cc:30
isc::d2::SimpleAddWithoutDHCIDTransaction::REPLACING_REV_PTRS_ST
static const int REPLACING_REV_PTRS_ST
State that attempts to replace reverse PTR records.
Definition simple_add_without_dhcid.h:57
isc::d2::SimpleAddWithoutDHCIDTransaction::defineEvents
virtual void defineEvents()
Adds events defined by SimpleAddWithoutDHCID to the event set.
Definition simple_add_without_dhcid.cc:47
isc::d2::SimpleAddWithoutDHCIDTransaction::REPLACING_FWD_ADDRS_ST
static const int REPLACING_FWD_ADDRS_ST
State that attempts to add forward address records.
Definition simple_add_without_dhcid.h:54
isc::d2::SimpleAddWithoutDHCIDTransaction::readyHandler
void readyHandler()
State handler for READY_ST.
Definition simple_add_without_dhcid.cc:119
isc::d2::SimpleAddWithoutDHCIDTransaction::buildReplaceRevPtrsRequest
void buildReplaceRevPtrsRequest()
Builds a DNS request to replace a reverse DNS entry for an FQDN.
Definition simple_add_without_dhcid.cc:498
isc::d2::SimpleAddWithoutDHCIDTransaction::buildReplaceFwdAddressRequest
void buildReplaceFwdAddressRequest()
Builds a DNS request to add/replace a forward DNS entry for an FQDN.
Definition simple_add_without_dhcid.cc:463
isc::d2::SimpleAddWithoutDHCIDTransaction::selectingRevServerHandler
void selectingRevServerHandler()
State handler for SELECTING_REV_SERVER_ST.
Definition simple_add_without_dhcid.cc:282
isc::d2::SimpleAddWithoutDHCIDTransaction::FQDN_IN_USE_EVT
static const int FQDN_IN_USE_EVT
Event sent when an add attempt fails with address in use.
Definition simple_add_without_dhcid.h:62
isc::d2::SimpleAddWithoutDHCIDTransaction::verifyEvents
virtual void verifyEvents()
Validates the contents of the set of events.
Definition simple_add_without_dhcid.cc:57
isc::d2::SimpleAddWithoutDHCIDTransaction::selectingFwdServerHandler
void selectingFwdServerHandler()
State handler for SELECTING_FWD_SERVER_ST.
Definition simple_add_without_dhcid.cc:139
isc::d2::SimpleAddWithoutDHCIDTransaction::verifyStates
virtual void verifyStates()
Validates the contents of the set of states.
Definition simple_add_without_dhcid.cc:103
isc::d2::SimpleAddWithoutDHCIDTransaction::replacingFwdAddrsHandler
void replacingFwdAddrsHandler()
State handler for REPLACING_FWD_ADDRS_ST.
Definition simple_add_without_dhcid.cc:168
isc::d2::SimpleAddWithoutDHCIDTransaction::processAddFailedHandler
void processAddFailedHandler()
State handler for PROCESS_TRANS_FAILED_ST.
Definition simple_add_without_dhcid.cc:445
isc::d2::SimpleAddWithoutDHCIDTransaction::~SimpleAddWithoutDHCIDTransaction
virtual ~SimpleAddWithoutDHCIDTransaction()
Destructor.
Definition simple_add_without_dhcid.cc:43
isc::d2::SimpleAddWithoutDHCIDTransaction::processAddOkHandler
void processAddOkHandler()
State handler for PROCESS_TRANS_OK_ST.
Definition simple_add_without_dhcid.cc:428
isc::dns::Name
The Name class encapsulates DNS names.
Definition name.h:219
isc::dns::RRClass::ANY
static const RRClass & ANY()
Definition rrclass.h:298
isc::dns::RRClass::IN
static const RRClass & IN()
Definition rrclass.h:304
isc::dns::RRTTL
The RRTTL class encapsulates TTLs used in DNS resource records.
Definition rrttl.h:51
isc::dns::RRType::PTR
static const RRType & PTR()
Definition rrtype.h:303
isc::dns::RRset
The RRset class is a concrete derived class of BasicRRset which contains a pointer to an additional R...
Definition rrset.h:844
isc::dns::Rcode
DNS Response Codes (RCODEs) class.
Definition rcode.h:40
isc::dns::Rcode::NOERROR
static const Rcode & NOERROR()
A constant object for the NOERROR Rcode (see Rcode::NOERROR_CODE).
Definition rcode.h:228
isc::dns::Rcode::getCode
uint16_t getCode() const
Returns the Rcode code value.
Definition rcode.h:106
isc::util::StateModel::endModel
void endModel()
Conducts a normal transition to the end of the model.
Definition state_model.cc:271
isc::util::StateModel::getStateInternal
const StatePtr getStateInternal(int value)
Fetches the state referred to by value.
Definition state_model.cc:219
isc::util::StateModel::defineEvent
void defineEvent(int value, const std::string &label)
Adds an event value and associated label to the set of events.
Definition state_model.cc:170
isc::util::StateModel::doOnEntry
bool doOnEntry()
Checks if on entry flag is true.
Definition state_model.cc:339
isc::util::StateModel::START_EVT
static const int START_EVT
Event issued to start the model execution.
Definition state_model.h:295
isc::util::StateModel::defineState
void defineState(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
isc::util::StateModel::getEvent
const EventPtr & getEvent(int value)
Fetches the event referred to by value.
Definition state_model.cc:186
isc::util::StateModel::transition
void transition(int state, int event)
Sets up the model to transition into given state with a given event.
Definition state_model.cc:264
isc::util::StateModel::getNextEvent
int getNextEvent() const
Fetches the model's next event.
Definition state_model.cc:373
isc::util::StateModel::getContextStr
std::string getContextStr() const
Convenience method which returns a string rendition of the current state and next event.
Definition state_model.cc:443
d2_cfg_mgr.h
d2_log.h
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition exceptions/exceptions.h:210
LOG_ERROR
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
Definition macros.h:32
LOG_INFO
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
Definition macros.h:20
isc::asiolink::IOServicePtr
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
Definition io_service.h:35
isc::d2
Definition check_exists_add.cc:19
isc::d2::D2UpdateMessagePtr
boost::shared_ptr< D2UpdateMessage > D2UpdateMessagePtr
Pointer to the DNS Update Message.
Definition d2_update_message.h:73
isc::d2::DHCP_DDNS_FORWARD_ADD_BUILD_FAILURE
const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_BUILD_FAILURE
Definition d2_messages.h:22
isc::d2::DdnsDomainPtr
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
Definition d2_config.h:624
isc::d2::DHCP_DDNS_FORWARD_ADD_REJECTED
const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_REJECTED
Definition d2_messages.h:24
isc::d2::DHCP_DDNS_REVERSE_REPLACE_RESP_CORRUPT
const isc::log::MessageID DHCP_DDNS_REVERSE_REPLACE_RESP_CORRUPT
Definition d2_messages.h:80
isc::d2::D2CfgMgrPtr
boost::shared_ptr< D2CfgMgr > D2CfgMgrPtr
Defines a shared pointer to D2CfgMgr.
Definition d2_cfg_mgr.h:367
isc::d2::DHCP_DDNS_ADD_SUCCEEDED
const isc::log::MessageID DHCP_DDNS_ADD_SUCCEEDED
Definition d2_messages.h:12
isc::d2::DHCP_DDNS_FORWARD_ADD_IO_ERROR
const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_IO_ERROR
Definition d2_messages.h:23
isc::d2::DHCP_DDNS_REVERSE_REPLACE_TIMEOUT
const isc::log::MessageID DHCP_DDNS_REVERSE_REPLACE_TIMEOUT
Definition d2_messages.h:81
isc::d2::DHCP_DDNS_ADD_FAILED
const isc::log::MessageID DHCP_DDNS_ADD_FAILED
Definition d2_messages.h:11
isc::d2::d2_to_dns_logger
isc::log::Logger d2_to_dns_logger("d2-to-dns")
Definition d2_log.h:20
isc::d2::DHCP_DDNS_FORWARD_ADD_TIMEOUT
const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_TIMEOUT
Definition d2_messages.h:26
isc::d2::DHCP_DDNS_REVERSE_REPLACE_REJECTED
const isc::log::MessageID DHCP_DDNS_REVERSE_REPLACE_REJECTED
Definition d2_messages.h:79
isc::d2::DHCP_DDNS_REVERSE_REPLACE_BUILD_FAILURE
const isc::log::MessageID DHCP_DDNS_REVERSE_REPLACE_BUILD_FAILURE
Definition d2_messages.h:77
isc::d2::DHCP_DDNS_FORWARD_ADD_BAD_DNSCLIENT_STATUS
const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_BAD_DNSCLIENT_STATUS
Definition d2_messages.h:21
isc::d2::DHCP_DDNS_REVERSE_REPLACE_BAD_DNSCLIENT_STATUS
const isc::log::MessageID DHCP_DDNS_REVERSE_REPLACE_BAD_DNSCLIENT_STATUS
Definition d2_messages.h:76
isc::d2::DHCP_DDNS_REVERSE_REPLACE_IO_ERROR
const isc::log::MessageID DHCP_DDNS_REVERSE_REPLACE_IO_ERROR
Definition d2_messages.h:78
isc::d2::DHCP_DDNS_FORWARD_ADD_RESP_CORRUPT
const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_RESP_CORRUPT
Definition d2_messages.h:25
isc::dhcp_ddns::ST_COMPLETED
@ ST_COMPLETED
Definition ncr_msg.h:54
isc::dhcp_ddns::ST_FAILED
@ ST_FAILED
Definition ncr_msg.h:55
isc::dhcp_ddns::NameChangeRequestPtr
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
Definition ncr_msg.h:241
isc::dhcp_ddns::CHG_ADD
@ CHG_ADD
Definition ncr_msg.h:46
isc::dns::RRsetPtr
boost::shared_ptr< AbstractRRset > RRsetPtr
A pointer-like type pointing to an RRset object.
Definition rrset.h:50
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
rdataclass.h
simple_add_without_dhcid.h
This file defines the class SimpleAddWithoutDHCIDTransaction.