Parcourir la source

[4204] Runtime option definitions held in the libdhcp++ library.

Marcin Siodelski il y a 9 ans
Parent
commit
b6beda2888

+ 0 - 1
src/bin/dhcp4/json_config_parser.cc

@@ -22,7 +22,6 @@
 #include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/parsers/client_class_def_parser.h>
 #include <dhcp4/json_config_parser.h>
-#include <dhcpsrv/option_space_container.h>
 #include <dhcpsrv/parsers/dbaccess_parser.h>
 #include <dhcpsrv/parsers/dhcp_parsers.h>
 #include <dhcpsrv/parsers/expiration_config_parser.h>

+ 1 - 0
src/lib/dhcp/Makefile.am

@@ -43,6 +43,7 @@ libkea_dhcp___la_SOURCES += option_data_types.cc option_data_types.h
 libkea_dhcp___la_SOURCES += option_definition.cc option_definition.h
 libkea_dhcp___la_SOURCES += option_opaque_data_tuples.cc option_opaque_data_tuples.h
 libkea_dhcp___la_SOURCES += option_space.cc option_space.h
+libkea_dhcp___la_SOURCES += option_space_container.h
 libkea_dhcp___la_SOURCES += option_string.cc option_string.h
 libkea_dhcp___la_SOURCES += protocol_util.cc protocol_util.h
 libkea_dhcp___la_SOURCES += pkt.cc pkt.h

+ 15 - 0
src/lib/dhcp/libdhcp++.cc

@@ -52,6 +52,10 @@ VendorOptionDefContainers LibDHCP::vendor4_defs_;
 
 VendorOptionDefContainers LibDHCP::vendor6_defs_;
 
+// Static container with option definitions created in runtime.
+OptionDefSpaceContainer LibDHCP::runtime_option_defs_;
+
+
 // Those two vendor classes are used for cable modems:
 
 /// DOCSIS3.0 compatible cable modem
@@ -194,6 +198,17 @@ LibDHCP::getVendorOptionDef(const Option::Universe u, const uint32_t vendor_id,
     return (OptionDefinitionPtr());
 }
 
+void
+LibDHCP::setRuntimeOptionDefs(const OptionDefSpaceContainer& defs) {
+    
+}
+
+void
+LibDHCP::clearRuntimeOptionDefs() {
+    runtime_option_defs_.clearItems();
+}
+
+
 bool
 LibDHCP::isStandardOption(const Option::Universe u, const uint16_t code) {
     if (u == Option::V6) {

+ 19 - 0
src/lib/dhcp/libdhcp++.h

@@ -16,6 +16,7 @@
 #define LIBDHCP_H
 
 #include <dhcp/option_definition.h>
+#include <dhcp/option_space_container.h>
 #include <dhcp/pkt6.h>
 #include <util/buffer.h>
 
@@ -256,6 +257,21 @@ public:
                                        const OptionBuffer& buf,
                                        isc::dhcp::OptionCollection& options);
 
+
+    /// @brief Copies option definitions created at runtime.
+    ///
+    /// Copied option definitions will be used as "runtime" option definitions.
+    /// A typical use case is to set option definitions specified by the user
+    /// in the server configuration. These option definitions should be removed
+    /// or replaced with new option definitions upon reconfiguration.
+    ///
+    /// @param defs Const reference to a container holding option definitions
+    /// grouped by option spaces.
+    static void setRuntimeOptionDefs(const OptionDefSpaceContainer& defs);
+
+    /// @brief Removes runtime option definitions.
+    static void clearRuntimeOptionDefs();
+
 private:
 
     /// Initialize standard DHCPv4 option definitions.
@@ -301,6 +317,9 @@ private:
 
     /// Container for v6 vendor option definitions
     static VendorOptionDefContainers vendor6_defs_;
+
+    /// Container for additional option defnitions created in runtime.
+    static OptionDefSpaceContainer runtime_option_defs_;
 };
 
 }

+ 5 - 0
src/lib/dhcp/option_definition.h

@@ -17,6 +17,7 @@
 
 #include <dhcp/option.h>
 #include <dhcp/option_data_types.h>
