Kea  2.3.5-git
isc::d2::NameChangeTransaction Class Reference

Embodies the "life-cycle" required to carry out a DDNS update. More...

#include <nc_trans.h>

+ Inheritance diagram for isc::d2::NameChangeTransaction:

Public Member Functions

 NameChangeTransaction (asiolink::IOServicePtr &io_service, dhcp_ddns::NameChangeRequestPtr &ncr, DdnsDomainPtr &forward_domain, DdnsDomainPtr &reverse_domain, D2CfgMgrPtr &cfg_mgr)
 Constructor. More...
 
virtual ~NameChangeTransaction ()
 Destructor. More...
 
const dns::RRTypegetAddressRRType () const
 Returns the DHCP data type for the lease address. More...
 
const DnsServerInfoPtrgetCurrentServer () const
 Fetches the currently selected server. More...
 
const DNSClientPtrgetDNSClient () const
 Fetches the DNSClient instance. More...
 
const D2UpdateMessagePtrgetDnsUpdateRequest () const
 Fetches the current DNS update request packet. More...
 
const D2UpdateMessagePtrgetDnsUpdateResponse () const
 Fetches the most recent DNS update response packet. More...
 
DNSClient::Status getDnsUpdateStatus () const
 Fetches the most recent DNS update status. More...
 
bool getForwardChangeCompleted () const
 Returns whether the forward change has completed or not. More...
 
DdnsDomainPtrgetForwardDomain ()
 Fetches the forward DdnsDomain. More...
 
const dhcp_ddns::NameChangeRequestPtrgetNcr () const
 Fetches the NameChangeRequest for this transaction. More...
 
dhcp_ddns::NameChangeStatus getNcrStatus () const
 Fetches the NameChangeRequest status of the transaction. More...
 
std::string getRequestId () const
 Fetches the request id that identifies this transaction. More...
 
bool getReverseChangeCompleted () const
 Returns whether the reverse change has completed or not. More...
 
DdnsDomainPtrgetReverseDomain ()
 Fetches the reverse DdnsDomain. More...
 
const TransactionKeygetTransactionKey () const
 Fetches the unique key that identifies this transaction. More...
 
size_t getUpdateAttempts () const
 Fetches the update attempt count for the current update. More...
 
virtual void operator() (DNSClient::Status status)
 Serves as the DNSClient IO completion event handler. More...
 
void startTransaction ()
 Begins execution of the transaction. More...
 
- Public Member Functions inherited from isc::d2::DNSClient::Callback
virtual ~Callback ()
 Virtual destructor. More...
 
- Public Member Functions inherited from isc::util::StateModel
 StateModel ()
 Constructor. More...
 
virtual ~StateModel ()
 Destructor. More...
 
bool didModelFail () const
 Returns whether or not the model failed. More...
 
void endModel ()
 Conducts a normal transition to the end of the model. More...
 
std::string getContextStr () const
 Convenience method which returns a string rendition of the current state and next event. More...
 
unsigned int getCurrState () const
 Fetches the model's current state. More...
 
std::string getEventLabel (const int event) const
 Fetches the label associated with an event value. More...
 
unsigned int getLastEvent () const
 Fetches the model's last event. More...
 
unsigned int getNextEvent () const
 Fetches the model's next event. More...
 
std::string getPrevContextStr () const
 Convenience method which returns a string rendition of the previous state and last event. More...
 
unsigned int getPrevState () const
 Fetches the model's previous state. More...
 
std::string getStateLabel (const int state) const
 Fetches the label associated with an state value. More...
 
bool isModelDone () const
 Returns whether or not the model has finished execution. More...
 
bool isModelNew () const
 Returns whether or not the model is new. More...
 
bool isModelPaused () const
 Returns whether or not the model is paused. More...
 
bool isModelRunning () const
 Returns whether or not the model is running. More...
 
bool isModelWaiting () const
 Returns whether or not the model is waiting. More...
 
void nopStateHandler ()
 An empty state handler. More...
 
virtual void runModel (unsigned int event)
 Processes events through the state model. More...
 
void startModel (const int start_state)
 Begins execution of the model. More...
 
void unpauseModel ()
 Unpauses state model. More...
 

Static Public Attributes

static const unsigned int DNS_UPDATE_DEFAULT_TIMEOUT = 100
 Default time to assign to a single DNS update. More...
 
static const unsigned int MAX_UPDATE_TRIES_PER_SERVER = 3
 Maximum times to attempt a single update on a given server. More...
 
static const int READY_ST = SM_DERIVED_STATE_MIN + 1
 State from which a transaction is started. More...
 
static const int SELECTING_FWD_SERVER_ST = SM_DERIVED_STATE_MIN + 2
 State in which forward DNS server selection is done. More...
 
static const int SELECTING_REV_SERVER_ST = SM_DERIVED_STATE_MIN + 3
 State in which reverse DNS server selection is done. More...
 
static const int PROCESS_TRANS_OK_ST = SM_DERIVED_STATE_MIN + 4
 State which processes successful transaction conclusion. More...
 
static const int PROCESS_TRANS_FAILED_ST = SM_DERIVED_STATE_MIN + 5
 State which processes an unsuccessful transaction conclusion. More...
 
static const int NCT_DERIVED_STATE_MIN = SM_DERIVED_STATE_MIN + 101
 Value at which custom states in a derived class should begin. More...
 
static const int SELECT_SERVER_EVT = SM_DERIVED_EVENT_MIN + 1
 Issued when a server needs to be selected. More...
 
static const int SERVER_SELECTED_EVT = SM_DERIVED_EVENT_MIN + 2
 Issued when a server has been selected. More...
 
