2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 05:55:28 +00:00

[4097a] Added Dhcpv6SrvTest.subnetGlobalPriority

This commit is contained in:
Francis Dupont
2015-11-25 13:22:04 +01:00
parent eda0988649
commit 0b33e529c6

View File

@@ -2003,6 +2003,72 @@ TEST_F(Dhcpv6SrvTest, subnetClassPriority) {
EXPECT_EQ(0, opt->getUint8());
}
// Checks subnet options have the priority over global options
TEST_F(Dhcpv6SrvTest, subnetGlobalPriority) {
IfaceMgrTestConfig test_config(true);
NakedDhcpv6Srv srv(0);
// Subnet sets an ipv6-forwarding option in the response.
// The router class matches incoming packets with foo in a host-name
// option (code 1234) and sets an ipv6-forwarding option in the response.
string config = "{ \"interfaces-config\": {"
" \"interfaces\": [ \"*\" ] }, "
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"valid-lifetime\": 4000, "
"\"option-def\": [ "
"{ \"name\": \"host-name\","
" \"code\": 1234,"
" \"type\": \"string\" },"
"{ \"name\": \"ipv6-forwarding\","
" \"code\": 2345,"
" \"type\": \"boolean\" }],"
"\"option-data\": ["
" { \"name\": \"ipv6-forwarding\", "
" \"data\": \"false\" } ], "
"\"subnet6\": [ "
"{ \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ], "
" \"subnet\": \"2001:db8:1::/48\", "
" \"interface\": \"eth1\", "
" \"option-data\": ["
" { \"name\": \"ipv6-forwarding\", "
" \"data\": \"false\" } ] } ] }";
ASSERT_NO_THROW(configure(config));
// Create a packet with enough to select the subnet and go through
// the SOLICIT processing
Pkt6Ptr query(new Pkt6(DHCPV6_SOLICIT, 1234));
query->setRemoteAddr(IOAddress("fe80::abcd"));
OptionPtr clientid = generateClientId();
query->addOption(clientid);
query->setIface("eth1");
query->addOption(generateIA(D6O_IA_NA, 123, 1500, 3000));
// Create and add an ORO option to the query
OptionUint16ArrayPtr oro(new OptionUint16Array(Option::V6, D6O_ORO));
ASSERT_TRUE(oro);
oro->addValue(2345);
query->addOption(oro);
// Create and add a host-name option to the query
OptionStringPtr hostname(new OptionString(Option::V6, 1234, "foo"));
ASSERT_TRUE(hostname);
query->addOption(hostname);
// Process the query
Pkt6Ptr response = srv.processSolicit(query);
// Processing should add an ip-forwarding option
OptionPtr opt = response->getOption(2345);
ASSERT_TRUE(opt);
ASSERT_GT(opt->len(), opt->getHeaderLen());
// Global sets the value to true/1, subnet to false/0
// Here subnet has the priority
EXPECT_EQ(0, opt->getUint8());
}
// Checks class options have the priority over global options
TEST_F(Dhcpv6SrvTest, classGlobalPriority) {
IfaceMgrTestConfig test_config(true);