+#include <dhcp/option_space_container.h>
 
 #include <boost/multi_index/hashed_index.hpp>
 #include <boost/multi_index/mem_fun.hpp>
@@ -766,6 +767,10 @@ typedef OptionDefContainer::nth_index<2>::type OptionDefContainerNameIndex;
 typedef std::pair<OptionDefContainerNameIndex::const_iterator,
                   OptionDefContainerNameIndex::const_iterator> OptionDefContainerNameRange;
 
+typedef OptionSpaceContainer<
+    OptionDefContainer, OptionDefinitionPtr, std::string
+> OptionDefSpaceContainer;
+
 
 } // namespace isc::dhcp
 } // namespace isc

src/lib/dhcpsrv/option_space_container.h → src/lib/dhcp/option_space_container.h


+ 0 - 1
src/lib/dhcpsrv/Makefile.am

@@ -128,7 +128,6 @@ libkea_dhcpsrv_la_SOURCES += ncr_generator.cc ncr_generator.h
 if HAVE_PGSQL
 libkea_dhcpsrv_la_SOURCES += pgsql_lease_mgr.cc pgsql_lease_mgr.h
 endif
-libkea_dhcpsrv_la_SOURCES += option_space_container.h
 libkea_dhcpsrv_la_SOURCES += pool.cc pool.h
 libkea_dhcpsrv_la_SOURCES += srv_config.cc srv_config.h
 libkea_dhcpsrv_la_SOURCES += subnet.cc subnet.h

+ 1 - 1
src/lib/dhcpsrv/cfg_option.h

@@ -16,8 +16,8 @@
 #define CFG_OPTION_H
 
 #include <dhcp/option.h>
+#include <dhcp/option_space_container.h>
 #include <dhcpsrv/key_from_key.h>
-#include <dhcpsrv/option_space_container.h>
 #include <boost/multi_index_container.hpp>
 #include <boost/multi_index/hashed_index.hpp>
 #include <boost/multi_index/sequenced_index.hpp>

+ 1 - 1
src/lib/dhcpsrv/cfg_option_def.h

@@ -16,7 +16,7 @@
 #define CFG_OPTION_DEF_H
 
 #include <dhcp/option_definition.h>
-#include <dhcpsrv/option_space_container.h>
+#include <dhcp/option_space_container.h>
 #include <string>
 
 namespace isc {

+ 1 - 7
src/lib/dhcpsrv/parsers/dhcp_parsers.h

@@ -18,10 +18,10 @@
 #include <asiolink/io_address.h>
 #include <cc/data.h>
 #include <dhcp/option_definition.h>
+#include <dhcp/option_space_container.h>
 #include <dhcpsrv/d2_client_cfg.h>
 #include <dhcpsrv/cfg_iface.h>
 #include <dhcpsrv/cfg_option.h>
-#include <dhcpsrv/option_space_container.h>
 #include <dhcpsrv/subnet.h>
 #include <dhcpsrv/parsers/dhcp_config_parser.h>
 #include <exceptions/exceptions.h>
@@ -36,12 +36,6 @@
 namespace isc {
 namespace dhcp {
 
-/// @brief Storage for option definitions.
-typedef OptionSpaceContainer<OptionDefContainer,
-    OptionDefinitionPtr, std::string> OptionDefStorage;
-/// @brief Shared pointer to option definitions storage.
-typedef boost::shared_ptr<OptionDefStorage> OptionDefStoragePtr;
-
 /// Collection of containers holding option spaces. Each container within
 /// a particular option space holds so-called option descriptors.
 typedef OptionSpaceContainer<OptionContainer, OptionDescriptor,

+ 1 - 1
src/lib/dhcpsrv/subnet.h

@@ -18,8 +18,8 @@
 #include <asiolink/io_address.h>
 #include <dhcp/option.h>
 #include <dhcp/classify.h>
+#include <dhcp/option_space_container.h>
 #include <dhcpsrv/cfg_option.h>
-#include <dhcpsrv/option_space_container.h>
 #include <dhcpsrv/pool.h>
 #include <dhcpsrv/triplet.h>
 #include <dhcpsrv/lease.h>