static const int SERVER_IO_ERROR_EVT = SM_DERIVED_EVENT_MIN + 3
 Issued when an update fails due to an IO error. More...
 
static const int NO_MORE_SERVERS_EVT =SM_DERIVED_EVENT_MIN + 4
 Issued when there are no more servers from which to select. More...
 
static const int IO_COMPLETED_EVT = SM_DERIVED_EVENT_MIN + 5
 Issued when a DNS update packet exchange has completed. More...
 
static const int UPDATE_OK_EVT = SM_DERIVED_EVENT_MIN + 6
 Issued when the attempted update successfully completed. More...
 
static const int UPDATE_FAILED_EVT = SM_DERIVED_EVENT_MIN + 7
 Issued when the attempted update fails to complete. More...
 
static const int NCT_DERIVED_EVENT_MIN = SM_DERIVED_EVENT_MIN + 101
 Value at which custom events in a derived class should begin. More...
 
- Static Public Attributes inherited from isc::util::StateModel
static const int NEW_ST = 0
 State that a state model is in immediately after construction. More...
 
static const int END_ST = 1
 Final state, all the state model has reached its conclusion. More...
 
static const int SM_DERIVED_STATE_MIN = 11
 Value at which custom states in a derived class should begin. More...
 
static const int NOP_EVT = 0
 Signifies that no event has occurred. More...
 
static const int START_EVT = 1
 Event issued to start the model execution. More...
 
static const int END_EVT = 2
 Event issued to end the model execution. More...
 
static const int FAIL_EVT = 3
 Event issued to abort the model execution. More...
 
static const int SM_DERIVED_EVENT_MIN = 11
 Value at which custom events in a derived class should begin. More...
 

Protected Member Functions

void addDhcidRdata (dns::RRsetPtr &rrset)
 Adds an RData for the lease client's DHCID to the given RRset. More...
 
void addLeaseAddressRdata (dns::RRsetPtr &rrset)
 Adds an RData for the lease address to the given RRset. More...
 
void addPtrRdata (dns::RRsetPtr &rrset)
 Adds an RData for the lease FQDN to the given RRset. More...
 
void clearDnsUpdateRequest ()
 Destroys the current update request packet. More...
 
void clearDnsUpdateResponse ()
 Destroys the current update response packet. More...
 
void clearUpdateAttempts ()
 Resets the update attempts count. More...
 
virtual void defineEvents ()
 Adds events defined by NameChangeTransaction to the event set. More...
 
virtual void defineStates ()
 Adds states defined by NameChangeTransaction to the state set. More...
 
const asiolink::IOServicePtrgetIOService ()
 Fetches the IOService the transaction uses for IO processing. More...
 
void initServerSelection (const DdnsDomainPtr &domain)
 Initializes server selection from the given DDNS domain. More...
 
virtual void onModelFailure (const std::string &explanation)
 Handler for fatal model execution errors. More...
 
virtual D2UpdateMessagePtr prepNewRequest (DdnsDomainPtr domain)
 Creates a new DNS update request based on the given domain. More...
 
std::string responseString () const
 Returns a string version of the current response status and rcode. More...
 
void retryTransition (const int fail_to_state)
 Determines the state and next event based on update attempts. More...
 
bool selectNextServer ()
 Selects the next server in the current server list. More...
 
bool selectTSIGKey ()
 Selects the TSIG key. More...
 
virtual void sendUpdate (const std::string &comment="")
 Send the update request to the current server. More...
 
void setDnsUpdateRequest (D2UpdateMessagePtr &request)
 Sets the update request packet to the given packet. More...
 
void setDnsUpdateResponse (D2UpdateMessagePtr &response)
 Sets the update response packet to the given packet. More...
 
void setDnsUpdateStatus (const DNSClient::Status &status)
 Sets the update status to the given status value. More...
 
void setForwardChangeCompleted (const bool value)
 Sets the forward change completion flag to the given value. More...
 
void setNcrStatus (const dhcp_ddns::NameChangeStatus &status)
 Sets the status of the transaction's NameChangeRequest. More...
 
void setReverseChangeCompleted (const bool value)
 Sets the reverse change completion flag to the given value. More...
 
void setUpdateAttempts (const size_t value)
 Sets the update attempt count to the given value. More...
 
std::string transactionOutcomeString () const
 Returns a string version of transaction outcome. More...
 
virtual void verifyEvents ()
 Validates the contents of the set of events. More...
 
virtual void verifyStates ()
 Validates the contents of the set of states. More...
 
- Protected Member Functions inherited from isc::util::StateModel
void abortModel (const std::string &explanation)
 Aborts model execution. More...
 
void defineEvent (unsigned int value, const std::string &label)
 Adds an event value and associated label to the set of events. More...
 
void defineState (unsigned int value, const std::string &label, StateHandler handler, const StatePausing &state_pausing=STATE_PAUSE_NEVER)
 Adds an state value and associated label to the set of states. More...
 
bool doOnEntry ()
 Checks if on entry flag is true. More...
 
bool doOnExit ()
 Checks if on exit flag is true. More...
 
const EventPtrgetEvent (unsigned int value)
 Fetches the event referred to by value. More...
 
const StatePtr getState (unsigned int value)
 Fetches the state referred to by value. More...
 
const StatePtr getStateInternal (unsigned int value)
 Fetches the state referred to by value. More...
 
void initDictionaries ()
 Initializes the event and state dictionaries. More...
 
void postNextEvent (unsigned int event)
 Sets the next event to the given event value. More...
 
void setState (unsigned int state)
 Sets the current state to the given state value. More...
 
