66 string identifier_name;
69 auto& map = entry->mapValue();
70 for (
auto const& element : map) {
71 if ((element.first ==
"hw-address") ||
72 (element.first ==
"duid") ||
73 (element.first ==
"circuit-id") ||
74 (element.first ==
"client-id") ||
75 (element.first ==
"flex-id")) {
76 if (!identifier_name.empty()) {
78 <<
"' and '" << identifier_name
79 <<
"' are mutually exclusive");
81 identifier = element.second->stringValue();
82 identifier_name = element.first;
86 if (element.first ==
"hostname") {
87 hostname = element.second->stringValue();
91 if (element.first ==
"user-context") {
92 user_context = element.second;
98 if (identifier_name.empty()) {
104 host.reset(
new Host(identifier, identifier_name,
110 host->setContext(user_context);
114 for (
auto const& element : map) {
115 if ((element.first ==
"hw-address") ||
116 (element.first ==
"duid") ||
117 (element.first ==
"circuit-id") ||
118 (element.first ==
"client-id") ||
119 (element.first ==
"flex-id") ||
120 (element.first ==
"hostname") ||
121 (element.first ==
"user-context")) {
125 if (element.first ==
"subnet-id4") {
126 host->setIPv4SubnetID(element.second->intValue());
130 if (element.first ==
"subnet-id6") {
131 host->setIPv6SubnetID(element.second->intValue());
135 if (element.first ==
"option-data4") {
138 parser.
parse(cfg_option, element.second);
142 if (element.first ==
"option-data6") {
145 parser.
parse(cfg_option, element.second);
149 if (element.first ==
"ip-address") {
150 host->setIPv4Reservation(
IOAddress(element.second->stringValue()));
154 if (element.first ==
"next-server") {
155 host->setNextServer(
IOAddress(element.second->stringValue()));
159 if (element.first ==
"server-hostname") {
160 host->setServerHostname(element.second->stringValue());
164 if (element.first ==
"boot-file-name") {
165 host->setBootFileName(element.second->stringValue());
169 if (element.first ==
"client-classes4") {
170 auto const& classes = element.second->listValue();
171 for (
auto const& cclass : classes) {
172 host->addClientClass4(cclass->stringValue());
177 if (element.first ==
"client-classes6") {
178 auto const& classes = element.second->listValue();
179 for (
auto const& cclass : classes) {
180 host->addClientClass6(cclass->stringValue());
185 if (element.first ==
"ip-addresses") {
186 auto const& addresses = element.second->listValue();
187 for (
auto const& addr : addresses) {
188 string address = addr->stringValue();
196 if (element.first ==
"prefixes") {
197 auto& prefixes = element.second->listValue();
198 for (
auto const& pref : prefixes) {
199 string prefix = pref->stringValue();
201 size_t pos = prefix.find(
'/');
202 if (pos == string::npos) {
204 }
else if (pos > prefix.length() - 1) {
208 string preflen = prefix.substr(pos + 1);
209 len = boost::lexical_cast<unsigned>(preflen);
210 }
catch (
const boost::bad_lexical_cast&) {
222 if (element.first ==
"host-id") {
223 int64_t hid = element.second->intValue();
224 host->setHostId(
static_cast<uint64_t
>(hid));
228 if (element.first ==
"negative") {
229 host->setNegative(element.second->boolValue());
239 }
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.