From: Marcin Siodelski Date: Wed, 26 Nov 2014 19:41:05 +0000 (+0100) Subject: [3628] Added configuration parser for host reservations list. X-Git-Tag: kea-eng-20141219~5^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3e92bbdfd08d976b3a1622c13fe2ea621d72f239;p=thirdparty%2Fkea.git [3628] Added configuration parser for host reservations list. --- diff --git a/src/lib/dhcpsrv/Makefile.am b/src/lib/dhcpsrv/Makefile.am index c85f83a4a9..96c8ecf455 100644 --- a/src/lib/dhcpsrv/Makefile.am +++ b/src/lib/dhcpsrv/Makefile.am @@ -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 index 0000000000..40c4cc3dad --- /dev/null +++ b/src/lib/dhcpsrv/parsers/host_reservations_list_parser.h @@ -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 +#include +#include + +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 + 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