void transition (unsigned int state, unsigned int event)
 Sets up the model to transition into given state with a given event. More...
 

Detailed Description

Embodies the "life-cycle" required to carry out a DDNS update.

NameChangeTransaction is the base class that provides the common state model mechanics and services performing the DNS updates needed to carry out a DHCP_DDNS request as described by a NameChangeRequest. It is derived from StateModel which supplies a simple, general purpose FSM implementation.

Upon construction, each transaction has all of the information and resources required to carry out its assigned request, including the list(s) of DNS server(s) needed. It is responsible for knowing what conversations it must have with which servers and in the order necessary to fulfill the request. Upon fulfillment of the request, the transaction's work is complete and it is destroyed.

Fulfillment of the request is carried out through the performance of the transaction's state model. Using a state driven implementation accounts for the conditional processing flow necessary to meet the DDNS RFCs as well as the asynchronous nature of IO with DNS servers.

Derivations of the class are responsible for defining the state model and conversations necessary to carry out the specific of request.

Conversations with DNS servers are done through the use of the DNSClient class. The DNSClient provides a IOService-based means a service which performs a single, packet exchange with a given DNS server. It sends a single update to the server and returns the response, asynchronously, through a callback. At each point in a transaction's state model, where an update is to be sent, the model "suspends" until notified by the DNSClient via the callback. Suspension is done by posting a StateModel::NOP_EVT as the next event, stopping the state model execution.

Resuming state model execution when a DNS update completes is done by a call to StateModel::runStateModel() from within the DNSClient callback, with an event value of IO_COMPLETED_EVT (described below).

This class defines a set of events and states that are a common to all transactions. Each derivation may add define additional states and events as needed, but it must support the common set. NameChangeTransaction does not supply any state handlers. These are the sole responsibility of derivations.

Definition at line 77 of file nc_trans.h.

Constructor & Destructor Documentation

◆ NameChangeTransaction()

isc::d2::NameChangeTransaction::NameChangeTransaction ( asiolink::IOServicePtr io_service,
dhcp_ddns::NameChangeRequestPtr ncr,
DdnsDomainPtr forward_domain,
DdnsDomainPtr reverse_domain,
D2CfgMgrPtr cfg_mgr 
)

Constructor.

Instantiates a transaction that is ready to be started.

Parameters
io_serviceIO service to be used for IO processing
ncris the NameChangeRequest to fulfill
forward_domainis the domain to use for forward DNS updates
reverse_domainis the domain to use for reverse DNS updates
cfg_mgrreference to the current configuration manager
Exceptions
NameChangeTransactionErrorif given an null request, if forward change is enabled but forward domain is null, if reverse change is enabled but reverse domain is null.
Todo:
if io_service is NULL we are multi-threading and should instantiate our own

Definition at line 68 of file nc_trans.cc.

References isc_throw.

◆ ~NameChangeTransaction()

isc::d2::NameChangeTransaction::~NameChangeTransaction ( )
virtual

Destructor.

Definition at line 106 of file nc_trans.cc.

Member Function Documentation

◆ addDhcidRdata()

void isc::d2::NameChangeTransaction::addDhcidRdata ( dns::RRsetPtr rrset)
protected

Adds an RData for the lease client's DHCID to the given RRset.

Creates an in::DHCID() RData instance from the NCR DHCID and adds it to the given RRset.

Parameters
rrsetRRset to which to add the RData
Exceptions
NameChangeTransactionErrorif RData cannot be constructed or the RData cannot be added to the given RRset.

Definition at line 388 of file nc_trans.cc.

References isc_throw, and isc::Exception::what().

Referenced by isc::d2::NameAddTransaction::buildAddFwdAddressRequest(), isc::d2::NameRemoveTransaction::buildRemoveFwdAddressRequest(), isc::d2::NameRemoveTransaction::buildRemoveFwdRRsRequest(), isc::d2::SimpleAddTransaction::buildReplaceFwdAddressRequest(), isc::d2::NameAddTransaction::buildReplaceFwdAddressRequest(), isc::d2::SimpleAddTransaction::buildReplaceRevPtrsRequest(), and isc::d2::NameAddTransaction::buildReplaceRevPtrsRequest().

+ Here is the call graph for this function:

◆ addLeaseAddressRdata()

void isc::d2::NameChangeTransaction::addLeaseAddressRdata ( dns::RRsetPtr rrset)
protected

Adds an RData for the lease address to the given RRset.

Creates an in::A() or in:AAAA() RData instance from the NCR lease address and adds it to the given RRset.

Parameters
rrsetRRset to which to add the RData
Exceptions
NameChangeTransactionErrorif RData cannot be constructed or the RData cannot be added to the given RRset.

Definition at line 366 of file nc_trans.cc.

References isc_throw, and isc::Exception::what().

Referenced by isc::d2::NameAddTransaction::buildAddFwdAddressRequest(), isc::d2::NameRemoveTransaction::buildRemoveFwdAddressRequest(), isc::d2::SimpleAddTransaction::buildReplaceFwdAddressRequest(), and isc::d2::NameAddTransaction::buildReplaceFwdAddressRequest().

+ Here is the call graph for this function:

◆ addPtrRdata()

void isc::d2::NameChangeTransaction::addPtrRdata ( dns::RRsetPtr rrset)
protected

Adds an RData for the lease FQDN to the given RRset.

Creates an in::PTR() RData instance from the NCR FQDN and adds it to the given RRset.

Parameters
rrsetRRset to which to add the RData
Exceptions
NameChangeTransactionErrorif RData cannot be constructed or the RData cannot be added to the given RRset.

