Kea: nc_trans.cc Source File

| Kea 3.0.0

nc_trans.cc
Go to the documentation of this file.
1// Copyright (C) 2013-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 <d2srv/d2_log.h>
10#include <d2srv/nc_trans.h>
11#include <cryptolink/crypto_rng.h>
12#include <dns/rdata.h>
13#include <dns/rdataclass.h>
14#include <hooks/hooks.h>
15#include <hooks/hooks_manager.h>
16
17#include <sstream>
18
19using namespace isc::hooks;
20using namespace isc::util;
21
22namespace {
23
25struct NcTransHooks {
26 int hooks_index_select_key_;
27
29 NcTransHooks() {
30 hooks_index_select_key_ = HooksManager::registerHook("select_key");
31 }
32};
33
34// Declare a Hooks object. As this is outside any function or method, it
35// will be instantiated (and the constructor run) when the module is loaded.
36// As a result, the hook indexes will be defined before any method in this
37// module is called.
38
39NcTransHooks Hooks;
40
41}
42
43namespace isc {
44namespace d2 {
45
46// Common transaction states
47const int NameChangeTransaction::READY_ST;
48const int NameChangeTransaction::SELECTING_FWD_SERVER_ST;
49const int NameChangeTransaction::SELECTING_REV_SERVER_ST;
50const int NameChangeTransaction::PROCESS_TRANS_OK_ST;
51const int NameChangeTransaction::PROCESS_TRANS_FAILED_ST;
52
53const int NameChangeTransaction::NCT_DERIVED_STATE_MIN;
54
55// Common transaction events
56const int NameChangeTransaction::SELECT_SERVER_EVT;
57const int NameChangeTransaction::SERVER_SELECTED_EVT;
58const int NameChangeTransaction::SERVER_IO_ERROR_EVT;
59const int NameChangeTransaction::NO_MORE_SERVERS_EVT;
60const int NameChangeTransaction::IO_COMPLETED_EVT;
61const int NameChangeTransaction::UPDATE_OK_EVT;
62const int NameChangeTransaction::UPDATE_FAILED_EVT;
63
64const int NameChangeTransaction::NCT_DERIVED_EVENT_MIN;
65
66const unsigned int NameChangeTransaction::MAX_UPDATE_TRIES_PER_SERVER;
67
68NameChangeTransaction::
69 NameChangeTransaction(asiolink::IOServicePtr& io_service,
70 dhcp_ddns::NameChangeRequestPtr& ncr,
71 DdnsDomainPtr& forward_domain,
72 DdnsDomainPtr& reverse_domain,
73 D2CfgMgrPtr& cfg_mgr)
74 : io_service_(io_service), ncr_(ncr), forward_domain_(forward_domain),
75 reverse_domain_(reverse_domain), dns_client_(), dns_update_request_(),
76 dns_update_status_(DNSClient::OTHER), dns_update_response_(),
77 forward_change_completed_(false), reverse_change_completed_(false),
78 current_server_list_(), current_server_(), next_server_pos_(0),
79 update_attempts_(0), cfg_mgr_(cfg_mgr), tsig_key_() {
82 if (!io_service_) {
83 isc_throw(NameChangeTransactionError, "IOServicePtr cannot be null");
84 }
85
86 if (!ncr_) {
87 isc_throw(NameChangeTransactionError,
88 "NameChangeRequest cannot be null");
89 }
90
91 if (ncr_->isForwardChange() && !(forward_domain_)) {
92 isc_throw(NameChangeTransactionError,
93 "Forward change must have a forward domain");
94 }
95
96 if (ncr_->isReverseChange() && !(reverse_domain_)) {
97 isc_throw(NameChangeTransactionError,
98 "Reverse change must have a reverse domain");
99 }
100
101 if (!cfg_mgr_) {
102 isc_throw(NameChangeTransactionError,
103 "Configuration manager cannot be null");
104 }
105}
106
107NameChangeTransaction::~NameChangeTransaction() {
108}
109
110void
111NameChangeTransaction::startTransaction() {
112 LOG_DEBUG(d2_to_dns_logger, isc::log::DBGLVL_TRACE_DETAIL,
113 DHCP_DDNS_STARTING_TRANSACTION)
114 .arg(getRequestId());
115
116 setNcrStatus(dhcp_ddns::ST_PENDING);
117 startModel(READY_ST);
118}
119
120void
121NameChangeTransaction::operator()(DNSClient::Status status) {
122 // Stow the completion status and re-enter the run loop with the event
123 // set to indicate IO completed.
124 // runModel is exception safe so we are good to call it here.
125 // It won't exit until we hit the next IO wait or the state model ends.
126 setDnsUpdateStatus(status);
127 LOG_DEBUG(d2_to_dns_logger, isc::log::DBGLVL_TRACE_DETAIL,
128 DHCP_DDNS_UPDATE_RESPONSE_RECEIVED)
129 .arg(getRequestId())
130 .arg(current_server_->toText())
131 .arg(responseString());
132
133 runModel(IO_COMPLETED_EVT);
134}
135
136std::string
137NameChangeTransaction::responseString() const {
138 std::ostringstream stream;
139 switch (getDnsUpdateStatus()) {
140 case DNSClient::SUCCESS:
141 stream << "SUCCESS, rcode: ";
142 if (getDnsUpdateResponse()) {
143 stream << getDnsUpdateResponse()->getRcode().toText();
144 } else {
145 stream << " update response is NULL";
146 }
147 break;
148 case DNSClient::TIMEOUT:
149 stream << "TIMEOUT";
150 break;
151 case DNSClient::IO_STOPPED:
152 stream << "IO_STOPPED";
153 break;
154 case DNSClient::INVALID_RESPONSE:
155 stream << "INVALID_RESPONSE";
156 break;
157 case DNSClient::OTHER:
158 stream << "OTHER";
159 break;
160 default:
161 stream << "UNKNOWN("
162 << static_cast<int>(getDnsUpdateStatus()) << ")";
163 break;
164
165 }
166
167 return (stream.str());
168}
169
170std::string
171NameChangeTransaction::transactionOutcomeString() const {
172 std::ostringstream stream;
173 stream << "Status: " << (getNcrStatus() == dhcp_ddns::ST_COMPLETED
174 ? "Completed, " : "Failed, ")
175 << "Event: " << getEventLabel(getNextEvent()) << ", ";
176
177 if (ncr_->isForwardChange()) {
178 stream << " Forward change:" << (getForwardChangeCompleted()
179 ? " completed, " : " failed, ");
180 }
181
182 if (ncr_->isReverseChange()) {
183 stream << " Reverse change:" << (getReverseChangeCompleted()
184 ? " completed, " : " failed, ");
185 }
186
187 stream << " request: " << ncr_->toText();
188 return (stream.str());
189}
190
191
192void
193NameChangeTransaction::sendUpdate(const std::string& comment) {
194 try {
195 ++update_attempts_;
196 // @todo add logic to add/replace TSIG key info in request if
197 // use_tsig_ is true. We should be able to navigate to the TSIG key
198 // for the current server. If not we would need to add that.
199
200 D2ParamsPtr d2_params = cfg_mgr_->getD2Params();
201 dns_client_->doUpdate(io_service_, current_server_->getIpAddress(),
202 current_server_->getPort(), *dns_update_request_,
203 d2_params->getDnsServerTimeout(), tsig_key_);
204 // Message is on its way, so the next event should be NOP_EVT.
205 postNextEvent(NOP_EVT);
206 LOG_DEBUG(d2_to_dns_logger, isc::log::DBGLVL_TRACE_DETAIL,
207 DHCP_DDNS_UPDATE_REQUEST_SENT)
208 .arg(getRequestId())
209 .arg(comment)
210 .arg(current_server_->toText());
211 } catch (const std::exception& ex) {
212 // We were unable to initiate the send.
213 // It is presumed that any throw from doUpdate is due to a programmatic
214 // error, such as an unforeseen permutation of data, rather than an IO
215 // failure. IO errors should be caught by the underlying asiolink
216 // mechanisms and manifested as an unsuccessful IO status in the
217 // DNSClient callback. Any problem here most likely means the request
218 // is corrupt in some way and cannot be completed, therefore we will
219 // log it and transition it to failure.
220 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_TRANS_SEND_ERROR)
221 .arg(getRequestId())
222 .arg(ex.what());
223 transition(PROCESS_TRANS_FAILED_ST, UPDATE_FAILED_EVT);
224 }
225}
226
227void
228NameChangeTransaction::defineEvents() {
229 // Call superclass impl first.
230 StateModel::defineEvents();
231
232 // Define NCT events.
233 defineEvent(SELECT_SERVER_EVT, "SELECT_SERVER_EVT");
234 defineEvent(SERVER_SELECTED_EVT, "SERVER_SELECTED_EVT");
235 defineEvent(SERVER_IO_ERROR_EVT, "SERVER_IO_ERROR_EVT");
236 defineEvent(NO_MORE_SERVERS_EVT, "NO_MORE_SERVERS_EVT");
237 defineEvent(IO_COMPLETED_EVT, "IO_COMPLETED_EVT");
238 defineEvent(UPDATE_OK_EVT, "UPDATE_OK_EVT");
239 defineEvent(UPDATE_FAILED_EVT, "UPDATE_FAILED_EVT");
240}
241
242void
243NameChangeTransaction::verifyEvents() {
244 // Call superclass impl first.
245 StateModel::verifyEvents();
246
247 // Verify NCT events.
248 getEvent(SELECT_SERVER_EVT);
249 getEvent(SERVER_SELECTED_EVT);
250 getEvent(SERVER_IO_ERROR_EVT);
251 getEvent(NO_MORE_SERVERS_EVT);
252 getEvent(IO_COMPLETED_EVT);
253 getEvent(UPDATE_OK_EVT);
254 getEvent(UPDATE_FAILED_EVT);
255}
256
257void
258NameChangeTransaction::defineStates() {
259 // Call superclass impl first.
260 StateModel::defineStates();
261 // This class is "abstract" in that it does not supply handlers for its
262 // states, derivations must do that therefore they must define them.
263}
264
265void
266NameChangeTransaction::verifyStates() {
267 // Call superclass impl first.
268 StateModel::verifyStates();
269
270 // Verify NCT states. This ensures that derivations provide the handlers.
271 getStateInternal(READY_ST);
272 getStateInternal(SELECTING_FWD_SERVER_ST);
273 getStateInternal(SELECTING_REV_SERVER_ST);
274 getStateInternal(PROCESS_TRANS_OK_ST);
275 getStateInternal(PROCESS_TRANS_FAILED_ST);
276}
277
278void
279NameChangeTransaction::onModelFailure(const std::string& explanation) {
280 setNcrStatus(dhcp_ddns::ST_FAILED);
281 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_STATE_MODEL_UNEXPECTED_ERROR)
282 .arg(getRequestId())
283 .arg(explanation);
284}
285
286void
287NameChangeTransaction::retryTransition(const int fail_to_state) {
288 if (update_attempts_ < MAX_UPDATE_TRIES_PER_SERVER) {
289 // Re-enter the current state with same server selected.
290 transition(getCurrState(), SERVER_SELECTED_EVT);
291 } else {
292 // Transition to given fail_to_state state if we are out
293 // of retries.
294 transition(fail_to_state, SERVER_IO_ERROR_EVT);
295 }
296}
297
298void
299NameChangeTransaction::setDnsUpdateRequest(D2UpdateMessagePtr& request) {
300 dns_update_request_ = request;
301}
302
303void
304NameChangeTransaction::clearDnsUpdateRequest() {
305 dns_update_request_.reset();
306}
307
308void
309NameChangeTransaction::clearUpdateAttempts() {
310 update_attempts_ = 0;
311}
312
313void
314NameChangeTransaction::setDnsUpdateStatus(const DNSClient::Status& status) {
315 dns_update_status_ = status;
316}
317
318void
319NameChangeTransaction::setDnsUpdateResponse(D2UpdateMessagePtr& response) {
320 dns_update_response_ = response;
321}
322
323void
324NameChangeTransaction::clearDnsUpdateResponse() {
325 dns_update_response_.reset();
326}
327
328void
329NameChangeTransaction::setForwardChangeCompleted(const bool value) {
330 forward_change_completed_ = value;
331}
332
333void
334NameChangeTransaction::setReverseChangeCompleted(const bool value) {
335 reverse_change_completed_ = value;
336}
337
338void
339NameChangeTransaction::setUpdateAttempts(const size_t value) {
340 update_attempts_ = value;
341}
342
343 D2UpdateMessagePtr
344NameChangeTransaction::prepNewRequest(DdnsDomainPtr domain) {
345 if (!domain) {
346 isc_throw(NameChangeTransactionError,
347 "prepNewRequest - domain cannot be null");
348 }
349
350 try {
351 // Create a "blank" update request.
352 D2UpdateMessagePtr request(new D2UpdateMessage(D2UpdateMessage::
353 OUTBOUND));
354 // Set the query id
355 request->setId(cryptolink::generateQid());
356 // Construct the Zone Section.
357 dns::Name zone_name(domain->getName());
358 request->setZone(zone_name, dns::RRClass::IN());
359 return (request);
360 } catch (const std::exception& ex) {
361 isc_throw(NameChangeTransactionError, "Cannot create new request :"
362 << ex.what());
363 }
364}
365
366void
367NameChangeTransaction::addLeaseAddressRdata(dns::RRsetPtr& rrset) {
368 if (!rrset) {
369 isc_throw(NameChangeTransactionError,
370 "addLeaseAddressRdata - RRset cannot cannot be null");
371 }
372
373 try {
374 // Manufacture an RData from the lease address then add it to the RR.
375 dns::rdata::ConstRdataPtr rdata;
376 if (ncr_->isV4()) {
377 rdata.reset(new dns::rdata::in::A(ncr_->getIpAddress()));
378 } else {
379 rdata.reset(new dns::rdata::in::AAAA(ncr_->getIpAddress()));
380 }
381 rrset->addRdata(rdata);
382 } catch (const std::exception& ex) {
383 isc_throw(NameChangeTransactionError, "Cannot add address rdata: "
384 << ex.what());
385 }
386}
387
388void
389NameChangeTransaction::addDhcidRdata(dns::RRsetPtr& rrset) {
390 if (!rrset) {
391 isc_throw(NameChangeTransactionError,
392 "addDhcidRdata - RRset cannot cannot be null");
393 }
394
395 try {
396 const std::vector<uint8_t>& ncr_dhcid = ncr_->getDhcid().getBytes();
397 util::InputBuffer buffer(ncr_dhcid.data(), ncr_dhcid.size());
398 dns::rdata::ConstRdataPtr rdata (new dns::rdata::in::
399 DHCID(buffer, ncr_dhcid.size()));
400 rrset->addRdata(rdata);
401 } catch (const std::exception& ex) {
402 isc_throw(NameChangeTransactionError, "Cannot add DCHID rdata: "
403 << ex.what());
404 }
405
406}
407
408void
409NameChangeTransaction::addPtrRdata(dns::RRsetPtr& rrset) {
410 if (!rrset) {
411 isc_throw(NameChangeTransactionError,
412 "addPtrRdata - RRset cannot cannot be null");
413 }
414
415 try {
416 dns::rdata::ConstRdataPtr rdata(new dns::rdata::generic::
417 PTR(getNcr()->getFqdn()));
418 rrset->addRdata(rdata);
419 } catch (const std::exception& ex) {
420 isc_throw(NameChangeTransactionError, "Cannot add PTR rdata: "
421 << ex.what());
422 }
423}
424
425const dhcp_ddns::NameChangeRequestPtr&
426NameChangeTransaction::getNcr() const {
427 return (ncr_);
428}
429
430const TransactionKey&
431NameChangeTransaction::getTransactionKey() const {
432 return (ncr_->getDhcid());
433}
434
435std::string
436NameChangeTransaction::getRequestId() const {
437 return (ncr_->getRequestId());
438}
439
440 dhcp_ddns::NameChangeStatus
441NameChangeTransaction::getNcrStatus() const {
442 return (ncr_->getStatus());
443}
444
445 DdnsDomainPtr&
446NameChangeTransaction::getForwardDomain() {
447 return (forward_domain_);
448}
449
450 DdnsDomainPtr&
451NameChangeTransaction::getReverseDomain() {
452 return (reverse_domain_);
453}
454
455void
456NameChangeTransaction::initServerSelection(const DdnsDomainPtr& domain) {
457 if (!domain) {
458 isc_throw(NameChangeTransactionError,
459 "initServerSelection called with an empty domain");
460 }
461
462 current_server_list_ = domain->getServers();
463 next_server_pos_ = 0;
464 current_server_.reset();
465}
466
467bool
468NameChangeTransaction::selectNextServer() {
469 for (;;) {
470 if ((current_server_list_) &&
471 (next_server_pos_ < current_server_list_->size())) {
472 current_server_ = (*current_server_list_)[next_server_pos_];
473 // Toss out any previous response.
474 dns_update_response_.reset();
475
476 // Set the tsig_key to that of the current server.
477 if (!selectTSIGKey()) {
478 ++next_server_pos_;
479 continue;
480 }
481
482 // @todo Protocol is set on DNSClient constructor. We need
483 // to propagate a configuration value downward, probably starting
484 // at global, then domain, finishing by server.
485 // Once that is supported we need to add it here.
486 dns_client_.reset(new DNSClient(dns_update_response_, this,
487 DNSClient::UDP));
488 ++next_server_pos_;
489 return (true);
490 }
491
492 return (false);
493 }
494}
495
496bool
497NameChangeTransaction::selectTSIGKey() {
498 TSIGKeyInfoPtr tsig_key_info = current_server_->getTSIGKeyInfo();
499 if (tsig_key_info) {
500 tsig_key_ = tsig_key_info->getTSIGKey();
501 } else {
502 tsig_key_.reset();
503 }
504
505 // This hook point allows hooks libraries to overwrite the TSIG key.
506 if (HooksManager::calloutsPresent(Hooks.hooks_index_select_key_)) {
507 CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle();
508
509 callout_handle->setArgument("current_server", current_server_);
510 callout_handle->setArgument("tsig_key", tsig_key_);
511
512 HooksManager::callCallouts(Hooks.hooks_index_select_key_,
513 *callout_handle);
514
515 // This server is skipped because the status is not NEXT_STEP_CONTINUE.
516 if (callout_handle->getStatus() != CalloutHandle::NEXT_STEP_CONTINUE) {
517 return (false);
518 }
519
520 // Reread the TSIG key.
521 callout_handle->getArgument("tsig_key", tsig_key_);
522 }
523
524 return (true);
525}
526
527
528const DNSClientPtr&
529NameChangeTransaction::getDNSClient() const {
530 return (dns_client_);
531}
532
533const DnsServerInfoPtr&
534NameChangeTransaction::getCurrentServer() const {
535 return (current_server_);
536}
537
538void
539NameChangeTransaction::setNcrStatus(const dhcp_ddns::NameChangeStatus& status) {
540 return (ncr_->setStatus(status));
541}
542
543const D2UpdateMessagePtr&
544NameChangeTransaction::getDnsUpdateRequest() const {
545 return (dns_update_request_);
546}
547
548 DNSClient::Status
549NameChangeTransaction::getDnsUpdateStatus() const {
550 return (dns_update_status_);
551}
552
553const D2UpdateMessagePtr&
554NameChangeTransaction::getDnsUpdateResponse() const {
555 return (dns_update_response_);
556}
557
558bool
559NameChangeTransaction::getForwardChangeCompleted() const {
560 return (forward_change_completed_);
561}
562
563bool
564NameChangeTransaction::getReverseChangeCompleted() const {
565 return (reverse_change_completed_);
566}
567
568size_t
569NameChangeTransaction::getUpdateAttempts() const {
570 return (update_attempts_);
571}
572
573const dns::RRType&
574NameChangeTransaction::getAddressRRType() const {
575 return (ncr_->isV4() ? dns::RRType::A() : dns::RRType::AAAA());
576}
577
578} // namespace isc::d2
579} // namespace isc
if
if(!(yy_init))
Definition agent_lexer.cc:1900
Hooks
CtrlAgentHooks Hooks
Definition ca_response_creator.cc:47
CalloutHandle::NEXT_STEP_CONTINUE
@ NEXT_STEP_CONTINUE
continue normally
Definition callout_handle.h:87
isc::d2::D2UpdateMessage
The D2UpdateMessage encapsulates a DNS Update message.
Definition d2_update_message.h:89
isc::d2::DNSClient
The DNSClient class handles communication with the DNS server.
Definition dns_client.h:47
isc::d2::DNSClient::Status
Status
A status code of the DNSClient.
Definition dns_client.h:58
isc::d2::DNSClient::IO_STOPPED
@ IO_STOPPED
IO was stopped.
Definition dns_client.h:61
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::DNSClient::UDP
@ UDP
Definition dns_client.h:53
isc::d2::NameChangeTransactionError
Thrown if the transaction encounters a general error.
Definition nc_trans.h:27
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:287
isc::d2::NameChangeTransaction::onModelFailure
virtual void onModelFailure(const std::string &explanation)
Handler for fatal model execution errors.
Definition nc_trans.cc:279
isc::d2::NameChangeTransaction::operator()
virtual void operator()(DNSClient::Status status)
Serves as the DNSClient IO completion event handler.
Definition nc_trans.cc:121
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::MAX_UPDATE_TRIES_PER_SERVER
static const unsigned int MAX_UPDATE_TRIES_PER_SERVER
Maximum times to attempt a single update on a given server.
Definition nc_trans.h:154
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:554
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::getDNSClient
const DNSClientPtr & getDNSClient() const
Fetches the DNSClient instance.
Definition nc_trans.cc:529
isc::d2::NameChangeTransaction::verifyStates
virtual void verifyStates()
Validates the contents of the set of states.
Definition nc_trans.cc:266
isc::d2::NameChangeTransaction::startTransaction
void startTransaction()
Begins execution of the transaction.
Definition nc_trans.cc:111
isc::d2::NameChangeTransaction::prepNewRequest
virtual D2UpdateMessagePtr prepNewRequest(DdnsDomainPtr domain)
Creates a new DNS update request based on the given domain.
Definition nc_trans.cc:344
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::getDnsUpdateRequest
const D2UpdateMessagePtr & getDnsUpdateRequest() const
Fetches the current DNS update request packet.
Definition nc_trans.cc:544
isc::d2::NameChangeTransaction::getAddressRRType
const dns::RRType & getAddressRRType() const
Returns the DHCP data type for the lease address.
Definition nc_trans.cc:574
isc::d2::NameChangeTransaction::getNcr
const dhcp_ddns::NameChangeRequestPtr & getNcr() const
Fetches the NameChangeRequest for this transaction.
Definition nc_trans.cc:426
isc::d2::NameChangeTransaction::initServerSelection
void initServerSelection(const DdnsDomainPtr &domain)
Initializes server selection from the given DDNS domain.
Definition nc_trans.cc:456
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::NCT_DERIVED_STATE_MIN
static const int NCT_DERIVED_STATE_MIN
Value at which custom states in a derived class should begin.
Definition nc_trans.h:108
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:436
isc::d2::NameChangeTransaction::defineStates
virtual void defineStates()
Adds states defined by NameChangeTransaction to the state set.
Definition nc_trans.cc:258
isc::d2::NameChangeTransaction::getTransactionKey
const TransactionKey & getTransactionKey() const
Fetches the unique key that identifies this transaction.
Definition nc_trans.cc:431
isc::d2::NameChangeTransaction::setUpdateAttempts
void setUpdateAttempts(const size_t value)
Sets the update attempt count to the given value.
Definition nc_trans.cc:339
isc::d2::NameChangeTransaction::addLeaseAddressRdata
void addLeaseAddressRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease address to the given RRset.
Definition nc_trans.cc:367
isc::d2::NameChangeTransaction::getForwardChangeCompleted
bool getForwardChangeCompleted() const
Returns whether the forward change has completed or not.
Definition nc_trans.cc:559
isc::d2::NameChangeTransaction::sendUpdate
virtual void sendUpdate(const std::string &comment="")
Send the update request to the current server.
Definition nc_trans.cc:193
isc::d2::NameChangeTransaction::setForwardChangeCompleted
void setForwardChangeCompleted(const bool value)
Sets the forward change completion flag to the given value.
Definition nc_trans.cc:329
isc::d2::NameChangeTransaction::addPtrRdata
void addPtrRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease FQDN to the given RRset.
Definition nc_trans.cc:409
isc::d2::NameChangeTransaction::setDnsUpdateResponse
void setDnsUpdateResponse(D2UpdateMessagePtr &response)
Sets the update response packet to the given packet.
Definition nc_trans.cc:319
isc::d2::NameChangeTransaction::selectNextServer
bool selectNextServer()
Selects the next server in the current server list.
Definition nc_trans.cc:468
isc::d2::NameChangeTransaction::setNcrStatus
void setNcrStatus(const dhcp_ddns::NameChangeStatus &status)
Sets the status of the transaction's NameChangeRequest.
Definition nc_trans.cc:539
isc::d2::NameChangeTransaction::getForwardDomain
DdnsDomainPtr & getForwardDomain()
Fetches the forward DdnsDomain.
Definition nc_trans.cc:446
isc::d2::NameChangeTransaction::selectTSIGKey
bool selectTSIGKey()
Selects the TSIG key.
Definition nc_trans.cc:497
isc::d2::NameChangeTransaction::verifyEvents
virtual void verifyEvents()
Validates the contents of the set of events.
Definition nc_trans.cc:243
isc::d2::NameChangeTransaction::addDhcidRdata
void addDhcidRdata(dns::RRsetPtr &rrset)
Adds an RData for the lease client's DHCID to the given RRset.
Definition nc_trans.cc:389
isc::d2::NameChangeTransaction::clearDnsUpdateRequest
void clearDnsUpdateRequest()
Destroys the current update request packet.
Definition nc_trans.cc:304
isc::d2::NameChangeTransaction::clearUpdateAttempts
void clearUpdateAttempts()
Resets the update attempts count.
Definition nc_trans.cc:309
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:549
isc::d2::NameChangeTransaction::setDnsUpdateStatus
void setDnsUpdateStatus(const DNSClient::Status &status)
Sets the update status to the given status value.
Definition nc_trans.cc:314
isc::d2::NameChangeTransaction::setDnsUpdateRequest
void setDnsUpdateRequest(D2UpdateMessagePtr &request)
Sets the update request packet to the given packet.
Definition nc_trans.cc:299
isc::d2::NameChangeTransaction::getReverseChangeCompleted
bool getReverseChangeCompleted() const
Returns whether the reverse change has completed or not.
Definition nc_trans.cc:564
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::getNcrStatus
dhcp_ddns::NameChangeStatus getNcrStatus() const
Fetches the NameChangeRequest status of the transaction.
Definition nc_trans.cc:441
isc::d2::NameChangeTransaction::NCT_DERIVED_EVENT_MIN
static const int NCT_DERIVED_EVENT_MIN
Value at which custom events in a derived class should begin.
Definition nc_trans.h:144
isc::d2::NameChangeTransaction::defineEvents
virtual void defineEvents()
Adds events defined by NameChangeTransaction to the event set.
Definition nc_trans.cc:228
isc::d2::NameChangeTransaction::clearDnsUpdateResponse
void clearDnsUpdateResponse()
Destroys the current update response packet.
Definition nc_trans.cc:324
isc::d2::NameChangeTransaction::responseString
std::string responseString() const
Returns a string version of the current response status and rcode.
Definition nc_trans.cc:137
isc::d2::NameChangeTransaction::setReverseChangeCompleted
void setReverseChangeCompleted(const bool value)
Sets the reverse change completion flag to the given value.
Definition nc_trans.cc:334
isc::d2::NameChangeTransaction::getUpdateAttempts
size_t getUpdateAttempts() const
Fetches the update attempt count for the current update.
Definition nc_trans.cc:569
isc::d2::NameChangeTransaction::getCurrentServer
const DnsServerInfoPtr & getCurrentServer() const
Fetches the currently selected server.
Definition nc_trans.cc:534
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:451
isc::d2::NameChangeTransaction::transactionOutcomeString
std::string transactionOutcomeString() const
Returns a string version of transaction outcome.
Definition nc_trans.cc:171
isc::d2::NameChangeTransaction::~NameChangeTransaction
virtual ~NameChangeTransaction()
Destructor.
Definition nc_trans.cc:107
isc::dns::Name
The Name class encapsulates DNS names.
Definition name.h:219
isc::dns::RRClass::IN
static const RRClass & IN()
Definition rrclass.h:304
isc::dns::RRType
The RRType class encapsulates DNS resource record types.
Definition rrtype.h:96
isc::dns::RRType::AAAA
static const RRType & AAAA()
Definition rrtype.h:315
isc::dns::RRType::A
static const RRType & A()
Definition rrtype.h:279
isc::dns::rdata::in::AAAA
Definition rdataclass.h:563
isc::dns::rdata::in::A
Definition rdataclass.h:547
isc::hooks::HooksManager::registerHook
static int registerHook(const std::string &name)
Register Hook.
Definition hooks_manager.cc:232
isc::hooks::HooksManager::calloutsPresent
static bool calloutsPresent(int index)
Are callouts present?
Definition hooks_manager.cc:54
isc::hooks::HooksManager::createCalloutHandle
static boost::shared_ptr< CalloutHandle > createCalloutHandle()
Return callout handle.
Definition hooks_manager.cc:203
isc::hooks::HooksManager::callCallouts
static void callCallouts(int index, CalloutHandle &handle)
Calls the callouts for a given hook.
Definition hooks_manager.cc:76
isc::util::InputBuffer
The InputBuffer class is a buffer abstraction for manipulating read-only data.
Definition buffer.h:81
isc::util::StateModel::getEvent
const EventPtr & getEvent(unsigned int value)
Fetches the event referred to by value.
Definition state_model.cc:186
isc::util::StateModel::runModel
virtual void runModel(unsigned int event)
Processes events through the state model.
Definition state_model.cc:112
isc::util::StateModel::defineEvents
virtual void defineEvents()
Populates the set of events.
Definition state_model.cc:229
isc::util::StateModel::postNextEvent
void postNextEvent(unsigned int event)
Sets the next event to the given event value.
Definition state_model.cc:320
isc::util::StateModel::verifyStates
virtual void verifyStates()
Validates the contents of the set of states.
Definition state_model.cc:253
isc::util::StateModel::getNextEvent
unsigned int getNextEvent() const
Fetches the model's next event.
Definition state_model.cc:373
isc::util::StateModel::defineEvent
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
isc::util::StateModel::transition
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
isc::util::StateModel::verifyEvents
virtual void verifyEvents()
Validates the contents of the set of events.
Definition state_model.cc:237
isc::util::StateModel::NOP_EVT
static const int NOP_EVT
Signifies that no event has occurred.
Definition state_model.h:292
isc::util::StateModel::getEventLabel
std::string getEventLabel(const int event) const
Fetches the label associated with an event value.
Definition state_model.cc:432
isc::util::StateModel::startModel
void startModel(const int start_state)
Begins execution of the model.
Definition state_model.cc:100
isc::util::StateModel::defineStates
virtual void defineStates()
Populates the set of states.
Definition state_model.cc:245
isc::util::StateModel::getStateInternal
const StatePtr getStateInternal(unsigned int value)
Fetches the state referred to by value.
Definition state_model.cc:219
isc::util::StateModel::getCurrState
unsigned int getCurrState() const
Fetches the model's current state.
Definition state_model.cc:355
crypto_rng.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
hooks.h
hooks_manager.h
LOG_ERROR
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
Definition macros.h:32
LOG_DEBUG
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
Definition macros.h:14
isc::asiolink::IOServicePtr
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
Definition io_service.h:28
isc::cryptolink::generateQid
uint16_t generateQid()
Generate a Qid.
Definition crypto_rng.cc:31
isc::d2
Definition check_exists_add.cc:19
isc::d2::DHCP_DDNS_STARTING_TRANSACTION
const isc::log::MessageID DHCP_DDNS_STARTING_TRANSACTION
Definition d2_messages.h:87
isc::d2::D2UpdateMessagePtr
boost::shared_ptr< D2UpdateMessage > D2UpdateMessagePtr
Pointer to the DNS Update Message.
Definition d2_update_message.h:73
isc::d2::DdnsDomainPtr
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
Definition d2_config.h:624
isc::d2::D2CfgMgrPtr
boost::shared_ptr< D2CfgMgr > D2CfgMgrPtr
Defines a shared pointer to D2CfgMgr.
Definition d2_cfg_mgr.h:367
isc::d2::DnsServerInfoPtr
boost::shared_ptr< DnsServerInfo > DnsServerInfoPtr
Defines a pointer for DnsServerInfo instances.
Definition d2_config.h:554
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_TRANS_SEND_ERROR
const isc::log::MessageID DHCP_DDNS_TRANS_SEND_ERROR
Definition d2_messages.h:89
isc::d2::TSIGKeyInfoPtr
boost::shared_ptr< TSIGKeyInfo > TSIGKeyInfoPtr
Defines a pointer for TSIGKeyInfo instances.
Definition d2_config.h:416
isc::d2::DNSClientPtr
boost::shared_ptr< DNSClient > DNSClientPtr
Definition dns_client.h:20
isc::d2::DHCP_DDNS_STATE_MODEL_UNEXPECTED_ERROR
const isc::log::MessageID DHCP_DDNS_STATE_MODEL_UNEXPECTED_ERROR
Definition d2_messages.h:88
isc::d2::D2ParamsPtr
boost::shared_ptr< D2Params > D2ParamsPtr
Defines a pointer for D2Params instances.
Definition d2_config.h:257
isc::d2::TransactionKey
isc::dhcp_ddns::D2Dhcid TransactionKey
Defines the type used as the unique key for transactions.
Definition nc_trans.h:35
isc::d2::DHCP_DDNS_UPDATE_RESPONSE_RECEIVED
const isc::log::MessageID DHCP_DDNS_UPDATE_RESPONSE_RECEIVED
Definition d2_messages.h:91
isc::d2::DHCP_DDNS_UPDATE_REQUEST_SENT
const isc::log::MessageID DHCP_DDNS_UPDATE_REQUEST_SENT
Definition d2_messages.h:90
isc::dhcp_ddns::NameChangeStatus
NameChangeStatus
Defines the runtime processing status values for requests.
Definition ncr_msg.h:51
isc::dhcp_ddns::ST_PENDING
@ ST_PENDING
Definition ncr_msg.h:53
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::dns::rdata::generic
Definition char_string.cc:28
isc::dns::rdata::in
Definition rdataclass.h:545
isc::dns::rdata
Definition char_string.cc:27
isc::dns::rdata::ConstRdataPtr
boost::shared_ptr< const Rdata > ConstRdataPtr
Definition rdata.h:69
isc::dns::RRsetPtr
boost::shared_ptr< AbstractRRset > RRsetPtr
A pointer-like type pointing to an RRset object.
Definition rrset.h:50
isc::hooks
Definition callout_handle.cc:21
isc::hooks::CalloutHandlePtr
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
Definition callout_handle.h:470
isc::log::DBGLVL_TRACE_DETAIL
const int DBGLVL_TRACE_DETAIL
Trace detailed operations.
Definition log_dbglevels.h:75
isc::util
Definition time_utils.cc:43
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
nc_trans.h
This file defines the class NameChangeTransaction.
rdata.h
rdataclass.h