Kea 3.3.3
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 next_ncr_(NameChangeRequestPtr()) {
262}
263
265 const bool forward_change, const bool reverse_change,
266 const std::string& fqdn, const std::string& ip_address,
267 const D2Dhcid& dhcid, const uint32_t lease_length,
268 const ConflictResolutionMode conflict_resolution_mode)
269 : change_type_(change_type), forward_change_(forward_change),
270 reverse_change_(reverse_change), fqdn_(fqdn), ip_io_address_("0.0.0.0"),
271 dhcid_(dhcid), lease_length_(lease_length),
272 conflict_resolution_mode_(conflict_resolution_mode),
273 status_(ST_NEW), next_ncr_(NameChangeRequestPtr()) {
274
275 // User setter to validate fqdn.
276 setFqdn(fqdn);
277
278 // User setter to validate address.
279 setIpAddress(ip_address);
280
281 // Validate the contents. This will throw a NcrMessageError if anything
282 // is invalid.
284}
285
288 isc::util::InputBuffer& buffer) {
289 // Based on the format requested, pull the marshalled request from
290 // InputBuffer and pass it into the appropriate format-specific factory.
292 switch (format) {
293 case FMT_JSON: {
294 try {
295 // Get the length of the JSON text.
296 size_t len = buffer.readUint16();
297
298 // Read the text from the buffer into a vector.
299 std::vector<uint8_t> vec;
300 buffer.readVector(vec, len);
301
302 // Turn the vector into a string.
303 std::string string_data(vec.begin(), vec.end());
304
305 // Pass the string of JSON text into JSON factory to create the
306 // NameChangeRequest instance. Note the factory may throw
307 // NcrMessageError.
308 ncr = NameChangeRequest::fromJSON(string_data);
309 } catch (const isc::Exception& ex) {
310 // Read error accessing data in InputBuffer.
311 isc_throw(NcrMessageError, "fromFormat: buffer read error: "
312 << ex.what());
313 } catch (const std::exception& ex) {
314 // known std error.
315 isc_throw(NcrMessageError, "fromFormat: buffer read error: "
316 << ex.what());
317 } catch (...) {
318 // unknown error.
319 isc_throw(NcrMessageError, "fromFormat: buffer read error: unknown error");
320 }
321
322 break;
323 }
324 default:
325 // Programmatic error, shouldn't happen.
326 isc_throw(NcrMessageError, "fromFormat - invalid format");
327 break;
328 }
329
330 return (ncr);
331}
332
333void
335 isc::util::OutputBuffer& buffer) const {
336 // Based on the format requested, invoke the appropriate format handler
337 // which will marshal this request's contents into the OutputBuffer.
338 switch (format) {
339 case FMT_JSON: {
340 // Invoke toJSON to create a JSON text of this request's contents.
341 std::string json = toJSON();
342 uint16_t length = json.size();
343
344 // Write the length of the JSON text to the OutputBuffer first, then
345 // write the JSON text itself.
346 buffer.writeUint16(length);
347 buffer.writeData(json.c_str(), length);
348 break;
349 }
350 default:
351 // Programmatic error, shouldn't happen.
352 isc_throw(NcrMessageError, "toFormat - invalid format");
353 break;
354 }
355}
356
358NameChangeRequest::fromJSON(const std::string& json) {
359 // This method leverages the existing JSON parsing provided by isc::data
360 // library. Should this prove to be a performance issue, it may be that
361 // lighter weight solution would be appropriate.
362
363 // Turn the string of JSON text into an Element set.
364 isc::data::ElementPtr elements;
365 try {
366 elements = isc::data::Element::fromJSON(json);
367 } catch (const isc::data::JSONError& ex) {
369 "Malformed NameChangeRequest JSON: " << ex.what());
370 }
371
372 // Everything is valid, return the new instance.
373 return (fromJSON(elements));
374}
375
378 // Get a map of the Elements, keyed by element name.
379 ElementMap element_map = elements->mapValue();
381
382 // Use default constructor to create a "blank" NameChangeRequest.
384
385 // For each member of NameChangeRequest, find its element in the map and
386 // call the appropriate Element-based setter. These setters may throw
387 // NcrMessageError if the given Element is the wrong type or its data
388 // content is lexically invalid. If the element is NOT found in the
389 // map, getElement will throw NcrMessageError indicating the missing
390 // member.
391 element = ncr->getElement("change-type", element_map);
392 ncr->setChangeType(element);
393
394 element = ncr->getElement("forward-change", element_map);
395 ncr->setForwardChange(element);
396
397 element = ncr->getElement("reverse-change", element_map);
398 ncr->setReverseChange(element);
399
400 element = ncr->getElement("fqdn", element_map);
401 ncr->setFqdn(element);
402
403 element = ncr->getElement("ip-address", element_map);
404 ncr->setIpAddress(element);
405
406 element = ncr->getElement("dhcid", element_map);
407 ncr->setDhcid(element);
408
409 element = ncr->getElement("lease-length", element_map);
410 ncr->setLeaseLength(element);
411
412 // conflict-resolution-mode supercedes use-conflict-resolution.
413 // Both are optional for backward compatibility. The default
414 // mode is CHECK_WITH_DHCID.
415 auto found = element_map.find("conflict-resolution-mode");
416 if (found != element_map.end()) {
417 ncr->setConflictResolutionMode(found->second);
418 } else {
419 found = element_map.find("use-conflict-resolution");
420 if (found != element_map.end()) {
421 ncr->translateUseConflictResolution(found->second);
422 } else {
423 ncr->setConflictResolutionMode(CHECK_WITH_DHCID);
424 }
425 }
426
427 found = element_map.find("next-ncr");
428 if (found != element_map.end()) {
429 auto next_ncr = fromJSON(found->second);
430 ncr->setNextNcr(next_ncr);
431 }
432
433 // All members were in the Element set and were correct lexically. Now
434 // validate the overall content semantically. This will throw an
435 // NcrMessageError if anything is amiss.
436 ncr->validateContent();
437
438 // Everything is valid, return the new instance.
439 return (ncr);
440}
441
442std::string
444
445 // Create a JSON string of this request's contents. Note that this method
446 // does NOT use the isc::data library as generating the output is straight
447 // forward.
448 std::ostringstream stream;
449
450 stream << "{\"change-type\":" << getChangeType() << ","
451 << "\"forward-change\":"
452 << (isForwardChange() ? "true" : "false") << ","
453 << "\"reverse-change\":"
454 << (isReverseChange() ? "true" : "false") << ","
455 << "\"fqdn\":\"" << getFqdn() << "\","
456 << "\"ip-address\":\"" << getIpAddress() << "\","
457 << "\"dhcid\":\"" << getDhcid().toStr() << "\","
458 << "\"lease-length\":" << getLeaseLength() << ","
459 << "\"conflict-resolution-mode\":"
461
462 if (next_ncr_) {
463 stream << ",\"next-ncr\":" << next_ncr_->toJSON();
464 }
465
466 stream << "}";
467
468 return (stream.str());
469}
470
471void
473 //@todo This is an initial implementation which provides a minimal amount
474 // of validation. FQDN and DHCID members are all currently
475 // strings, these may be replaced with richer classes.
476 if (fqdn_ == "") {
477 isc_throw(NcrMessageError, "FQDN cannot be blank");
478 }
479
480 // Validate the DHCID.
481 if (dhcid_.getBytes().size() == 0) {
482 isc_throw(NcrMessageError, "DHCID cannot be blank");
483 }
484
485 // Ensure the request specifies at least one direction to update.
486 if (!forward_change_ && !reverse_change_) {
488 "Invalid Request, forward and reverse flags are both false");
489 }
490}
491
493NameChangeRequest::getElement(const std::string& name,
494 const ElementMap& element_map) const {
495 // Look for "name" in the element map.
496 ElementMap::const_iterator it = element_map.find(name);
497 if (it == element_map.end()) {
498 // Didn't find the element, so throw.
500 "NameChangeRequest value missing for: " << name );
501 }
502
503 // Found the element, return it.
504 return (it->second);
505}
506
507void
509 change_type_ = value;
510}
511
512void
514 long raw_value = -1;
515 try {
516 // Get the element's integer value.
517 raw_value = element->intValue();
518 } catch (const isc::data::TypeError& ex) {
519 // We expect a integer Element type, don't have one.
521 "Wrong data type for change_type: " << ex.what());
522 }
523
524 if ((raw_value != CHG_ADD) && (raw_value != CHG_REMOVE)) {
525 // Value is not a valid change type.
527 "Invalid data value for change_type: " << raw_value);
528 }
529
530 // Good to go, make the assignment.
531 setChangeType(static_cast<NameChangeType>(raw_value));
532}
533
534void
536 forward_change_ = value;
537}
538
539void
541 bool value;
542 try {
543 // Get the element's boolean value.
544 value = element->boolValue();
545 } catch (const isc::data::TypeError& ex) {
546 // We expect a boolean Element type, don't have one.
548 "Wrong data type for forward-change: " << ex.what());
549 }
550
551 // Good to go, make the assignment.
552 setForwardChange(value);
553}
554
555void
557 reverse_change_ = value;
558}
559
560void
562 bool value;
563 try {
564 // Get the element's boolean value.
565 value = element->boolValue();
566 } catch (const isc::data::TypeError& ex) {
567 // We expect a boolean Element type, don't have one.
569 "Wrong data type for reverse_change: " << ex.what());
570 }
571
572 // Good to go, make the assignment.
573 setReverseChange(value);
574}
575
576void
578 setFqdn(element->stringValue());
579}
580
581void
582NameChangeRequest::setFqdn(const std::string& value) {
583 try {
584 dns::Name tmp(value);
585 fqdn_ = tmp.toText();
586 } catch (const std::exception& ex) {
588 "Invalid FQDN value: " << value << ", reason: "
589 << ex.what());
590 }
591}
592
593void
594NameChangeRequest::setIpAddress(const std::string& value) {
595 // Validate IP Address.
596 try {
597 ip_io_address_ = isc::asiolink::IOAddress(value);
598 } catch (const isc::asiolink::IOError&) {
600 "Invalid ip address string for ip_address: " << value);
601 }
602}
603
604void
606 ip_io_address_ = value;
607}
608
609void
613
614void
615NameChangeRequest::setDhcid(const std::string& value) {
616 dhcid_.fromStr(value);
617}
618
619void
621 setDhcid(element->stringValue());
622}
623
624void
626 lease_length_ = value;
627}
628
629void
631 long value = -1;
632 try {
633 // Get the element's integer value.
634 value = element->intValue();
635 } catch (const isc::data::TypeError& ex) {
636 // We expect a integer Element type, don't have one.
638 "Wrong data type for lease_length: " << ex.what());
639 }
640
641 // Make sure we the range is correct and value is positive.
642 if (value > std::numeric_limits<uint32_t>::max()) {
643 isc_throw(NcrMessageError, "lease_length value " << value <<
644 "is too large for unsigned 32-bit integer.");
645 }
646 if (value < 0) {
647 isc_throw(NcrMessageError, "lease_length value " << value <<
648 "is negative. It must greater than or equal to zero ");
649 }
650
651 // Good to go, make the assignment.
652 setLeaseLength(static_cast<uint32_t>(value));
653}
654
655void
657 try {
658 bool value = element->boolValue();
660 } catch (const isc::data::TypeError& ex) {
661 // We expect a boolean Element type, don't have one.
662 isc_throw(NcrMessageError, "Wrong data type for use-conflict-resolution: "
663 << ex.what());
664 }
665}
666
667void
669 conflict_resolution_mode_ = value;
670}
671
672void
674 try {
675 // Get the element's string value.
676 auto value = StringToConflictResolutionMode(element->stringValue());
678 } catch (const isc::data::TypeError& ex) {
679 // We expect a string Element type, don't have one.
680 isc_throw(NcrMessageError, "Wrong data type for conflict-resolution-mode: "
681 << ex.what());
682 }
683}
684
685void
687 status_ = value;
688}
689
690std::string
692 std::ostringstream stream;
693
694 stream << "Type: " << static_cast<int>(change_type_) << " (";
695 switch (change_type_) {
696 case CHG_ADD:
697 stream << "CHG_ADD)\n";
698 break;
699 case CHG_REMOVE:
700 stream << "CHG_REMOVE)\n";
701 break;
702 default:
703 // Shouldn't be possible.
704 stream << "Invalid Value\n";
705 }
706
707 stream << "Forward Change: " << (forward_change_ ? "yes" : "no")
708 << std::endl
709 << "Reverse Change: " << (reverse_change_ ? "yes" : "no")
710 << std::endl
711 << "FQDN: [" << fqdn_ << "]" << std::endl
712 << "IP Address: [" << ip_io_address_ << "]" << std::endl
713 << "DHCID: [" << dhcid_.toStr() << "]" << std::endl
714 << "TTL: " << lease_length_ << std::endl
715 << "Conflict Resolution Mode: "
717 << std::endl;
718
719 if (next_ncr_) {
720 stream << "Next NCR:" << std::endl << next_ncr_->toText();
721 }
722
723 return (stream.str());
724}
725
726bool
728 return ((change_type_ == other.change_type_) &&
729 (forward_change_ == other.forward_change_) &&
730 (reverse_change_ == other.reverse_change_) &&
731 (fqdn_ == other.fqdn_) &&
732 (ip_io_address_ == other.ip_io_address_) &&
733 (dhcid_ == other.dhcid_) &&
734 (lease_length_ == other.lease_length_) &&
735 (conflict_resolution_mode_ == other.conflict_resolution_mode_));
736}
737
738bool
740 return (!(*this == other));
741}
742
743} // end of isc::dhcp namespace
744} // 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:865
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:117
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:42
bool operator==(const NameChangeRequest &b) const
Definition ncr_msg.cc:727
bool operator!=(const NameChangeRequest &b) const
Definition ncr_msg.cc:739
void setStatus(const NameChangeStatus value)
Sets the request status to the given value.
Definition ncr_msg.cc:686
const std::string & getFqdn() const
Fetches the request FQDN.
Definition ncr_msg.h:560
void setChangeType(const NameChangeType value)
Sets the change type to the given value.
Definition ncr_msg.cc:508
std::string toText() const
Returns a text rendition of the contents of the request.
Definition ncr_msg.cc:691
uint32_t getLeaseLength() const
Fetches the request lease length.
Definition ncr_msg.h:677
void setIpAddress(const std::string &value)
Sets the IP address to the given value.
Definition ncr_msg.cc:594
void translateUseConflictResolution(isc::data::ConstElementPtr element)
Sets the conflict resolution mode based on the value of the given boolean Element.
Definition ncr_msg.cc:656
const D2Dhcid & getDhcid() const
Fetches the request DHCID.
Definition ncr_msg.h:637
void setDhcid(const std::string &value)
Sets the DHCID based on the given string value.
Definition ncr_msg.cc:615
std::string toJSON() const
Instance method for marshalling the contents of the request into a string of JSON text.
Definition ncr_msg.cc:443
ConflictResolutionMode getConflictResolutionMode() const
Fetches the conflict resolution mode.
Definition ncr_msg.h:697
std::string getIpAddress() const
Fetches the request IP address string.
Definition ncr_msg.h:587
void setFqdn(const std::string &value)
Sets the FQDN to the given value.
Definition ncr_msg.cc:582
void setReverseChange(const bool value)
Sets the reverse change flag to the given value.
Definition ncr_msg.cc:556
void setLeaseLength(const uint32_t value)
Sets the lease length to the given value.
Definition ncr_msg.cc:625
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:334
NameChangeRequest()
Default Constructor.
Definition ncr_msg.cc:257
NameChangeType getChangeType() const
Fetches the request change type.
Definition ncr_msg.h:496
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:358
void setForwardChange(const bool value)
Sets the forward change flag to the given value.
Definition ncr_msg.cc:535
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:493
void setConflictResolutionMode(const ConflictResolutionMode value)
Sets the conflict resolution mode to the given value.
Definition ncr_msg.cc:668
bool isForwardChange() const
Checks forward change flag.
Definition ncr_msg.h:516
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:287
void validateContent()
Validates the content of a populated request.
Definition ncr_msg.cc:472
bool isReverseChange() const
Checks reverse change flag.
Definition ncr_msg.h:538
Exception thrown when NameChangeRequest marshalling error occurs.
Definition ncr_msg.h:34
The Name class encapsulates DNS names.
Definition name.h:217
std::string toText(bool omit_final_dot=false) const
Convert the Name to a string.
Definition name.cc:509
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:271
uint16_t readUint16()
Read an unsigned 16-bit integer in network byte order from the buffer, and return it.
Definition buffer.h:173
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition buffer.h:355
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:510
void writeData(const void *data, size_t len)
Copy an arbitrary length of data into the buffer.
Definition buffer.h:568
#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:63
NameChangeStatus
Defines the runtime processing status values for requests.
Definition ncr_msg.h:55
NameChangeType
Defines the types of DNS updates that can be requested.
Definition ncr_msg.h:49
@ NO_CHECK_WITHOUT_DHCID
Definition ncr_msg.h:72
@ CHECK_EXISTS_WITH_DHCID
Definition ncr_msg.h:71
@ NO_CHECK_WITH_DHCID
Definition ncr_msg.h:70
std::map< std::string, isc::data::ConstElementPtr > ElementMap
Defines a map of Elements, keyed by their string name.
Definition ncr_msg.h:248
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:245
std::string ncrFormatToString(NameChangeFormat format)
Function which converts NameChangeFormat enums to text labels.
Definition ncr_msg.cc:32
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
Definition hwaddr.h:166
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 ...