Definition at line 408 of file nc_trans.cc.

References getNcr(), isc_throw, and isc::Exception::what().

Referenced by isc::d2::NameRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::SimpleAddTransaction::buildReplaceRevPtrsRequest(), and isc::d2::NameAddTransaction::buildReplaceRevPtrsRequest().

+ Here is the call graph for this function:

◆ clearDnsUpdateRequest()

◆ clearDnsUpdateResponse()

void isc::d2::NameChangeTransaction::clearDnsUpdateResponse ( )
protected

Destroys the current update response packet.

Definition at line 323 of file nc_trans.cc.

◆ clearUpdateAttempts()

◆ defineEvents()

void isc::d2::NameChangeTransaction::defineEvents ( )
protectedvirtual

Adds events defined by NameChangeTransaction to the event set.

This method adds the events common to NCR transaction processing to the set of define events. It invokes the superclass's implementation first to maintain the hierarchical chain of event definition. Derivations of NameChangeTransaction must invoke its implementation in like fashion.

Exceptions
StateModelErrorif an event definition is invalid or a duplicate.

Reimplemented from isc::util::StateModel.

Reimplemented in isc::d2::NameAddTransaction, isc::d2::NameRemoveTransaction, isc::d2::SimpleAddTransaction, and isc::d2::SimpleRemoveTransaction.

Definition at line 227 of file nc_trans.cc.

References isc::util::StateModel::defineEvent(), isc::util::StateModel::defineEvents(), IO_COMPLETED_EVT, NO_MORE_SERVERS_EVT, SELECT_SERVER_EVT, SERVER_IO_ERROR_EVT, SERVER_SELECTED_EVT, UPDATE_FAILED_EVT, and UPDATE_OK_EVT.

Referenced by isc::d2::SimpleRemoveTransaction::defineEvents(), isc::d2::SimpleAddTransaction::defineEvents(), isc::d2::NameRemoveTransaction::defineEvents(), and isc::d2::NameAddTransaction::defineEvents().

+ Here is the call graph for this function:

◆ defineStates()

void isc::d2::NameChangeTransaction::defineStates ( )
protectedvirtual

Adds states defined by NameChangeTransaction to the state set.

This method adds the states common to NCR transaction processing to the dictionary of states. It invokes the superclass's implementation first to maintain the hierarchical chain of state definition. Derivations of NameChangeTransaction must invoke its implementation in like fashion.

Exceptions
StateModelErrorif an state definition is invalid or a duplicate.

Reimplemented from isc::util::StateModel.

Reimplemented in isc::d2::NameAddTransaction, isc::d2::NameRemoveTransaction, isc::d2::SimpleAddTransaction, and isc::d2::SimpleRemoveTransaction.

Definition at line 257 of file nc_trans.cc.

References isc::util::StateModel::defineStates().

Referenced by isc::d2::SimpleRemoveTransaction::defineStates(), isc::d2::SimpleAddTransaction::defineStates(), isc::d2::NameRemoveTransaction::defineStates(), and isc::d2::NameAddTransaction::defineStates().

+ Here is the call graph for this function:

◆ getAddressRRType()

const dns::RRType & isc::d2::NameChangeTransaction::getAddressRRType ( ) const

Returns the DHCP data type for the lease address.

Returns
constant reference to dns::RRType::A() if the lease address is IPv4 or dns::RRType::AAAA() if the lease address is IPv6.

Definition at line 573 of file nc_trans.cc.

References isc::dns::RRType::A(), and isc::dns::RRType::AAAA().

Referenced by isc::d2::NameAddTransaction::buildAddFwdAddressRequest(), isc::d2::NameRemoveTransaction::buildRemoveFwdAddressRequest(), isc::d2::SimpleRemoveTransaction::buildRemoveFwdRRsRequest(), isc::d2::SimpleAddTransaction::buildReplaceFwdAddressRequest(), and isc::d2::NameAddTransaction::buildReplaceFwdAddressRequest().

+ Here is the call graph for this function:

◆ getCurrentServer()

◆ getDNSClient()

const DNSClientPtr & isc::d2::NameChangeTransaction::getDNSClient ( ) const

Fetches the DNSClient instance.

Returns
A const pointer reference to the DNSClient

Definition at line 528 of file nc_trans.cc.

◆ getDnsUpdateRequest()

const D2UpdateMessagePtr & isc::d2::NameChangeTransaction::getDnsUpdateRequest ( ) const

Fetches the current DNS update request packet.

Returns
A const pointer reference to the current D2UpdateMessage request.

Definition at line 543 of file nc_trans.cc.

◆ getDnsUpdateResponse()

◆ getDnsUpdateStatus()

◆ getForwardChangeCompleted()

bool isc::d2::NameChangeTransaction::getForwardChangeCompleted ( ) const

Returns whether the forward change has completed or not.

The value returned is only meaningful if the NameChangeRequest calls for a forward change to be done. The value returned indicates if forward change has been completed successfully.

Returns
True if the forward change has been completed, false otherwise.

Definition at line 558 of file nc_trans.cc.

Referenced by transactionOutcomeString().

◆ getForwardDomain()

◆ getIOService()

const asiolink::IOServicePtr& isc::d2::NameChangeTransaction::getIOService ( )
inlineprotected

Fetches the IOService the transaction uses for IO processing.

Returns
returns a const pointer to the IOService.

Definition at line 364 of file nc_trans.h.

◆ getNcr()

const dhcp_ddns::NameChangeRequestPtr & isc::d2::NameChangeTransaction::getNcr ( ) const

Fetches the NameChangeRequest for this transaction.

Returns
A const pointer reference to the NameChangeRequest.

