7#ifndef HOST_DATA_PARSER_H
8#define HOST_DATA_PARSER_H
12#include <boost/pointer_cast.hpp>
13#include <boost/shared_ptr.hpp>
29template<
typename ParserBase>
49 bool required =
true) {
50 uint32_t subnet_id = dhcp::SUBNET_ID_UNUSED;
51 boost::shared_ptr<isc::data::MapElement> new_map = boost::dynamic_pointer_cast<
54 for (
auto const& el : host_data->mapValue()) {
55 if (el.first ==
"subnet-id") {
58 "'subnet-id' parameter is not integer.");
61 if (el.second->intValue() < 0 ||
62 el.second->intValue() > dhcp::SUBNET_ID_MAX) {
64 "subnet-id: " << el.second->intValue()
65 <<
" is invalid," <<
" must be between 0 and "
66 << dhcp::SUBNET_ID_MAX <<
" (inclusive).");
69 subnet_id =
static_cast<uint32_t
>(el.second->intValue());
71 new_map->set(el.first, el.second);
75 if (required && (subnet_id == dhcp::SUBNET_ID_UNUSED)) {
77 "Mandatory 'subnet-id' parameter missing."
78 <<
" Use `reservation-get-by-id' or"
79 <<
" 'reservation-get-by-address' to get the list of"
80 <<
" reservations with given identifier or address.");
84 return (ParserBase::parse(subnet_id,
85 boost::dynamic_pointer_cast<const isc::data::Element>(new_map),
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
A class for parsing extended host reservation data.
isc::dhcp::HostPtr parseWithSubnet(isc::data::ConstElementPtr host_data, bool required=true)
Parser specified parameter as host reservation data.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Host > HostPtr
Pointer to the Host object.
HostDataParser< isc::dhcp::HostReservationParser6 > HostDataParser6
Parser for DHCPv4 host reservation.
HostDataParser< isc::dhcp::HostReservationParser4 > HostDataParser4
Parser for DHCPv4 host reservation.
Defines the logger used by the top-level component of kea-lfc.