Kea 3.1.7
ncr_msg.cc
Go to the documentation of this file.
1// Copyright (C) 2013-2026 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <dhcp_ddns/ncr_msg.h>
10#include <asiolink/io_address.h>
11#include <asiolink/io_error.h>
14#include <util/encode/encode.h>
15
16#include <boost/algorithm/string/predicate.hpp>
17
18#include <sstream>
19#include <limits>
20
21namespace isc {
22namespace dhcp_ddns {
23
24NameChangeFormat stringToNcrFormat(const std::string& fmt_str) {
25 if (boost::iequals(fmt_str, "JSON")) {
26 return FMT_JSON;
27 }
28
29 isc_throw(BadValue, "Invalid NameChangeRequest format: " << fmt_str);
30}
31
33 if (format == FMT_JSON) {
34 return ("JSON");
35 }
36
37 std::ostringstream stream;
38 stream << "UNKNOWN(" << format << ")";
39 return (stream.str());
40}
41
43 if (mode_str == "check-with-dhcid") {
44 return (CHECK_WITH_DHCID);
45 }
46
47 if (mode_str == "no-check-with-dhcid") {
48 return (NO_CHECK_WITH_DHCID);
49 }
50
51 if (mode_str == "check-exists-with-dhcid") {
53 }
54
55 if (mode_str == "no-check-without-dhcid") {
57 }
58
59 isc_throw(BadValue, "Invalid ConflictResolutionMode: " << mode_str);
60}
61
62std::string
64 switch (mode) {
66 return ("check-with-dhcid");
68 return ("no-check-with-dhcid");
70 return ("check-exists-with-dhcid");
72 return ("no-check-without-dhcid");
73 default:
74 break;
75 }
76
77 std::ostringstream stream;
78 stream << "unknown(" << mode << ")";
79 return (stream.str());
80}
81
82/********************************* D2Dhcid ************************************/
83
84namespace {
85
88
89
90const uint8_t DHCID_ID_HWADDR = 0x0;
92const uint8_t DHCID_ID_CLIENTID = 0x1;
94const uint8_t DHCID_ID_DUID = 0x2;
95
96}
97
100
101D2Dhcid::D2Dhcid(const std::string& data) {
102 fromStr(data);
103}
104
106 const std::vector<uint8_t>& wire_fqdn) {
107 fromHWAddr(hwaddr, wire_fqdn);
108}
109
110D2Dhcid::D2Dhcid(const std::vector<uint8_t>& clientid_data,
111 const std::vector<uint8_t>& wire_fqdn) {
112 fromClientId(clientid_data, wire_fqdn);
113}
114
116 const std::vector<uint8_t>& wire_fqdn) {
117 fromDUID(duid, wire_fqdn);
118}
119
120void
121D2Dhcid::fromStr(const std::string& data) {
122 bytes_.clear();
123 try {
125 } catch (const isc::Exception& ex) {
126 isc_throw(NcrMessageError, "Invalid data in Dhcid: " << ex.what());
127 }
128}
129
130std::string
132 return (isc::util::encode::encodeHex(bytes_));
133}
134
135void
136D2Dhcid::fromClientId(const std::vector<uint8_t>& clientid_data,
137 const std::vector<uint8_t>& wire_fqdn) {
138 // IPv4 Client ID containing a DUID looks like this in RFC4361
139 // Type IAID DUID
140 // +-----+----+----+----+----+----+----+---
141 // | 255 | i1 | i2 | i3 | i4 | d1 | d2 |...
142 // +-----+----+----+----+----+----+----+---
143 if (!clientid_data.empty() && clientid_data[0] == 255) {
144 if (clientid_data.size() <= 5) {
146 "unable to compute DHCID from client identifier, embedded DUID "
147 "length of: " << clientid_data.size() << ", is too short");
148 }
149 // RFC3315 states that the DUID is a type code of 2 octets followed
150 // by no more then 128 octets. So add the 5 from above and make sure
151 // the length is not too long.
152 if (clientid_data.size() > 135) {
154 "unable to compute DHCID from client identifier, embedded DUID "
155 "length of: " << clientid_data.size() << ", is too long");
156 }
157 std::vector<uint8_t>::const_iterator start = clientid_data.begin() + 5;
158 std::vector<uint8_t>::const_iterator end = clientid_data.end();
159 std::vector<uint8_t> duid(start, end);
160 createDigest(DHCID_ID_DUID, duid, wire_fqdn);
161 } else {
162 createDigest(DHCID_ID_CLIENTID, clientid_data, wire_fqdn);
163 }
164}
165
166void
168 const std::vector<uint8_t>& wire_fqdn) {
169 if (!hwaddr) {
171 "unable to compute DHCID from the HW address, "
172 "NULL pointer has been specified");
173 } else if (hwaddr->hwaddr_.empty()) {
175 "unable to compute DHCID from the HW address, "
176 "HW address is empty");
177 }
178 std::vector<uint8_t> hwaddr_data;
179 hwaddr_data.push_back(hwaddr->htype_);
180 hwaddr_data.insert(hwaddr_data.end(), hwaddr->hwaddr_.begin(),
181 hwaddr->hwaddr_.end());
182 createDigest(DHCID_ID_HWADDR, hwaddr_data, wire_fqdn);
183}
184
185void
187 const std::vector<uint8_t>& wire_fqdn) {
188
189 createDigest(DHCID_ID_DUID, duid.getDuid(), wire_fqdn);
190}
191
192void
193D2Dhcid::createDigest(const uint8_t identifier_type,
194 const std::vector<uint8_t>& identifier_data,
195 const std::vector<uint8_t>& wire_fqdn) {
196 // We get FQDN in the wire format, so we don't know if it is
197 // valid. It is caller's responsibility to make sure it is in
198 // the valid format. Here we just make sure it is not empty.
199 if (wire_fqdn.empty()) {
201 "empty FQDN used to create DHCID");
202 }
203
204 // It is a responsibility of the classes which encapsulate client
205 // identifiers, e.g. DUID, to validate the client identifier data.
206 // But let's be on the safe side and at least check that it is not
207 // empty.
208 if (identifier_data.empty()) {
210 "empty DUID used to create DHCID");
211 }
212
213 // A data buffer will be used to compute the digest.
214 std::vector<uint8_t> data = identifier_data;
215
216 // Append FQDN in the wire format.
217 data.insert(data.end(), wire_fqdn.begin(), wire_fqdn.end());
218
219 // Use the DUID and FQDN to compute the digest (see RFC4701, section 3).
220
222 try {
223 // We have checked already that the DUID and FQDN aren't empty
224 // so it is safe to assume that the data buffer is not empty.
225 cryptolink::digest(&data[0], data.size(), cryptolink::SHA256, hash);
226 } catch (const std::exception& ex) {
227 isc_throw(isc::dhcp_ddns::DhcidRdataComputeError,
228 "error while generating DHCID from DUID: "
229 << ex.what());
230 }
231
232 // The DHCID RDATA has the following structure:
233 //
234 // < identifier-type > < digest-type > < digest >
235 //
236 // where identifier type
237
238 // Let's allocate the space for the identifier-type (2 bytes) and
239 // digest-type (1 byte). This is 3 bytes all together.
240 bytes_.resize(3 + hash.getLength());
241 // Leave first byte 0 and set the second byte. Those two bytes
242 // form the identifier-type.
243 bytes_[1] = identifier_type;
244 // Third byte is always equal to 1, which specifies SHA-256 digest type.
245 bytes_[2] = 1;
246 // Now let's append the digest.
247 std::memcpy(&bytes_[3], hash.getData(), hash.getLength());
248}
249
250std::ostream&
251operator<<(std::ostream& os, const D2Dhcid& dhcid) {
252 os << dhcid.toStr();
253 return (os);
254}
255
256/**************************** NameChangeRequest ******************************/
258 : change_type_(CHG_ADD), forward_change_(false), reverse_change_(false),
259 fqdn_(""), ip_io_address_("0.0.0.0"), dhcid_(), lease_length_(0),
260 conflict_resolution_mode_(CHECK_WITH_DHCID), status_(ST_NEW) {
261}
262
264 const bool forward_change, const bool reverse_change,
265 const std::string& fqdn, const std::string& ip_address,
266 const D2Dhcid& dhcid, const uint32_t lease_length,
267 const ConflictResolutionMode conflict_resolution_mode)
268 : change_type_(change_type), forward_change_(forward_change),
269 reverse_change_(reverse_change), fqdn_(fqdn), ip_io_address_("0.0.0.0"),
270 dhcid_(dhcid), lease_length_(lease_length),
271 conflict_resolution_mode_(conflict_resolution_mode),
272 status_(ST_NEW) {
273
274 // User setter to validate fqdn.
275 setFqdn(fqdn);
276
277 // User setter to validate address.
278 setIpAddress(ip_address);
279
280 // Validate the contents. This will throw a NcrMessageError if anything
281 // is invalid.
283}
284
287 isc::util::InputBuffer& buffer) {
288 // Based on the format requested, pull the marshalled request from
289 // InputBuffer and pass it into the appropriate format-specific factory.
291 switch (format) {
292 case FMT_JSON: {
293 try {
294 // Get the length of the JSON text.
295 size_t len = buffer.readUint16();
296
297 // Read the text from the buffer into a vector.
298 std::vector<uint8_t> vec;
299 buffer.readVector(vec, len);
300
301 // Turn the vector into a string.
302 std::string string_data(vec.begin(), vec.end());
303
304 // Pass the string of JSON text into JSON factory to create the
305 // NameChangeRequest instance. Note the factory may throw
306 // NcrMessageError.
307 ncr = NameChangeRequest::fromJSON(string_data);
308 } catch (const isc::Exception& ex) {
309 // Read error accessing data in InputBuffer.
310 isc_throw(NcrMessageError, "fromFormat: buffer read error: "
311 << ex.what());
312 }
313
314 break;
315 }
316 default:
317 // Programmatic error, shouldn't happen.
318 isc_throw(NcrMessageError, "fromFormat - invalid format");
319 break;
320 }
321
322 return (ncr);
323}
324
325void
327 isc::util::OutputBuffer& buffer) const {
328 // Based on the format requested, invoke the appropriate format handler
329 // which will marshal this request's contents into the OutputBuffer.
330 switch (format) {
331 case FMT_JSON: {
332 // Invoke toJSON to create a JSON text of this request's contents.
333 std::string json = toJSON();
334 uint16_t length = json.size();
335
336 // Write the length of the JSON text to the OutputBuffer first, then
337 // write the JSON text itself.
338 buffer.writeUint16(length);
339 buffer.writeData(json.c_str(), length);
340 break;
341 }
342 default:
343 // Programmatic error, shouldn't happen.
344 isc_throw(NcrMessageError, "toFormat - invalid format");
345 break;
346 }
347}
348
350NameChangeRequest::fromJSON(const std::string& json) {
351 // This method leverages the existing JSON parsing provided by isc::data
352 // library. Should this prove to be a performance issue, it may be that
353 // lighter weight solution would be appropriate.
354
355 // Turn the string of JSON text into an Element set.
356 isc::data::ElementPtr elements;
357 try {
358 elements = isc::data::Element::fromJSON(json);
359 } catch (const isc::data::JSONError& ex) {
361 "Malformed NameChangeRequest JSON: " << ex.what());
362 }
363
364 // Get a map of the Elements, keyed by element name.
365 ElementMap element_map = elements->mapValue();
367
368 // Use default constructor to create a "blank" NameChangeRequest.
370
371 // For each member of NameChangeRequest, find its element in the map and
372 // call the appropriate Element-based setter. These setters may throw
373 // NcrMessageError if the given Element is the wrong type or its data
374 // content is lexically invalid. If the element is NOT found in the
375 // map, getElement will throw NcrMessageError indicating the missing
376 // member.
377 element = ncr->getElement("change-type", element_map);
378 ncr->setChangeType(element);
379
380 element = ncr->getElement("forward-change", element_map);
381 ncr->setForwardChange(element);
382
383 element = ncr->getElement("reverse-change", element_map);
384 ncr->setReverseChange(element);
385
386 element = ncr->getElement("fqdn", element_map);
387 ncr->setFqdn(element);
388
389 element = ncr->getElement("ip-address", element_map);
390 ncr->setIpAddress(element);
391
392 element = ncr->getElement("dhcid", element_map);
393 ncr->setDhcid(element);
394
395 element = ncr->getElement("lease-length", element_map);
396 ncr->setLeaseLength(element);
397
398 // conflict-resolution-mode supercedes use-conflict-resolution.
399 // Both are optional for backward compatibility. The default
400 // mode is CHECK_WITH_DHCID.
401 auto found = element_map.find("conflict-resolution-mode");
402 if (found != element_map.end()) {
403 ncr->setConflictResolutionMode(found->second);
404 } else {
405 found = element_map.find("use-conflict-resolution");
406 if (found != element_map.end()) {
407 ncr->translateUseConflictResolution(found->second);
408 } else {
409 ncr->setConflictResolutionMode(CHECK_WITH_DHCID);
410 }
411 }
412
413 // All members were in the Element set and were correct lexically. Now
414 // validate the overall content semantically. This will throw an
415 // NcrMessageError if anything is amiss.
416 ncr->validateContent();
417
418 // Everything is valid, return the new instance.
419 return (ncr);
420}
421
422std::string
424 // Create a JSON string of this request's contents. Note that this method
425 // does NOT use the isc::data library as generating the output is straight
426 // forward.
427 std::ostringstream stream;
428
429 stream << "{\"change-type\":" << getChangeType() << ","
430 << "\"forward-change\":"
431 << (isForwardChange() ? "true" : "false") << ","
432 << "\"reverse-change\":"
433 << (isReverseChange() ? "true" : "false") << ","
434 << "\"fqdn\":\"" << getFqdn() << "\","
435 << "\"ip-address\":\"" << getIpAddress() << "\","
436 << "\"dhcid\":\"" << getDhcid().toStr() << "\","
437 << "\"lease-length\":" << getLeaseLength() << ","
438 << "\"conflict-resolution-mode\":"
440 << "}";
441
442 return (stream.str());
443}
444
445void
447 //@todo This is an initial implementation which provides a minimal amount
448 // of validation. FQDN and DHCID members are all currently
449 // strings, these may be replaced with richer classes.
450 if (fqdn_ == "") {
451 isc_throw(NcrMessageError, "FQDN cannot be blank");
452 }
453
454 // Validate the DHCID.
455 if (dhcid_.getBytes().size() == 0) {
456 isc_throw(NcrMessageError, "DHCID cannot be blank");
457 }
458
459 // Ensure the request specifies at least one direction to update.
460 if (!forward_change_ && !reverse_change_) {
462 "Invalid Request, forward and reverse flags are both false");
463 }
464}
465
467NameChangeRequest::getElement(const std::string& name,
468 const ElementMap& element_map) const {
469 // Look for "name" in the element map.
470 ElementMap::const_iterator it = element_map.find(name);
471 if (it == element_map.end()) {
472 // Didn't find the element, so throw.
474 "NameChangeRequest value missing for: " << name );
475 }
476
477 // Found the element, return it.
478 return (it->second);
479}
480
481void
483 change_type_ = value;
484}
485
486void
488 long raw_value = -1;
489 try {
490 // Get the element's integer value.
491 raw_value = element->intValue();
492 } catch (const isc::data::TypeError& ex) {
493 // We expect a integer Element type, don't have one.
495 "Wrong data type for change_type: " << ex.what());
496 }
497
498 if ((raw_value != CHG_ADD) && (raw_value != CHG_REMOVE)) {
499 // Value is not a valid change type.
501 "Invalid data value for change_type: " << raw_value);
502 }
503
504 // Good to go, make the assignment.
505 setChangeType(static_cast<NameChangeType>(raw_value));
506}
507
508void
510 forward_change_ = value;
511}
512
513void
515 bool value;
516 try {
517 // Get the element's boolean value.
518 value = element->boolValue();
519 } catch (const isc::data::TypeError& ex) {
520 // We expect a boolean Element type, don't have one.
522 "Wrong data type for forward-change: " << ex.what());
523 }
524
525 // Good to go, make the assignment.
526 setForwardChange(value);
527}
528
529void
531 reverse_change_ = value;
532}
533
534void
536 bool value;
537 try {
538 // Get the element's boolean value.
539 value = element->boolValue();
540 } catch (const isc::data::TypeError& ex) {
541 // We expect a boolean Element type, don't have one.
543 "Wrong data type for reverse_change: " << ex.what());
544 }
545
546 // Good to go, make the assignment.
547 setReverseChange(value);
548}
549
550void
552 setFqdn(element->stringValue());
553}
554
555void
556NameChangeRequest::setFqdn(const std::string& value) {
557 try {
558 dns::Name tmp(value);
559 fqdn_ = tmp.toText();
560 } catch (const std::exception& ex) {
562 "Invalid FQDN value: " << value << ", reason: "
563 << ex.what());
564 }
565}
566
567void
568NameChangeRequest::setIpAddress(const std::string& value) {
569 // Validate IP Address.
570 try {
571 ip_io_address_ = isc::asiolink::IOAddress(value);
572 } catch (const isc::asiolink::IOError&) {
574 "Invalid ip address string for ip_address: " << value);
575 }
576}
577
578void
582
583void
584NameChangeRequest::setDhcid(const std::string& value) {
585 dhcid_.fromStr(value);
586}
587
588void
590 setDhcid(element->stringValue());
591}
592
593void
595 lease_length_ = value;
596}
597
598void
600 long value = -1;
601 try {
602 // Get the element's integer value.
603 value = element->intValue();
604 } catch (const isc::data::TypeError& ex) {
605 // We expect a integer Element type, don't have one.
607 "Wrong data type for lease_length: " << ex.what());
608 }
609
610 // Make sure we the range is correct and value is positive.
611 if (value > std::numeric_limits<uint32_t>::max()) {
612 isc_throw(NcrMessageError, "lease_length value " << value <<
613 "is too large for unsigned 32-bit integer.");
614 }
615 if (value < 0) {
616 isc_throw(NcrMessageError, "lease_length value " << value <<
617 "is negative. It must greater than or equal to zero ");
618 }
619
620 // Good to go, make the assignment.
621 setLeaseLength(static_cast<uint32_t>(value));
622}
623
624void
626 try {
627 bool value = element->boolValue();
629 } catch (const isc::data::TypeError& ex) {
630 // We expect a boolean Element type, don't have one.
631 isc_throw(NcrMessageError, "Wrong data type for use-conflict-resolution: "
632 << ex.what());
633 }
634}
635
636void
638 conflict_resolution_mode_ = value;
639}
640
641void
643 try {
644 // Get the element's string value.
645 auto value = StringToConflictResolutionMode(element->stringValue());
647 } catch (const isc::data::TypeError& ex) {
648 // We expect a string Element type, don't have one.
649 isc_throw(NcrMessageError, "Wrong data type for conflict-resolution-mode: "
650 << ex.what());
651 }
652}
653
654void
656 status_ = value;
657}
658
659std::string
661 std::ostringstream stream;
662
663 stream << "Type: " << static_cast<int>(change_type_) << " (";
664 switch (change_type_) {
665 case CHG_ADD:
666 stream << "CHG_ADD)\n";
667 break;
668 case CHG_REMOVE:
669 stream << "CHG_REMOVE)\n";
670 break;
671 default:
672 // Shouldn't be possible.
673 stream << "Invalid Value\n";
674 }
675
676 stream << "Forward Change: " << (forward_change_ ? "yes" : "no")
677 << std::endl
678 << "Reverse Change: " << (reverse_change_ ? "yes" : "no")
679 << std::endl
680 << "FQDN: [" << fqdn_ << "]" << std::endl
681 << "IP Address: [" << ip_io_address_ << "]" << std::endl
682 << "DHCID: [" << dhcid_.toStr() << "]" << std::endl
683 << "Lease Length: " << lease_length_ << std::endl
684 << "Conflict Resolution Mode: "
686 << std::endl;
687
688 return (stream.str());
689}
690
691bool
693 return ((change_type_ == other.change_type_) &&
694 (forward_change_ == other.forward_change_) &&
695 (reverse_change_ == other.reverse_change_) &&
696 (fqdn_ == other.fqdn_) &&
697 (ip_io_address_ == other.ip_io_address_) &&
698 (dhcid_ == other.dhcid_) &&
699 (lease_length_ == other.lease_length_) &&
700 (conflict_resolution_mode_ == other.conflict_resolution_mode_));
701}
702
703bool
705 return (!(*this == other));
706}
707
708} // end of isc::dhcp namespace
709} // end of isc namespace
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
static ElementPtr fromJSON(const std::string &in, bool preproc=false)
These functions will parse the given string (JSON) representation of a compound element.
Definition data.cc:859
A standard Data module exception that is thrown if a parse error is encountered when constructing an ...
Definition data.h:50
A standard Data module exception that is thrown if a function is called for an Element that has a wro...
Definition data.h:37
Holds DUID (DHCPv6 Unique Identifier)
Definition duid.h:142
const std::vector< uint8_t > & getDuid() const
Returns a const reference to the actual DUID value.
Definition duid.cc:33
Container class for handling the DHCID value within a NameChangeRequest.
Definition ncr_msg.h:113
void fromHWAddr(const isc::dhcp::HWAddrPtr &hwaddr, const std::vector< uint8_t > &wire_fqdn)
Sets the DHCID value based on the HW address and FQDN.
Definition ncr_msg.cc:167
void fromDUID(const isc::dhcp::DUID &duid, const std::vector< uint8_t > &wire_fqdn)
Sets the DHCID value based on the DUID and FQDN.
Definition ncr_msg.cc:186
D2Dhcid()
Default constructor.
Definition ncr_msg.cc:98
void fromClientId(const std::vector< uint8_t > &clientid_data, const std::vector< uint8_t > &wire_fqdn)
Sets the DHCID value based on the Client Identifier.
Definition ncr_msg.cc:136
void fromStr(const std::string &data)
Sets the DHCID value based on the given string.
Definition ncr_msg.cc:121
std::string toStr() const
Returns the DHCID value as a string of hexadecimal digits.
Definition ncr_msg.cc:131
Exception thrown when there is an error occurred during computation of the DHCID.
Definition ncr_msg.h:38
bool operator==(const NameChangeRequest &b) const
Definition ncr_msg.cc:692
bool operator!=(const NameChangeRequest &b) const
Definition ncr_msg.cc:704
void setStatus(const NameChangeStatus value)
Sets the request status to the given value.
Definition ncr_msg.cc:655
void setChangeType(const NameChangeType value)
Sets the change type to the given value.
Definition ncr_msg.cc:482
std::string toText() const
Returns a text rendition of the contents of the request.
Definition ncr_msg.cc:660
uint32_t getLeaseLength() const
Fetches the request lease length.
Definition ncr_msg.h:618
void setIpAddress(const std::string &value)
Sets the IP address to the given value.
Definition ncr_msg.cc:568
void translateUseConflictResolution(isc::data::ConstElementPtr element)
Sets the conflict resolution mode based on the value of the given boolean Element.
Definition ncr_msg.cc:625
const D2Dhcid & getDhcid() const
Fetches the request DHCID.
Definition ncr_msg.h:578
void setDhcid(const std::string &value)
Sets the DHCID based on the given string value.
Definition ncr_msg.cc:584
std::string toJSON() const
Instance method for marshalling the contents of the request into a string of JSON text.
Definition ncr_msg.cc:423
ConflictResolutionMode getConflictResolutionMode() const
Fetches the conflict resolution mode.
Definition ncr_msg.h:638
std::string getIpAddress() const
Fetches the request IP address string.
Definition ncr_msg.h:537
void setFqdn(const std::string &value)
Sets the FQDN to the given value.
Definition ncr_msg.cc:556
void setReverseChange(const bool value)
Sets the reverse change flag to the given value.
Definition ncr_msg.cc:530
void setLeaseLength(const uint32_t value)
Sets the lease length to the given value.
Definition ncr_msg.cc:594
void toFormat(const NameChangeFormat format, isc::util::OutputBuffer &buffer) const
Instance method for marshalling the contents of the request into the given buffer in the given format...
Definition ncr_msg.cc:326
NameChangeRequest()
Default Constructor.
Definition ncr_msg.cc:257
NameChangeType getChangeType() const
Fetches the request change type.
Definition ncr_msg.h:453
static NameChangeRequestPtr fromJSON(const std::string &json)
Static method for creating a NameChangeRequest from a string containing a JSON rendition of a request...
Definition ncr_msg.cc:350
void setForwardChange(const bool value)
Sets the forward change flag to the given value.
Definition ncr_msg.cc:509
isc::data::ConstElementPtr getElement(const std::string &name, const ElementMap &element_map) const
Given a name, finds and returns an element from a map of elements.
Definition ncr_msg.cc:467
void setConflictResolutionMode(const ConflictResolutionMode value)
Sets the conflict resolution mode to the given value.
Definition ncr_msg.cc:637
bool isForwardChange() const
Checks forward change flag.
Definition ncr_msg.h:473
static NameChangeRequestPtr fromFormat(const NameChangeFormat format, isc::util::InputBuffer &buffer)
Static method for creating a NameChangeRequest from a buffer containing a marshalled request in a giv...
Definition ncr_msg.cc:286
void validateContent()
Validates the content of a populated request.
Definition ncr_msg.cc:446
const std::string getFqdn() const
Fetches the request FQDN.
Definition ncr_msg.h:517
bool isReverseChange() const
Checks reverse change flag.
Definition ncr_msg.h:495
Exception thrown when NameChangeRequest marshalling error occurs.
Definition ncr_msg.h:30
The Name class encapsulates DNS names.
Definition name.h:219
std::string toText(bool omit_final_dot=false) const
Convert the Name to a string.
Definition name.cc:503
The InputBuffer class is a buffer abstraction for manipulating read-only data.
Definition buffer.h:81
void readVector(std::vector< uint8_t > &data, size_t len)
Read specified number of bytes as a vector.
Definition buffer.h:262
uint16_t readUint16()
Read an unsigned 16-bit integer in network byte order from the buffer, and return it.
Definition buffer.h:166
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition buffer.h:346
void writeUint16(uint16_t data)
Write an unsigned 16-bit integer in host byte order into the buffer in network byte order.
Definition buffer.h:501
void writeData(const void *data, size_t len)
Copy an arbitrary length of data into the buffer.
Definition buffer.h:559
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
NameChangeFormat
Defines the list of data wire formats supported.
Definition ncr_msg.h:59
NameChangeStatus
Defines the runtime processing status values for requests.
Definition ncr_msg.h:51
@ NO_CHECK_WITHOUT_DHCID
Definition ncr_msg.h:68
@ CHECK_EXISTS_WITH_DHCID
Definition ncr_msg.h:67
@ NO_CHECK_WITH_DHCID
Definition ncr_msg.h:66
std::map< std::string, isc::data::ConstElementPtr > ElementMap
Defines a map of Elements, keyed by their string name.
Definition ncr_msg.h:244
std::ostream & operator<<(std::ostream &os, const D2Dhcid &dhcid)
Definition ncr_msg.cc:251
NameChangeFormat stringToNcrFormat(const std::string &fmt_str)
Function which converts labels to NameChangeFormat enum values.
Definition ncr_msg.cc:24
ConflictResolutionMode StringToConflictResolutionMode(const std::string &mode_str)
Function which converts string to ConflictResolutionMode enum values.
Definition ncr_msg.cc:42
std::string ConflictResolutionModeToString(const ConflictResolutionMode &mode)
Function which converts ConflictResolutionMode enums to text labels.
Definition ncr_msg.cc:63
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
Definition ncr_msg.h:241
std::string ncrFormatToString(NameChangeFormat format)
Function which converts NameChangeFormat enums to text labels.
Definition ncr_msg.cc:32
NameChangeType
Defines the types of DNS updates that can be requested.
Definition ncr_msg.h:45
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
Definition hwaddr.h:154
void decodeHex(const string &encoded_str, vector< uint8_t > &output)
Decode a base16 encoded string into binary data.
Definition encode.cc:367
string encodeHex(const vector< uint8_t > &binary)
Encode binary data in the base16 format.
Definition encode.cc:361
Defines the logger used by the top-level component of kea-lfc.
This file provides the classes needed to embody, compose, and decompose DNS update requests that are ...