Definition at line 425 of file nc_trans.cc.

Referenced by isc::d2::NameAddTransaction::addingFwdAddrsHandler(), addPtrRdata(), isc::d2::NameAddTransaction::buildAddFwdAddressRequest(), isc::d2::NameRemoveTransaction::buildRemoveFwdAddressRequest(), isc::d2::SimpleRemoveTransaction::buildRemoveFwdRRsRequest(), isc::d2::NameRemoveTransaction::buildRemoveFwdRRsRequest(), isc::d2::SimpleRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::NameRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::SimpleAddTransaction::buildReplaceFwdAddressRequest(), isc::d2::NameAddTransaction::buildReplaceFwdAddressRequest(), isc::d2::SimpleAddTransaction::buildReplaceRevPtrsRequest(), isc::d2::NameAddTransaction::buildReplaceRevPtrsRequest(), isc::d2::SimpleAddTransaction::processAddOkHandler(), isc::d2::NameAddTransaction::processAddOkHandler(), isc::d2::SimpleRemoveTransaction::processRemoveOkHandler(), isc::d2::NameRemoveTransaction::processRemoveOkHandler(), isc::d2::NameRemoveTransaction::removingFwdAddrsHandler(), isc::d2::SimpleRemoveTransaction::removingFwdRRsHandler(), isc::d2::NameRemoveTransaction::removingFwdRRsHandler(), isc::d2::SimpleRemoveTransaction::removingRevPtrsHandler(), isc::d2::NameRemoveTransaction::removingRevPtrsHandler(), isc::d2::SimpleAddTransaction::replacingFwdAddrsHandler(), isc::d2::NameAddTransaction::replacingFwdAddrsHandler(), isc::d2::SimpleAddTransaction::replacingRevPtrsHandler(), and isc::d2::NameAddTransaction::replacingRevPtrsHandler().

◆ getNcrStatus()

dhcp_ddns::NameChangeStatus isc::d2::NameChangeTransaction::getNcrStatus ( ) const

Fetches the NameChangeRequest status of the transaction.

This is the current status of the NameChangeRequest, not to be confused with the state of the transaction. Once the transaction is reached its conclusion, the request will end up with a final status.

Returns
A dhcp_ddns::NameChangeStatus representing the current status of the transaction.

Definition at line 440 of file nc_trans.cc.

Referenced by transactionOutcomeString().

◆ getRequestId()

std::string isc::d2::NameChangeTransaction::getRequestId ( ) const

Fetches the request id that identifies this transaction.

This is a wrapper around getRequestId from the NCR which currently returns DHCID. In the future we may include a distinct request id. The primary purpose of this function is to provide a consistent way to identify requests for logging purposes.

Returns
a string with the request's request ID (currently DHCID)

Definition at line 435 of file nc_trans.cc.

Referenced by isc::d2::NameAddTransaction::addingFwdAddrsHandler(), onModelFailure(), operator()(), isc::d2::SimpleAddTransaction::processAddFailedHandler(), isc::d2::NameAddTransaction::processAddFailedHandler(), isc::d2::SimpleAddTransaction::processAddOkHandler(), isc::d2::NameAddTransaction::processAddOkHandler(), isc::d2::SimpleRemoveTransaction::processRemoveFailedHandler(), isc::d2::NameRemoveTransaction::processRemoveFailedHandler(), isc::d2::SimpleRemoveTransaction::processRemoveOkHandler(), isc::d2::NameRemoveTransaction::processRemoveOkHandler(), isc::d2::NameRemoveTransaction::removingFwdAddrsHandler(), isc::d2::SimpleRemoveTransaction::removingFwdRRsHandler(), isc::d2::NameRemoveTransaction::removingFwdRRsHandler(), isc::d2::SimpleRemoveTransaction::removingRevPtrsHandler(), isc::d2::NameRemoveTransaction::removingRevPtrsHandler(), isc::d2::SimpleAddTransaction::replacingFwdAddrsHandler(), isc::d2::NameAddTransaction::replacingFwdAddrsHandler(), isc::d2::SimpleAddTransaction::replacingRevPtrsHandler(), isc::d2::NameAddTransaction::replacingRevPtrsHandler(), sendUpdate(), and startTransaction().

◆ getReverseChangeCompleted()

bool isc::d2::NameChangeTransaction::getReverseChangeCompleted ( ) const

Returns whether the reverse change has completed or not.

The value returned is only meaningful if the NameChangeRequest calls for a reverse change to be done. The value returned indicates if reverse change has been completed successfully.

Returns
True if the reverse change has been completed, false otherwise.

Definition at line 563 of file nc_trans.cc.

Referenced by transactionOutcomeString().

◆ getReverseDomain()

◆ getTransactionKey()

const TransactionKey & isc::d2::NameChangeTransaction::getTransactionKey ( ) const

Fetches the unique key that identifies this transaction.

Transactions are uniquely identified by a TransactionKey. Currently this is wrapper around a D2Dhcid.

Returns
A const reference to the TransactionKey.

Definition at line 430 of file nc_trans.cc.

◆ getUpdateAttempts()

size_t isc::d2::NameChangeTransaction::getUpdateAttempts ( ) const

Fetches the update attempt count for the current update.

Returns
size_t which is the number of times the current request has been attempted against the current server.

Definition at line 568 of file nc_trans.cc.

◆ initServerSelection()

void isc::d2::NameChangeTransaction::initServerSelection ( const DdnsDomainPtr domain)
protected

Initializes server selection from the given DDNS domain.

