67 string identifier_name;
70 auto& map = entry->mapValue();
71 for (
auto const& element : map) {
72 if ((element.first ==
"hw-address") ||
73 (element.first ==
"duid") ||
74 (element.first ==
"circuit-id") ||
75 (element.first ==
"client-id") ||
76 (element.first ==
"flex-id")) {
77 if (!identifier_name.empty()) {
79 <<
"' and '" << identifier_name
80 <<
"' are mutually exclusive");
82 identifier = element.second->stringValue();
83 identifier_name = element.first;
87 if (element.first ==
"hostname") {
88 hostname = element.second->stringValue();
92 if (element.first ==
"user-context") {
93 user_context = element.second;
99 if (identifier_name.empty()) {
105 host.reset(
new Host(identifier, identifier_name,
111 host->setContext(user_context);
115 for (
auto const& element : map) {
116 if ((element.first ==
"hw-address") ||
117 (element.first ==
"duid") ||
118 (element.first ==
"circuit-id") ||
119 (element.first ==
"client-id") ||
120 (element.first ==
"flex-id") ||
121 (element.first ==
"hostname") ||
122 (element.first ==
"user-context")) {
126 if (element.first ==
"subnet-id4") {
127 host->setIPv4SubnetID(element.second->intValue());
131 if (element.first ==
"subnet-id6") {
132 host->setIPv6SubnetID(element.second->intValue());
136 if (element.first ==
"option-data4") {
139 parser.
parse(cfg_option, element.second);
143 if (element.first ==
"option-data6") {
146 parser.
parse(cfg_option, element.second);
150 if (element.first ==
"ip-address") {
151 host->setIPv4Reservation(
IOAddress(element.second->stringValue()));
155 if (element.first ==
"next-server") {
156 host->setNextServer(
IOAddress(element.second->stringValue()));
160 if (element.first ==
"server-hostname") {
161 host->setServerHostname(element.second->stringValue());
165 if (element.first ==
"boot-file-name") {
166 host->setBootFileName(element.second->stringValue());
170 if (element.first ==
"client-classes4") {
171 auto const& classes = element.second->listValue();
172 for (
auto const& cclass : classes) {
173 host->addClientClass4(cclass->stringValue());
178 if (element.first ==
"client-classes6") {
179 auto const& classes = element.second->listValue();
180 for (
auto const& cclass : classes) {
181 host->addClientClass6(cclass->stringValue());
186 if (element.first ==
"ip-addresses") {
187 auto const& addresses = element.second->listValue();
188 for (
auto const& addr : addresses) {
189 string address = addr->stringValue();
197 if (element.first ==
"prefixes") {
198 auto& prefixes = element.second->listValue();
199 for (
auto const& pref : prefixes) {
200 string prefix = pref->stringValue();
202 size_t pos = prefix.find(
'/');
203 if (pos == string::npos) {
205 }
else if (pos > prefix.length() - 1) {
209 string preflen = prefix.substr(pos + 1);
210 len = boost::lexical_cast<unsigned>(preflen);
211 }
catch (
const boost::bad_lexical_cast&) {
223 if (element.first ==
"host-id") {
224 int64_t hid = element.second->intValue();
225 host->setHostId(
static_cast<uint64_t
>(hid));
229 if (element.first ==
"negative") {
230 host->setNegative(element.second->boolValue());
240 }
catch (
const exception& ex) {
void parse(const CfgOptionPtr &cfg, isc::data::ConstElementPtr option_data_list, bool encapsulate=true)
Parses a list of options, instantiates them and stores in cfg.
dhcp::HostPtr parse(const data::ConstElementPtr &entry)
Parses Host Cache entry.