17 #include <boost/lexical_cast.hpp>
23 : trace_scanning_(false), trace_parsing_(false),
24 option_universe_(option_universe), check_defined_(check_defined)
70 const isc::eval::location& loc)
74 n = boost::lexical_cast<int>(option_code);
75 }
catch (
const boost::bad_lexical_cast &) {
77 error(loc,
"Option code has invalid value in " + option_code);
79 if (option_universe_ == Option::V6) {
80 if (n < 0 || n > 65535) {
81 error(loc,
"Option code has invalid value in "
82 + option_code +
". Allowed range: 0..65535");
85 if (n < 0 || n > 255) {
86 error(loc,
"Option code has invalid value in "
87 + option_code +
". Allowed range: 0..255");
90 return (
static_cast<uint16_t
>(n));
95 const isc::eval::location& loc)
97 const std::string global_space = (option_universe_ == Option::V4) ?
103 option_def = LibDHCP::getRuntimeOptionDef(global_space, option_name);
107 option_def = LibDHCP::getLastResortOptionDef(global_space, option_name);
111 error(loc,
"option '" + option_name +
"' is not defined");
114 return (option_def->getCode());
119 const isc::eval::location& loc)
122 if (option_universe_ == Option::V6) {
124 error(loc,
"Nest level has invalid value in "
125 + nest_level +
". Allowed range: -32..31");
128 error(loc,
"Nest level invalid for DHCPv4 packets");
136 const isc::eval::location& loc)
140 n = boost::lexical_cast<int>(number);
141 }
catch (
const boost::bad_lexical_cast &) {
142 error(loc,
"Invalid integer value in " + number);
144 if (n < 0 || n > std::numeric_limits<uint8_t>::max()) {
145 error(loc,
"Invalid value in "
146 + number +
". Allowed range: 0..255");
149 return (
static_cast<uint8_t
>(n));
154 const isc::eval::location& loc)
158 n = boost::lexical_cast<int>(number);
159 }
catch (
const boost::bad_lexical_cast &) {
160 error(loc,
"Invalid integer value in " + number);
162 if (n < std::numeric_limits<int8_t>::min() ||
163 n > std::numeric_limits<int8_t>::max()) {
164 error(loc,
"Invalid value in "
165 + number +
". Allowed range: 0..255");
168 return (
static_cast<uint8_t
>(n));
173 const isc::eval::location& loc)
177 n = boost::lexical_cast<uint64_t>(number);
178 }
catch (
const boost::bad_lexical_cast &) {
179 error(loc,
"Invalid value in " + number);
181 if (n > std::numeric_limits<uint32_t>::max()) {
182 error(loc,
"Invalid value in "
183 + number +
". Allowed range: 0..4294967295");
186 return (
static_cast<uint32_t
>(n));
191 std::string tmp(4, 0);
192 tmp[0] = (integer >> 24) & 0xff;
193 tmp[1] = (integer >> 16) & 0xff;
194 tmp[2] = (integer >> 8) & 0xff;
195 tmp[3] = integer & 0xff;
202 return (check_defined_(client_class));