Method prepares internal data to conduct server selection from the list of servers supplied by the given domain. This method should be called when a transaction is ready to begin selecting servers from a new list. Typically this will be prior to starting the updates for a given DNS direction.

Parameters
domainis the domain from which server selection is to be conducted.

Definition at line 455 of file nc_trans.cc.

References isc_throw.

Referenced by isc::d2::SimpleRemoveTransaction::selectingFwdServerHandler(), isc::d2::SimpleAddTransaction::selectingFwdServerHandler(), isc::d2::NameRemoveTransaction::selectingFwdServerHandler(), isc::d2::NameAddTransaction::selectingFwdServerHandler(), isc::d2::SimpleRemoveTransaction::selectingRevServerHandler(), isc::d2::SimpleAddTransaction::selectingRevServerHandler(), isc::d2::NameRemoveTransaction::selectingRevServerHandler(), and isc::d2::NameAddTransaction::selectingRevServerHandler().

◆ onModelFailure()

void isc::d2::NameChangeTransaction::onModelFailure ( const std::string &  explanation)
protectedvirtual

Handler for fatal model execution errors.

This handler is called by the StateModel implementation when the model execution encounters a model violation: attempt to call an unmapped state, an event not valid for the current state, or an uncaught exception thrown during a state handler invocation. When such an error occurs the transaction is deemed inoperable, and further model execution cannot be performed. It marks the transaction as failed by setting the NCR status to dhcp_ddns::ST_FAILED

Parameters
explanationis text detailing the error

Reimplemented from isc::util::StateModel.

Definition at line 278 of file nc_trans.cc.

References isc::d2::d2_to_dns_logger, isc::d2::DHCP_DDNS_STATE_MODEL_UNEXPECTED_ERROR, getRequestId(), LOG_ERROR, setNcrStatus(), and isc::dhcp_ddns::ST_FAILED.

+ Here is the call graph for this function:

◆ operator()()

void isc::d2::NameChangeTransaction::operator() ( DNSClient::Status  status)
virtual

Serves as the DNSClient IO completion event handler.

This is the implementation of the method inherited by our derivation from DNSClient::Callback. When the DNSClient completes an update it invokes this method as the completion handler. This method stores the given status and invokes runStateModel() with an event value of IO_COMPLETED_EVT.

Parameters
statusis the outcome of the DNS update packet exchange. This method is exception safe.

Implements isc::d2::DNSClient::Callback.

Definition at line 120 of file nc_trans.cc.

References isc::d2::d2_to_dns_logger, isc::log::DBGLVL_TRACE_DETAIL, isc::d2::DHCP_DDNS_UPDATE_RESPONSE_RECEIVED, getRequestId(), IO_COMPLETED_EVT, LOG_DEBUG, responseString(), isc::util::StateModel::runModel(), and setDnsUpdateStatus().

+ Here is the call graph for this function:

◆ prepNewRequest()

D2UpdateMessagePtr isc::d2::NameChangeTransaction::prepNewRequest ( DdnsDomainPtr  domain)
protectedvirtual

◆ responseString()

std::string isc::d2::NameChangeTransaction::responseString ( ) const
protected

Returns a string version of the current response status and rcode.

Renders a string containing the text label of current DNS update status and RCODE (if status is DNSClient::SUCCESS)

Returns
std::string containing constructed text

Definition at line 136 of file nc_trans.cc.

References getDnsUpdateResponse(), getDnsUpdateStatus(), isc::d2::DNSClient::INVALID_RESPONSE, isc::d2::DNSClient::IO_STOPPED, isc::d2::DNSClient::OTHER, isc::d2::DNSClient::SUCCESS, and isc::d2::DNSClient::TIMEOUT.

Referenced by operator()().

+ Here is the call graph for this function:

◆ retryTransition()

void isc::d2::NameChangeTransaction::retryTransition ( const int  fail_to_state)
protected

Determines the state and next event based on update attempts.

This method will post a next event of SERVER_SELECTED_EVT to the current state if the number of update attempts has not reached the maximum allowed.

If the maximum number of attempts has been reached, it will transition to the given state with a next event of SERVER_IO_ERROR_EVT.

Parameters
fail_to_stateState to transition to if maximum attempts have been tried.

Definition at line 286 of file nc_trans.cc.

References isc::util::StateModel::getCurrState(), MAX_UPDATE_TRIES_PER_SERVER, SERVER_IO_ERROR_EVT, SERVER_SELECTED_EVT, and isc::util::StateModel::transition().

Referenced by isc::d2::NameAddTransaction::addingFwdAddrsHandler(), isc::d2::NameRemoveTransaction::removingFwdAddrsHandler(), isc::d2::SimpleRemoveTransaction::removingFwdRRsHandler(), isc::d2::NameRemoveTransaction::removingFwdRRsHandler(), isc::d2::SimpleRemoveTransaction::removingRevPtrsHandler(), isc::d2::NameRemoveTransaction::removingRevPtrsHandler(), isc::d2::SimpleAddTransaction::replacingFwdAddrsHandler(), isc::d2::NameAddTransaction::replacingFwdAddrsHandler(), isc::d2::SimpleAddTransaction::replacingRevPtrsHandler(), and isc::d2::NameAddTransaction::replacingRevPtrsHandler().

+ Here is the call graph for this function:

◆ selectNextServer()

bool isc::d2::NameChangeTransaction::selectNextServer ( )
protected

Selects the next server in the current server list.

This method is used to iterate over the list of servers. If there are no more servers in the list, it returns false. Otherwise it sets the current server to the next server and creates a new DNSClient instance.

Returns
True if a server has been selected, false if there are no more servers from which to select.

Definition at line 467 of file nc_trans.cc.

