Kea: nc_trans.cc Source File

| Kea 1.5.0

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