]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4204] Runtime option definitions held in the libdhcp++ library.
authorMarcin Siodelski <marcin@isc.org>
Fri, 20 Nov 2015 13:25:18 +0000 (14:25 +0100)
committerMarcin Siodelski <marcin@isc.org>
Mon, 23 Nov 2015 12:33:04 +0000 (13:33 +0100)
src/bin/dhcp4/json_config_parser.cc
src/lib/dhcp/Makefile.am
src/lib/dhcp/libdhcp++.cc
src/lib/dhcp/libdhcp++.h
src/lib/dhcp/option_definition.h
src/lib/dhcp/option_space_container.h [moved from src/lib/dhcpsrv/option_space_container.h with 100% similarity]
src/lib/dhcpsrv/Makefile.am
src/lib/dhcpsrv/cfg_option.h
src/lib/dhcpsrv/cfg_option_def.h
src/lib/dhcpsrv/parsers/dhcp_parsers.h
src/lib/dhcpsrv/subnet.h

index d9c381e33c11c5460021f5c4c9f291aacf61f88b..8b6a7192541165dc1a0679e7e7f8158d70884f94 100644 (file)
@@ -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>
index b892192b9ccf61637d697805c8f5c462916239f4..1e1719925bca019c284b2e173033d34dec7f46c4 100644 (file)
@@ -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
index 069f09a04a2ca22712a621d59e71486c01a8ec54..a537417f2fa2758be9368f6735c0edac92141f84 100644 (file)
@@ -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) {
index 57fac075bfe5aa17bc24608778f433fc67677d88..45fda662e4fa5b74b48bff772d4dc5e8ef845926 100644 (file)
@@ -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_;
 };
 
 }
index 04a9693b54d7af26820e55cb7867b757f35f96ca..d1e548e72bff1fb602128cbde638e9911e6ff84c 100644 (file)
@@ -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
index 151fb574c59efcdfcab2aaf17338feb81ef5599b..b140c7e48f00509839031782d3a1d396b36e026a 100644 (file)
@@ -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
index 4dad5b4ca31e2479aa9e121667299baabc17f547..0b599aaceaca27c22c58415ac497fdd16006dd38 100644 (file)
@@ -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>
index 81850e87389873fe96229e7bbdf02a7760aa260c..413cf9365c88a01c01dab274a875cfe1c5c39b2e 100644 (file)
@@ -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 {
index 5513d7250396537707ca70ea3ae91a4c82f5cb95..f48a0cce74d196857c503bac977c935752101e49 100644 (file)
 #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>
 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,
index 54ce6a6ee0433c81b914f8b4d1635b32f57f487d..14a6284ee0b01f4cd29fc98c3ac6a78866203bfd 100644 (file)
@@ -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>