diff --git a/src/bin/dhcp4/tests/dhcp4_client.cc b/src/bin/dhcp4/tests/dhcp4_client.cc index 38290bda92..a23c915973 100644 --- a/src/bin/dhcp4/tests/dhcp4_client.cc +++ b/src/bin/dhcp4/tests/dhcp4_client.cc @@ -511,6 +511,7 @@ Dhcp4Client::receiveOneMsg() { msg_copy->setRemotePort(msg->getLocalPort()); msg_copy->setLocalPort(msg->getRemotePort()); msg_copy->setIface(msg->getIface()); + msg_copy->setIndex(msg->getIndex()); msg_copy->unpack(); diff --git a/src/bin/dhcp6/tests/dhcp6_client.cc b/src/bin/dhcp6/tests/dhcp6_client.cc index 74f375bef0..3a1522942b 100644 --- a/src/bin/dhcp6/tests/dhcp6_client.cc +++ b/src/bin/dhcp6/tests/dhcp6_client.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -103,6 +104,7 @@ Dhcp6Client::Dhcp6Client() : duid_(generateDUID(DUID::DUID_LLT)), link_local_("fe80::3a60:77ff:fed5:cdef"), iface_name_("eth0"), + iface_index_(ETH0_INDEX), srv_(boost::shared_ptr(new NakedDhcpv6Srv(0))), use_relay_(false), use_oro_(false), @@ -121,6 +123,7 @@ Dhcp6Client::Dhcp6Client(boost::shared_ptr& srv) : duid_(generateDUID(DUID::DUID_LLT)), link_local_("fe80::3a60:77ff:fed5:cdef"), iface_name_("eth0"), + iface_index_(ETH0_INDEX), srv_(srv), use_relay_(false), use_oro_(false), @@ -970,6 +973,7 @@ Dhcp6Client::sendMsg(const Pkt6Ptr& msg) { msg_copy->setRemoteAddr(link_local_); msg_copy->setLocalAddr(dest_addr_); msg_copy->setIface(iface_name_); + msg_copy->setIndex(iface_index_); // Copy classes const ClientClasses& classes = msg->getClasses(); diff --git a/src/bin/dhcp6/tests/dhcp6_client.h b/src/bin/dhcp6/tests/dhcp6_client.h index 0fb1cc382c..e236a3d9b7 100644 --- a/src/bin/dhcp6/tests/dhcp6_client.h +++ b/src/bin/dhcp6/tests/dhcp6_client.h @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -575,6 +575,13 @@ public: iface_name_ = iface_name; } + /// @brief Sets the interface to be used by the client. + /// + /// @param iface_index Interface index. + void setIfaceIndex(uint32_t iface_index) { + iface_index_ = iface_index; + } + /// @brief Sets link local address used by the client. /// /// @param link_local New link local address. @@ -912,9 +919,12 @@ private: /// @brief Currently used link local address. asiolink::IOAddress link_local_; - /// @brief Currently used interface. + /// @brief Currently used interface (name). std::string iface_name_; + /// @brief Currently used interface (index). + uint32_t iface_index_; + /// @brief Pointer to the server that the client is communicating with. boost::shared_ptr srv_; diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.cc b/src/bin/dhcp6/tests/dhcp6_test_utils.cc index 8e7b84ad79..b15deea174 100644 --- a/src/bin/dhcp6/tests/dhcp6_test_utils.cc +++ b/src/bin/dhcp6/tests/dhcp6_test_utils.cc @@ -210,6 +210,7 @@ Dhcpv6SrvTest::createMessage(uint8_t message_type, Lease::Type lease_type, Pkt6Ptr msg = Pkt6Ptr(new Pkt6(message_type, 1234)); msg->setRemoteAddr(IOAddress("fe80::abcd")); msg->setIface("eth0"); + msg->setIndex(ETH0_INDEX); msg->addOption(createIA(lease_type, addr, prefix_len, iaid)); return (msg); } @@ -338,6 +339,7 @@ Dhcpv6SrvTest::testRenewBasic(Lease::Type type, req.reset(new Pkt6(message_type, 1234)); req->setRemoteAddr(IOAddress("fe80::abcd")); req->setIface("eth0"); + req->setIndex(ETH0_INDEX); // from createIA uint16_t code; diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.h b/src/bin/dhcp6/tests/dhcp6_test_utils.h index 6b0f359780..a41431ff41 100644 --- a/src/bin/dhcp6/tests/dhcp6_test_utils.h +++ b/src/bin/dhcp6/tests/dhcp6_test_utils.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include