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