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