Commit f85ebcc1 authored by Francis Dupont's avatar Francis Dupont
Browse files

[5425a] Reverted last 2 commits (unfinished as they include doc fixes)

parent 36354d84
......@@ -109,7 +109,7 @@
// This one is for VoIP devices only.
{
"pool": "192.0.4.1 - 192.0.4.200",
"client-classes": [ "VoIP" ]
"client-class": "VoIP"
},
// This one doesn't have any client-class specified,
......
......@@ -82,7 +82,7 @@
"pools": [
{
"pool": "2001:db8:3::/80",
"client-classes": [ "cable-modems" ]
"client-class": "cable-modems"
} ],
"subnet": "2001:db8:4::/64",
"interface": "ethY"
......
......@@ -805,12 +805,8 @@ concatenation of the strings</entry></row>
<title>Configuring Pools With Class Information</title>
<para>
Similar to the subnets, it is possible to restrict access to the certain address
or prefix pools to the clients belonging to a specific class or
classes, using the "client-classes" parameter when defining the
pool. As opposed to subnets, the pools scope allows to define
more than one class that is allowed. The incoming packet has to
belong to only one of the classes listed to be able to get an
address from that pool.
or prefix pools to the clients belonging to a specific class, using
the "client-class" parameter when defining the pool.
</para>
<para>
......@@ -845,7 +841,7 @@ concatenation of the strings</entry></row>
"pools": [
{
"pool": "192.0.2.10 - 192.0.2.20",
"client-classes": [ "Client_foo" ]
"client-class": "Client_foo"
}
]</userinput>
},
......@@ -884,7 +880,7 @@ concatenation of the strings</entry></row>
"pools": [
{
"pool": "2001:db8:1::-2001:db8:1::ffff",
"client-classes": [ "Client_foo" ]
"client-class": "Client_foo"
}
]</userinput>
},
......
......@@ -1961,7 +1961,7 @@ should include options from the isc option space:
<para>
Client classification can also be used to restrict access to specific
pools within a subnet. This is useful when to segregate clients belonging
to the same subnet into different address or prefix ranges.
to the same subnet into different address ranges.
</para>
<para>
......
This diff is collapsed.
......@@ -813,7 +813,6 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
\"client-classes\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP4:
case isc::dhcp::Parser4Context::POOLS:
case isc::dhcp::Parser4Context::RESERVATIONS:
return isc::dhcp::Dhcp4Parser::make_CLIENT_CLASSES(driver.loc_);
default:
......@@ -824,6 +823,7 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
\"client-class\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::SUBNET4:
case isc::dhcp::Parser4Context::POOLS:
case isc::dhcp::Parser4Context::SHARED_NETWORK:
case isc::dhcp::Parser4Context::CLIENT_CLASSES:
return isc::dhcp::Dhcp4Parser::make_CLIENT_CLASS(driver.loc_);
......
This diff is collapsed.
......@@ -1344,7 +1344,7 @@ pool_params: pool_param
pool_param: pool_entry
| option_data_list
| client_class_names_list
| client_class
| user_context
| comment
| unknown_map_entry
......@@ -1459,7 +1459,7 @@ not_empty_reservation_params: reservation_param
/// @todo probably need to add mac-address as well here
reservation_param: duid
| client_class_names_list
| reservation_client_classes
| client_id_value
| circuit_id_value
| flex_id_value
......@@ -1555,7 +1555,7 @@ hostname: HOSTNAME {
ctx.leave();
};
client_class_names_list: CLIENT_CLASSES {
reservation_client_classes: CLIENT_CLASSES {
ElementPtr c(new ListElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("client-classes", c);
ctx.stack_.push_back(c);
......
......@@ -4168,15 +4168,15 @@ TEST_F(Dhcp4ParserTest, classifyPools) {
"\"subnet4\": [ { "
" \"pools\": [ { "
" \"pool\": \"192.0.2.1 - 192.0.2.100\", "
" \"client-classes\": [ \"alpha\" ] "
" \"client-class\": \"alpha\" "
" },"
" {"
" \"pool\": \"192.0.3.101 - 192.0.3.150\", "
" \"client-classes\": [ \"beta\" ] "
" \"client-class\": \"beta\" "
" },"
" {"
" \"pool\": \"192.0.4.101 - 192.0.4.150\", "
" \"client-classes\": [ \"gamma\", \"alpha\" ] "
" \"client-class\": \"gamma\" "
" },"
" {"
" \"pool\": \"192.0.5.101 - 192.0.5.150\" "
......@@ -4200,13 +4200,13 @@ TEST_F(Dhcp4ParserTest, classifyPools) {
ASSERT_EQ(4, pools.size()); // We expect 4 pools
// Let's check if client belonging to alpha class is supported in pool[0]
// and pool[2] (which allows 2 classes) and not supported in any other
// pool (except pool[3], which allows everyone).
// and not supported in any other pool (except pool[3], which allows
// everyone).
ClientClasses classes;
classes.insert("alpha");
EXPECT_TRUE(pools.at(0)->clientSupported(classes));
EXPECT_FALSE(pools.at(1)->clientSupported(classes));
EXPECT_TRUE(pools.at(2)->clientSupported(classes));
EXPECT_FALSE(pools.at(2)->clientSupported(classes));
EXPECT_TRUE(pools.at(3)->clientSupported(classes));
// Let's check if client belonging to beta class is supported in pool[1]
......
......@@ -2337,9 +2337,9 @@ TEST_F(Dhcpv4SrvTest, clientPoolClassify) {
"\"subnet4\": [ "
"{ \"pools\": [ { "
" \"pool\": \"192.0.2.1 - 192.0.2.100\", "
" \"client-classes\": [ \"foo\" ] }, "
" \"client-class\": \"foo\" }, "
" { \"pool\": \"192.0.3.1 - 192.0.3.100\", "
" \"client-classes\": [ \"xyzzy\" ] } ], "
" \"client-class\": \"xyzzy\" } ], "
" \"subnet\": \"192.0.0.0/16\" } "
"],"
"\"valid-lifetime\": 4000 }";
......
......@@ -1245,15 +1245,15 @@ const char* EXTRACTED_CONFIGS[] = {
" {\n"
" \"pools\": [\n"
" {\n"
" \"client-classes\": [ \"alpha\" ],\n"
" \"client-class\": \"alpha\",\n"
" \"pool\": \"192.0.2.1 - 192.0.2.100\"\n"
" },\n"
" {\n"
" \"client-classes\": [ \"beta\" ],\n"
" \"client-class\": \"beta\",\n"
" \"pool\": \"192.0.3.101 - 192.0.3.150\"\n"
" },\n"
" {\n"
" \"client-classes\": [ \"gamma\", \"alpha\" ],\n"
" \"client-class\": \"gamma\",\n"
" \"pool\": \"192.0.4.101 - 192.0.4.150\"\n"
" },\n"
" {\n"
......@@ -5267,17 +5267,17 @@ const char* UNPARSED_CONFIGS[] = {
" \"option-data\": [ ],\n"
" \"pools\": [\n"
" {\n"
" \"client-classes\": [ \"alpha\" ],\n"
" \"client-class\": \"alpha\",\n"
" \"option-data\": [ ],\n"
" \"pool\": \"192.0.2.1-192.0.2.100\"\n"
" },\n"
" {\n"
" \"client-classes\": [ \"beta\" ],\n"
" \"client-class\": \"beta\",\n"
" \"option-data\": [ ],\n"
" \"pool\": \"192.0.3.101-192.0.3.150\"\n"
" },\n"
" {\n"
" \"client-classes\": [ \"alpha\", \"gamma\" ],\n"
" \"client-class\": \"gamma\",\n"
" \"option-data\": [ ],\n"
" \"pool\": \"192.0.4.101-192.0.4.150\"\n"
" },\n"
......
......@@ -891,7 +891,7 @@ const char* NETWORKS_CONFIG[] = {
" \"pools\": ["
" {"
" \"pool\": \"192.0.2.1 - 192.0.2.63\","
" \"client-classes\": [ \"a-devices\" ]"
" \"client-class\": \"a-devices\""
" },"
" {"
" \"pool\": \"192.0.2.100 - 192.0.2.100\""
......@@ -931,11 +931,11 @@ const char* NETWORKS_CONFIG[] = {
" \"pools\": ["
" {"
" \"pool\": \"192.0.2.1 - 192.0.2.63\","
" \"client-classes\": [ \"a-devices\" ]"
" \"client-class\": \"a-devices\""
" },"
" {"
" \"pool\": \"192.0.2.100 - 192.0.2.100\","
" \"client-classes\": [ \"b-devices\" ]"
" \"client-class\": \"b-devices\""
" }"
" ]"
" }"
......@@ -969,7 +969,7 @@ const char* NETWORKS_CONFIG[] = {
" \"pools\": ["
" {"
" \"pool\": \"192.0.2.1 - 192.0.2.63\","
" \"client-classes\": [ \"a-devices\" ]"
" \"client-class\": \"a-devices\""
" },"
" {"
" \"pool\": \"192.0.2.100 - 192.0.2.100\""
......@@ -1004,11 +1004,11 @@ const char* NETWORKS_CONFIG[] = {
" \"pools\": ["
" {"
" \"pool\": \"192.0.2.1 - 192.0.2.63\","
" \"client-classes\": [ \"a-devices\" ]"
" \"client-class\": \"a-devices\""
" },"
" {"
" \"pool\": \"192.0.2.100 - 192.0.2.100\","
" \"client-classes\": [ \"b-devices\" ]"
" \"client-class\": \"b-devices\""
" }"
" ]"
" }"
......
This diff is collapsed.
......@@ -1068,8 +1068,6 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
\"client-classes\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::DHCP6:
case isc::dhcp::Parser6Context::POOLS:
case isc::dhcp::Parser6Context::PD_POOLS:
case isc::dhcp::Parser6Context::RESERVATIONS:
return isc::dhcp::Dhcp6Parser::make_CLIENT_CLASSES(driver.loc_);
default:
......@@ -1080,6 +1078,8 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
\"client-class\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::SUBNET6:
case isc::dhcp::Parser6Context::POOLS:
case isc::dhcp::Parser6Context::PD_POOLS:
case isc::dhcp::Parser6Context::CLIENT_CLASSES:
case isc::dhcp::Parser6Context::SHARED_NETWORK:
return isc::dhcp::Dhcp6Parser::make_CLIENT_CLASS(driver.loc_);
......
This diff is collapsed.
......@@ -1440,7 +1440,7 @@ namespace isc { namespace dhcp {
enum
{
yyeof_ = 0,
yylast_ = 917, ///< Last index in yytable_.
yylast_ = 931, ///< Last index in yytable_.
yynnts_ = 352, ///< Number of nonterminal symbols.
yyfinal_ = 30, ///< Termination state number.
yyterror_ = 1,
......
......@@ -1307,7 +1307,7 @@ pool_params: pool_param
pool_param: pool_entry
| option_data_list
| client_class_names_list
| client_class
| user_context
| comment
| unknown_map_entry
......@@ -1428,7 +1428,7 @@ pd_pool_param: pd_prefix
| pd_prefix_len
| pd_delegated_len
| option_data_list
| client_class_names_list
| client_class
| excluded_prefix
| excluded_prefix_len
| user_context
......@@ -1516,7 +1516,7 @@ not_empty_reservation_params: reservation_param
/// @todo probably need to add mac-address as well here
reservation_param: duid
| client_class_names_list
| reservation_client_classes
| ip_addresses
| prefixes
| hw_address
......@@ -1580,7 +1580,7 @@ flex_id_value: FLEX_ID {
ctx.leave();
};
client_class_names_list: CLIENT_CLASSES {
reservation_client_classes: CLIENT_CLASSES {
ElementPtr c(new ListElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("client-classes", c);
ctx.stack_.push_back(c);
......@@ -1664,7 +1664,6 @@ client_class_test: TEST {
ctx.leave();
};
// --- end of client classes ---------------------------------
// --- server-id ---------------------------------------------
......
......@@ -645,11 +645,11 @@ TEST_F(ClassifyTest, clientClassifyPool) {
" { \"pools\": [ "
" { "
" \"pool\": \"2001:db8:1::/64\", "
" \"client-classes\": [ \"foo\" ] "
" \"client-class\": \"foo\" "
" }, "
" { "
" \"pool\": \"2001:db8:2::/64\", "
" \"client-classes\": [ \"xyzzy\" ] "
" \"client-class\": \"xyzzy\" "
" } "
" ], "
" \"subnet\": \"2001:db8:2::/40\" "
......
......@@ -4222,15 +4222,15 @@ TEST_F(Dhcp6ParserTest, classifyPools) {
"\"subnet6\": [ { "
" \"pools\": [ { "
" \"pool\": \"2001:db8:1::/80\", "
" \"client-classes\": [ \"alpha\" ] "
" \"client-class\": \"alpha\" "
" },"
" {"
" \"pool\": \"2001:db8:2::/80\", "
" \"client-classes\": [ \"beta\" ] "
" \"client-class\": \"beta\" "
" },"
" {"
" \"pool\": \"2001:db8:3::/80\", "
" \"client-classes\": [ \"gamma\" ] "
" \"client-class\": \"gamma\" "
" },"
" {"
" \"pool\": \"2001:db8:4::/80\" "
......@@ -4313,20 +4313,20 @@ TEST_F(Dhcp6ParserTest, classifyPdPools) {
" \"pd-pools\": [ { "
" \"prefix-len\": 48, "
" \"delegated-len\": 64, "
" \"prefix\": \"2001:db8:1::\", \n"
" \"client-classes\": [ \"alpha\" ]\n "
" \"prefix\": \"2001:db8:1::\", "
" \"client-class\": \"alpha\" "
" },"
" {"
" \"prefix-len\": 48, "
" \"delegated-len\": 64, "
" \"prefix\": \"2001:db8:2::\", "
" \"client-classes\": [ \"beta\" ]\n "
" \"client-class\": \"beta\" "
" },"
" {"
" \"prefix-len\": 48, "
" \"delegated-len\": 64, "
" \"prefix\": \"2001:db8:3::\", "
" \"client-classes\": [ \"gamma\" ]\n "
" \"client-class\": \"gamma\" "
" },"
" {"
" \"prefix-len\": 48, "
......
......@@ -1028,15 +1028,15 @@ const char* EXTRACTED_CONFIGS[] = {
" {\n"
" \"pools\": [\n"
" {\n"
" \"client-classes\": [ \"alpha\" ],\n"
" \"client-class\": \"alpha\",\n"
" \"pool\": \"2001:db8:1::/80\"\n"
" },\n"
" {\n"
" \"client-classes\": [ \"beta\" ],\n"
" \"client-class\": \"beta\",\n"
" \"pool\": \"2001:db8:2::/80\"\n"
" },\n"
" {\n"
" \"client-classes\": [ \"gamma\" ],\n"
" \"client-class\": \"gamma\",\n"
" \"pool\": \"2001:db8:3::/80\"\n"
" },\n"
" {\n"
......@@ -1061,19 +1061,19 @@ const char* EXTRACTED_CONFIGS[] = {
" {\n"
" \"pd-pools\": [\n"
" {\n"
" \"client-classes\": [ \"alpha\" ],\n"
" \"client-class\": \"alpha\",\n"
" \"delegated-len\": 64,\n"
" \"prefix\": \"2001:db8:1::\",\n"
" \"prefix-len\": 48\n"
" },\n"
" {\n"
" \"client-classes\": [ \"beta\" ],\n"
" \"client-class\": \"beta\",\n"
" \"delegated-len\": 64,\n"
" \"prefix\": \"2001:db8:2::\",\n"
" \"prefix-len\": 48\n"
" },\n"
" {\n"
" \"client-classes\": [ \"gamma\" ],\n"
" \"client-class\": \"gamma\",\n"
" \"delegated-len\": 64,\n"
" \"prefix\": \"2001:db8:3::\",\n"
" \"prefix-len\": 48\n"
......@@ -4595,17 +4595,17 @@ const char* UNPARSED_CONFIGS[] = {
" \"pd-pools\": [ ],\n"
" \"pools\": [\n"
" {\n"
" \"client-classes\": [ \"alpha\" ],\n"
" \"client-class\": \"alpha\",\n"
" \"option-data\": [ ],\n"
" \"pool\": \"2001:db8:1::/80\"\n"
" },\n"
" {\n"
" \"client-classes\": [ \"beta\" ],\n"
" \"client-class\": \"beta\",\n"
" \"option-data\": [ ],\n"
" \"pool\": \"2001:db8:2::/80\"\n"
" },\n"
" {\n"
" \"client-classes\": [ \"gamma\" ],\n"
" \"client-class\": \"gamma\",\n"
" \"option-data\": [ ],\n"
" \"pool\": \"2001:db8:3::/80\"\n"
" },\n"
......@@ -4684,21 +4684,21 @@ const char* UNPARSED_CONFIGS[] = {
" \"option-data\": [ ],\n"
" \"pd-pools\": [\n"
" {\n"
" \"client-classes\": [ \"alpha\" ],\n"
" \"client-class\": \"alpha\",\n"
" \"delegated-len\": 64,\n"
" \"option-data\": [ ],\n"
" \"prefix\": \"2001:db8:1::\",\n"
" \"prefix-len\": 48\n"
" },\n"
" {\n"
" \"client-classes\": [ \"beta\" ],\n"
" \"client-class\": \"beta\",\n"
" \"delegated-len\": 64,\n"
" \"option-data\": [ ],\n"
" \"prefix\": \"2001:db8:2::\",\n"
" \"prefix-len\": 48\n"
" },\n"
" {\n"
" \"client-classes\": [ \"gamma\" ],\n"
" \"client-class\": \"gamma\",\n"
" \"delegated-len\": 64,\n"
" \"option-data\": [ ],\n"
" \"prefix\": \"2001:db8:3::\",\n"
......
......@@ -984,7 +984,7 @@ const char* NETWORKS_CONFIG[] = {
" \"pools\": ["
" {"
" \"pool\": \"2001:db8:1::20 - 2001:db8:1::20\","
" \"client-classes\": [ \"a-devices\" ]"
" \"client-class\": \"a-devices\""
" },"
" {"
" \"pool\": \"2001:db8:1::50 - 2001:db8:1::50\""
......@@ -1021,11 +1021,11 @@ const char* NETWORKS_CONFIG[] = {
" \"pools\": ["
" {"
" \"pool\": \"2001:db8:1::20 - 2001:db8:1::20\","
" \"client-classes\": [ \"a-devices\" ]"
" \"client-class\": \"a-devices\""
" },"
" {"
" \"pool\": \"2001:db8:1::50 - 2001:db8:1::50\","
" \"client-classes\": [ \"b-devices\" ]"
" \"client-class\": \"b-devices\""
" }"
" ]"
" }"
......@@ -1055,7 +1055,7 @@ const char* NETWORKS_CONFIG[] = {
" \"pools\": ["
" {"
" \"pool\": \"2001:db8:1::20 - 2001:db8:1::20\","
" \"client-classes\": [ \"a-devices\" ]"
" \"client-class\": \"a-devices\""
" },"
" {"
" \"pool\": \"2001:db8:1::50 - 2001:db8:1::50\""
......@@ -1089,11 +1089,11 @@ const char* NETWORKS_CONFIG[] = {
" \"pools\": ["
" {"
" \"pool\": \"2001:db8:1::20 - 2001:db8:1::20\","
" \"client-classes\": [ \"a-devices\" ]"
" \"client-class\": \"a-devices\""
" },"
" {"
" \"pool\": \"2001:db8:1::50 - 2001:db8:1::50\","
" \"client-classes\": [ \"b-devices\" ]"
" \"client-class\": \"b-devices\""
" }"
" ]"
" }"
......
......@@ -83,6 +83,7 @@ protected:
///
/// @param subnet next address will be returned from pool of that subnet
/// @param client_classes list of classes client belongs to
/// @param duid Client's DUID
/// @param hint client's hint
///
......
......@@ -379,13 +379,11 @@ PoolParser::parse(PoolStoragePtr pools,
}
// Client-class.
ConstElementPtr class_list = pool_structure->get("client-classes");
if (class_list) {
BOOST_FOREACH(ConstElementPtr c, class_list->listValue()) {
string cclass = c->stringValue();
if (!cclass.empty()) {
pool->allowClientClass(cclass);
}
ConstElementPtr client_class = pool_structure->get("client-class");
if (client_class) {
string cclass = client_class->stringValue();
if (!cclass.empty()) {
pool->allowClientClass(cclass);
}
}
}
......@@ -857,7 +855,7 @@ PdPoolParser::parse(PoolStoragePtr pools, ConstElementPtr pd_pool_) {
user_context_ = user_context;
}
ConstElementPtr client_class = pd_pool_->get("client-classes");
ConstElementPtr client_class = pd_pool_->get("client-class");
if (client_class) {
client_class_ = client_class;
}
......@@ -886,13 +884,10 @@ PdPoolParser::parse(PoolStoragePtr pools, ConstElementPtr pd_pool_) {
}
// If present, this is a list of class names
if (client_class_) {
BOOST_FOREACH(ConstElementPtr c, client_class_->listValue()) {
string cclass = c->stringValue();
if (!cclass.empty()) {
pool_->allowClientClass(cclass);
}
string cclass = client_class_->stringValue();
if (!cclass.empty()) {
pool_->allowClientClass(cclass);
}
}
......
......@@ -651,14 +651,8 @@ private:
/// A storage for pool specific option values.
CfgOptionPtr options_;
/// @brief User context (optional, may be null)
///
/// User context is arbitrary user data, to be used by hooks.
isc::data::ConstElementPtr user_context_;
/// @brief List of client classes a client has to be belong to to use this pd-pool
///
/// If empty, everyone is allowed. This is a white-list
isc::data::ConstElementPtr client_class_;
};
......
......@@ -111,12 +111,11 @@ Pool::toElement() const {
// Set client-class
const ClientClasses& cclasses = getClientClasses();
if (!cclasses.empty()) {
ElementPtr list = Element::createList();
for (auto c : cclasses) {
list->add(Element::create(c));
}
map->set("client-classes", list);
if (cclasses.size() > 1) {
isc_throw(ToElementError, "client-class has too many items: "
<< cclasses.size());
} else if (!cclasses