cout << "Offered address to client3=" << addr3.toText() << endl;
}
- TEST_F(Dhcpv4SrvTest, discoverEchoClientId) {
+// Checks whether echoing back client-id is controllable, i.e.
+// whether the server obeys echo-client-id and sends (or not)
+// client-id
++TEST_F(Dhcpv4SrvFakeIfaceTest, discoverEchoClientId) {
+ NakedDhcpv4Srv srv(0);
+
+ Pkt4Ptr dis = Pkt4Ptr(new Pkt4(DHCPDISCOVER, 1234));
+ dis->setRemoteAddr(IOAddress("192.0.2.1"));
+ OptionPtr clientid = generateClientId();
+ dis->addOption(clientid);
++ dis->setIface("eth0");
+
+ // Pass it to the server and get an offer
+ Pkt4Ptr offer = srv.processDiscover(dis);
+
+ // Check if we get response at all
+ checkResponse(offer, DHCPOFFER, 1234);
+ checkClientId(offer, clientid);
+
+ CfgMgr::instance().echoClientId(false);
+ offer = srv.processDiscover(dis);
+
+ // Check if we get response at all
+ checkResponse(offer, DHCPOFFER, 1234);
+ checkClientId(offer, clientid);
+}
+
// This test verifies that incoming REQUEST can be handled properly, that an
// ACK is generated, that the response has an address and that address
// really belongs to the configured pool.
cout << "Offered address to client3=" << addr3.toText() << endl;
}
- TEST_F(Dhcpv4SrvTest, requestEchoClientId) {
+// Checks whether echoing back client-id is controllable
++TEST_F(Dhcpv4SrvFakeIfaceTest, requestEchoClientId) {
+ NakedDhcpv4Srv srv(0);
+
+ Pkt4Ptr dis = Pkt4Ptr(new Pkt4(DHCPREQUEST, 1234));
+ dis->setRemoteAddr(IOAddress("192.0.2.1"));
+ OptionPtr clientid = generateClientId();
+ dis->addOption(clientid);
++ dis->setIface("eth0");
+
+ // Pass it to the server and get ACK
+ Pkt4Ptr ack = srv.processRequest(dis);
+
+ // Check if we get response at all
+ checkResponse(ack, DHCPACK, 1234);
+ checkClientId(ack, clientid);
+
+ CfgMgr::instance().echoClientId(false);
+ ack = srv.processDiscover(dis);
+
+ // Check if we get response at all
+ checkResponse(ack, DHCPOFFER, 1234);
+ checkClientId(ack, clientid);
+}
+
// This test verifies that incoming (positive) REQUEST/Renewing can be handled properly, that a
// REPLY is generated, that the response has an address and that address
// it's ok if that fails. There should not be such a file anyway
unlink(SRVID_FILE);
-
- const IfaceMgr::IfaceCollection& ifaces = IfaceMgr::instance().getIfaces();
-
- // There must be some interface detected
- if (ifaces.empty()) {
- // We can't use ASSERT in constructor
- ADD_FAILURE() << "No interfaces detected.";
- }
-
- valid_iface_ = ifaces.begin()->getName();
}
+Dhcpv4SrvTest::~Dhcpv4SrvTest() {
+
+ // Make sure that we revert to default value
+ CfgMgr::instance().echoClientId(true);
+}
+
void Dhcpv4SrvTest::addPrlOption(Pkt4Ptr& pkt) {
OptionUint8ArrayPtr option_prl =
/// @param iface reference to interface structure.
/// @param addr an address the created socket should be bound to
/// @param port a port that created socket should be bound to
+ /// @param join_multicast A boolean parameter which indicates whether
+ /// socket should join All_DHCP_Relay_Agents_and_servers multicast
+ /// group.
///
/// @return socket descriptor
- int openSocket6(Iface& iface, const isc::asiolink::IOAddress& addr, uint16_t port);
+ int openSocket6(Iface& iface, const isc::asiolink::IOAddress& addr,
+ uint16_t port, const bool join_multicast);
- /// @brief Detects network interfaces.
- ///
- /// This method will eventually detect available interfaces. For now
- /// it offers stub implementation. First interface name and link-local
- /// IPv6 address is read from interfaces.txt file.
- void
- detectIfaces();
-
/// @brief Stub implementation of network interface detection.
///
/// This implementations reads a single line from interfaces.txt file