References selectTSIGKey(), and isc::d2::DNSClient::UDP.

Referenced by isc::d2::SimpleRemoveTransaction::selectingFwdServerHandler(), isc::d2::SimpleAddTransaction::selectingFwdServerHandler(), isc::d2::NameRemoveTransaction::selectingFwdServerHandler(), isc::d2::NameAddTransaction::selectingFwdServerHandler(), isc::d2::SimpleRemoveTransaction::selectingRevServerHandler(), isc::d2::SimpleAddTransaction::selectingRevServerHandler(), isc::d2::NameRemoveTransaction::selectingRevServerHandler(), and isc::d2::NameAddTransaction::selectingRevServerHandler().

+ Here is the call graph for this function:

◆ selectTSIGKey()

bool isc::d2::NameChangeTransaction::selectTSIGKey ( )
protected

Selects the TSIG key.

This method uses the current server and the select_key callout. When no TSIG key is selected the tsig_key_ pointer is null.

Returns
False when the current server should be skipped.

Definition at line 496 of file nc_trans.cc.

References Hooks.

Referenced by selectNextServer().

◆ sendUpdate()

void isc::d2::NameChangeTransaction::sendUpdate ( const std::string &  comment = "")
protectedvirtual

Send the update request to the current server.

This method increments the update attempt count and then passes the current update request to the DNSClient instance to be sent to the currently selected server. Since the send is asynchronous, the method posts NOP_EVT as the next event and then returns.

If tsig_key_ is not NULL, then the update will be conducted using the key to sign the request and verify the response, otherwise it will be conducted without TSIG.

Parameters
commenttext to include in log detail

If an exception occurs it will be logged and and the transaction will be failed.

Definition at line 192 of file nc_trans.cc.

References isc::d2::d2_to_dns_logger, isc::log::DBGLVL_TRACE_DETAIL, isc::d2::DHCP_DDNS_TRANS_SEND_ERROR, isc::d2::DHCP_DDNS_UPDATE_REQUEST_SENT, getRequestId(), LOG_DEBUG, LOG_ERROR, isc::util::StateModel::NOP_EVT, isc::util::StateModel::postNextEvent(), PROCESS_TRANS_FAILED_ST, isc::util::StateModel::transition(), and UPDATE_FAILED_EVT.

Referenced by isc::d2::NameAddTransaction::addingFwdAddrsHandler(), isc::d2::NameRemoveTransaction::removingFwdAddrsHandler(), isc::d2::SimpleRemoveTransaction::removingFwdRRsHandler(), isc::d2::NameRemoveTransaction::removingFwdRRsHandler(), isc::d2::SimpleRemoveTransaction::removingRevPtrsHandler(), isc::d2::NameRemoveTransaction::removingRevPtrsHandler(), isc::d2::SimpleAddTransaction::replacingFwdAddrsHandler(), isc::d2::NameAddTransaction::replacingFwdAddrsHandler(), isc::d2::SimpleAddTransaction::replacingRevPtrsHandler(), and isc::d2::NameAddTransaction::replacingRevPtrsHandler().

+ Here is the call graph for this function:

◆ setDnsUpdateRequest()

◆ setDnsUpdateResponse()

void isc::d2::NameChangeTransaction::setDnsUpdateResponse ( D2UpdateMessagePtr response)
protected

Sets the update response packet to the given packet.

Parameters
responseis the new response packet to assign.

Definition at line 318 of file nc_trans.cc.

◆ setDnsUpdateStatus()

void isc::d2::NameChangeTransaction::setDnsUpdateStatus ( const DNSClient::Status status)
protected

Sets the update status to the given status value.

Parameters
statusis the new value for the update status.

Definition at line 313 of file nc_trans.cc.

Referenced by operator()().

◆ setForwardChangeCompleted()

void isc::d2::NameChangeTransaction::setForwardChangeCompleted ( const bool  value)
protected

◆ setNcrStatus()

◆ setReverseChangeCompleted()

void isc::d2::NameChangeTransaction::setReverseChangeCompleted ( const bool  value)
protected

Sets the reverse change completion flag to the given value.

Parameters
valueis the new value to assign to the flag.

Definition at line 333 of file nc_trans.cc.

Referenced by isc::d2::SimpleRemoveTransaction::removingRevPtrsHandler(), isc::d2::NameRemoveTransaction::removingRevPtrsHandler(), isc::d2::SimpleAddTransaction::replacingRevPtrsHandler(), and isc::d2::NameAddTransaction::replacingRevPtrsHandler().

◆ setUpdateAttempts()

void isc::d2::NameChangeTransaction::setUpdateAttempts ( const size_t  value)
protected

Sets the update attempt count to the given value.

Parameters
valueis the new value to assign.

Definition at line 338 of file nc_trans.cc.

◆ startTransaction()

void isc::d2::NameChangeTransaction::startTransaction ( )

Begins execution of the transaction.

This method invokes StateModel::startModel() with a value of READY_ST. This causes transaction's state model to attempt to begin execution with the state handler for READY_ST.

Definition at line 110 of file nc_trans.cc.

References isc::d2::d2_to_dns_logger, isc::log::DBGLVL_TRACE_DETAIL, isc::d2::DHCP_DDNS_STARTING_TRANSACTION, getRequestId(), LOG_DEBUG, READY_ST, setNcrStatus(), isc::dhcp_ddns::ST_PENDING, and isc::util::StateModel::startModel().

+ Here is the call graph for this function:

◆ transactionOutcomeString()

std::string isc::d2::NameChangeTransaction::transactionOutcomeString ( ) const
protected

Returns a string version of transaction outcome.

