Kea: nc_trans.cc Source File

| Kea 3.2.0-git

nc_trans.cc
Go to the documentation of this file.
1// Copyright (C) 2013-2025 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(" << getDnsUpdateStatus() << ")";
162 break;
163
164 }
165
166 return (stream.str());
167}
168
169std::string
170NameChangeTransaction::transactionOutcomeString() const {
171 std::ostringstream stream;
172 stream << "Status: " << (getNcrStatus() == dhcp_ddns::ST_COMPLETED
173 ? "Completed, " : "Failed, ")
174 << "Event: " << getEventLabel(getNextEvent()) << ", ";
175
176 if (ncr_->isForwardChange()) {
177 stream << " Forward change:" << (getForwardChangeCompleted()
178 ? " completed, " : " failed, ");
179 }
180
181 if (ncr_->isReverseChange()) {
182 stream << " Reverse change:" << (getReverseChangeCompleted()
183 ? " completed, " : " failed, ");
184 }
185
186 stream << " request: " << ncr_->toText();
187 return (stream.str());
188}
189
190
191void
192NameChangeTransaction::sendUpdate(const std::string& comment) {
193 try {
194 ++update_attempts_;
195 // @todo add logic to add/replace TSIG key info in request if
196 // use_tsig_ is true. We should be able to navigate to the TSIG key
197 // for the current server. If not we would need to add that.
198
199 D2ParamsPtr d2_params = cfg_mgr_->getD2Params();
200 dns_client_->doUpdate(io_service_, current_server_->getIpAddress(),
201 current_server_->getPort(), *dns_update_request_,
202 d2_params->getDnsServerTimeout(), tsig_key_);
203 // Message is on its way, so the next event should be NOP_EVT.
204 postNextEvent(NOP_EVT);
205 LOG_DEBUG(d2_to_dns_logger, isc::log::DBGLVL_TRACE_DETAIL,
206 DHCP_DDNS_UPDATE_REQUEST_SENT)
207 .arg(getRequestId())
208 .arg(comment)
209 .arg(current_server_->toText());
210 } catch (const std::exception& ex) {
211 // We were unable to initiate the send.
212 // It is presumed that any throw from doUpdate is due to a programmatic
213 // error, such as an unforeseen permutation of data, rather than an IO
214 // failure. IO errors should be caught by the underlying asiolink
215 // mechanisms and manifested as an unsuccessful IO status in the
216 // DNSClient callback. Any problem here most likely means the request
217 // is corrupt in some way and cannot be completed, therefore we will
218 // log it and transition it to failure.
219 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_TRANS_SEND_ERROR)
220 .arg(getRequestId())
221 .arg(ex.what());
222 transition(PROCESS_TRANS_FAILED_ST, UPDATE_FAILED_EVT);
223 }
224}
225
226void
227NameChangeTransaction::defineEvents() {
228 // Call superclass impl first.
229 StateModel::defineEvents();
230
231 // Define NCT events.
232 defineEvent(SELECT_SERVER_EVT, "SELECT_SERVER_EVT");
233 defineEvent(SERVER_SELECTED_EVT, "SERVER_SELECTED_EVT");
234 defineEvent(SERVER_IO_ERROR_EVT, "SERVER_IO_ERROR_EVT");
235 defineEvent(NO_MORE_SERVERS_EVT, "NO_MORE_SERVERS_EVT");
236 defineEvent(IO_COMPLETED_EVT, "IO_COMPLETED_EVT");
237 defineEvent(UPDATE_OK_EVT, "UPDATE_OK_EVT");
238 defineEvent(UPDATE_FAILED_EVT, "UPDATE_FAILED_EVT");
239}
240
241void
242NameChangeTransaction::verifyEvents() {
243 // Call superclass impl first.
244 StateModel::verifyEvents();
245
246 // Verify NCT events.
247 getEvent(SELECT_SERVER_EVT);
248 getEvent(SERVER_SELECTED_EVT);
249 getEvent(SERVER_IO_ERROR_EVT);
250 getEvent(NO_MORE_SERVERS_EVT);
251 getEvent(IO_COMPLETED_EVT);
252 getEvent(UPDATE_OK_EVT);
253 getEvent(UPDATE_FAILED_EVT);
254}
255
256void
257NameChangeTransaction::defineStates() {
258 // Call superclass impl first.
259 StateModel::defineStates();
260 // This class is "abstract" in that it does not supply handlers for its
261 // states, derivations must do that therefore they must define them.
262}
263
264void
265NameChangeTransaction::verifyStates() {
266 // Call superclass impl first.
267 StateModel::verifyStates();
268
269 // Verify NCT states. This ensures that derivations provide the handlers.
270 getStateInternal(READY_ST);
271 getStateInternal(SELECTING_FWD_SERVER_ST);
272 getStateInternal(SELECTING_REV_SERVER_ST);
273 getStateInternal(PROCESS_TRANS_OK_ST);
274 getStateInternal(PROCESS_TRANS_FAILED_ST);
275}
276
277void
278NameChangeTransaction::onModelFailure(const std::string& explanation) {
279 setNcrStatus(dhcp_ddns::ST_FAILED);
280 LOG_ERROR(d2_to_dns_logger, DHCP_DDNS_STATE_MODEL_UNEXPECTED_ERROR)
281 .arg(getRequestId())
282 .arg(explanation);
283}
284
285void
286NameChangeTransaction::retryTransition(const int fail_to_state) {
287 if (update_attempts_ < MAX_UPDATE_TRIES_PER_SERVER) {
288 // Re-enter the current state with same server selected.
289 transition(getCurrState(), SERVER_SELECTED_EVT);
290 } else {
291 // Transition to given fail_to_state state if we are out
292 // of retries.
293 transition(fail_to_state, SERVER_IO_ERROR_EVT);
294 }
295}
296
297void
298NameChangeTransaction::setDnsUpdateRequest(D2UpdateMessagePtr& request) {
299 dns_update_request_ = request;
300}
301
302void
303NameChangeTransaction::clearDnsUpdateRequest() {
304 dns_update_request_.reset();
305}
306
307void
308NameChangeTransaction::clearUpdateAttempts() {
309 update_attempts_ = 0;
310}
311
312void
313NameChangeTransaction::setDnsUpdateStatus(const DNSClient::Status& status) {
314 dns_update_status_ = status;
315}
316
317void
318NameChangeTransaction::setDnsUpdateResponse(D2UpdateMessagePtr& response) {
319 dns_update_response_ = response;
320}
321
322void
323NameChangeTransaction::clearDnsUpdateResponse() {
324 dns_update_response_.reset();
325}
326
327void
328NameChangeTransaction::setForwardChangeCompleted(const bool value) {
329 forward_change_completed_ = value;
330}
331
332void
333NameChangeTransaction::setReverseChangeCompleted(const bool value) {
334 reverse_change_completed_ = value;
335}
336
337void
338NameChangeTransaction::setUpdateAttempts(const size_t value) {
339 update_attempts_ = value;
340}
341
342 D2UpdateMessagePtr
343NameChangeTransaction::prepNewRequest(DdnsDomainPtr domain) {
344 if (!domain) {
345 isc_throw(NameChangeTransactionError,
346 "prepNewRequest - domain cannot be null");
347 }
348
349 try {
350 // Create a "blank" update request.
351 D2UpdateMessagePtr request(new D2UpdateMessage(D2UpdateMessage::
352 OUTBOUND));
353 // Set the query id
354 request->setId(cryptolink::generateQid());
355 // Construct the Zone Section.
356 dns::Name zone_name(domain->getName());
357 request->setZone(zone_name, dns::RRClass::IN());
358 return (request);
359 } catch (const std::exception& ex) {
360 isc_throw(NameChangeTransactionError, "Cannot create new request :"
361 << ex.what());
362 }
363}
364
365void
366NameChangeTransaction::addLeaseAddressRdata(dns::RRsetPtr& rrset) {
367 if (!rrset) {
368 isc_throw(NameChangeTransactionError,
369 "addLeaseAddressRdata - RRset cannot cannot be null");
370 }
371
372 try {
373 // Manufacture an RData from the lease address then add it to the RR.
374 dns::rdata::ConstRdataPtr rdata;
375 if (ncr_->isV4()) {
376 rdata.reset(new dns::rdata::in::A(ncr_->getIpAddress()));
377 } else {
378 rdata.reset(new dns::rdata::in::AAAA(ncr_->getIpAddress()));
379 }
380 rrset->addRdata(rdata);
381 } catch (const std::exception& ex) {
382 isc_throw(NameChangeTransactionError, "Cannot add address rdata: "
383 << ex.what());
384 }
385}
386
387void
388NameChangeTransaction::addDhcidRdata(dns::RRsetPtr& rrset) {
389 if (!rrset) {
390 isc_throw(NameChangeTransactionError,
391 "addDhcidRdata - RRset cannot cannot be null");
392 }
393
394 try {
395 const std::vector<uint8_t>& ncr_dhcid = ncr_->getDhcid().getBytes();
396 util::InputBuffer buffer(ncr_dhcid.data(), ncr_dhcid.size());
397 dns::rdata::ConstRdataPtr rdata (new dns::rdata::in::
398 DHCID(buffer, ncr_dhcid.size()));
399 rrset->addRdata(rdata);
400 } catch (const std::exception& ex) {
401 isc_throw(NameChangeTransactionError, "Cannot add DCHID rdata: "
402 << ex.what());
403 }
404
405}
406
407void
408NameChangeTransaction::addPtrRdata(dns::RRsetPtr& rrset) {
409 if (!rrset) {
410 isc_throw(NameChangeTransactionError,
411 "addPtrRdata - RRset cannot cannot be null");
412 }
413
414 try {
415 dns::rdata::ConstRdataPtr rdata(new dns::rdata::generic::
416 PTR(getNcr()->getFqdn()));
417 rrset->addRdata(rdata);
418 } catch (const std::exception& ex) {
419 isc_throw(NameChangeTransactionError, "Cannot add PTR rdata: "
420 << ex.what());
421 }
422}
423
424const dhcp_ddns::NameChangeRequestPtr&
425NameChangeTransaction::getNcr() const {
426 return (ncr_);
427}
428
429const TransactionKey&
430NameChangeTransaction::getTransactionKey() const {
431 return (ncr_->getDhcid());
432}
433
434std::string
435NameChangeTransaction::getRequestId() const {
436 return (ncr_->getRequestId());
437}
438
439 dhcp_ddns::NameChangeStatus
440NameChangeTransaction::getNcrStatus() const {
441 return (ncr_->getStatus());
442}
443
444 DdnsDomainPtr&
445NameChangeTransaction::getForwardDomain() {
446 return (forward_domain_);
447}
448
449 DdnsDomainPtr&
450NameChangeTransaction::getReverseDomain() {
451 return (reverse_domain_);
452}
453
454void
455NameChangeTransaction::initServerSelection(const DdnsDomainPtr& domain) {
456 if (!domain) {
457 isc_throw(NameChangeTransactionError,
458 "initServerSelection called with an empty domain");
459 }
460
461 current_server_list_ = domain->getServers();
462 next_server_pos_ = 0;
463 current_server_.reset();
464}
465
466bool
467NameChangeTransaction::selectNextServer() {
468 for (;;) {
469 if ((current_server_list_) &&
470 (next_server_pos_ < current_server_list_->size())) {
471 current_server_ = (*current_server_list_)[next_server_pos_];
472 // Toss out any previous response.
473 dns_update_response_.reset();
474
475 // Set the tsig_key to that of the current server.
476 if (!selectTSIGKey()) {
477 ++next_server_pos_;
478 continue;
479 }
480
481 // @todo Protocol is set on DNSClient constructor. We need
482 // to propagate a configuration value downward, probably starting
483 // at global, then domain, finishing by server.
484 // Once that is supported we need to add it here.
485 dns_client_.reset(new DNSClient(dns_update_response_, this,
486 DNSClient::UDP));
487 ++next_server_pos_;
488 return (true);
489 }
490
491 return (false);
492 }
493}
494
495bool
496NameChangeTransaction::selectTSIGKey() {
497 TSIGKeyInfoPtr tsig_key_info = current_server_->getTSIGKeyInfo();
498 if (tsig_key_info) {
499 tsig_key_ = tsig_key_info->getTSIGKey();
500 } else {
501 tsig_key_.reset();
502 }
503
504 // This hook point allows hooks libraries to overwrite the TSIG key.
505 if (HooksManager::calloutsPresent(Hooks.hooks_index_select_key_)) {
506 CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle();
507
508 callout_handle->setArgument("current_server", current_server_);
509 callout_handle->setArgument("tsig_key", tsig_key_);
510
511 HooksManager::callCallouts(Hooks.hooks_index_select_key_,
512 *callout_handle);
513
514 // This server is skipped because the status is not NEXT_STEP_CONTINUE.
515 if (callout_handle->getStatus() != CalloutHandle::NEXT_STEP_CONTINUE) {
516 return (false);
517 }
518
519 // Reread the TSIG key.
520 callout_handle->getArgument("tsig_key", tsig_key_);
521 }
522
523 return (true);
524}
525
526
527const DNSClientPtr&
528NameChangeTransaction::getDNSClient() const {
529 return (dns_client_);
530}
531
532const DnsServerInfoPtr&
533NameChangeTransaction::getCurrentServer() const {
534 return (current_server_);
535}
536
537void
538NameChangeTransaction::setNcrStatus(const dhcp_ddns::NameChangeStatus& status) {
539 return (ncr_->setStatus(status));
540}
541
542const D2UpdateMessagePtr&
543NameChangeTransaction::getDnsUpdateRequest() const {
544 return (dns_update_request_);
545}
546
547 DNSClient::Status
548NameChangeTransaction::getDnsUpdateStatus() const {
549 return (dns_update_status_);
550}
551
552const D2UpdateMessagePtr&
553NameChangeTransaction::getDnsUpdateResponse() const {
554 return (dns_update_response_);
555}
556
557bool
558NameChangeTransaction::getForwardChangeCompleted() const {
559 return (forward_change_completed_);
560}
561
562bool
563NameChangeTransaction::getReverseChangeCompleted() const {
564 return (reverse_change_completed_);
565}
566
567size_t
568NameChangeTransaction::getUpdateAttempts() const {
569 return (update_attempts_);
570}
571
572const dns::RRType&
573NameChangeTransaction::getAddressRRType() const {
574 return (ncr_->isV4() ? dns::RRType::A() : dns::RRType::AAAA());
575}
576
577} // namespace isc::d2
578} // namespace isc
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:286
isc::d2::NameChangeTransaction::onModelFailure
virtual void onModelFailure(const std::string &explanation)
Handler for fatal model execution errors.
Definition nc_trans.cc:278
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: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::getDNSClient
const DNSClientPtr & getDNSClient() const
Fetches the DNSClient instance.
Definition nc_trans.cc:528
isc::d2::NameChangeTransaction::verifyStates
virtual void verifyStates()
Validates the contents of the set of states.
Definition nc_trans.cc:265
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: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::getDnsUpdateRequest
const D2UpdateMessagePtr & getDnsUpdateRequest() const
Fetches the current DNS update request packet.
Definition nc_trans.cc:543
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::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: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::getTransactionKey
const TransactionKey & getTransactionKey() const
Fetches the unique key that identifies this transaction.
Definition nc_trans.cc:430
isc::d2::NameChangeTransaction::setUpdateAttempts
void setUpdateAttempts(const size_t value)
Sets the update attempt count to the given value.
Definition nc_trans.cc:338
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::getForwardChangeCompleted
bool getForwardChangeCompleted() const
Returns whether the forward change has completed or not.
Definition nc_trans.cc:558
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::setDnsUpdateResponse
void setDnsUpdateResponse(D2UpdateMessagePtr &response)
Sets the update response packet to the given packet.
Definition nc_trans.cc:318
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::selectTSIGKey
bool selectTSIGKey()
Selects the TSIG key.
Definition nc_trans.cc:496
isc::d2::NameChangeTransaction::verifyEvents
virtual void verifyEvents()
Validates the contents of the set of events.
Definition nc_trans.cc:242
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:388
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::setDnsUpdateStatus
void setDnsUpdateStatus(const DNSClient::Status &status)
Sets the update status to the given status value.
Definition nc_trans.cc:313
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::getReverseChangeCompleted
bool getReverseChangeCompleted() const
Returns whether the reverse change has completed or not.
Definition nc_trans.cc:563
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:440
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:227
isc::d2::NameChangeTransaction::clearDnsUpdateResponse
void clearDnsUpdateResponse()
Destroys the current update response packet.
Definition nc_trans.cc:323
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:333
isc::d2::NameChangeTransaction::getUpdateAttempts
size_t getUpdateAttempts() const
Fetches the update attempt count for the current update.
Definition nc_trans.cc:568
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::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::getStateInternal
const StatePtr getStateInternal(int value)
Fetches the state referred to by value.
Definition state_model.cc:219
isc::util::StateModel::defineEvents
virtual void defineEvents()
Populates the set of events.
Definition state_model.cc:229
isc::util::StateModel::verifyStates
virtual void verifyStates()
Validates the contents of the set of states.
Definition state_model.cc:253
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::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::getCurrState
int getCurrState() const
Fetches the model's current state.
Definition state_model.cc:355
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::getEvent
const EventPtr & getEvent(int value)
Fetches the event referred to by value.
Definition state_model.cc:186
isc::util::StateModel::defineStates
virtual void defineStates()
Populates the set of states.
Definition state_model.cc:245
isc::util::StateModel::runModel
virtual void runModel(int event)
Processes events through the state model.
Definition state_model.cc:112
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::postNextEvent
void postNextEvent(int event)
Sets the next event to the given event value.
Definition state_model.cc:320
crypto_rng.h
if
if(!(yy_init))
Definition d2_lexer.cc:1515
d2_log.h
Hooks
Dhcp4Hooks Hooks
Definition dhcp4_srv.cc:213
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:35
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:92
isc::d2::DHCP_DDNS_UPDATE_REQUEST_SENT
const isc::log::MessageID DHCP_DDNS_UPDATE_REQUEST_SENT
Definition d2_messages.h:91
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 check_exists_add.cc:18
nc_trans.h
This file defines the class NameChangeTransaction.
rdata.h
rdataclass.h