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