Renders a string containing summarizes the outcome of the transaction. The information includes the overall status, the last event, whether not forward and reverse changes were done, as well as the NCR serviced.

Returns
std::string containing constructed text

Definition at line 170 of file nc_trans.cc.

References isc::util::StateModel::getEventLabel(), getForwardChangeCompleted(), getNcrStatus(), isc::util::StateModel::getNextEvent(), getReverseChangeCompleted(), and isc::dhcp_ddns::ST_COMPLETED.

Referenced by isc::d2::SimpleAddTransaction::processAddFailedHandler(), isc::d2::NameAddTransaction::processAddFailedHandler(), isc::d2::SimpleRemoveTransaction::processRemoveFailedHandler(), and isc::d2::NameRemoveTransaction::processRemoveFailedHandler().

+ Here is the call graph for this function:

◆ verifyEvents()

void isc::d2::NameChangeTransaction::verifyEvents ( )
protectedvirtual

Validates the contents of the set of events.

This method verifies that the events defined by both the superclass and this class are defined. As with defineEvents, this method calls the superclass's implementation first, to verify events defined by it and then this implementation to verify events defined by NameChangeTransaction.

Exceptions
StateModelErrorif an event value is undefined.

Reimplemented from isc::util::StateModel.

Reimplemented in isc::d2::NameAddTransaction, isc::d2::NameRemoveTransaction, isc::d2::SimpleAddTransaction, and isc::d2::SimpleRemoveTransaction.

Definition at line 242 of file nc_trans.cc.

References isc::util::StateModel::getEvent(), IO_COMPLETED_EVT, NO_MORE_SERVERS_EVT, SELECT_SERVER_EVT, SERVER_IO_ERROR_EVT, SERVER_SELECTED_EVT, UPDATE_FAILED_EVT, UPDATE_OK_EVT, and isc::util::StateModel::verifyEvents().

Referenced by isc::d2::SimpleRemoveTransaction::verifyEvents(), isc::d2::SimpleAddTransaction::verifyEvents(), isc::d2::NameRemoveTransaction::verifyEvents(), and isc::d2::NameAddTransaction::verifyEvents().

+ Here is the call graph for this function:

◆ verifyStates()

void isc::d2::NameChangeTransaction::verifyStates ( )
protectedvirtual

Validates the contents of the set of states.

This method verifies that the states defined by both the superclass and this class are defined. As with defineStates, this method calls the superclass's implementation first, to verify states defined by it and then this implementation to verify states defined by NameChangeTransaction.

Exceptions
StateModelErrorif an event value is undefined.

Reimplemented from isc::util::StateModel.

Reimplemented in isc::d2::NameAddTransaction, isc::d2::NameRemoveTransaction, isc::d2::SimpleAddTransaction, and isc::d2::SimpleRemoveTransaction.

Definition at line 265 of file nc_trans.cc.

References isc::util::StateModel::getStateInternal(), PROCESS_TRANS_FAILED_ST, PROCESS_TRANS_OK_ST, READY_ST, SELECTING_FWD_SERVER_ST, SELECTING_REV_SERVER_ST, and isc::util::StateModel::verifyStates().

Referenced by isc::d2::SimpleRemoveTransaction::verifyStates(), isc::d2::SimpleAddTransaction::verifyStates(), isc::d2::NameRemoveTransaction::verifyStates(), and isc::d2::NameAddTransaction::verifyStates().

+ Here is the call graph for this function:

Member Data Documentation

◆ DNS_UPDATE_DEFAULT_TIMEOUT

const unsigned int isc::d2::NameChangeTransaction::DNS_UPDATE_DEFAULT_TIMEOUT = 100
static

Default time to assign to a single DNS update.

Todo:
This value will be made configurable in the very near future under trac3268. For now we will define it to 100 milliseconds so unit tests will run within a reasonable amount of time.

Definition at line 151 of file nc_trans.h.

◆ IO_COMPLETED_EVT

◆ MAX_UPDATE_TRIES_PER_SERVER

const unsigned int isc::d2::NameChangeTransaction::MAX_UPDATE_TRIES_PER_SERVER = 3
static

Maximum times to attempt a single update on a given server.

Definition at line 154 of file nc_trans.h.

Referenced by retryTransition().

◆ NCT_DERIVED_EVENT_MIN

const int isc::d2::NameChangeTransaction::NCT_DERIVED_EVENT_MIN = SM_DERIVED_EVENT_MIN + 101
static

Value at which custom events in a derived class should begin.

Definition at line 144 of file nc_trans.h.

◆ NCT_DERIVED_STATE_MIN

const int isc::d2::NameChangeTransaction::NCT_DERIVED_STATE_MIN = SM_DERIVED_STATE_MIN + 101
static

Value at which custom states in a derived class should begin.

Definition at line 108 of file nc_trans.h.

◆ NO_MORE_SERVERS_EVT

◆ PROCESS_TRANS_FAILED_ST

const int isc::d2::NameChangeTransaction::PROCESS_TRANS_FAILED_ST = SM_DERIVED_STATE_MIN + 5
static

◆ PROCESS_TRANS_OK_ST

◆ READY_ST

const int isc::d2::NameChangeTransaction::READY_ST = SM_DERIVED_STATE_MIN + 1
static

◆ SELECT_SERVER_EVT

◆ SELECTING_FWD_SERVER_ST

◆ SELECTING_REV_SERVER_ST

◆ SERVER_IO_ERROR_EVT

◆ SERVER_SELECTED_EVT

◆ UPDATE_FAILED_EVT

◆ UPDATE_OK_EVT


The documentation for this class was generated from the following files: