/// - the following class defined: option[93].hex == 0x0009, DROP
///
/// - Configuration 6:
-/// - Used for the DROP class and reservations.
+/// - Used for the DROP class and reservation existence.
/// - 1 subnet: 10.0.0.0/24
/// - 1 pool: 10.0.0.10-10.0.0.100
/// - 1 reservation for HW address 'aa:bb:cc:dd:ee:ff'
/// @note the reservation includes a hostname because raw reservations are
/// not yet allowed.
///
+/// - Configuration 7:
+/// - Used for the DROP class and reservation class.
+/// - 1 subnet: 10.0.0.0/24
+/// - 1 pool: 10.0.0.10-10.0.0.100
+/// - 1 reservation for HW address 'aa:bb:cc:dd:ee:ff'
+/// setting the allowed class
+/// - the following classes defined:
+/// - allowed
+/// - member('KNOWN') or member('UNKNOWN'), t
+/// not member('allowed') and member('t'), DROP
+///
const char* CONFIGS[] = {
// Configuration 0
"{ \"interfaces-config\": {"
"\"client-classes\": ["
"{"
" \"name\": \"DROP\","
- " \"test\": \"member('UNKNOWN')\""
+ " \"test\": \"not member('KNOWN')\""
"}],"
"\"subnet4\": [ { "
" \"subnet\": \"10.0.0.0/24\", "
" \"hw-address\": \"aa:bb:cc:dd:ee:ff\","
" \"hostname\": \"allowed\" } ]"
" } ]"
+ "}",
+
+ // Configuration 7
+ "{ \"interfaces-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "},"
+ "\"valid-lifetime\": 600,"
+ "\"client-classes\": ["
+ "{"
+ " \"name\": \"allowed\""
+ "},"
+ "{"
+ " \"name\": \"t\","
+ " \"test\": \"member('KNOWN') or member('UNKNOWN')\""
+ "},"
+ "{"
+ " \"name\": \"DROP\","
+ " \"test\": \"not member('allowed') and member('t')\""
+ "}],"
+ "\"subnet4\": [ { "
+ " \"subnet\": \"10.0.0.0/24\", "
+ " \"id\": 1,"
+ " \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ],"
+ " \"reservations\": [ {"
+ " \"hw-address\": \"aa:bb:cc:dd:ee:ff\","
+ " \"client-classes\": [ \"allowed\" ] } ]"
+ " } ]"
"}"
};
}
// This test checks the handling for the DROP special class at the host
-// reservation classification point.
-TEST_F(ClassifyTest, dropClassHR) {
+// reservation classification point with KNOWN / UNKNOWN.
+TEST_F(ClassifyTest, dropClassUnknown) {
+ Dhcp4Client client(Dhcp4Client::SELECTING);
+
+ // Configure DHCP server.
+ configure(CONFIGS[6], *client.getServer());
+
+ // Set the HW address to the reservation.
+ client.setHWAddress("aa:bb:cc:dd:ee:ff");
+
+ // Send the discover.
+ client.doDiscover();
+
+ // Reservation match: no drop.
+ EXPECT_TRUE(client.getContext().response_);
+
+ // Retry with another HW address.
+ Dhcp4Client client2(Dhcp4Client::SELECTING);
+ client2.setHWAddress("aa:bb:cc:dd:ee:fe");
+
+ // Send the discover.
+ client2.doDiscover();
+
+ // No reservation, dropped.
+ EXPECT_FALSE(client2.getContext().response_);
+
+ // There should also be pkt4-receive-drop stat bumped up.
+ stats::StatsMgr& mgr = stats::StatsMgr::instance();
+ stats::ObservationPtr drop_stat = mgr.getObservation("pkt4-receive-drop");
+
+ // This statistic must be present and must be set to 1.
+ ASSERT_TRUE(drop_stat);
+ EXPECT_EQ(1, drop_stat->getInteger().first);
+}
+
+// This test checks the handling for the DROP special class at the host
+// reservation classification point with a reserved class.
+TEST_F(ClassifyTest, dropClassReservedClass) {
Dhcp4Client client(Dhcp4Client::SELECTING);
// Configure DHCP server.