Kea 2.7.4
ncr_msg.cc
Go to the documentation of this file.
1// Copyright (C) 2013-2024 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
21
22namespace isc {
23namespace dhcp_ddns {
24
25
26NameChangeFormat stringToNcrFormat(const std::string& fmt_str) {
27 if (boost::iequals(fmt_str, "JSON")) {
28 return FMT_JSON;
29 }
30
31 isc_throw(BadValue, "Invalid NameChangeRequest format: " << fmt_str);
32}
33
34
36 if (format == FMT_JSON) {
37 return ("JSON");
38 }
39
40 std::ostringstream stream;
41 stream << "UNKNOWN(" << format << ")";
42 return (stream.str());
43}
44
46 if (mode_str == "check-with-dhcid") {
47 return (CHECK_WITH_DHCID);
48 }
49
50 if (mode_str == "no-check-with-dhcid") {
51 return (NO_CHECK_WITH_DHCID);
52 }
53
54 if (mode_str == "check-exists-with-dhcid") {
56 }
57
58 if (mode_str == "no-check-without-dhcid") {
60 }
61
62 isc_throw(BadValue, "Invalid ConflictResolutionMode: " << mode_str);
63}
64
65std::string
67 switch (mode) {
69 return ("check-with-dhcid");
71 return ("no-check-with-dhcid");
73 return ("check-exists-with-dhcid");
75 return ("no-check-without-dhcid");
76 default:
77 break;
78 }
79
80 std::ostringstream stream;
81 stream << "unknown(" << mode << ")";
82 return (stream.str());
83}
84
85/********************************* D2Dhcid ************************************/
86
87namespace {
88
91
92
93const uint8_t DHCID_ID_HWADDR = 0x0;
95const uint8_t DHCID_ID_CLIENTID = 0x1;
97const uint8_t DHCID_ID_DUID = 0x2;
98
99}
100
103
104D2Dhcid::D2Dhcid(const std::string& data) {
105 fromStr(data);
106}
107
109 const std::vector<uint8_t>& wire_fqdn) {
110 fromHWAddr(hwaddr, wire_fqdn);
111}
112
113D2Dhcid::D2Dhcid(const std::vector<uint8_t>& clientid_data,
114 const std::vector<uint8_t>& wire_fqdn) {
115 fromClientId(clientid_data, wire_fqdn);
116}
117
119 const std::vector<uint8_t>& wire_fqdn) {
120 fromDUID(duid, wire_fqdn);
121}
122
123
124void
125D2Dhcid::fromStr(const std::string& data) {
126 bytes_.clear();
127 try {
128 isc::util::encode::decodeHex(data, bytes_);
129 } catch (const isc::Exception& ex) {
130 isc_throw(NcrMessageError, "Invalid data in Dhcid: " << ex.what());
131 }
132}
133
134std::string
136 return (isc::util::encode::encodeHex(bytes_));
137}
138
139void
140D2Dhcid::fromClientId(const std::vector<uint8_t>& clientid_data,
141 const std::vector<uint8_t>& wire_fqdn) {
142 // IPv4 Client ID containing a DUID looks like this in RFC4361
143 // Type IAID DUID
144 // +-----+----+----+----+----+----+----+---
145 // | 255 | i1 | i2 | i3 | i4 | d1 | d2 |...
146 // +-----+----+----+----+----+----+----+---
147 if (!clientid_data.empty() && clientid_data[0] == 255) {
148 if (clientid_data.size() <= 5) {
150 "unable to compute DHCID from client identifier, embedded DUID "
151 "length of: " << clientid_data.size() << ", is too short");
152 }
153 // RFC3315 states that the DUID is a type code of 2 octets followed
154 // by no more then 128 octets. So add the 5 from above and make sure
155 // the length is not too long.
156 if (clientid_data.size() > 135) {
158 "unable to compute DHCID from client identifier, embedded DUID "
159 "length of: " << clientid_data.size() << ", is too long");
160 }
161 std::vector<uint8_t>::const_iterator start = clientid_data.begin() + 5;
162 std::vector<uint8_t>::const_iterator end = clientid_data.end();
163 std::vector<uint8_t> duid(start, end);
164 createDigest(DHCID_ID_DUID, duid, wire_fqdn);
165 } else {
166 createDigest(DHCID_ID_CLIENTID, clientid_data, wire_fqdn);
167 }
168}
169
170void
172 const std::vector<uint8_t>& wire_fqdn) {
173 if (!hwaddr) {
175 "unable to compute DHCID from the HW address, "
176 "NULL pointer has been specified");
177 } else if (hwaddr->hwaddr_.empty()) {
179 "unable to compute DHCID from the HW address, "
180 "HW address is empty");
181 }
182 std::vector<uint8_t> hwaddr_data;
183 hwaddr_data.push_back(hwaddr->htype_);
184 hwaddr_data.insert(hwaddr_data.end(), hwaddr->hwaddr_.begin(),
185 hwaddr->hwaddr_.end());
186 createDigest(DHCID_ID_HWADDR, hwaddr_data, wire_fqdn);
187}
188
189
190void
192 const std::vector<uint8_t>& wire_fqdn) {
193
194 createDigest(DHCID_ID_DUID, duid.getDuid(), wire_fqdn);
195}
196
197void
198D2Dhcid::createDigest(const uint8_t identifier_type,
199 const std::vector<uint8_t>& identifier_data,
200 const std::vector<uint8_t>& wire_fqdn) {
201 // We get FQDN in the wire format, so we don't know if it is
202 // valid. It is caller's responsibility to make sure it is in
203 // the valid format. Here we just make sure it is not empty.
204 if (wire_fqdn.empty()) {
206 "empty FQDN used to create DHCID");
207 }
208
209 // It is a responsibility of the classes which encapsulate client
210 // identifiers, e.g. DUID, to validate the client identifier data.
211 // But let's be on the safe side and at least check that it is not
212 // empty.
213 if (identifier_data.empty()) {
215 "empty DUID used to create DHCID");
216 }
217
218 // A data buffer will be used to compute the digest.
219 std::vector<uint8_t> data = identifier_data;
220
221 // Append FQDN in the wire format.
222 data.insert(data.end(), wire_fqdn.begin(), wire_fqdn.end());
223
224 // Use the DUID and FQDN to compute the digest (see RFC4701, section 3).
225
227 try {
228 // We have checked already that the DUID and FQDN aren't empty
229 // so it is safe to assume that the data buffer is not empty.
230 cryptolink::digest(&data[0], data.size(), cryptolink::SHA256, hash);
231 } catch (const std::exception& ex) {
233 "error while generating DHCID from DUID: "
234 << ex.what());
235 }
236
237 // The DHCID RDATA has the following structure:
238 //
239 // < identifier-type > < digest-type > < digest >
240 //
241 // where identifier type
242
243 // Let's allocate the space for the identifier-type (2 bytes) and
244 // digest-type (1 byte). This is 3 bytes all together.
245 bytes_.resize(3 + hash.getLength());
246 // Leave first byte 0 and set the second byte. Those two bytes
247 // form the identifier-type.
248 bytes_[1] = identifier_type;
249 // Third byte is always equal to 1, which specifies SHA-256 digest type.
250 bytes_[2] = 1;
251 // Now let's append the digest.
252 std::memcpy(&bytes_[3], hash.getData(), hash.getLength());
253}
254
255std::ostream&
256operator<<(std::ostream& os, const D2Dhcid& dhcid) {
257 os << dhcid.toStr();
258 return (os);
259}
260
261
262
263/**************************** NameChangeRequest ******************************/
264
266 : change_type_(CHG_ADD), forward_change_(false),
267 reverse_change_(false), fqdn_(""), ip_io_address_("0.0.0.0"),
268 dhcid_(), lease_expires_on_(), lease_length_(0),
269 conflict_resolution_mode_(CHECK_WITH_DHCID),
270 status_(ST_NEW) {
271}
272
274 const bool forward_change, const bool reverse_change,
275 const std::string& fqdn, const std::string& ip_address,
276 const D2Dhcid& dhcid,
277 const uint64_t lease_expires_on,
278 const uint32_t lease_length,
279 const ConflictResolutionMode conflict_resolution_mode)
280 : change_type_(change_type), forward_change_(forward_change),
281 reverse_change_(reverse_change), fqdn_(fqdn), ip_io_address_("0.0.0.0"),
282 dhcid_(dhcid), lease_expires_on_(lease_expires_on),
283 lease_length_(lease_length),
284 conflict_resolution_mode_(conflict_resolution_mode),
285 status_(ST_NEW) {
286
287 // User setter to validate fqdn.
288 setFqdn(fqdn);
289
290 // User setter to validate address.
291 setIpAddress(ip_address);
292
293 // Validate the contents. This will throw a NcrMessageError if anything
294 // is invalid.
296}
297
300 isc::util::InputBuffer& buffer) {
301 // Based on the format requested, pull the marshalled request from
302 // InputBuffer and pass it into the appropriate format-specific factory.
304 switch (format) {
305 case FMT_JSON: {
306 try {
307 // Get the length of the JSON text.
308 size_t len = buffer.readUint16();
309
310 // Read the text from the buffer into a vector.
311 std::vector<uint8_t> vec;
312 buffer.readVector(vec, len);
313
314 // Turn the vector into a string.
315 std::string string_data(vec.begin(), vec.end());
316
317 // Pass the string of JSON text into JSON factory to create the
318 // NameChangeRequest instance. Note the factory may throw
319 // NcrMessageError.
320 ncr = NameChangeRequest::fromJSON(string_data);
321 } catch (const isc::Exception& ex) {
322 // Read error accessing data in InputBuffer.
323 isc_throw(NcrMessageError, "fromFormat: buffer read error: "
324 << ex.what());
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 // Get a map of the Elements, keyed by element name.
378 ElementMap element_map = elements->mapValue();
380
381 // Use default constructor to create a "blank" NameChangeRequest.
383
384 // For each member of NameChangeRequest, find its element in the map and
385 // call the appropriate Element-based setter. These setters may throw
386 // NcrMessageError if the given Element is the wrong type or its data
387 // content is lexically invalid. If the element is NOT found in the
388 // map, getElement will throw NcrMessageError indicating the missing
389 // member.
390 element = ncr->getElement("change-type", element_map);
391 ncr->setChangeType(element);
392
393 element = ncr->getElement("forward-change", element_map);
394 ncr->setForwardChange(element);
395
396 element = ncr->getElement("reverse-change", element_map);
397 ncr->setReverseChange(element);
398
399 element = ncr->getElement("fqdn", element_map);
400 ncr->setFqdn(element);
401
402 element = ncr->getElement("ip-address", element_map);
403 ncr->setIpAddress(element);
404
405 element = ncr->getElement("dhcid", element_map);
406 ncr->setDhcid(element);
407
408 element = ncr->getElement("lease-expires-on", element_map);
409 ncr->setLeaseExpiresOn(element);
410
411 element = ncr->getElement("lease-length", element_map);
412 ncr->setLeaseLength(element);
413
414 // conflict-resolution-mode supercedes use-conflict-resolution.
415 // Both are optional for backward compatibility. The default
416 // mode is CHECK_WITH_DHCID.
417 auto found = element_map.find("conflict-resolution-mode");
418 if (found != element_map.end()) {
419 ncr->setConflictResolutionMode(found->second);
420 } else {
421 found = element_map.find("use-conflict-resolution");
422 if (found != element_map.end()) {
423 ncr->translateUseConflictResolution(found->second);
424 } else {
425 ncr->setConflictResolutionMode(CHECK_WITH_DHCID);
426 }
427 }
428
429 // All members were in the Element set and were correct lexically. Now
430 // validate the overall content semantically. This will throw an
431 // NcrMessageError if anything is amiss.
432 ncr->validateContent();
433
434 // Everything is valid, return the new instance.
435 return (ncr);
436}
437
438std::string
440 // Create a JSON string of this request's contents. Note that this method
441 // does NOT use the isc::data library as generating the output is straight
442 // forward.
443 std::ostringstream stream;
444
445 stream << "{\"change-type\":" << getChangeType() << ","
446 << "\"forward-change\":"
447 << (isForwardChange() ? "true" : "false") << ","
448 << "\"reverse-change\":"
449 << (isReverseChange() ? "true" : "false") << ","
450 << "\"fqdn\":\"" << getFqdn() << "\","
451 << "\"ip-address\":\"" << getIpAddress() << "\","
452 << "\"dhcid\":\"" << getDhcid().toStr() << "\","
453 << "\"lease-expires-on\":\"" << getLeaseExpiresOnStr() << "\","
454 << "\"lease-length\":" << getLeaseLength() << ","
455 << "\"conflict-resolution-mode\":"
457 << "}";
458
459 return (stream.str());
460}
461
462
463void
465 //@todo This is an initial implementation which provides a minimal amount
466 // of validation. FQDN and DHCID members are all currently
467 // strings, these may be replaced with richer classes.
468 if (fqdn_ == "") {
469 isc_throw(NcrMessageError, "FQDN cannot be blank");
470 }
471
472 // Validate the DHCID.
473 if (dhcid_.getBytes().size() == 0) {
474 isc_throw(NcrMessageError, "DHCID cannot be blank");
475 }
476
477 // Ensure the request specifies at least one direction to update.
478 if (!forward_change_ && !reverse_change_) {
480 "Invalid Request, forward and reverse flags are both false");
481 }
482}
483
485NameChangeRequest::getElement(const std::string& name,
486 const ElementMap& element_map) const {
487 // Look for "name" in the element map.
488 ElementMap::const_iterator it = element_map.find(name);
489 if (it == element_map.end()) {
490 // Didn't find the element, so throw.
492 "NameChangeRequest value missing for: " << name );
493 }
494
495 // Found the element, return it.
496 return (it->second);
497}
498
499void
501 change_type_ = value;
502}
503
504
505void
507 long raw_value = -1;
508 try {
509 // Get the element's integer value.
510 raw_value = element->intValue();
511 } catch (const isc::data::TypeError& ex) {
512 // We expect a integer Element type, don't have one.
514 "Wrong data type for change_type: " << ex.what());
515 }
516
517 if ((raw_value != CHG_ADD) && (raw_value != CHG_REMOVE)) {
518 // Value is not a valid change type.
520 "Invalid data value for change_type: " << raw_value);
521 }
522
523 // Good to go, make the assignment.
524 setChangeType(static_cast<NameChangeType>(raw_value));
525}
526
527void
529 forward_change_ = value;
530}
531
532void
534 bool value;
535 try {
536 // Get the element's boolean value.
537 value = element->boolValue();
538 } catch (const isc::data::TypeError& ex) {
539 // We expect a boolean Element type, don't have one.
541 "Wrong data type for forward-change: " << ex.what());
542 }
543
544 // Good to go, make the assignment.
545 setForwardChange(value);
546}
547
548void
550 reverse_change_ = value;
551}
552
553void
555 bool value;
556 try {
557 // Get the element's boolean value.
558 value = element->boolValue();
559 } catch (const isc::data::TypeError& ex) {
560 // We expect a boolean Element type, don't have one.
562 "Wrong data type for reverse_change: " << ex.what());
563 }
564
565 // Good to go, make the assignment.
566 setReverseChange(value);
567}
568
569
570void
572 setFqdn(element->stringValue());
573}
574
575void
576NameChangeRequest::setFqdn(const std::string& value) {
577 try {
578 dns::Name tmp(value);
579 fqdn_ = tmp.toText();
580 } catch (const std::exception& ex) {
582 "Invalid FQDN value: " << value << ", reason: "
583 << ex.what());
584 }
585}
586
587void
588NameChangeRequest::setIpAddress(const std::string& value) {
589 // Validate IP Address.
590 try {
591 ip_io_address_ = isc::asiolink::IOAddress(value);
592 } catch (const isc::asiolink::IOError&) {
594 "Invalid ip address string for ip_address: " << value);
595 }
596}
597
598void
602
603
604void
605NameChangeRequest::setDhcid(const std::string& value) {
606 dhcid_.fromStr(value);
607}
608
609void
611 setDhcid(element->stringValue());
612}
613
614std::string
616 return (isc::util::timeToText64(lease_expires_on_));
617}
618
619void
620NameChangeRequest::setLeaseExpiresOn(const std::string& value) {
621 try {
622 lease_expires_on_ = isc::util::timeFromText64(value);
623 } catch (...) {
624 // We were given an invalid string, so throw.
626 "Invalid date-time string: [" << value << "]");
627 }
628
629}
630
632 // Pull out the string value and pass it into the string setter.
633 setLeaseExpiresOn(element->stringValue());
634}
635
636void
638 lease_length_ = value;
639}
640
641void
643 long value = -1;
644 try {
645 // Get the element's integer value.
646 value = element->intValue();
647 } catch (const isc::data::TypeError& ex) {
648 // We expect a integer Element type, don't have one.
650 "Wrong data type for lease_length: " << ex.what());
651 }
652
653 // Make sure we the range is correct and value is positive.
654 if (value > std::numeric_limits<uint32_t>::max()) {
655 isc_throw(NcrMessageError, "lease_length value " << value <<
656 "is too large for unsigned 32-bit integer.");
657 }
658 if (value < 0) {
659 isc_throw(NcrMessageError, "lease_length value " << value <<
660 "is negative. It must greater than or equal to zero ");
661 }
662
663 // Good to go, make the assignment.
664 setLeaseLength(static_cast<uint32_t>(value));
665}
666
667void
669 try {
670 bool value = element->boolValue();
672 } catch (const isc::data::TypeError& ex) {
673 // We expect a boolean Element type, don't have one.
674 isc_throw(NcrMessageError, "Wrong data type for use-conflict-resolution: "
675 << ex.what());
676 }
677}
678
679void
681 conflict_resolution_mode_ = value;
682}
683
684void
686 try {
687 // Get the element's string value.
688 auto value = StringToConflictResolutionMode(element->stringValue());
690 } catch (const isc::data::TypeError& ex) {
691 // We expect a string Element type, don't have one.
692 isc_throw(NcrMessageError, "Wrong data type for conflict-resolution-mode: "
693 << ex.what());
694 }
695}
696
697void
699 status_ = value;
700}
701
702std::string
704 std::ostringstream stream;
705
706 stream << "Type: " << static_cast<int>(change_type_) << " (";
707 switch (change_type_) {
708 case CHG_ADD:
709 stream << "CHG_ADD)\n";
710 break;
711 case CHG_REMOVE:
712 stream << "CHG_REMOVE)\n";
713 break;
714 default:
715 // Shouldn't be possible.
716 stream << "Invalid Value\n";
717 }
718
719 stream << "Forward Change: " << (forward_change_ ? "yes" : "no")
720 << std::endl
721 << "Reverse Change: " << (reverse_change_ ? "yes" : "no")
722 << std::endl
723 << "FQDN: [" << fqdn_ << "]" << std::endl
724 << "IP Address: [" << ip_io_address_ << "]" << std::endl
725 << "DHCID: [" << dhcid_.toStr() << "]" << std::endl
726 << "Lease Expires On: " << getLeaseExpiresOnStr() << std::endl
727 << "Lease Length: " << lease_length_ << std::endl
728 << "Conflict Resolution Mode: "
730 << std::endl;
731
732 return (stream.str());
733}
734
735bool
737 return ((change_type_ == other.change_type_) &&
738 (forward_change_ == other.forward_change_) &&
739 (reverse_change_ == other.reverse_change_) &&
740 (fqdn_ == other.fqdn_) &&
741 (ip_io_address_ == other.ip_io_address_) &&
742 (dhcid_ == other.dhcid_) &&
743 (lease_expires_on_ == other.lease_expires_on_) &&
744 (lease_length_ == other.lease_length_) &&
745 (conflict_resolution_mode_ == other.conflict_resolution_mode_));
746}
747
748bool
750 return (!(*this == other));
751}
752
753
754}; // end of isc::dhcp namespace
755}; // 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:798
A standard Data module exception that is thrown if a parse error is encountered when constructing an ...
Definition data.h:49
A standard Data module exception that is thrown if a function is called for an Element that has a wro...
Definition data.h:36
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:171
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:191
const std::vector< uint8_t > & getBytes() const
Returns a reference to the DHCID byte vector.
Definition ncr_msg.h:196
D2Dhcid()
Default constructor.
Definition ncr_msg.cc:101
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:140
void fromStr(const std::string &data)
Sets the DHCID value based on the given string.
Definition ncr_msg.cc:125
std::string toStr() const
Returns the DHCID value as a string of hexadecimal digits.
Definition ncr_msg.cc:135
Exception thrown when there is an error occurred during computation of the DHCID.
Definition ncr_msg.h:38
Represents a DHCP-DDNS client request.
Definition ncr_msg.h:254
bool operator==(const NameChangeRequest &b) const
Definition ncr_msg.cc:736
bool operator!=(const NameChangeRequest &b) const
Definition ncr_msg.cc:749
void setStatus(const NameChangeStatus value)
Sets the request status to the given value.
Definition ncr_msg.cc:698
void setChangeType(const NameChangeType value)
Sets the change type to the given value.
Definition ncr_msg.cc:500
std::string toText() const
Returns a text rendition of the contents of the request.
Definition ncr_msg.cc:703
void setDhcid(isc::data::ConstElementPtr element)
Sets the DHCID based on the value of the given Element.
Definition ncr_msg.cc:610
uint32_t getLeaseLength() const
Fetches the request lease length.
Definition ncr_msg.h:671
void setIpAddress(const std::string &value)
Sets the IP address to the given value.
Definition ncr_msg.cc:588
void translateUseConflictResolution(isc::data::ConstElementPtr element)
Sets the conflict resolution mode based on the value of the given boolean Element.
Definition ncr_msg.cc:668
const D2Dhcid & getDhcid() const
Fetches the request DHCID.
Definition ncr_msg.h:590
void setDhcid(const std::string &value)
Sets the DHCID based on the given string value.
Definition ncr_msg.cc:605
std::string toJSON() const
Instance method for marshalling the contents of the request into a string of JSON text.
Definition ncr_msg.cc:439
ConflictResolutionMode getConflictResolutionMode() const
Fetches the conflict resolution mode.
Definition ncr_msg.h:691
std::string getIpAddress() const
Fetches the request IP address string.
Definition ncr_msg.h:549
void setFqdn(const std::string &value)
Sets the FQDN to the given value.
Definition ncr_msg.cc:576
void setReverseChange(const bool value)
Sets the reverse change flag to the given value.
Definition ncr_msg.cc:549
void setLeaseLength(const uint32_t value)
Sets the lease length to the given value.
Definition ncr_msg.cc:637
void setLeaseExpiresOn(const std::string &value)
Sets the lease expiration based on the given string.
Definition ncr_msg.cc:620
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:265
NameChangeType getChangeType() const
Fetches the request change type.
Definition ncr_msg.h:465
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:528
std::string getLeaseExpiresOnStr() const
Fetches the request lease expiration as string.
Definition ncr_msg.cc:615
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:485
void setConflictResolutionMode(const ConflictResolutionMode value)
Sets the conflict resolution mode to the given value.
Definition ncr_msg.cc:680
bool isForwardChange() const
Checks forward change flag.
Definition ncr_msg.h:485
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:299
void validateContent()
Validates the content of a populated request.
Definition ncr_msg.cc:464
const std::string getFqdn() const
Fetches the request FQDN.
Definition ncr_msg.h:529
bool isReverseChange() const
Checks reverse change flag.
Definition ncr_msg.h:507
Exception thrown when NameChangeRequest marshalling error occurs.
Definition ncr_msg.h:30
The Name class encapsulates DNS names.
Definition name.h:219
The InputBuffer class is a buffer abstraction for manipulating read-only data.
Definition buffer.h:81
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition buffer.h:343
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
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:256
NameChangeFormat stringToNcrFormat(const std::string &fmt_str)
Function which converts labels to NameChangeFormat enum values.
Definition ncr_msg.cc:26
ConflictResolutionMode StringToConflictResolutionMode(const std::string &mode_str)
Function which converts string to ConflictResolutionMode enum values.
Definition ncr_msg.cc:45
std::string ConflictResolutionModeToString(const ConflictResolutionMode &mode)
Function which converts ConflictResolutionMode enums to text labels.
Definition ncr_msg.cc:66
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:35
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
string timeToText64(uint64_t value)
Convert integral DNSSEC time to textual form, 64-bit version.
Definition time_utils.cc:85
uint64_t timeFromText64(const string &time_txt)
Convert textual DNSSEC time to integer, 64-bit version.
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 ...