Commit 23995669 authored by Thomas Markwalder's avatar Thomas Markwalder
Browse files

[master] Merge branch 'trac3222'

b10-dhcp6 fully able to do DHCP-DDNS
parents e26e83b4 7385971a
// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -20,6 +20,7 @@
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <string>
......@@ -131,7 +132,7 @@ DdnsDomainListMgr::matchDomain(const std::string& fqdn, DdnsDomainPtr& domain) {
// If the lengths are identical and the names match we're done.
if (req_len == dom_len) {
if (fqdn == domain_name) {
if (boost::iequals(fqdn, domain_name)) {
// exact match, done
domain = map_pair.second;
return (true);
......@@ -143,7 +144,7 @@ DdnsDomainListMgr::matchDomain(const std::string& fqdn, DdnsDomainPtr& domain) {
// prevents "onetwo.net" from matching "two.net".
size_t offset = req_len - dom_len;
if ((fqdn[offset - 1] == '.') &&
(fqdn.compare(offset, std::string::npos, domain_name) == 0)) {
(boost::iequals(fqdn.substr(offset), domain_name))) {
// Fqdn contains domain name, keep it if its better than
// any we have matched so far.
if (dom_len > match_len) {
......
......@@ -344,10 +344,10 @@ due to invalid data contained in the NameChangeRequest. The request will be
aborted. This is most likely a configuration issue.
% DHCP_DDNS_ADD_SUCCEEDED DHCP_DDNS successfully added the DNS mapping addition for this request: %1
This is a debug message issued after DHCP_DDNS has submitted DNS mapping
additions which were received and accepted by an appropriate DNS server.
This is an informational message issued after DHCP_DDNS has submitted DNS
mapping additions which were received and accepted by an appropriate DNS server.
% DHCP_DDNS_ADD_FAILED DHCP_DDNS failed attempting to make DNS mapping additions for this request: %1, event: %2
% DHCP_DDNS_ADD_FAILED DHCP_DDNS Transaction outcome: %1
This is an error message issued after DHCP_DDNS attempts to submit DNS mapping
entry additions have failed. The precise reason for the failure should be
documented in preceding log entries.
......@@ -430,17 +430,17 @@ while DHCP_DDNS was removing a reverse address mapping. The request will be
aborted. This is most likely a programmatic issue and should be reported.
% DHCP_DDNS_REMOVE_SUCCEEDED DHCP_DDNS successfully removed the DNS mapping addition for this request: %1
This is a debug message issued after DHCP_DDNS has submitted DNS mapping
removals which were received and accepted by an appropriate DNS server.
This is an informational message issued after DHCP_DDNS has submitted DNS
mapping removals which were received and accepted by an appropriate DNS server.
% DHCP_DDNS_REMOVE_FAILED DHCP_DDNS failed attempting to make DNS mapping removals for this request: %1, event: %2
% DHCP_DDNS_REMOVE_FAILED DHCP_DDNS Transaction outcome: %1
This is an error message issued after DHCP_DDNS attempts to submit DNS mapping
entry removals have failed. The precise reason for the failure should be
documented in preceding log entries.
% DHCP_DDNS_STARTING_TRANSACTION Transaction Key: %1
% DHCP_DDNS_UPDATE_REQUEST_SENT for transaction key: %1 to server: %2
% DHCP_DDNS_UPDATE_REQUEST_SENT %1 for transaction key: %2 to server: %3
This is a debug message issued when DHCP_DDNS sends a DNS request to a DNS
server.
......
// Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -202,7 +202,7 @@ NameAddTransaction::addingFwdAddrsHandler() {
// Call sendUpdate() to initiate the async send. Note it also sets
// next event to NOP_EVT.
sendUpdate();
sendUpdate("Foward Add");
break;
case IO_COMPLETED_EVT: {
......@@ -313,7 +313,7 @@ NameAddTransaction::replacingFwdAddrsHandler() {
// Call sendUpdate() to initiate the async send. Note it also sets
// next event to NOP_EVT.
sendUpdate();
sendUpdate("Forward Replace");
break;
case IO_COMPLETED_EVT: {
......@@ -459,7 +459,7 @@ NameAddTransaction::replacingRevPtrsHandler() {
// Call sendUpdate() to initiate the async send. Note it also sets
// next event to NOP_EVT.
sendUpdate();
sendUpdate("Reverse Replace");
break;
case IO_COMPLETED_EVT: {
......@@ -539,7 +539,7 @@ void
NameAddTransaction::processAddOkHandler() {
switch(getNextEvent()) {
case UPDATE_OK_EVT:
LOG_DEBUG(dctl_logger, DBGLVL_TRACE_DETAIL, DHCP_DDNS_ADD_SUCCEEDED)
LOG_INFO(dctl_logger, DHCP_DDNS_ADD_SUCCEEDED)
.arg(getNcr()->toText());
setNcrStatus(dhcp_ddns::ST_COMPLETED);
endModel();
......@@ -556,9 +556,9 @@ NameAddTransaction::processAddFailedHandler() {
switch(getNextEvent()) {
case UPDATE_FAILED_EVT:
case NO_MORE_SERVERS_EVT:
LOG_ERROR(dctl_logger, DHCP_DDNS_ADD_FAILED).arg(getNcr()->toText())
.arg(getEventLabel(getNextEvent()));
setNcrStatus(dhcp_ddns::ST_FAILED);
LOG_ERROR(dctl_logger, DHCP_DDNS_ADD_FAILED)
.arg(transactionOutcomeString());
endModel();
break;
default:
......
// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -207,7 +207,7 @@ NameRemoveTransaction::removingFwdAddrsHandler() {
// Call sendUpdate() to initiate the async send. Note it also sets
// next event to NOP_EVT.
sendUpdate();
sendUpdate("Forward A/AAAA Remove");
break;
case IO_COMPLETED_EVT: {
......@@ -311,7 +311,7 @@ NameRemoveTransaction::removingFwdRRsHandler() {
// Call sendUpdate() to initiate the async send. Note it also sets
// next event to NOP_EVT.
sendUpdate();
sendUpdate("Forward RR Remove");
break;
case IO_COMPLETED_EVT: {
......@@ -464,7 +464,7 @@ NameRemoveTransaction::removingRevPtrsHandler() {
// Call sendUpdate() to initiate the async send. Note it also sets
// next event to NOP_EVT.
sendUpdate();
sendUpdate("Reverse Remove");
break;
case IO_COMPLETED_EVT: {
......@@ -547,8 +547,8 @@ void
NameRemoveTransaction::processRemoveOkHandler() {
switch(getNextEvent()) {
case UPDATE_OK_EVT:
LOG_DEBUG(dctl_logger, DBGLVL_TRACE_DETAIL, DHCP_DDNS_REMOVE_SUCCEEDED)
.arg(getNcr()->toText());
LOG_INFO(dctl_logger, DHCP_DDNS_REMOVE_SUCCEEDED)
.arg(getNcr()->toText());
setNcrStatus(dhcp_ddns::ST_COMPLETED);
endModel();
break;
......@@ -565,9 +565,9 @@ NameRemoveTransaction::processRemoveFailedHandler() {
case UPDATE_FAILED_EVT:
case NO_MORE_SERVERS_EVT:
case SERVER_IO_ERROR_EVT:
LOG_ERROR(dctl_logger, DHCP_DDNS_REMOVE_FAILED).arg(getNcr()->toText())
.arg(getEventLabel(getNextEvent()));
setNcrStatus(dhcp_ddns::ST_FAILED);
LOG_ERROR(dctl_logger, DHCP_DDNS_REMOVE_FAILED)
.arg(transactionOutcomeString());
endModel();
break;
default:
......
// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -16,6 +16,8 @@
#include <d2/nc_trans.h>
#include <dns/rdata.h>
#include <sstream>
namespace isc {
namespace d2 {
......@@ -94,18 +96,75 @@ NameChangeTransaction::operator()(DNSClient::Status status) {
// set to indicate IO completed.
// runModel is exception safe so we are good to call it here.
// It won't exit until we hit the next IO wait or the state model ends.
setDnsUpdateStatus(status);
LOG_DEBUG(dctl_logger, DBGLVL_TRACE_DETAIL,
DHCP_DDNS_UPDATE_RESPONSE_RECEIVED)
.arg(getTransactionKey().toStr())
.arg(current_server_->toText())
.arg(status);
.arg(responseString());
setDnsUpdateStatus(status);
runModel(IO_COMPLETED_EVT);
}
std::string
NameChangeTransaction::responseString() const {
std::ostringstream stream;
switch (getDnsUpdateStatus()) {
case DNSClient::SUCCESS:
stream << "SUCCESS, rcode: ";
if (getDnsUpdateResponse()) {
stream << getDnsUpdateResponse()->getRcode().toText();
} else {
stream << " update response is NULL";
}
break;
case DNSClient::TIMEOUT:
stream << "TIMEOUT";
break;
case DNSClient::IO_STOPPED:
stream << "IO_STOPPED";
break;
case DNSClient::INVALID_RESPONSE:
stream << "INVALID_RESPONSE";
break;
case DNSClient::OTHER:
stream << "OTHER";
break;
default:
stream << "UKNOWNN("
<< static_cast<int>(getDnsUpdateStatus()) << ")";
break;
}
return (stream.str());
}
std::string
NameChangeTransaction::transactionOutcomeString() const {
std::ostringstream stream;
stream << "Status: " << (getNcrStatus() == dhcp_ddns::ST_COMPLETED
? "Completed, " : "Failed, ")
<< "Event: " << getEventLabel(getNextEvent()) << ", ";
if (ncr_->isForwardChange()) {
stream << " Forward change:" << (getForwardChangeCompleted()
? " completed, " : " failed, ");
}
if (ncr_->isReverseChange()) {
stream << " Reverse change:" << (getReverseChangeCompleted()
? " completed, " : " failed, ");
}
stream << " request: " << ncr_->toText();
return (stream.str());
}
void
NameChangeTransaction::sendUpdate(bool /* use_tsig_ */) {
NameChangeTransaction::sendUpdate(const std::string& comment,
bool /* use_tsig_ */) {
try {
++update_attempts_;
// @todo add logic to add/replace TSIG key info in request if
......@@ -122,6 +181,7 @@ NameChangeTransaction::sendUpdate(bool /* use_tsig_ */) {
postNextEvent(NOP_EVT);
LOG_DEBUG(dctl_logger, DBGLVL_TRACE_DETAIL,
DHCP_DDNS_UPDATE_REQUEST_SENT)
.arg(comment)
.arg(getTransactionKey().toStr())
.arg(current_server_->toText());
} catch (const std::exception& ex) {
......
......@@ -207,12 +207,14 @@ protected:
/// currently selected server. Since the send is asynchronous, the method
/// posts NOP_EVT as the next event and then returns.
///
/// @param comment text to include in log detail
/// @param use_tsig True if the update should be include a TSIG key. This
/// is not yet implemented.
///
/// If an exception occurs it will be logged and and the transaction will
/// be failed.
virtual void sendUpdate(bool use_tsig = false);
virtual void sendUpdate(const std::string& comment = "",
bool use_tsig = false);
/// @brief Adds events defined by NameChangeTransaction to the event set.
///
......@@ -401,6 +403,24 @@ protected:
/// the RData cannot be added to the given RRset.
void addPtrRdata(dns::RRsetPtr& rrset);
/// @brief Returns a string version of the current response status and rcode
///
/// Renders a string containing the a text label current DNS update status
/// and RCODE (if status is DNSClient::SUCCESS)
///
/// @return std::string containing constructed text
std::string responseString() const;
/// @brief 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.
///
/// @return std::string containing constructed text
std::string transactionOutcomeString() const;
public:
/// @brief Fetches the NameChangeRequest for this transaction.
///
......
// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -1066,6 +1066,10 @@ TEST_F(D2CfgMgrTest, forwardMatch) {
EXPECT_TRUE(cfg_mgr_->matchForward("tmark.org", match));
EXPECT_EQ("tmark.org", match->getName());
// Verify that search is case insensisitive.
EXPECT_TRUE(cfg_mgr_->matchForward("TMARK.ORG", match));
EXPECT_EQ("tmark.org", match->getName());
// Verify that an exact match works.
EXPECT_TRUE(cfg_mgr_->matchForward("one.tmark.org", match));
EXPECT_EQ("one.tmark.org", match->getName());
......@@ -1207,7 +1211,8 @@ TEST_F(D2CfgMgrTest, matchReverse) {
" \"dns_servers\" : [ "
" { \"ip_address\": \"127.0.0.1\" } "
" ] }, "
"{ \"name\": \"2.0.3.0.8.B.D.0.1.0.0.2.ip6.arpa.\" , "
// Note mixed case to test case insensitivity.
"{ \"name\": \"2.0.3.0.8.b.d.0.1.0.0.2.IP6.ARPA.\" , "
" \"dns_servers\" : [ "
" { \"ip_address\": \"127.0.0.1\" } "
" ] },"
......@@ -1247,7 +1252,7 @@ TEST_F(D2CfgMgrTest, matchReverse) {
// Verify a IPv6 match.
EXPECT_TRUE(cfg_mgr_->matchReverse("2001:db8:302:99::",match));
EXPECT_EQ("2.0.3.0.8.B.D.0.1.0.0.2.ip6.arpa.", match->getName());
EXPECT_EQ("2.0.3.0.8.b.d.0.1.0.0.2.IP6.ARPA.", match->getName());
// Verify a IPv6 wild card match.
EXPECT_TRUE(cfg_mgr_->matchReverse("2001:db8:99:302::",match));
......
......@@ -54,10 +54,11 @@ public:
/// It will also simulate an exception-based failure of sendUpdate, if
/// the simulate_send_exception_ flag is true.
///
/// @param use_tsig_ Parameter is unused, but present in the base class
/// method.
/// @param comment Parameter is unused, but present in base class method.
/// @param use_tsig_ Parameter is unused, but present in base class method.
///
virtual void sendUpdate(bool /* use_tsig_ = false */) {
virtual void sendUpdate(const std::string& /*comment*/,
bool /* use_tsig_ = false */) {
if (simulate_send_exception_) {
// Make the flag a one-shot by resetting it.
simulate_send_exception_ = false;
......
// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -55,10 +55,11 @@ public:
/// It will also simulate an exception-based failure of sendUpdate, if
/// the simulate_send_exception_ flag is true.
///
/// @param use_tsig_ Parameter is unused, but present in the base class
/// method.
/// @param comment Parameter is unused, but present in base class method
/// @param use_tsig Parameter is unused, but present in base class method.
///
virtual void sendUpdate(bool /* use_tsig_ = false */) {
virtual void sendUpdate(const std::string& /* comment */,
bool /* use_tsig = false */) {
if (simulate_send_exception_) {
// Make the flag a one-shot by resetting it.
simulate_send_exception_ = false;
......
......@@ -262,6 +262,8 @@ public:
using NameChangeTransaction::addLeaseAddressRdata;
using NameChangeTransaction::addDhcidRdata;
using NameChangeTransaction::addPtrRdata;
using NameChangeTransaction::responseString;
using NameChangeTransaction::transactionOutcomeString;
};
// Declare them so Gtest can see them.
......@@ -507,8 +509,87 @@ TEST_F(NameChangeTransactionTest, dnsUpdateResponseAccessors) {
// Should be empty again.
EXPECT_FALSE(name_change->getDnsUpdateResponse());
}
/// @brief Tests responseString method.
TEST_F(NameChangeTransactionTest, responseString) {
// Create a transaction.
NameChangeStubPtr name_change;
ASSERT_NO_THROW(name_change = makeCannedTransaction());
// Make sure it is safe to call when status says success but there
// is no update response.
ASSERT_NO_THROW(name_change->setDnsUpdateStatus(DNSClient::SUCCESS));
EXPECT_EQ("SUCCESS, rcode: update response is NULL",
name_change->responseString());
// Create a response. (We use an OUTBOUND message so we can set RCODE)
D2UpdateMessagePtr resp;
ASSERT_NO_THROW(resp.reset(new D2UpdateMessage(D2UpdateMessage::OUTBOUND)));
ASSERT_NO_THROW(name_change->setDnsUpdateResponse(resp));
// Make sure we decode Rcode when status is successful.
ASSERT_NO_THROW(resp->setRcode(dns::Rcode::NXDOMAIN()));
EXPECT_EQ("SUCCESS, rcode: NXDOMAIN", name_change->responseString());
// Test all of the non-success values for status.
ASSERT_NO_THROW(name_change->setDnsUpdateStatus(DNSClient::TIMEOUT));
EXPECT_EQ("TIMEOUT", name_change->responseString());
ASSERT_NO_THROW(name_change->setDnsUpdateStatus(DNSClient::IO_STOPPED));
EXPECT_EQ("IO_STOPPED", name_change->responseString());
ASSERT_NO_THROW(name_change->setDnsUpdateStatus(DNSClient::
INVALID_RESPONSE));
EXPECT_EQ("INVALID_RESPONSE", name_change->responseString());
ASSERT_NO_THROW(name_change->setDnsUpdateStatus(DNSClient::OTHER));
EXPECT_EQ("OTHER", name_change->responseString());
}
/// @brief Tests transactionOutcomeString method.
TEST_F(NameChangeTransactionTest, transactionOutcomeString) {
// Create a transaction.
NameChangeStubPtr name_change;
dhcp_ddns::NameChangeRequestPtr ncr;
ASSERT_NO_THROW(name_change = makeCannedTransaction());
ncr = name_change->getNcr();
// Check case of failed transaction in both directions
std::string exp_str("Status: Failed, Event: UNDEFINED, Forward change:"
" failed, Reverse change: failed, request: ");
exp_str += ncr->toText();
std::string tstring = name_change->transactionOutcomeString();
std::cout << "tstring is: [" << tstring << "]" << std::endl;
EXPECT_EQ(exp_str, name_change->transactionOutcomeString());
// Check case of success all around
name_change->setNcrStatus(dhcp_ddns::ST_COMPLETED);
name_change->setForwardChangeCompleted(true);
name_change->setReverseChangeCompleted(true);
exp_str = "Status: Completed, Event: UNDEFINED, Forward change: completed,"
" Reverse change: completed, request: " + ncr->toText();
EXPECT_EQ(exp_str, name_change->transactionOutcomeString());
// Check case of success, with no forward change
name_change->setNcrStatus(dhcp_ddns::ST_COMPLETED);
ncr->setForwardChange(false);
exp_str = "Status: Completed, Event: UNDEFINED, "
" Reverse change: completed, request: " + ncr->toText();
EXPECT_EQ(exp_str, name_change->transactionOutcomeString());
// Check case of success, with no reverse change
name_change->setNcrStatus(dhcp_ddns::ST_COMPLETED);
ncr->setForwardChange(true);
ncr->setReverseChange(false);
exp_str = "Status: Completed, Event: UNDEFINED, "
" Forward change: completed, request: " + ncr->toText();
EXPECT_EQ(exp_str, name_change->transactionOutcomeString());
}
/// @brief Tests event and state dictionary construction and verification.
TEST_F(NameChangeTransactionTest, dictionaryCheck) {
......
......@@ -114,6 +114,16 @@ ControlledDhcpv6Srv::dhcp6ConfigHandler(ConstElementPtr new_config) {
return (answer);
}
// Server will start DDNS communications if its enabled.
try {
server_->startD2();
} catch (const std::exception& ex) {
std::ostringstream err;
err << "error starting DHCP_DDNS client "
" after server reconfiguration: " << ex.what();
return (isc::config::createAnswer(1, err.str()));
}
// Configuration may change active interfaces. Therefore, we have to reopen
// sockets according to new configuration. This operation is not exception
// safe and we really don't want to emit exceptions to the callback caller.
......@@ -212,6 +222,10 @@ void ControlledDhcpv6Srv::establishSession() {
try {
// Pull the full configuration out from the session.
configureDhcp6Server(*this, config_session_->getFullConfig());
// Server will start DDNS communications if its enabled.
server_->startD2();
// Configuration may disable or enable interfaces so we have to
// reopen sockets according to new configuration.
openActiveSockets(getPort());
......
......@@ -91,6 +91,11 @@ New values: hostname = %2, reverse mapping = %3, forward mapping = %4
This debug message is logged when FQDN mapping for a particular lease has been
changed by the recent Renew message. This mapping will be changed in DNS.
% DHCP6_DDNS_REQUEST_SEND_FAILED failed sending a request to b10-dhcp-ddns, error: %1, ncr: %2
This error message indicates that IPv6 DHCP server failed to send a DDNS
update reqeust to the DHCP-DDNS server. This is most likely a configuration or
networking error.
% DHCP6_DEACTIVATE_INTERFACE deactivate interface %1
This message is printed when DHCPv6 server disables an interface from being
used to receive DHCPv6 traffic. Sockets on this interface will not be opened
......
......@@ -494,9 +494,6 @@ bool Dhcpv6Srv::run() {
LOG_ERROR(dhcp6_logger, DHCP6_PACKET_SEND_FAIL)
.arg(e.what());
}
// Send NameChangeRequests to the b10-dhcp-ddns module.
sendNameChangeRequests();
}
}
......@@ -1077,18 +1074,19 @@ Dhcpv6Srv::createNameChangeRequests(const Pkt6Ptr& answer) {
// Get the IP address from the lease. Also, use the S flag to determine
// if forward change should be performed. This flag will always be
// set if server has taken responsibility for the forward update.
NameChangeRequest ncr(isc::dhcp_ddns::CHG_ADD,
opt_fqdn->getFlag(Option6ClientFqdn::FLAG_S),
true, opt_fqdn->getDomainName(),
iaaddr->getAddress().toText(),
dhcid, 0, iaaddr->getValid());
// Add the request to the queue. This queue will be read elsewhere in
// the code and all requests from this queue will be sent to the
// D2 module.
name_change_reqs_.push(ncr);
NameChangeRequestPtr ncr;
ncr.reset(new NameChangeRequest(isc::dhcp_ddns::CHG_ADD,
opt_fqdn->getFlag(Option6ClientFqdn::
FLAG_S),
true, opt_fqdn->getDomainName(),
iaaddr->getAddress().toText(),
dhcid, 0, iaaddr->getValid()));
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL,
DHCP6_DDNS_CREATE_ADD_NAME_CHANGE_REQUEST).arg(ncr.toText());
DHCP6_DDNS_CREATE_ADD_NAME_CHANGE_REQUEST).arg(ncr->toText());
// Post the NCR to the D2ClientMgr.
CfgMgr::instance().getD2ClientMgr().sendRequest(ncr);
/// @todo Currently we create NCR with the first IPv6 address that
/// is carried in one of the IA_NAs. In the future, the NCR API should
......@@ -1138,31 +1136,21 @@ Dhcpv6Srv::createRemovalNameChangeRequest(const Lease6Ptr& lease) {
}
isc::dhcp_ddns::D2Dhcid dhcid(*lease->duid_, hostname_wire);
// Create a NameChangeRequest to remove the entry.
NameChangeRequest ncr(isc::dhcp_ddns::CHG_REMOVE,
lease->fqdn_fwd_, lease->fqdn_rev_,
lease->hostname_,
lease->addr_.toText(),
dhcid, 0, lease->valid_lft_);
name_change_reqs_.push(ncr);
NameChangeRequestPtr ncr;
ncr.reset(new NameChangeRequest(isc::dhcp_ddns::CHG_REMOVE,
lease->fqdn_fwd_, lease->fqdn_rev_,
lease->hostname_,
lease->addr_.toText(),
dhcid, 0, lease->valid_lft_));
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL,
DHCP6_DDNS_CREATE_REMOVE_NAME_CHANGE_REQUEST).arg(ncr.toText());
}
DHCP6_DDNS_CREATE_REMOVE_NAME_CHANGE_REQUEST).arg(ncr->toText());
void
Dhcpv6Srv::sendNameChangeRequests() {
while (!name_change_reqs_.empty()) {
// @todo Once next NameChangeRequest is picked from the queue
// we should send it to the b10-dhcp_ddns module. Currently we
// just drop it.
name_change_reqs_.pop();
}
// Post the NCR to the D2ClientMgr.
CfgMgr::instance().getD2ClientMgr().sendRequest(ncr);
}
OptionPtr
Dhcpv6Srv::assignIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
const Pkt6Ptr& query, const Pkt6Ptr& answer,
......@@ -2455,5 +2443,29 @@ Dhcpv6Srv::generateFqdn(const Pkt6Ptr& answer) {
}
}
void
Dhcpv6Srv::startD2() {
D2ClientMgr& d2_mgr = CfgMgr::instance().getD2ClientMgr();
if (d2_mgr.ddnsEnabled()) {
// Updates are enabled, so lets start the sender, passing in
// our error handler.
// This may throw so wherever this is called needs to ready.
d2_mgr.startSender(boost::bind(&Dhcpv6Srv::d2ClientErrorHandler,
this, _1,