|
@@ -39,6 +39,16 @@ namespace {
|
|
|
/// - Domain Name Server option present: 192.0.2.202, 192.0.2.203.
|
|
|
/// - Log Servers option present: 192.0.2.200 and 192.0.2.201
|
|
|
/// - Quotes Servers option present: 192.0.2.202, 192.0.2.203.
|
|
|
+///
|
|
|
+/// - Configuration 2:
|
|
|
+/// - This configuration provides reservations for next-server,
|
|
|
+/// server-hostname and boot-file-name value.
|
|
|
+/// - 1 subnet: 192.0.2.0/24
|
|
|
+/// - 1 reservation for this subnet:
|
|
|
+/// - Client's HW address: aa:bb:cc:dd:ee:ff
|
|
|
+/// - next-server = 10.0.0.7
|
|
|
+/// - server name = "some-name.example.org"
|
|
|
+/// - boot-file-name = "bootfile.efi"
|
|
|
const char* INFORM_CONFIGS[] = {
|
|
|
// Configuration 0
|
|
|
"{ \"interfaces-config\": {"
|
|
@@ -91,7 +101,26 @@ const char* INFORM_CONFIGS[] = {
|
|
|
" \"data\": \"10.0.0.202,10.0.0.203\""
|
|
|
" } ]"
|
|
|
" } ]"
|
|
|
- "}"
|
|
|
+ "}",
|
|
|
+
|
|
|
+// Configuration 2
|
|
|
+ "{ \"interfaces-config\": {"
|
|
|
+ " \"interfaces\": [ \"*\" ]"
|
|
|
+ "},"
|
|
|
+ "\"valid-lifetime\": 600,"
|
|
|
+ "\"next-server\": \"10.0.0.1\","
|
|
|
+ "\"subnet4\": [ { "
|
|
|
+ " \"subnet\": \"192.0.2.0/24\", "
|
|
|
+ " \"reservations\": [ "
|
|
|
+ " {"
|
|
|
+ " \"hw-address\": \"aa:bb:cc:dd:ee:ff\","
|
|
|
+ " \"next-server\": \"10.0.0.7\","
|
|
|
+ " \"server-hostname\": \"some-name.example.org\","
|
|
|
+ " \"boot-file-name\": \"bootfile.efi\""
|
|
|
+ " }"
|
|
|
+ " ]"
|
|
|
+ "} ]"
|
|
|
+ "}",
|
|
|
};
|
|
|
|
|
|
/// @brief Test fixture class for testing DHCPINFORM.
|
|
@@ -364,6 +393,32 @@ TEST_F(InformTest, relayedClientNoCiaddr) {
|
|
|
EXPECT_EQ("192.0.2.203", client.config_.dns_servers_[1].toText());
|
|
|
}
|
|
|
|
|
|
+// This test verifies that the server assigns reserved values for the
|
|
|
+// siaddr, sname and file fields carried within DHCPv4 message.
|
|
|
+TEST_F(InformTest, messageFieldsReservations) {
|
|
|
+ // Client has a reservation.
|
|
|
+ Dhcp4Client client(Dhcp4Client::SELECTING);
|
|
|
+ // Message is relayed.
|
|
|
+ client.useRelay();
|
|
|
+ // Set explicit HW address so as it matches the reservation in the
|
|
|
+ // configuration used below.
|
|
|
+ client.setHWAddress("aa:bb:cc:dd:ee:ff");
|
|
|
+ // Configure DHCP server.
|
|
|
+ configure(INFORM_CONFIGS[2], *client.getServer());
|
|
|
+ // Client sends DHCPINFORM and should receive reserved fields.
|
|
|
+ ASSERT_NO_THROW(client.doInform());
|
|
|
+ // Make sure that the server responded.
|
|
|
+ ASSERT_TRUE(client.getContext().response_);
|
|
|
+ Pkt4Ptr resp = client.getContext().response_;
|
|
|
+ // Make sure that the server has responded with DHCPACK.
|
|
|
+ ASSERT_EQ(DHCPACK, static_cast<int>(resp->getType()));
|
|
|
+
|
|
|
+ // Check that the reserved values have been assigned.
|
|
|
+ EXPECT_EQ("10.0.0.7", client.config_.siaddr_.toText());
|
|
|
+ EXPECT_EQ("some-name.example.org", client.config_.sname_);
|
|
|
+ EXPECT_EQ("bootfile.efi", client.config_.boot_file_name_);
|
|
|
+}
|
|
|
+
|
|
|
/// This test verifies that after a client completes its INFORM exchange,
|
|
|
/// appropriate statistics are updated.
|
|
|
TEST_F(InformTest, statisticsInform) {
|