diff options
-rw-r--r-- | src/hooks/dhcp/pgsql/pgsql_cb_dhcp4.cc | 132 | ||||
-rw-r--r-- | src/hooks/dhcp/pgsql/pgsql_cb_dhcp6.cc | 131 | ||||
-rw-r--r-- | src/hooks/dhcp/pgsql/pgsql_query_macros_dhcp.h | 16 |
3 files changed, 231 insertions, 48 deletions
diff --git a/src/hooks/dhcp/pgsql/pgsql_cb_dhcp4.cc b/src/hooks/dhcp/pgsql/pgsql_cb_dhcp4.cc index 222eddb115..365477f2be 100644 --- a/src/hooks/dhcp/pgsql/pgsql_cb_dhcp4.cc +++ b/src/hooks/dhcp/pgsql/pgsql_cb_dhcp4.cc @@ -510,7 +510,27 @@ public: last_subnet->setAllocatorType(worker.getString(73)); } - // server_tag at 74. + // ddns_ttl_percent at 74. + if (!worker.isColumnNull(74)) { + last_subnet->setDdnsTtlPercent(worker.getDouble(74)); + } + + // ddns_ttl at 75. + if (!worker.isColumnNull(75)) { + last_subnet->setDdnsTtl(worker.getInt(75)); + } + + // ddns_ttl_min at 76. + if (!worker.isColumnNull(76)) { + last_subnet->setDdnsTtlMin(worker.getInt(76)); + } + + // ddns_ttl_max at 77. + if (!worker.isColumnNull(77)) { + last_subnet->setDdnsTtlMax(worker.getInt(77)); + } + + // server_tag at 78. // Subnet ready. Add it to the list. auto ret = subnets.insert(last_subnet); @@ -523,9 +543,9 @@ public: } } - // Check for new server tags at 74. - if (!worker.isColumnNull(74)) { - std::string new_tag = worker.getString(74); + // Check for new server tags at 78. + if (!worker.isColumnNull(78)) { + std::string new_tag = worker.getString(78); if (last_tag != new_tag) { if (!new_tag.empty() && !last_subnet->hasServerTag(ServerTag(new_tag))) { last_subnet->setServerTag(new_tag); @@ -937,6 +957,10 @@ public: in_bindings.addOptional(subnet->getCacheMaxAge(Network::Inheritance::NONE)); in_bindings.addOptional(subnet->getOfferLft(Network::Inheritance::NONE)); in_bindings.addOptional(subnet->getAllocatorType(Network::Inheritance::NONE)); + in_bindings.addOptional(subnet->getDdnsTtlPercent(Network::Inheritance::NONE)); + in_bindings.addOptional(subnet->getDdnsTtl(Network::Inheritance::NONE)); + in_bindings.addOptional(subnet->getDdnsTtlMin(Network::Inheritance::NONE)); + in_bindings.addOptional(subnet->getDdnsTtlMax(Network::Inheritance::NONE)); // Start transaction. PgSqlTransaction transaction(conn_); @@ -1344,7 +1368,27 @@ public: last_network->setAllocatorType(worker.getString(47)); } - // server_tag at 48. + // ddns_ttl_percent at 48. + if (!worker.isColumnNull(48)) { + last_network->setDdnsTtlPercent(worker.getDouble(48)); + } + + // ddns_ttl at 49. + if (!worker.isColumnNull(49)) { + last_network->setDdnsTtl(worker.getInt(49)); + } + + // ddns_ttl_min at 50. + if (!worker.isColumnNull(50)) { + last_network->setDdnsTtlMin(worker.getInt(50)); + } + + // ddns_ttl_max at 51. + if (!worker.isColumnNull(51)) { + last_network->setDdnsTtlMax(worker.getInt(51)); + } + + // server_tag at 52. // Add the shared network. auto ret = shared_networks.push_back(last_network); @@ -1358,8 +1402,8 @@ public: } // Check for new server tags. - if (!worker.isColumnNull(48)) { - std::string new_tag = worker.getString(48); + if (!worker.isColumnNull(52)) { + std::string new_tag = worker.getString(52); if (last_tag != new_tag) { if (!new_tag.empty() && !last_network->hasServerTag(ServerTag(new_tag))) { last_network->setServerTag(new_tag); @@ -1512,6 +1556,10 @@ public: in_bindings.addOptional(shared_network->getCacheMaxAge(Network::Inheritance::NONE)); in_bindings.addOptional(shared_network->getOfferLft(Network::Inheritance::NONE)); in_bindings.addOptional(shared_network->getAllocatorType(Network::Inheritance::NONE)); + in_bindings.addOptional(shared_network->getDdnsTtlPercent(Network::Inheritance::NONE)); + in_bindings.addOptional(shared_network->getDdnsTtl(Network::Inheritance::NONE)); + in_bindings.addOptional(shared_network->getDdnsTtlMin(Network::Inheritance::NONE)); + in_bindings.addOptional(shared_network->getDdnsTtlMax(Network::Inheritance::NONE)); // Start transaction. PgSqlTransaction transaction(conn_); @@ -3315,7 +3363,7 @@ TaggedStatementArray tagged_statements = { { // Insert a subnet. { // PgSqlConfigBackendDHCPv4Impl::INSERT_SUBNET4, - 38, + 42, { OID_INT8, // 1 subnet_id, OID_VARCHAR, // 2 subnet_prefix @@ -3354,7 +3402,11 @@ TaggedStatementArray tagged_statements = { { OID_TEXT, // 35 cache_threshold - cast as float OID_INT8, // 36 cache_max_age OID_INT8, // 37 offer_lifetime - OID_VARCHAR // 38 allocator + OID_VARCHAR, // 38 allocator + OID_TEXT, // 39 ddns_ttl_percent - cast as float + OID_INT8, // 40 ddns_ttl + OID_INT8, // 41 ddns_ttl_min + OID_INT8, // 42 ddns_ttl_max }, "INSERT_SUBNET4", "INSERT INTO dhcp4_subnet(" @@ -3395,12 +3447,17 @@ TaggedStatementArray tagged_statements = { { " cache_threshold," " cache_max_age," " offer_lifetime," - " allocator" + " allocator," + " ddns_ttl_percent," + " ddns_ttl," + " ddns_ttl_min," + " ddns_ttl_max" ") VALUES (" "$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, " "cast($11 as inet), $12, $13, $14, $15, $16, $17, $18, cast($19 as json), $20, " "$21, $22, $23, cast($24 as float), cast($25 as float), $26, $27, $28, $29, $30, " - "$31, $32, $33, $34, cast($35 as float), $36, $37, $38" + "$31, $32, $33, $34, cast($35 as float), $36, $37, $38, " + "cast($39 as float), $40, $41, $42" ")" }, @@ -3437,7 +3494,7 @@ TaggedStatementArray tagged_statements = { { // Insert a shared network. { // PgSqlConfigBackendDHCPv4Impl::INSERT_SHARED_NETWORK4, - 33, + 37, { OID_VARCHAR, // 1 name, OID_TEXT, // 2 client_classes, @@ -3471,7 +3528,11 @@ TaggedStatementArray tagged_statements = { { OID_TEXT, // 30 cache_threshold - cast as float OID_INT8, // 31 cache_max_age OID_INT8, // 32 offer_lifetime - OID_VARCHAR // 33 allocator + OID_VARCHAR, // 33 allocator + OID_TEXT, // 34 ddns_ttl_percent - cast as float + OID_INT8, // 35 ddns_ttl + OID_INT8, // 36 ddns_ttl_min + OID_INT8 // 37 ddns_ttl_max }, "INSERT_SHARED_NETWORK4", "INSERT INTO dhcp4_shared_network(" @@ -3507,12 +3568,17 @@ TaggedStatementArray tagged_statements = { { " cache_threshold," " cache_max_age," " offer_lifetime," - " allocator" + " allocator," + " ddns_ttl_percent," + " ddns_ttl," + " ddns_ttl_min," + " ddns_ttl_max" ") VALUES (" "$1, $2, $3, $4, $5, $6, $7, $8, $9, $10," "cast($11 as json), $12, $13, $14, $15, " "cast($16 as float), cast($17 as float), $18, $19, cast($20 as inet), " - "$21, $22, $23, $24, $25, $26, $27, $28, $29, cast($30 as float), $31, $32, $33" + "$21, $22, $23, $24, $25, $26, $27, $28, $29, cast($30 as float), $31, $32, $33, " + "cast($34 as float), $35, $36, $37" ")" }, @@ -3717,7 +3783,7 @@ TaggedStatementArray tagged_statements = { { // Update existing subnet. { // PgSqlConfigBackendDHCPv4Impl::UPDATE_SUBNET4, - 40, + 44, { OID_INT8, // 1 subnet_id, OID_VARCHAR, // 2 subnet_prefix @@ -3757,8 +3823,12 @@ TaggedStatementArray tagged_statements = { { OID_INT8, // 36 cache_max_age" OID_INT8, // 37 offer_lifetime" OID_VARCHAR, // 38 allocator - OID_INT8, // 39 subnet_id (of subnet to update) - OID_VARCHAR, // 40 subnet_prefix (of subnet to update) + OID_TEXT, // 39 ddns_ttl_percent - cast as float + OID_INT8, // 40 ddns_ttl + OID_INT8, // 41 ddns_ttl_min + OID_INT8, // 42 ddns_ttl_max + OID_INT8, // 43 subnet_id (of subnet to update) + OID_VARCHAR, // 44 subnet_prefix (of subnet to update) }, "UPDATE_SUBNET4,", "UPDATE dhcp4_subnet SET" @@ -3799,14 +3869,18 @@ TaggedStatementArray tagged_statements = { { " cache_threshold = cast($35 as float)," " cache_max_age = $36," " offer_lifetime = $37," - " allocator = $38 " - "WHERE subnet_id = $39 OR subnet_prefix = $40" + " allocator = $38," + " ddns_ttl_percent = cast($39 as float)," + " ddns_ttl = $40," + " ddns_ttl_min = $41," + " ddns_ttl_max = $42 " + "WHERE subnet_id = $43 OR subnet_prefix = $44" }, // Update existing shared network. { // PgSqlConfigBackendDHCPv4Impl::UPDATE_SHARED_NETWORK4, - 34, + 38, { OID_VARCHAR, // 1 name, OID_TEXT, // 2 client_classes, @@ -3840,8 +3914,12 @@ TaggedStatementArray tagged_statements = { { OID_TEXT, // 30 cache_threshold - cast as float OID_INT8, // 31 cache_max_age OID_INT8, // 32 offer_lifetime - OID_VARCHAR, // 33 name (of network to update) - OID_VARCHAR // 34 allocator + OID_VARCHAR, // 33 allocator + OID_TEXT, // 34 ddns_ttl_percent - cast as float + OID_INT8, // 35 ddns_ttl + OID_INT8, // 36 ddns_ttl_min + OID_INT8, // 37 ddns_ttl_max + OID_VARCHAR, // 38 name (of network to update) }, "UPDATE_SHARED_NETWORK4", "UPDATE dhcp4_shared_network SET" @@ -3877,8 +3955,12 @@ TaggedStatementArray tagged_statements = { { " cache_threshold = cast($30 as float)," " cache_max_age = $31," " offer_lifetime = $32," - " allocator = $33 " - "WHERE name = $34" + " allocator = $33," + " ddns_ttl_percent = cast($34 as float)," + " ddns_ttl = $35," + " ddns_ttl_min = $36," + " ddns_ttl_max = $37 " + "WHERE name = $38" }, // Update existing option definition. diff --git a/src/hooks/dhcp/pgsql/pgsql_cb_dhcp6.cc b/src/hooks/dhcp/pgsql/pgsql_cb_dhcp6.cc index f6ded02bf9..fe5d519a91 100644 --- a/src/hooks/dhcp/pgsql/pgsql_cb_dhcp6.cc +++ b/src/hooks/dhcp/pgsql/pgsql_cb_dhcp6.cc @@ -506,7 +506,27 @@ public: last_subnet->setPdAllocatorType(worker.getString(98)); } - // server_tag at 99. + // ddns_ttl_percent at 99. + if (!worker.isColumnNull(99)) { + last_subnet->setDdnsTtlPercent(worker.getDouble(99)); + } + + // ddns_ttl at 100. + if (!worker.isColumnNull(100)) { + last_subnet->setDdnsTtl(worker.getInt(100)); + } + + // ddns_ttl_min at 101. + if (!worker.isColumnNull(101)) { + last_subnet->setDdnsTtlMin(worker.getInt(101)); + } + + // ddns_ttl_max at 102. + if (!worker.isColumnNull(102)) { + last_subnet->setDdnsTtlMax(worker.getInt(102)); + } + + // server_tag at 103. // Subnet ready. Add it to the list. auto ret = subnets.insert(last_subnet); @@ -519,9 +539,9 @@ public: } } - // Check for new server tags at 99. - if (!worker.isColumnNull(99)) { - std::string new_tag = worker.getString(99); + // Check for new server tags at 103. + if (!worker.isColumnNull(103)) { + std::string new_tag = worker.getString(103); if (last_tag != new_tag) { if (!new_tag.empty() && !last_subnet->hasServerTag(ServerTag(new_tag))) { last_subnet->setServerTag(new_tag); @@ -1101,6 +1121,10 @@ public: in_bindings.addOptional(subnet->getCacheMaxAge(Network::Inheritance::NONE)); in_bindings.addOptional(subnet->getAllocatorType(Network::Inheritance::NONE)); in_bindings.addOptional(subnet->getPdAllocatorType(Network::Inheritance::NONE)); + in_bindings.addOptional(subnet->getDdnsTtlPercent(Network::Inheritance::NONE)); + in_bindings.addOptional(subnet->getDdnsTtl(Network::Inheritance::NONE)); + in_bindings.addOptional(subnet->getDdnsTtlMin(Network::Inheritance::NONE)); + in_bindings.addOptional(subnet->getDdnsTtlMax(Network::Inheritance::NONE)); // Start transaction. PgSqlTransaction transaction(conn_); @@ -1577,7 +1601,27 @@ public: last_network->setPdAllocatorType(worker.getString(48)); } - // server_tag at 49. + // ddns_ttl_percent at 49. + if (!worker.isColumnNull(49)) { + last_network->setDdnsTtlPercent(worker.getDouble(49)); + } + + // ddns_ttl at 50. + if (!worker.isColumnNull(50)) { + last_network->setDdnsTtl(worker.getInt(50)); + } + + // ddns_ttl_min at 51. + if (!worker.isColumnNull(51)) { + last_network->setDdnsTtlMin(worker.getInt(51)); + } + + // ddns_ttl_max at 52. + if (!worker.isColumnNull(52)) { + last_network->setDdnsTtlMax(worker.getInt(52)); + } + + // server_tag at 53. // Add the shared network. auto ret = shared_networks.push_back(last_network); @@ -1591,8 +1635,8 @@ public: } // Check for new server tags. - if (!worker.isColumnNull(49)) { - std::string new_tag = worker.getString(49); + if (!worker.isColumnNull(53)) { + std::string new_tag = worker.getString(53); if (last_tag != new_tag) { if (!new_tag.empty() && !last_network->hasServerTag(ServerTag(new_tag))) { last_network->setServerTag(new_tag); @@ -1745,6 +1789,10 @@ public: in_bindings.addOptional(shared_network->getCacheMaxAge(Network::Inheritance::NONE)); in_bindings.addOptional(shared_network->getAllocatorType(Network::Inheritance::NONE)); in_bindings.addOptional(shared_network->getPdAllocatorType(Network::Inheritance::NONE)); + in_bindings.addOptional(shared_network->getDdnsTtlPercent(Network::Inheritance::NONE)); + in_bindings.addOptional(shared_network->getDdnsTtl(Network::Inheritance::NONE)); + in_bindings.addOptional(shared_network->getDdnsTtlMin(Network::Inheritance::NONE)); + in_bindings.addOptional(shared_network->getDdnsTtlMax(Network::Inheritance::NONE)); // Start transaction. PgSqlTransaction transaction(conn_); @@ -3712,7 +3760,7 @@ TaggedStatementArray tagged_statements = { { // Insert a subnet. { // PgSqlConfigBackendDHCPv6Impl::INSERT_SUBNET6, - 35, + 39, { OID_INT8, // 1 subnet_id, OID_VARCHAR, // 2 subnet_prefix @@ -3748,7 +3796,11 @@ TaggedStatementArray tagged_statements = { { OID_TEXT, // 32 cache_threshold - cast as float OID_INT8, // 33 cache_max_age OID_VARCHAR, // 34 allocator - OID_VARCHAR // 35 pd_allocator + OID_VARCHAR, // 35 pd_allocator + OID_TEXT, // 36 ddns_ttl_percent - cast as float + OID_INT8, // 37 ddns_ttl + OID_INT8, // 38 ddns_ttl_min + OID_INT8 // 39 ddns_ttl_max }, "INSERT_SUBNET6", "INSERT INTO dhcp6_subnet(" @@ -3786,12 +3838,17 @@ TaggedStatementArray tagged_statements = { { " cache_threshold," " cache_max_age," " allocator," - " pd_allocator" + " pd_allocator," + " ddns_ttl_percent," + " ddns_ttl," + " ddns_ttl_min," + " ddns_ttl_max" ") VALUES (" " $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, " " $11, $12, $13, $14, $15, cast($16 as json), $17, $18, $19, $20, " " cast($21 as float), cast($22 as float), $23, $24, $25, $26, $27, $28, $29, $30, " - " $31, cast($32 as float), $33, $34, $35" + " $31, cast($32 as float), $33, $34, $35, " + " cast($36 as float), $37, $38, $39" ")" }, @@ -3848,7 +3905,7 @@ TaggedStatementArray tagged_statements = { { // Insert a shared network. { // PgSqlConfigBackendDHCPv6Impl::INSERT_SHARED_NETWORK6, - 33, + 37, { OID_VARCHAR, // 1 name OID_TEXT, // 2 client_classes @@ -3882,7 +3939,11 @@ TaggedStatementArray tagged_statements = { { OID_TEXT, // 30 cache_threshold - cast as float OID_INT8, // 31 cache_max_age OID_VARCHAR, // 32 allocator - OID_VARCHAR // 33 pd_allocator + OID_VARCHAR, // 33 pd_allocator + OID_TEXT, // 34 ddns_ttl_percent - cast as float + OID_INT8, // 35 ddns_ttl + OID_INT8, // 36 ddns_ttl_min + OID_INT8 // 37 ddns_ttl_max }, "INSERT_SHARED_NETWORK6", "INSERT INTO dhcp6_shared_network(" @@ -3918,12 +3979,17 @@ TaggedStatementArray tagged_statements = { { " cache_threshold," " cache_max_age," " allocator," - " pd_allocator" + " pd_allocator," + " ddns_ttl_percent," + " ddns_ttl," + " ddns_ttl_min," + " ddns_ttl_max" ") VALUES (" " $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, " " $11, $12, $13, cast($14 as json), $15, $16, $17, $18," " cast($19 as float), cast($20 as float), $21, $22, $23," - " $24, $25, $26, $27, $28, $29, cast($30 as float), $31, $32, $33" + " $24, $25, $26, $27, $28, $29, cast($30 as float), $31, $32, $33, " + " cast($34 as float), $35, $36, $37" ")" }, @@ -4127,7 +4193,7 @@ TaggedStatementArray tagged_statements = { { // Update existing subnet. { // PgSqlConfigBackendDHCPv6Impl::UPDATE_SUBNET6, - 37, + 41, { OID_INT8, // 1 subnet_id, OID_VARCHAR, // 2 subnet_prefix @@ -4163,7 +4229,13 @@ TaggedStatementArray tagged_statements = { { OID_TEXT, // 32 cache_threshold - cast as float OID_INT8, // 33 cache_max_age OID_VARCHAR, // 34 allocator - OID_VARCHAR // 35 pd_allocator + OID_VARCHAR, // 35 pd_allocator + OID_TEXT, // 36 ddns_ttl_percent - cast as float + OID_INT8, // 37 ddns_ttl + OID_INT8, // 38 ddns_ttl_min + OID_INT8, // 39 ddns_ttl_max + OID_INT8, // 40 subnet_id, + OID_VARCHAR // 41 subnet_prefix }, "UPDATE_SUBNET6", "UPDATE dhcp6_subnet SET" @@ -4201,14 +4273,18 @@ TaggedStatementArray tagged_statements = { { " cache_threshold = cast($32 as float)," " cache_max_age = $33," " allocator = $34," - " pd_allocator = $35 " - "WHERE subnet_id = $36 OR subnet_prefix = $37" + " pd_allocator = $35," + " ddns_ttl_percent = cast($36 as float)," + " ddns_ttl = $37," + " ddns_ttl_min = $38," + " ddns_ttl_max = $39 " + "WHERE subnet_id = $40 OR subnet_prefix = $41" }, // Update existing shared network. { // PgSqlConfigBackendDHCPv6Impl::UPDATE_SHARED_NETWORK6, - 34, + 38, { OID_VARCHAR, // 1 name OID_TEXT, // 2 client_classes @@ -4242,7 +4318,12 @@ TaggedStatementArray tagged_statements = { { OID_TEXT, // 30 cache_threshold - cast as float OID_INT8, // 31 cache_max_age OID_VARCHAR, // 32 allocator - OID_VARCHAR // 33 pd_allocator + OID_VARCHAR, // 33 pd_allocator + OID_TEXT, // 34 ddns_ttl_percent - cast as float + OID_INT8, // 35 ddns_ttl + OID_INT8, // 36 ddns_ttl_min + OID_INT8, // 37 ddns_ttl_max + OID_VARCHAR // 38 name }, "UPDATE_SHARED_NETWORK6", "UPDATE dhcp6_shared_network SET" @@ -4278,8 +4359,12 @@ TaggedStatementArray tagged_statements = { { " cache_threshold = cast($30 as float)," " cache_max_age = $31," " allocator = $32," - " pd_allocator = $33 " - "WHERE name = $34" + " pd_allocator = $33," + " ddns_ttl_percent = cast($34 as float)," + " ddns_ttl = $35," + " ddns_ttl_min = $36," + " ddns_ttl_max = $37 " + "WHERE name = $38" }, // Update existing option definition. diff --git a/src/hooks/dhcp/pgsql/pgsql_query_macros_dhcp.h b/src/hooks/dhcp/pgsql/pgsql_query_macros_dhcp.h index 172c3b0ac5..4afa396059 100644 --- a/src/hooks/dhcp/pgsql/pgsql_query_macros_dhcp.h +++ b/src/hooks/dhcp/pgsql/pgsql_query_macros_dhcp.h @@ -120,6 +120,10 @@ namespace { " s.cache_max_age," \ " s.offer_lifetime," \ " s.allocator," \ + " s.ddns_ttl_percent," \ + " s.ddns_ttl," \ + " s.ddns_ttl_min," \ + " s.ddns_ttl_max," \ " srv.tag " \ "FROM dhcp4_subnet AS s " \ server_join \ @@ -256,6 +260,10 @@ namespace { " s.cache_max_age," \ " s.allocator," \ " s.pd_allocator," \ + " s.ddns_ttl_percent," \ + " s.ddns_ttl," \ + " s.ddns_ttl_min," \ + " s.ddns_ttl_max," \ " srv.tag " \ "FROM dhcp6_subnet AS s " \ server_join \ @@ -474,6 +482,10 @@ namespace { " n.cache_max_age," \ " n.offer_lifetime," \ " n.allocator," \ + " n.ddns_ttl_percent," \ + " n.ddns_ttl," \ + " n.ddns_ttl_min," \ + " n.ddns_ttl_max," \ " s.tag " \ "FROM dhcp4_shared_network AS n " \ server_join \ @@ -558,6 +570,10 @@ namespace { " n.cache_max_age," \ " n.allocator," \ " n.pd_allocator," \ + " n.ddns_ttl_percent," \ + " n.ddns_ttl," \ + " n.ddns_ttl_min," \ + " n.ddns_ttl_max," \ " s.tag " \ "FROM dhcp6_shared_network AS n " \ server_join \ |