Commit 3e92bbdf authored by Marcin Siodelski's avatar Marcin Siodelski

[3628] Added configuration parser for host reservations list.

parent 043dac65
......@@ -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
......
// 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment