Commit 54c6fbbd authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[5102] 'client-id' host identifier type is now included in default config.

parent ec873ef2
......@@ -892,7 +892,7 @@ TEST_F(DORATest, reservation) {
// DUID carried in the Client Identifier option.
TEST_F(DORATest, reservationByDUID) {
Dhcp4Client client(Dhcp4Client::SELECTING);
// Use relay agent so as the circuit-id can be inserted.
// Use relay agent.
client.useRelay(true, IOAddress("10.0.0.1"), IOAddress("10.0.0.2"));
// Modify HW address so as the server doesn't assign reserved
// address by HW address.
......@@ -944,6 +944,30 @@ TEST_F(DORATest, reservationByCircuitId) {
ASSERT_EQ("10.0.0.9", client.config_.lease_.addr_.toText());
}
// This test checks that it is possible to make a reservation by
// client-id.
TEST_F(DORATest, reservationByClientId) {
Dhcp4Client client(Dhcp4Client::SELECTING);
// Use relay agent so as the circuit-id can be inserted.
client.useRelay(true, IOAddress("10.0.0.20"), IOAddress("10.0.0.21"));
// Specify client identifier.
client.includeClientId("01:11:22:33:44:55:66");
// Configure DHCP server.
configure(DORA_CONFIGS[2], *client.getServer());
// Client A performs 4-way exchange and should obtain a reserved
// address.
ASSERT_NO_THROW(client.doDORA(boost::shared_ptr<
IOAddress>(new IOAddress("0.0.0.0"))));
// 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()));
// Make sure that the client has got the lease for the reserved address.
ASSERT_EQ("10.0.0.1", client.config_.lease_.addr_.toText());
}
// This test verifies that order in which host identifiers are used to
// retrieve host reservations can be controlled.
TEST_F(DORATest, hostIdentifiersOrder) {
......
This diff is collapsed.
......@@ -26,6 +26,7 @@ CfgHostOperations::createConfig4() {
cfg->addIdentifierType("hw-address");
cfg->addIdentifierType("duid");
cfg->addIdentifierType("circuit-id");
cfg->addIdentifierType("client-id");
return (cfg);
}
......
......@@ -97,6 +97,7 @@ TEST(CfgHostOperationsTest, createConfig4) {
EXPECT_TRUE(identifierAtPosition(*cfg, Host::IDENT_HWADDR, 0));
EXPECT_TRUE(identifierAtPosition(*cfg, Host::IDENT_DUID, 1));
EXPECT_TRUE(identifierAtPosition(*cfg, Host::IDENT_CIRCUIT_ID, 2));
EXPECT_TRUE(identifierAtPosition(*cfg, Host::IDENT_CLIENT_ID, 3));
}
// This test verifies that the default DHCPv6 configuration is created
......
......@@ -450,7 +450,7 @@ TEST_F(SrvConfigTest, unparse) {
std::string defaults4 = "\"echo-client-id\": true,\n";
defaults4 += "\"subnet4\": [ ],\n";
defaults4 += "\"host-reservation-identifiers\": ";
defaults4 += "[ \"hw-address\", \"duid\", \"circuit-id\" ],\n";
defaults4 += "[ \"hw-address\", \"duid\", \"circuit-id\", \"client-id\" ],\n";
std::string defaults6 = "\"relay-supplied-options\": [ \"65\" ],\n";
defaults6 += "\"subnet6\": [ ],\n";
......
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