summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Markwalder <tmark@isc.org>2024-11-01 20:30:58 +0100
committerThomas Markwalder <tmark@isc.org>2024-11-26 18:19:56 +0100
commit575046046630aec2e48023097db614abab1f8bf7 (patch)
tree8cc7248c79c7daba4aed7bfafef48afc883ef4da /src
parent[#3592] Update schemas (diff)
downloadkea-575046046630aec2e48023097db614abab1f8bf7.tar.xz
kea-575046046630aec2e48023097db614abab1f8bf7.zip
[#3592] MySql and Posgresql CB updated
modified: src/hooks/dhcp/mysql/mysql_cb_dhcp4.cc modified: src/hooks/dhcp/mysql/mysql_cb_dhcp6.cc modified: src/hooks/dhcp/mysql/mysql_query_macros_dhcp.h modified: src/hooks/dhcp/pgsql/pgsql_cb_dhcp4.cc modified: src/hooks/dhcp/pgsql/pgsql_cb_dhcp6.cc modified: src/hooks/dhcp/pgsql/pgsql_query_macros_dhcp.h modified: src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc modified: src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc
Diffstat (limited to 'src')
-rw-r--r--src/hooks/dhcp/mysql/mysql_cb_dhcp4.cc49
-rw-r--r--src/hooks/dhcp/mysql/mysql_cb_dhcp6.cc65
-rw-r--r--src/hooks/dhcp/mysql/mysql_query_macros_dhcp.h24
-rw-r--r--src/hooks/dhcp/pgsql/pgsql_cb_dhcp4.cc50
-rw-r--r--src/hooks/dhcp/pgsql/pgsql_cb_dhcp6.cc68
-rw-r--r--src/hooks/dhcp/pgsql/pgsql_query_macros_dhcp.h24
-rw-r--r--src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc2
-rw-r--r--src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc2
8 files changed, 127 insertions, 157 deletions
diff --git a/src/hooks/dhcp/mysql/mysql_cb_dhcp4.cc b/src/hooks/dhcp/mysql/mysql_cb_dhcp4.cc
index 15a2b6b302..872c420bc5 100644
--- a/src/hooks/dhcp/mysql/mysql_cb_dhcp4.cc
+++ b/src/hooks/dhcp/mysql/mysql_cb_dhcp4.cc
@@ -455,10 +455,9 @@ public:
last_subnet->setFilename(out_bindings[5]->getString());
}
- // client_class at 6.
- if (!out_bindings[6]->amNull()) {
- last_subnet->allowClientClass(out_bindings[6]->getString());
- }
+ // client_classes at 6.
+ clientClassesFromBinding(out_bindings[6], "client_classes",
+ last_subnet->getMutableClientClasses());
// interface at 7.
if (!out_bindings[7]->amNull()) {
@@ -653,10 +652,9 @@ public:
last_pool = Pool4::create(IOAddress(out_bindings[21]->getInteger<uint32_t>()),
IOAddress(out_bindings[22]->getInteger<uint32_t>()));
- // pool client_class at 59.
- if (!out_bindings[59]->amNull()) {
- last_pool->allowClientClass(out_bindings[59]->getString());
- }
+ // pool client_classes at 59.
+ clientClassesFromBinding(out_bindings[59], "client_classes",
+ last_pool->getMutableClientClasses());
// pool evaluate_additional_classes at 60.
clientClassesFromBinding(out_bindings[60], "evaluate_additional_classes",
@@ -881,10 +879,9 @@ public:
// pool subnet_id (3) (ignored)
- // pool client_class (4)
- if (!out_bindings[4]->amNull()) {
- last_pool->allowClientClass(out_bindings[4]->getString());
- }
+ // pool client_classes (4)
+ clientClassesFromBinding(out_bindings[4], "client_classes",
+ last_pool->getMutableClientClasses());
// pool evaluate_additional_classes (5)
clientClassesFromBinding(out_bindings[5], "evaluate_additional_classes",
@@ -996,13 +993,6 @@ public:
dhcp4o6_subnet = s.str();
}
- // Create JSON list of additional classes.
- ElementPtr additional_classes_element = Element::createList();
- auto const& additional_classes = subnet->getAdditionalClasses();
- for (auto const& additional_class : additional_classes) {
- additional_classes_element->add(Element::create(additional_class));
- }
-
// Create binding for DDNS replace client name mode.
MySqlBindingPtr ddns_rcn_mode_binding;
auto ddns_rcn_mode = subnet->getDdnsReplaceClientNameMode(Network::Inheritance::NONE);
@@ -1048,7 +1038,7 @@ public:
dhcp4o6_interface_id_binding,
MySqlBinding::condCreateString(dhcp4o6_subnet),
MySqlBinding::condCreateString(subnet->getFilename(Network::Inheritance::NONE)),
- MySqlBinding::condCreateString(subnet->getClientClass(Network::Inheritance::NONE)),
+ createInputClientClassesBinding(subnet->getClientClasses()),
MySqlBinding::condCreateString(subnet->getIface(Network::Inheritance::NONE)),
MySqlBinding::condCreateBool(subnet->getMatchClientId(Network::Inheritance::NONE)),
MySqlBinding::createTimestamp(subnet->getModificationTime()),
@@ -1153,7 +1143,7 @@ public:
MySqlBinding::createInteger<uint32_t>(pool->getFirstAddress().toUint32()),
MySqlBinding::createInteger<uint32_t>(pool->getLastAddress().toUint32()),
MySqlBinding::createInteger<uint32_t>(static_cast<uint32_t>(subnet->getID())),
- MySqlBinding::condCreateString(pool->getClientClass()),
+ createInputClientClassesBinding(pool->getClientClasses()),
createInputClientClassesBinding(pool->getAdditionalClasses()),
createInputContextBinding(pool),
MySqlBinding::createTimestamp(subnet->getModificationTime())
@@ -1363,10 +1353,9 @@ public:
last_network = SharedNetwork4::create(out_bindings[1]->getString());
last_network->setId(last_network_id);
- // client_class at 2.
- if (!out_bindings[2]->amNull()) {
- last_network->allowClientClass(out_bindings[2]->getString());
- }
+ // client_classes at 2.
+ clientClassesFromBinding(out_bindings[2], "client_classes",
+ last_network->getMutableClientClasses());
// interface at 3.
if (!out_bindings[3]->amNull()) {
@@ -1673,7 +1662,7 @@ public:
MySqlBindingCollection in_bindings = {
MySqlBinding::createString(shared_network->getName()),
- MySqlBinding::condCreateString(shared_network->getClientClass(Network::Inheritance::NONE)),
+ createInputClientClassesBinding(shared_network->getClientClasses()),
MySqlBinding::condCreateString(shared_network->getIface(Network::Inheritance::NONE)),
MySqlBinding::condCreateBool(shared_network->getMatchClientId(Network::Inheritance::NONE)),
MySqlBinding::createTimestamp(shared_network->getModificationTime()),
@@ -3188,7 +3177,7 @@ TaggedStatementArray tagged_statements = { {
" 4o6_interface_id,"
" 4o6_subnet,"
" boot_file_name,"
- " client_class,"
+ " client_classes,"
" interface,"
" match_client_id,"
" modification_ts,"
@@ -3237,7 +3226,7 @@ TaggedStatementArray tagged_statements = { {
{ MySqlConfigBackendDHCPv4Impl::INSERT_SHARED_NETWORK4,
"INSERT INTO dhcp4_shared_network("
" name,"
- " client_class,"
+ " client_classes,"
" interface,"
" match_client_id,"
" modification_ts,"
@@ -3351,7 +3340,7 @@ TaggedStatementArray tagged_statements = { {
" 4o6_interface_id = ?,"
" 4o6_subnet = ?,"
" boot_file_name = ?,"
- " client_class = ?,"
+ " client_classes = ?,"
" interface = ?,"
" match_client_id = ?,"
" modification_ts = ?,"
@@ -3389,7 +3378,7 @@ TaggedStatementArray tagged_statements = { {
{ MySqlConfigBackendDHCPv4Impl::UPDATE_SHARED_NETWORK4,
"UPDATE dhcp4_shared_network SET"
" name = ?,"
- " client_class = ?,"
+ " client_classes = ?,"
" interface = ?,"
" match_client_id = ?,"
" modification_ts = ?,"
diff --git a/src/hooks/dhcp/mysql/mysql_cb_dhcp6.cc b/src/hooks/dhcp/mysql/mysql_cb_dhcp6.cc
index 6cc0605077..9c0c61e264 100644
--- a/src/hooks/dhcp/mysql/mysql_cb_dhcp6.cc
+++ b/src/hooks/dhcp/mysql/mysql_cb_dhcp6.cc
@@ -472,10 +472,9 @@ public:
// 0 and 1 are subnet_id and subnet_prefix
- // client_class (2)
- if (!out_bindings[2]->amNull()) {
- last_subnet->allowClientClass(out_bindings[2]->getString());
- }
+ // client_classes (2)
+ clientClassesFromBinding(out_bindings[2], "client_classes",
+ last_subnet->getMutableClientClasses());
// interface (3)
if (!out_bindings[3]->amNull()) {
@@ -681,10 +680,9 @@ public:
// 18 is pool subnet_id (ignored)
// 19 is pool modification_ts (ignored)
- // pool client_class (79)
- if (!out_bindings[79]->amNull()) {
- last_pool->allowClientClass(out_bindings[79]->getString());
- }
+ // pool client_classes (79)
+ clientClassesFromBinding(out_bindings[79], "client_classes",
+ last_pool->getMutableClientClasses());
// pool evaluate_additional_classes (80)
clientClassesFromBinding(out_bindings[80], "evaluate_additional_classes",
@@ -730,10 +728,9 @@ public:
excluded_prefix,
out_bindings[83]->getInteger<uint8_t>());
- // pd pool client_class (84)
- if (!out_bindings[84]->amNull()) {
- last_pd_pool->allowClientClass(out_bindings[84]->getString());
- }
+ // pd pool client_classes (84)
+ clientClassesFromBinding(out_bindings[84], "client_classes",
+ last_pd_pool->getMutableClientClasses());
// pd pool evaluate_additional_classes (85)
clientClassesFromBinding(out_bindings[85], "evaluate_additional_classes",
@@ -969,10 +966,9 @@ public:
// pool subnet_id (3) (ignored)
- // pool client_class (4)
- if (!out_bindings[4]->amNull()) {
- last_pool->allowClientClass(out_bindings[4]->getString());
- }
+ // pool client_classes (4)
+ clientClassesFromBinding(out_bindings[4], "client_classes",
+ last_pool->getMutableClientClasses());
// pool evaluate_additional_classes (5)
clientClassesFromBinding(out_bindings[5], "evaluate_additional_classes",
@@ -1080,9 +1076,8 @@ public:
out_bindings[6]->getInteger<uint8_t>());
// pd pool client_class (7)
- if (!out_bindings[7]->amNull()) {
- last_pd_pool->allowClientClass(out_bindings[7]->getString());
- }
+ clientClassesFromBinding(out_bindings[7], "client_classes",
+ last_pd_pool->getMutableClientClasses());
// pd pool evaluate_additional_classes (8)
clientClassesFromBinding(out_bindings[8], "evaluate_additional_classes",
@@ -1214,13 +1209,6 @@ public:
" (unassigned) is unsupported at the moment");
}
- // Create JSON list of additional classes.
- ElementPtr additional_classes_element = Element::createList();
- auto const& additional_classes = subnet->getAdditionalClasses();
- for (auto const& additional_class : additional_classes) {
- additional_classes_element->add(Element::create(additional_class));
- }
-
// Create binding for DDNS replace client name mode.
MySqlBindingPtr ddns_rcn_mode_binding;
auto ddns_rcn_mode = subnet->getDdnsReplaceClientNameMode(Network::Inheritance::NONE);
@@ -1273,7 +1261,7 @@ public:
MySqlBindingCollection in_bindings = {
MySqlBinding::createInteger<uint32_t>(subnet->getID()),
MySqlBinding::createString(subnet->toText()),
- MySqlBinding::condCreateString(subnet->getClientClass(Network::Inheritance::NONE)),
+ createInputClientClassesBinding(subnet->getClientClasses()),
MySqlBinding::condCreateString(subnet->getIface(Network::Inheritance::NONE)),
MySqlBinding::createTimestamp(subnet->getModificationTime()),
createBinding(subnet->getPreferred(Network::Inheritance::NONE)),
@@ -1387,7 +1375,7 @@ public:
MySqlBinding::createString(pool->getFirstAddress().toText()),
MySqlBinding::createString(pool->getLastAddress().toText()),
MySqlBinding::createInteger<uint32_t>(static_cast<uint32_t>(subnet->getID())),
- MySqlBinding::condCreateString(pool->getClientClass()),
+ createInputClientClassesBinding(pool->getClientClasses()),
createInputClientClassesBinding(pool->getAdditionalClasses()),
createInputContextBinding(pool),
MySqlBinding::createTimestamp(subnet->getModificationTime())
@@ -1438,7 +1426,7 @@ public:
MySqlBinding::createInteger<uint32_t>(static_cast<uint32_t>(subnet->getID())),
MySqlBinding::condCreateString(xprefix_txt),
MySqlBinding::createInteger<uint8_t>(xlen),
- MySqlBinding::condCreateString(pd_pool->getClientClass()),
+ createInputClientClassesBinding(pd_pool->getClientClasses()),
createInputClientClassesBinding(pd_pool->getAdditionalClasses()),
createInputContextBinding(pd_pool),
MySqlBinding::createTimestamp(subnet->getModificationTime())
@@ -1588,7 +1576,7 @@ public:
MySqlBindingCollection out_bindings = {
MySqlBinding::createInteger<uint64_t>(), // id
MySqlBinding::createString(SHARED_NETWORK_NAME_BUF_LENGTH), // name
- MySqlBinding::createString(CLIENT_CLASS_BUF_LENGTH), // client_class
+ MySqlBinding::createString(CLIENT_CLASS_LIST_BUF_LENGTH), // client_classes
MySqlBinding::createString(INTERFACE_BUF_LENGTH), // interface
MySqlBinding::createTimestamp(), // modification_ts
MySqlBinding::createInteger<uint32_t>(), // preferred_lifetime
@@ -1667,10 +1655,9 @@ public:
last_network = SharedNetwork6::create(out_bindings[1]->getString());
last_network->setId(last_network_id);
- // client_class at 2.
- if (!out_bindings[2]->amNull()) {
- last_network->allowClientClass(out_bindings[2]->getString());
- }
+ // client_classes at 2.
+ clientClassesFromBinding(out_bindings[2], "client_classes",
+ last_network->getMutableClientClasses());
// interface at 3.
if (!out_bindings[3]->amNull()) {
@@ -1988,7 +1975,7 @@ public:
MySqlBindingCollection in_bindings = {
MySqlBinding::createString(shared_network->getName()),
- MySqlBinding::condCreateString(shared_network->getClientClass(Network::Inheritance::NONE)),
+ createInputClientClassesBinding(shared_network->getClientClasses()),
MySqlBinding::condCreateString(shared_network->getIface(Network::Inheritance::NONE)),
MySqlBinding::createTimestamp(shared_network->getModificationTime()),
createBinding(shared_network->getPreferred(Network::Inheritance::NONE)),
@@ -3594,7 +3581,7 @@ TaggedStatementArray tagged_statements = { {
"INSERT INTO dhcp6_subnet("
" subnet_id,"
" subnet_prefix,"
- " client_class,"
+ " client_classes,"
" interface,"
" modification_ts,"
" preferred_lifetime,"
@@ -3649,7 +3636,7 @@ TaggedStatementArray tagged_statements = { {
{ MySqlConfigBackendDHCPv6Impl::INSERT_SHARED_NETWORK6,
"INSERT INTO dhcp6_shared_network("
" name,"
- " client_class,"
+ " client_classes,"
" interface,"
" modification_ts,"
" preferred_lifetime,"
@@ -3758,7 +3745,7 @@ TaggedStatementArray tagged_statements = { {
"UPDATE dhcp6_subnet SET"
" subnet_id = ?,"
" subnet_prefix = ?,"
- " client_class = ?,"
+ " client_classes = ?,"
" interface = ?,"
" modification_ts = ?,"
" preferred_lifetime = ?,"
@@ -3797,7 +3784,7 @@ TaggedStatementArray tagged_statements = { {
{ MySqlConfigBackendDHCPv6Impl::UPDATE_SHARED_NETWORK6,
"UPDATE dhcp6_shared_network SET"
" name = ?,"
- " client_class = ?,"
+ " client_classes = ?,"
" interface = ?,"
" modification_ts = ?,"
" preferred_lifetime = ?,"
diff --git a/src/hooks/dhcp/mysql/mysql_query_macros_dhcp.h b/src/hooks/dhcp/mysql/mysql_query_macros_dhcp.h
index bfdd98579d..1f6f45bc42 100644
--- a/src/hooks/dhcp/mysql/mysql_query_macros_dhcp.h
+++ b/src/hooks/dhcp/mysql/mysql_query_macros_dhcp.h
@@ -56,7 +56,7 @@ namespace {
" s.4o6_interface_id," \
" s.4o6_subnet," \
" s.boot_file_name," \
- " s.client_class," \
+ " s.client_classes," \
" s.interface," \
" s.match_client_id," \
" s.modification_ts," \
@@ -109,7 +109,7 @@ namespace {
" s.authoritative," \
" s.min_valid_lifetime," \
" s.max_valid_lifetime," \
- " p.client_class," \
+ " p.client_classes," \
" p.evaluate_additional_classes," \
" p.user_context," \
" s.ddns_send_updates," \
@@ -163,7 +163,7 @@ namespace {
"SELECT" \
" s.subnet_id," \
" s.subnet_prefix," \
- " s.client_class," \
+ " s.client_classes," \
" s.interface," \
" s.modification_ts," \
" s.preferred_lifetime," \
@@ -240,12 +240,12 @@ namespace {
" s.max_preferred_lifetime," \
" s.min_valid_lifetime," \
" s.max_valid_lifetime," \
- " p.client_class," \
+ " p.client_classes," \
" p.evaluate_additional_classes," \
" p.user_context," \
" d.excluded_prefix," \
" d.excluded_prefix_length," \
- " d.client_class," \
+ " d.client_classes," \
" d.evaluate_additional_classes," \
" d.user_context," \
" s.ddns_send_updates," \
@@ -303,7 +303,7 @@ namespace {
" p.start_address," \
" p.end_address," \
" p.subnet_id," \
- " p.client_class," \
+ " p.client_classes," \
" p.evaluate_additional_classes," \
" p.user_context," \
" p.modification_ts," \
@@ -345,7 +345,7 @@ namespace {
" p.start_address," \
" p.end_address," \
" p.subnet_id," \
- " p.client_class," \
+ " p.client_classes," \
" p.evaluate_additional_classes," \
" p.user_context," \
" p.modification_ts," \
@@ -390,7 +390,7 @@ namespace {
" p.subnet_id," \
" p.excluded_prefix," \
" p.excluded_prefix_length," \
- " p.client_class," \
+ " p.client_classes," \
" p.evaluate_additional_classes," \
" p.user_context," \
" p.modification_ts," \
@@ -431,7 +431,7 @@ namespace {
"SELECT" \
" n.id," \
" n.name," \
- " n.client_class," \
+ " n.client_classes," \
" n.interface," \
" n.match_client_id," \
" n.modification_ts," \
@@ -514,7 +514,7 @@ namespace {
"SELECT" \
" n.id," \
" n.name," \
- " n.client_class," \
+ " n.client_classes," \
" n.interface," \
" n.modification_ts," \
" n.preferred_lifetime," \
@@ -859,7 +859,7 @@ namespace {
" start_address," \
" end_address," \
" subnet_id," \
- " client_class," \
+ " client_classes," \
" evaluate_additional_classes," \
" user_context," \
" modification_ts" \
@@ -875,7 +875,7 @@ namespace {
" subnet_id," \
" excluded_prefix," \
" excluded_prefix_length," \
- " client_class," \
+ " client_classes," \
" evaluate_additional_classes," \
" user_context," \
" modification_ts" \
diff --git a/src/hooks/dhcp/pgsql/pgsql_cb_dhcp4.cc b/src/hooks/dhcp/pgsql/pgsql_cb_dhcp4.cc
index 709b47e61a..222eddb115 100644
--- a/src/hooks/dhcp/pgsql/pgsql_cb_dhcp4.cc
+++ b/src/hooks/dhcp/pgsql/pgsql_cb_dhcp4.cc
@@ -363,10 +363,9 @@ public:
last_subnet->setFilename(worker.getString(5));
}
- // client_class at 6.
- if (!worker.isColumnNull(6)) {
- last_subnet->allowClientClass(worker.getString(6));
- }
+ // client_classes at 6.
+ clientClassesFromColumn(worker, 6, "client_classes",
+ last_subnet->getMutableClientClasses());
// interface at 7.
if (!worker.isColumnNull(7)) {
@@ -552,10 +551,9 @@ public:
last_pool = Pool4::create(IOAddress(worker.getInet4(21)),
IOAddress(worker.getInet4(22)));
- // pool client_class at 59.
- if (!worker.isColumnNull(59)) {
- last_pool->allowClientClass(worker.getString(59));
- }
+ // pool client_classes at 59.
+ clientClassesFromColumn(worker, 59, "client_classes",
+ last_pool->getMutableClientClasses());
// pool evaluate_additional_classes at 60.
clientClassesFromColumn(worker, 60, "evaluate_additional_classes",
@@ -760,10 +758,9 @@ public:
// pool subnet_id (3) (ignored)
- // pool client_class (4)
- if (!worker.isColumnNull(4)) {
- last_pool->allowClientClass(worker.getString(4));
- }
+ // pool client_classes (4)
+ clientClassesFromColumn(worker, 4, "client_classes",
+ last_pool->getMutableClientClasses());
// pool evaluate_additional_classes (5)
clientClassesFromColumn(worker, 5, "evaluate_additional_classes",
@@ -884,7 +881,7 @@ public:
in_bindings.addOptional(dhcp4o6_subnet);
in_bindings.addOptional(subnet->getFilename(Network::Inheritance::NONE));
- in_bindings.addOptional(subnet->getClientClass(Network::Inheritance::NONE));
+ addClientClassesBinding(in_bindings, subnet->getClientClasses());
in_bindings.addOptional(subnet->getIface(Network::Inheritance::NONE));
in_bindings.addOptional(subnet->getMatchClientId(Network::Inheritance::NONE));
in_bindings.addTimestamp(subnet->getModificationTime());
@@ -1032,7 +1029,7 @@ public:
in_bindings.addInet4(pool->getFirstAddress());
in_bindings.addInet4(pool->getLastAddress());
in_bindings.add(subnet->getID());
- in_bindings.addOptional(pool->getClientClass());
+ addClientClassesBinding(in_bindings, pool->getClientClasses());
addAdditionalClassesBinding(in_bindings, pool);
in_bindings.add(pool->getContext());
in_bindings.addTimestamp(subnet->getModificationTime());
@@ -1192,10 +1189,9 @@ public:
last_network = SharedNetwork4::create(worker.getString(1));
last_network->setId(last_network_id);
- // client_class at 2.
- if (!worker.isColumnNull(2)) {
- last_network->allowClientClass(worker.getString(2));
- }
+ // client_classes at 2.
+ clientClassesFromColumn(worker, 2, "client_classes",
+ last_network->getMutableClientClasses());
// interface at 3.
if (!worker.isColumnNull(3)) {
@@ -1484,7 +1480,7 @@ public:
PsqlBindArray in_bindings;
in_bindings.addTempString(shared_network->getName());
- in_bindings.addOptional(shared_network->getClientClass(Network::Inheritance::NONE));
+ addClientClassesBinding(in_bindings, shared_network->getClientClasses());
in_bindings.addOptional(shared_network->getIface(Network::Inheritance::NONE));
in_bindings.addOptional(shared_network->getMatchClientId(Network::Inheritance::NONE));
in_bindings.addTimestamp(shared_network->getModificationTime()),
@@ -3327,7 +3323,7 @@ TaggedStatementArray tagged_statements = { {
OID_VARCHAR, // 4 interface_id_4o6
OID_VARCHAR, // 5 subnet_4o6
OID_VARCHAR, // 6 boot_file_name
- OID_VARCHAR, // 7 client_class
+ OID_TEXT, // 7 client_classes
OID_VARCHAR, // 8 interface
OID_BOOL, // 9 match_client_id
OID_TIMESTAMP, // 10 modification_ts
@@ -3368,7 +3364,7 @@ TaggedStatementArray tagged_statements = { {
" interface_id_4o6,"
" subnet_4o6,"
" boot_file_name,"
- " client_class,"
+ " client_classes,"
" interface,"
" match_client_id,"
" modification_ts,"
@@ -3429,7 +3425,7 @@ TaggedStatementArray tagged_statements = { {
OID_TEXT, // 1 start_address - cast as inet
OID_TEXT, // 2 end_address - cast as inet
OID_INT8, // 3 subnet_id
- OID_VARCHAR, // 4 client_class
+ OID_TEXT, // 4 client_classes
OID_TEXT, // 5 evaluate_additional_classes
OID_TEXT, // 6 user_context - cast as json
OID_TIMESTAMP // 7 modification_ts
@@ -3444,7 +3440,7 @@ TaggedStatementArray tagged_statements = { {
33,
{
OID_VARCHAR, // 1 name,
- OID_VARCHAR, // 2 client_class,
+ OID_TEXT, // 2 client_classes,
OID_VARCHAR, // 3 interface,
OID_BOOL, // 4 match_client_id,
OID_TIMESTAMP, // 5 modification_ts,
@@ -3480,7 +3476,7 @@ TaggedStatementArray tagged_statements = { {
"INSERT_SHARED_NETWORK4",
"INSERT INTO dhcp4_shared_network("
" name,"
- " client_class,"
+ " client_classes,"
" interface,"
" match_client_id,"
" modification_ts,"
@@ -3772,7 +3768,7 @@ TaggedStatementArray tagged_statements = { {
" interface_id_4o6 = $4,"
" subnet_4o6 = $5,"
" boot_file_name = $6,"
- " client_class = $7,"
+ " client_classes = $7,"
" interface = $8,"
" match_client_id = $9,"
" modification_ts = $10,"
@@ -3813,7 +3809,7 @@ TaggedStatementArray tagged_statements = { {
34,
{
OID_VARCHAR, // 1 name,
- OID_VARCHAR, // 2 client_class,
+ OID_TEXT, // 2 client_classes,
OID_VARCHAR, // 3 interface,
OID_BOOL, // 4 match_client_id,
OID_TIMESTAMP, // 5 modification_ts,
@@ -3850,7 +3846,7 @@ TaggedStatementArray tagged_statements = { {
"UPDATE_SHARED_NETWORK4",
"UPDATE dhcp4_shared_network SET"
" name = $1,"
- " client_class = $2,"
+ " client_classes = $2,"
" interface = $3,"
" match_client_id = $4,"
" modification_ts = $5,"
diff --git a/src/hooks/dhcp/pgsql/pgsql_cb_dhcp6.cc b/src/hooks/dhcp/pgsql/pgsql_cb_dhcp6.cc
index 16fc0533be..f6ded02bf9 100644
--- a/src/hooks/dhcp/pgsql/pgsql_cb_dhcp6.cc
+++ b/src/hooks/dhcp/pgsql/pgsql_cb_dhcp6.cc
@@ -360,9 +360,8 @@ public:
// 0 and 1 are subnet_id and subnet_prefix
// client_class at 2.
- if (!worker.isColumnNull(2)) {
- last_subnet->allowClientClass(worker.getString(2));
- }
+ clientClassesFromColumn(worker, 2, "client_classes",
+ last_subnet->getMutableClientClasses());
// interface at 3.
if (!worker.isColumnNull(3)) {
@@ -437,7 +436,7 @@ public:
// 77 and 78 are {min,max}_valid_lifetime
- // 79 is pool client_class
+ // 79 is pool client_classes
// 80 is pool evaluate_additional_classes
// 81 is pool user_context
// 82 is pd pool excluded_prefix
@@ -553,10 +552,9 @@ public:
// pool subnet_id at 18 (ignored)
// pool modification_ts at 19 (ignored)
- // pool client_class at 79.
- if (!worker.isColumnNull(79)) {
- last_pool->allowClientClass(worker.getString(79));
- }
+ // pool client_classes at 79.
+ clientClassesFromColumn(worker, 79, "client_classes",
+ last_pool->getMutableClientClasses());
// pool evaluate_additional_classes at 80.
clientClassesFromColumn(worker, 80, "evaluate_additional_classes",
@@ -605,10 +603,9 @@ public:
excluded_prefix,
static_cast<uint8_t>(worker.getSmallInt(83)));
- // pd pool client_class (84)
- if (!worker.isColumnNull(84)) {
- last_pd_pool->allowClientClass(worker.getString(84));
- }
+ // pd pool client_classes (84)
+ clientClassesFromColumn(worker, 84, "client_classes",
+ last_pd_pool->getMutableClientClasses());
// pd pool evaluate_additional_classes at 85.
clientClassesFromColumn(worker, 85, "evaluate_additional_classes",
@@ -824,10 +821,9 @@ public:
// pool subnet_id (3) (ignored)
- // pool client_class (4)
- if (!worker.isColumnNull(4)) {
- last_pool->allowClientClass(worker.getString(4));
- }
+ // pool client_classes (4)
+ clientClassesFromColumn(worker, 4, "client_classes",
+ last_pool->getMutableClientClasses());
// pool evaluate_additional_classes (5)
clientClassesFromColumn(worker, 5, "evaluate_additional_classes",
@@ -912,9 +908,8 @@ public:
// pd pool subnet_id (4) (ignored)
// pool client_class (7)
- if (!worker.isColumnNull(7)) {
- last_pd_pool->allowClientClass(worker.getString(7));
- }
+ clientClassesFromColumn(worker, 7, "client_classes",
+ last_pd_pool->getMutableClientClasses());
// pool evaluate_additional_classes (8)
clientClassesFromColumn(worker, 8, "evaluate_additional_classes",
@@ -1049,7 +1044,7 @@ public:
PsqlBindArray in_bindings;
in_bindings.add(subnet->getID());
in_bindings.addTempString(subnet->toText());
- in_bindings.addOptional(subnet->getClientClass(Network::Inheritance::NONE));
+ addClientClassesBinding(in_bindings, subnet->getClientClasses());
in_bindings.addOptional(subnet->getIface(Network::Inheritance::NONE));
in_bindings.addTimestamp(subnet->getModificationTime());
in_bindings.add(subnet->getPreferred(Network::Inheritance::NONE));
@@ -1205,7 +1200,7 @@ public:
in_bindings.addInet6(pool->getFirstAddress());
in_bindings.addInet6(pool->getLastAddress());
in_bindings.add(subnet->getID());
- in_bindings.addOptional(pool->getClientClass());
+ addClientClassesBinding(in_bindings, pool->getClientClasses());
addAdditionalClassesBinding(in_bindings, pool);
in_bindings.add(pool->getContext());
in_bindings.addTimestamp(subnet->getModificationTime());
@@ -1259,7 +1254,7 @@ public:
in_bindings.add(subnet->getID());
in_bindings.addOptional(xprefix_txt);
in_bindings.add(xlen);
- in_bindings.addOptional(pd_pool->getClientClass());
+ addClientClassesBinding(in_bindings, pd_pool->getClientClasses());
addAdditionalClassesBinding(in_bindings, pd_pool);
in_bindings.add(pd_pool->getContext());
in_bindings.addTimestamp(subnet->getModificationTime());
@@ -1437,10 +1432,9 @@ public:
last_network = SharedNetwork6::create(worker.getString(1));
last_network->setId(last_network_id);
- // client_class at 2.
- if (!worker.isColumnNull(2)) {
- last_network->allowClientClass(worker.getString(2));
- }
+ // client_classes at 2.
+ clientClassesFromColumn(worker, 2, "client_classes",
+ last_network->getMutableClientClasses());
// interface at 3.
if (!worker.isColumnNull(3)) {
@@ -1719,7 +1713,7 @@ public:
PsqlBindArray in_bindings;
in_bindings.addTempString(shared_network->getName());
- in_bindings.addOptional(shared_network->getClientClass(Network::Inheritance::NONE));
+ addClientClassesBinding(in_bindings, shared_network->getClientClasses());
in_bindings.addOptional(shared_network->getIface(Network::Inheritance::NONE));
in_bindings.addTimestamp(shared_network->getModificationTime());
in_bindings.add(shared_network->getPreferred(Network::Inheritance::NONE));
@@ -3722,7 +3716,7 @@ TaggedStatementArray tagged_statements = { {
{
OID_INT8, // 1 subnet_id,
OID_VARCHAR, // 2 subnet_prefix
- OID_VARCHAR, // 3 client_class
+ OID_TEXT, // 3 client_class
OID_VARCHAR, // 4 interface
OID_TIMESTAMP, // 5 modification_ts
OID_INT8, // 6 preferred_lifetime
@@ -3760,7 +3754,7 @@ TaggedStatementArray tagged_statements = { {
"INSERT INTO dhcp6_subnet("
" subnet_id,"
" subnet_prefix,"
- " client_class,"
+ " client_classes,"
" interface,"
" modification_ts,"
" preferred_lifetime,"
@@ -3822,7 +3816,7 @@ TaggedStatementArray tagged_statements = { {
OID_TEXT, // 1 start_address - cast as inet
OID_TEXT, // 2 end_address - cast as inet
OID_INT8, // 3 subnet_id
- OID_VARCHAR, // 4 client_class
+ OID_TEXT, // 4 client_classes
OID_TEXT, // 5 evaluate_additional_classes
OID_TEXT, // 6 user_context - cast as json
OID_TIMESTAMP // 7 modification_ts
@@ -3842,7 +3836,7 @@ TaggedStatementArray tagged_statements = { {
OID_INT8, // 4 subnet_id
OID_VARCHAR, // 5 excluded_prefix
OID_INT2, // 6 excluded_prefix_length
- OID_VARCHAR, // 7 client_class
+ OID_TEXT, // 7 client_classes
OID_TEXT, // 8 evaluate_additional_classes
OID_TEXT, // 9 user_context - cast as json
OID_TIMESTAMP, // 10 modification_ts
@@ -3857,7 +3851,7 @@ TaggedStatementArray tagged_statements = { {
33,
{
OID_VARCHAR, // 1 name
- OID_VARCHAR, // 2 client_class
+ OID_TEXT, // 2 client_classes
OID_VARCHAR, // 3 interface
OID_TIMESTAMP, // 4 modification_ts
OID_INT8, // 5 preferred_lifetime
@@ -3893,7 +3887,7 @@ TaggedStatementArray tagged_statements = { {
"INSERT_SHARED_NETWORK6",
"INSERT INTO dhcp6_shared_network("
" name,"
- " client_class,"
+ " client_classes,"
" interface,"
" modification_ts,"
" preferred_lifetime,"
@@ -4137,7 +4131,7 @@ TaggedStatementArray tagged_statements = { {
{
OID_INT8, // 1 subnet_id,
OID_VARCHAR, // 2 subnet_prefix
- OID_VARCHAR, // 3 client_class
+ OID_TEXT, // 3 client_classes
OID_VARCHAR, // 4 interface
OID_TIMESTAMP, // 5 modification_ts
OID_INT8, // 6 preferred_lifetime
@@ -4175,7 +4169,7 @@ TaggedStatementArray tagged_statements = { {
"UPDATE dhcp6_subnet SET"
" subnet_id = $1,"
" subnet_prefix = $2,"
- " client_class = $3,"
+ " client_classes = $3,"
" interface = $4,"
" modification_ts = $5,"
" preferred_lifetime = $6,"
@@ -4217,7 +4211,7 @@ TaggedStatementArray tagged_statements = { {
34,
{
OID_VARCHAR, // 1 name
- OID_VARCHAR, // 2 client_class
+ OID_TEXT, // 2 client_classes
OID_VARCHAR, // 3 interface
OID_TIMESTAMP, // 4 modification_ts
OID_INT8, // 5 preferred_lifetime
@@ -4253,7 +4247,7 @@ TaggedStatementArray tagged_statements = { {
"UPDATE_SHARED_NETWORK6",
"UPDATE dhcp6_shared_network SET"
" name = $1,"
- " client_class = $2,"
+ " client_classes = $2,"
" interface = $3,"
" modification_ts = $4,"
" preferred_lifetime = $5,"
diff --git a/src/hooks/dhcp/pgsql/pgsql_query_macros_dhcp.h b/src/hooks/dhcp/pgsql/pgsql_query_macros_dhcp.h
index 429fca0f1e..172c3b0ac5 100644
--- a/src/hooks/dhcp/pgsql/pgsql_query_macros_dhcp.h
+++ b/src/hooks/dhcp/pgsql/pgsql_query_macros_dhcp.h
@@ -52,7 +52,7 @@ namespace {
" s.interface_id_4o6," \
" s.subnet_4o6," \
" s.boot_file_name," \
- " s.client_class," \
+ " s.client_classes," \
" s.interface," \
" s.match_client_id," \
" gmt_epoch(s.modification_ts) as modification_ts, " \
@@ -105,7 +105,7 @@ namespace {
" s.authoritative," \
" s.min_valid_lifetime," \
" s.max_valid_lifetime," \
- " p.client_class," \
+ " p.client_classes," \
" p.evaluate_additional_classes," \
" p.user_context," \
" s.ddns_send_updates," \
@@ -159,7 +159,7 @@ namespace {
"SELECT" \
" s.subnet_id," \
" s.subnet_prefix," \
- " s.client_class," \
+ " s.client_classes," \
" s.interface," \
" gmt_epoch(s.modification_ts) as modification_ts, " \
" s.preferred_lifetime," \
@@ -236,12 +236,12 @@ namespace {
" s.max_preferred_lifetime," \
" s.min_valid_lifetime," \
" s.max_valid_lifetime," \
- " p.client_class," \
+ " p.client_classes," \
" p.evaluate_additional_classes," \
" p.user_context," \
" d.excluded_prefix," \
" d.excluded_prefix_length," \
- " d.client_class," \
+ " d.client_classes," \
" d.evaluate_additional_classes," \
" d.user_context," \
" s.ddns_send_updates," \
@@ -299,7 +299,7 @@ namespace {
" p.start_address," \
" p.end_address," \
" p.subnet_id," \
- " p.client_class," \
+ " p.client_classes," \
" p.evaluate_additional_classes," \
" p.user_context," \
" gmt_epoch(p.modification_ts) as modification_ts, " \
@@ -341,7 +341,7 @@ namespace {
" p.start_address," \
" p.end_address," \
" p.subnet_id," \
- " p.client_class," \
+ " p.client_classes," \
" p.evaluate_additional_classes," \
" p.user_context," \
" gmt_epoch(p.modification_ts) as modification_ts, " \
@@ -387,7 +387,7 @@ namespace {
" p.subnet_id," \
" p.excluded_prefix," \
" p.excluded_prefix_length," \
- " p.client_class," \
+ " p.client_classes," \
" p.evaluate_additional_classes," \
" p.user_context," \
" gmt_epoch(p.modification_ts) as modification_ts, " \
@@ -428,7 +428,7 @@ namespace {
"SELECT" \
" n.id," \
" n.name," \
- " n.client_class," \
+ " n.client_classes," \
" n.interface," \
" n.match_client_id," \
" gmt_epoch(n.modification_ts) as modification_ts, " \
@@ -511,7 +511,7 @@ namespace {
"SELECT" \
" n.id," \
" n.name," \
- " n.client_class," \
+ " n.client_classes," \
" n.interface," \
" gmt_epoch(n.modification_ts) as modification_ts, " \
" n.preferred_lifetime," \
@@ -856,7 +856,7 @@ namespace {
" start_address," \
" end_address," \
" subnet_id," \
- " client_class," \
+ " client_classes," \
" evaluate_additional_classes," \
" user_context," \
" modification_ts" \
@@ -872,7 +872,7 @@ namespace {
" subnet_id," \
" excluded_prefix," \
" excluded_prefix_length," \
- " client_class," \
+ " client_classes," \
" evaluate_additional_classes," \
" user_context," \
" modification_ts" \
diff --git a/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc b/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc
index a35a1e79f3..ed830e3b7f 100644
--- a/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc
+++ b/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc
@@ -107,6 +107,7 @@ GenericConfigBackendDHCPv4Test::initTestSubnets() {
subnet->get4o6().setSubnet4o6(IOAddress("2001:db8:1::"), 64);
subnet->setFilename("/tmp/filename");
subnet->allowClientClass("home");
+ subnet->allowClientClass("office");
subnet->setIface("eth1");
subnet->setMatchClientId(false);
subnet->setSiaddr(IOAddress("10.1.2.3"));
@@ -163,6 +164,7 @@ GenericConfigBackendDHCPv4Test::initTestSubnets() {
IOAddress("10.0.0.60")));
pool2->allowClientClass("work");
+ pool2->allowClientClass("play");
pool2->addAdditionalClass("required-class3");
pool2->addAdditionalClass("required-class4");
user_context = Element::createMap();
diff --git a/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc b/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc
index 593a51209c..620f08b0d5 100644
--- a/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc
+++ b/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc
@@ -106,6 +106,7 @@ GenericConfigBackendDHCPv6Test::initTestSubnets() {
Subnet6Ptr subnet(new Subnet6(IOAddress("2001:db8::"), 64,
30, 40, 50, 60, 1024));
subnet->allowClientClass("home");
+ subnet->allowClientClass("office");
subnet->setIface("eth1");
subnet->setInterfaceId(opt_interface_id);
subnet->setT2(323212);
@@ -171,6 +172,7 @@ GenericConfigBackendDHCPv6Test::initTestSubnets() {
subnet->addPool(pool2);
pool2->allowClientClass("work");
+ pool2->allowClientClass("play");
pool2->addAdditionalClass("required-class3");
pool2->addAdditionalClass("required-class4");
user_context = Element::createMap();