]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3628] Added configuration parser for host reservations list.
authorMarcin Siodelski <marcin@isc.org>
Wed, 26 Nov 2014 19:41:05 +0000 (20:41 +0100)
committerMarcin Siodelski <marcin@isc.org>
Wed, 26 Nov 2014 19:41:05 +0000 (20:41 +0100)
src/lib/dhcpsrv/Makefile.am
src/lib/dhcpsrv/parsers/host_reservations_list_parser.h [new file with mode: 0644]

index c85f83a4a9f1a4e9bcc1c929917b4b4af89d185c..96c8ecf45556bb3e5676aaf33d012d4a50cad1c8 100644 (file)
@@ -26,6 +26,7 @@ EXTRA_DIST =
 EXTRA_DIST += dbaccess_parser.cc dbaccess_parser.h
 EXTRA_DIST += dhcp_parsers.cc dhcp_parsers.h
 EXTRA_DIST += host_reservation_parser.cc host_reservation_parser.h
+EXTRA_DIST += host_reservations_list_parser.h
 
 # Define rule to build logging source files from message file
 dhcpsrv_messages.h dhcpsrv_messages.cc: s-messages
@@ -105,6 +106,8 @@ libkea_dhcpsrv_la_SOURCES += parsers/dhcp_parsers.cc
 libkea_dhcpsrv_la_SOURCES += parsers/dhcp_parsers.h
 libkea_dhcpsrv_la_SOURCES += parsers/host_reservation_parser.cc
 libkea_dhcpsrv_la_SOURCES += parsers/host_reservation_parser.h
+libkea_dhcpsrv_la_SOURCES += parsers/host_reservations_list_parser.h
+
 
 nodist_libkea_dhcpsrv_la_SOURCES = dhcpsrv_messages.h dhcpsrv_messages.cc
 
diff --git a/src/lib/dhcpsrv/parsers/host_reservations_list_parser.h b/src/lib/dhcpsrv/parsers/host_reservations_list_parser.h
new file mode 100644 (file)
index 0000000..40c4cc3
--- /dev/null
@@ -0,0 +1,65 @@
+// Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef HOST_RESERVATIONS_LIST_PARSER_H
+#define HOST_RESERVATIONS_LIST_PARSER_H
+
+#include <dhcpsrv/subnet_id.h>
+#include <dhcpsrv/parsers/dhcp_config_parser.h>
+#include <boost/foreach.hpp>
+
+namespace isc {
+namespace dhcp {
+
+/// @brief Parser for a list of host reservations for a subnet.
+class HostReservationsListParser : public DhcpConfigParser {
+public:
+
+    /// @brief Constructor.
+    ///
+    /// @param subnet_id Identifier of the subnet to which the reservations
+    /// belong.
+    HostReservationsListParser(const SubnetID& subnet_id)
+        : subnet_id_(subnet_id) {
+    }
+
+    /// @brief Parses a list of host reservation entries for a subnet.
+    ///
+    /// @param hr_list Data element holding a list of host reservations.
+    /// Each host reservation is described by a map object.
+    ///
+    /// @throw DhcpConfigError If the configuration if any of the reservations
+    /// is invalid.
+    template<typename HostReservationParserType>
+    virtual void build(isc::data::ConstElementPtr hr_list) {
+        BOOST_FOREACH(ConstElementPtr reservation, hr_list->listValue()) {
+            ParserPtr parser(new HostReservationParserType(subnet_id_));
+            parser->build(reservation);
+        }
+    }
+
+    /// @brief Commit, unused.
+    virtual void commit() { }
+
+private:
+
+    /// @brief Identifier of the subnet to whic the reservations belong.
+    SubnetID subnet_id_;
+
+};
+
+}
+}
+
+#endif // HOST_RESERVATIONS_LIST_PARSER_H