Kea 3.1.10
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 } catch (const std::exception& ex) {
313 // known std error.
314 isc_throw(NcrMessageError, "fromFormat: buffer read error: "
315 << ex.what());
316 } catch (...) {
317 // unknown error.
318 isc_throw(NcrMessageError, "fromFormat: buffer read error: unknown error");
319 }
320
321 break;
322 }
323 default:
324 // Programmatic error, shouldn't happen.
325 isc_throw(NcrMessageError, "fromFormat - invalid format");
326 break;
327 }
328
329 return (ncr);
330}
331
332void
334 isc::util::OutputBuffer& buffer) const {
335 // Based on the format requested, invoke the appropriate format handler
336 // which will marshal this request's contents into the OutputBuffer.
337 switch (format) {
338 case FMT_JSON: {
339 // Invoke toJSON to create a JSON text of this request's contents.
340 std::string json = toJSON();
341 uint16_t length = json.size();
342
343 // Write the length of the JSON text to the OutputBuffer first, then
344 // write the JSON text itself.
345 buffer.writeUint16(length);
346 buffer.writeData(json.c_str(), length);
347 break;
348 }
349 default:
350 // Programmatic error, shouldn't happen.
351 isc_throw(NcrMessageError, "toFormat - invalid format");
352 break;
353 }
354}
355
357NameChangeRequest::fromJSON(const std::string& json) {
358 // This method leverages the existing JSON parsing provided by isc::data
359 // library. Should this prove to be a performance issue, it may be that
360 // lighter weight solution would be appropriate.
361
362 // Turn the string of JSON text into an Element set.
363 isc::data::ElementPtr elements;
364 try {
365 elements = isc::data::Element::fromJSON(json);
366 } catch (const isc::data::JSONError& ex) {
368 "Malformed NameChangeRequest JSON: " << ex.what());
369 }
370
371 // Get a map of the Elements, keyed by element name.
372 ElementMap element_map = elements->mapValue();
374
375 // Use default constructor to create a "blank" NameChangeRequest.
377
378 // For each member of NameChangeRequest, find its element in the map and
379 // call the appropriate Element-based setter. These setters may throw
380 // NcrMessageError if the given Element is the wrong type or its data
381 // content is lexically invalid. If the element is NOT found in the
382 // map, getElement will throw NcrMessageError indicating the missing
383 // member.
384 element = ncr->getElement("change-type", element_map);
385 ncr->setChangeType(element);
386
387 element = ncr->getElement("forward-change", element_map);
388 ncr->setForwardChange(element);
389
390 element = ncr->getElement("reverse-change", element_map);
391 ncr->setReverseChange(element);
392
393 element = ncr->getElement("fqdn", element_map);
394 ncr->setFqdn(element);
395
396 element = ncr->getElement("ip-address", element_map);
397 ncr->setIpAddress(element);
398
399 element = ncr->getElement("dhcid", element_map);
400 ncr->setDhcid(element);
401
402 element = ncr->getElement("lease-length", element_map);
403 ncr->setLeaseLength(element);
404
405 // conflict-resolution-mode supercedes use-conflict-resolution.
406 // Both are optional for backward compatibility. The default
407 // mode is CHECK_WITH_DHCID.
408 auto found = element_map.find("conflict-resolution-mode");
409 if (found != element_map.end()) {
410 ncr->setConflictResolutionMode(found->second);
411 } else {
412 found = element_map.find("use-conflict-resolution");
413 if (found != element_map.end()) {
414 ncr->translateUseConflictResolution(found->second);
415 } else {
416 ncr->setConflictResolutionMode(CHECK_WITH_DHCID);
417 }
418 }
419
420 // All members were in the Element set and were correct lexically. Now
421 // validate the overall content semantically. This will throw an
422 // NcrMessageError if anything is amiss.
423 ncr->validateContent();
424
425 // Everything is valid, return the new instance.
426 return (ncr);
427}
428
429std::string
431 // Create a JSON string of this request's contents. Note that this method
432 // does NOT use the isc::data library as generating the output is straight
433 // forward.
434 std::ostringstream stream;
435
436 stream << "{\"change-type\":" << getChangeType() << ","
437 << "\"forward-change\":"
438 << (isForwardChange() ? "true" : "false") << ","
439 << "\"reverse-change\":"
440 << (isReverseChange() ? "true" : "false") << ","
441 << "\"fqdn\":\"" << getFqdn() << "\","
442 << "\"ip-address\":\"" << getIpAddress() << "\","
443 << "\"dhcid\":\"" << getDhcid().toStr() << "\","
444 << "\"lease-length\":" << getLeaseLength() << ","
445 << "\"conflict-resolution-mode\":"
447 << "}";
448
449 return (stream.str());
450}
451
452void
454 //@todo This is an initial implementation which provides a minimal amount
455 // of validation. FQDN and DHCID members are all currently
456 // strings, these may be replaced with richer classes.
457 if (fqdn_ == "") {
458 isc_throw(NcrMessageError, "FQDN cannot be blank");
459 }
460
461 // Validate the DHCID.
462 if (dhcid_.getBytes().size() == 0) {
463 isc_throw(NcrMessageError, "DHCID cannot be blank");
464 }
465
466 // Ensure the request specifies at least one direction to update.
467 if (!forward_change_ && !reverse_change_) {
469 "Invalid Request, forward and reverse flags are both false");
470 }
471}
472
474NameChangeRequest::getElement(const std::string& name,
475 const ElementMap& element_map) const {
476 // Look for "name" in the element map.
477 ElementMap::const_iterator it = element_map.find(name);
478 if (it == element_map.end()) {
479 // Didn't find the element, so throw.
481 "NameChangeRequest value missing for: " << name );
482 }
483
484 // Found the element, return it.
485 return (it->second);
486}
487
488void
490 change_type_ = value;
491}
492
493void
495 long raw_value = -1;
496 try {
497 // Get the element's integer value.
498 raw_value = element->intValue();
499 } catch (const isc::data::TypeError& ex) {
500 // We expect a integer Element type, don't have one.
502 "Wrong data type for change_type: " << ex.what());
503 }
504
505 if ((raw_value != CHG_ADD) && (raw_value != CHG_REMOVE)) {
506 // Value is not a valid change type.
508 "Invalid data value for change_type: " << raw_value);
509 }
510
511 // Good to go, make the assignment.
512 setChangeType(static_cast<NameChangeType>(raw_value));
513}
514
515void
517 forward_change_ = value;
518}
519
520void
522 bool value;
523 try {
524 // Get the element's boolean value.
525 value = element->boolValue();
526 } catch (const isc::data::TypeError& ex) {
527 // We expect a boolean Element type, don't have one.
529 "Wrong data type for forward-change: " << ex.what());
530 }
531
532 // Good to go, make the assignment.
533 setForwardChange(value);
534}
535
536void
538 reverse_change_ = value;
539}
540
541void
543 bool value;
544 try {
545 // Get the element's boolean value.
546 value = element->boolValue();
547 } catch (const isc::data::TypeError& ex) {
548 // We expect a boolean Element type, don't have one.
550 "Wrong data type for reverse_change: " << ex.what());
551 }
552
553 // Good to go, make the assignment.
554 setReverseChange(value);
555}
556
557void
559 setFqdn(element->stringValue());
560}
561
562void
563NameChangeRequest::setFqdn(const std::string& value) {
564 try {
565 dns::Name tmp(value);
566 fqdn_ = tmp.toText();
567 } catch (const std::exception& ex) {
569 "Invalid FQDN value: " << value << ", reason: "
570 << ex.what());
571 }
572}
573
574void
575NameChangeRequest::setIpAddress(const std::string& value) {
576 // Validate IP Address.
577 try {
578 ip_io_address_ = isc::asiolink::IOAddress(value);
579 } catch (const isc::asiolink::IOError&) {
581 "Invalid ip address string for ip_address: " << value);
582 }
583}
584
585void
589
590void
591NameChangeRequest::setDhcid(const std::string& value) {
592 dhcid_.fromStr(value);
593}
594
595void
597 setDhcid(element->stringValue());
598}
599
600void
602 lease_length_ = value;
603}
604
605void
607 long value = -1;
608 try {
609 // Get the element's integer value.
610 value = element->intValue();
611 } catch (const isc::data::TypeError& ex) {
612 // We expect a integer Element type, don't have one.
614 "Wrong data type for lease_length: " << ex.what());
615 }
616
617 // Make sure we the range is correct and value is positive.
618 if (value > std::numeric_limits<uint32_t>::max()) {
619 isc_throw(NcrMessageError, "lease_length value " << value <<
620 "is too large for unsigned 32-bit integer.");
621 }
622 if (value < 0) {
623 isc_throw(NcrMessageError, "lease_length value " << value <<
624 "is negative. It must greater than or equal to zero ");
625 }
626
627 // Good to go, make the assignment.
628 setLeaseLength(static_cast<uint32_t>(value));
629}
630
631void
633 try {
634 bool value = element->boolValue();
636 } catch (const isc::data::TypeError& ex) {
637 // We expect a boolean Element type, don't have one.
638 isc_throw(NcrMessageError, "Wrong data type for use-conflict-resolution: "
639 << ex.what());
640 }
641}
642
643void
645 conflict_resolution_mode_ = value;
646}
647
648void
650 try {
651 // Get the element's string value.
652 auto value = StringToConflictResolutionMode(element->stringValue());
654 } catch (const isc::data::TypeError& ex) {
655 // We expect a string Element type, don't have one.
656 isc_throw(NcrMessageError, "Wrong data type for conflict-resolution-mode: "
657 << ex.what());
658 }
659}
660
661void
663 status_ = value;
664}
665
666std::string
668 std::ostringstream stream;
669
670 stream << "Type: " << static_cast<int>(change_type_) << " (";
671 switch (change_type_) {
672 case CHG_ADD:
673 stream << "CHG_ADD)\n";
674 break;
675 case CHG_REMOVE:
676 stream << "CHG_REMOVE)\n";
677 break;
678 default:
679 // Shouldn't be possible.
680 stream << "Invalid Value\n";
681 }
682
683 stream << "Forward Change: " << (forward_change_ ? "yes" : "no")
684 << std::endl
685 << "Reverse Change: " << (reverse_change_ ? "yes" : "no")
686 << std::endl
687 << "FQDN: [" << fqdn_ << "]" << std::endl
688 << "IP Address: [" << ip_io_address_ << "]" << std::endl
689 << "DHCID: [" << dhcid_.toStr() << "]" << std::endl
690 << "TTL: " << lease_length_ << std::endl
691 << "Conflict Resolution Mode: "
693 << std::endl;
694
695 return (stream.str());
696}
697
698bool
700 return ((change_type_ == other.change_type_) &&
701 (forward_change_ == other.forward_change_) &&
702 (reverse_change_ == other.reverse_change_) &&
703 (fqdn_ == other.fqdn_) &&
704 (ip_io_address_ == other.ip_io_address_) &&
705 (dhcid_ == other.dhcid_) &&
706 (lease_length_ == other.lease_length_) &&
707 (conflict_resolution_mode_ == other.conflict_resolution_mode_));
708}
709
710bool
712 return (!(*this == other));
713}
714
715} // end of isc::dhcp namespace
716} // 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:864
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:699
bool operator!=(const NameChangeRequest &b) const
Definition ncr_msg.cc:711
void setStatus(const NameChangeStatus value)
Sets the request status to the given value.
Definition ncr_msg.cc:662
void setChangeType(const NameChangeType value)
Sets the change type to the given value.
Definition ncr_msg.cc:489
std::string toText() const
Returns a text rendition of the contents of the request.
Definition ncr_msg.cc:667
void setDhcid(isc::data::ConstElementPtr element)
Sets the DHCID based on the value of the given Element.
Definition ncr_msg.cc:596
uint32_t getLeaseLength() const
Fetches the request lease length.
Definition ncr_msg.h:616
void setIpAddress(const std::string &value)
Sets the IP address to the given value.
Definition ncr_msg.cc:575
void translateUseConflictResolution(isc::data::ConstElementPtr element)
Sets the conflict resolution mode based on the value of the given boolean Element.
Definition ncr_msg.cc:632
const D2Dhcid & getDhcid() const
Fetches the request DHCID.
Definition ncr_msg.h:576
void setDhcid(const std::string &value)
Sets the DHCID based on the given string value.
Definition ncr_msg.cc:591
std::string toJSON() const
Instance method for marshalling the contents of the request into a string of JSON text.
Definition ncr_msg.cc:430
ConflictResolutionMode getConflictResolutionMode() const
Fetches the conflict resolution mode.
Definition ncr_msg.h:636
std::string getIpAddress() const
Fetches the request IP address string.
Definition ncr_msg.h:535
void setFqdn(const std::string &value)
Sets the FQDN to the given value.
Definition ncr_msg.cc:563
void setReverseChange(const bool value)
Sets the reverse change flag to the given value.
Definition ncr_msg.cc:537
void setLeaseLength(const uint32_t value)
Sets the lease length to the given value.
Definition ncr_msg.cc:601
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:333
NameChangeRequest()
Default Constructor.
Definition ncr_msg.cc:257
NameChangeType getChangeType() const
Fetches the request change type.
Definition ncr_msg.h:451
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:357
void setForwardChange(const bool value)
Sets the forward change flag to the given value.
Definition ncr_msg.cc:516
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:474
void setConflictResolutionMode(const ConflictResolutionMode value)
Sets the conflict resolution mode to the given value.
Definition ncr_msg.cc:644
bool isForwardChange() const
Checks forward change flag.
Definition ncr_msg.h:471
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:453
const std::string getFqdn() const
Fetches the request FQDN.
Definition ncr_msg.h:515
bool isReverseChange() const
Checks reverse change flag.
Definition ncr_msg.h:493
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 ...