Commit 9d9c8337 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[2414] Removed hardcoded DNS_SERVERS option

DNS_SERVERS option is now sent only if requested by clients
 (as it should be)
parent c778e931
......@@ -49,8 +49,6 @@ using namespace isc::util;
using namespace std;
using namespace boost;
const std::string HARDCODED_DNS_SERVER = "2001:db8:1::1";
Dhcpv6Srv::Dhcpv6Srv(uint16_t port) {
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_START, DHCP6_OPEN_SOCKET).arg(port);
......@@ -322,18 +320,7 @@ void Dhcpv6Srv::appendDefaultOptions(const Pkt6Ptr& question, Pkt6Ptr& answer) {
.arg(question->getRemoteAddr().toText());
return;
}
// Add DNS_SERVERS option. It should have been configured.
const Subnet::OptionContainer& options = subnet->getOptions();
const Subnet::OptionContainerTypeIndex& idx = options.get<1>();
const Subnet::OptionContainerTypeRange range =
idx.equal_range(D6O_NAME_SERVERS);
// In theory we may have multiple options with the same
// option code. They are not differentiated right now
// until support for option spaces is implemented.
// Until that's the case, simply add the first found option.
if (std::distance(range.first, range.second) > 0) {
answer->addOption(range.first->option);
}
}
void Dhcpv6Srv::appendRequestedOptions(const Pkt6Ptr& question, Pkt6Ptr& answer) {
......@@ -345,11 +332,6 @@ void Dhcpv6Srv::appendRequestedOptions(const Pkt6Ptr& question, Pkt6Ptr& answer)
return;
}
// Add dns-servers option.
OptionPtr dnsservers(new Option6AddrLst(D6O_NAME_SERVERS,
IOAddress(HARDCODED_DNS_SERVER)));
answer->addOption(dnsservers);
// Client requests some options using ORO option. Try to
// get this option from client's message.
boost::shared_ptr<Option6IntArray<uint16_t> > option_oro =
......
......@@ -344,13 +344,16 @@ TEST_F(Dhcpv6SrvTest, advertiseOptions) {
// We have not requested option with code 1000 so it should not
// be included in the response.
ASSERT_FALSE(adv->getOption(1000));
ASSERT_FALSE(adv->getOption(D6O_NAME_SERVERS));
// Let's now request option with code 1000.
// We expect that server will include this option in its reply.
boost::shared_ptr<Option6IntArray<uint16_t> >
option_oro(new Option6IntArray<uint16_t>(D6O_ORO));
// Create vector with one code equal to 1000.
std::vector<uint16_t> codes(1, 1000);
// Create vector with two option codes.
std::vector<uint16_t> codes(2);
codes[0] = 1000;
codes[1] = D6O_NAME_SERVERS;
// Pass this code to option.
option_oro->setValues(codes);
// Append ORO to SOLICIT message.
......@@ -407,7 +410,7 @@ TEST_F(Dhcpv6SrvTest, advertiseOptions) {
// - copy of client-id
// - server-id
// - IA that includes IAADDR
TEST_F(Dhcpv6SrvTest, SolicitBasic2) {
TEST_F(Dhcpv6SrvTest, SolicitBasic) {
boost::scoped_ptr<NakedDhcpv6Srv> srv;
ASSERT_NO_THROW( srv.reset(new NakedDhcpv6Srv(0)) );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment