Kea 2.7.6
|
Represents a DHCP-DDNS client request. More...
#include <ncr_msg.h>
Public Member Functions | |
NameChangeRequest () | |
Default Constructor. | |
NameChangeRequest (const NameChangeType change_type, const bool forward_change, const bool reverse_change, const std::string &fqdn, const std::string &ip_address, const D2Dhcid &dhcid, const uint64_t lease_expires_on, const uint32_t lease_length, const ConflictResolutionMode conflict_resolution_mode=CHECK_WITH_DHCID) | |
Constructor. | |
NameChangeType | getChangeType () const |
Fetches the request change type. | |
ConflictResolutionMode | getConflictResolutionMode () const |
Fetches the conflict resolution mode. | |
const D2Dhcid & | getDhcid () const |
Fetches the request DHCID. | |
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. | |
const std::string | getFqdn () const |
Fetches the request FQDN. | |
std::string | getIpAddress () const |
Fetches the request IP address string. | |
const asiolink::IOAddress & | getIpIoAddress () const |
Fetches the request IP address as an IOAddress. | |
uint64_t | getLeaseExpiresOn () const |
Fetches the request lease expiration. | |
std::string | getLeaseExpiresOnStr () const |
Fetches the request lease expiration as string. | |
uint32_t | getLeaseLength () const |
Fetches the request lease length. | |
std::string | getRequestId () const |
Fetches the request ID. | |
NameChangeStatus | getStatus () const |
Fetches the request status. | |
bool | isForwardChange () const |
Checks forward change flag. | |
bool | isReverseChange () const |
Checks reverse change flag. | |
bool | isV4 () const |
Returns true if the lease address is a IPv4 lease. | |
bool | isV6 () const |
Returns true if the lease address is a IPv6 lease. | |
bool | operator!= (const NameChangeRequest &b) const |
bool | operator== (const NameChangeRequest &b) const |
void | setChangeType (const NameChangeType value) |
Sets the change type to the given value. | |
void | setChangeType (isc::data::ConstElementPtr element) |
Sets the change type to the value of the given Element. | |
void | setConflictResolutionMode (const ConflictResolutionMode value) |
Sets the conflict resolution mode to the given value. | |
void | setConflictResolutionMode (isc::data::ConstElementPtr element) |
Sets the conflict resolution mode to the value of the given Element. | |
void | setDhcid (const std::string &value) |
Sets the DHCID based on the given string value. | |
void | setDhcid (isc::data::ConstElementPtr element) |
Sets the DHCID based on the value of the given Element. | |
void | setForwardChange (const bool value) |
Sets the forward change flag to the given value. | |
void | setForwardChange (isc::data::ConstElementPtr element) |
Sets the forward change flag to the value of the given Element. | |
void | setFqdn (const std::string &value) |
Sets the FQDN to the given value. | |
void | setFqdn (isc::data::ConstElementPtr element) |
Sets the FQDN to the value of the given Element. | |
void | setIpAddress (const std::string &value) |
Sets the IP address to the given value. | |
void | setIpAddress (isc::data::ConstElementPtr element) |
Sets the IP address to the value of the given Element. | |
void | setLeaseExpiresOn (const std::string &value) |
Sets the lease expiration based on the given string. | |
void | setLeaseExpiresOn (isc::data::ConstElementPtr element) |
Sets the lease expiration based on the given Element. | |
void | setLeaseLength (const uint32_t value) |
Sets the lease length to the given value. | |
void | setLeaseLength (isc::data::ConstElementPtr element) |
Sets the lease length to the value of the given Element. | |
void | setReverseChange (const bool value) |
Sets the reverse change flag to the given value. | |
void | setReverseChange (isc::data::ConstElementPtr element) |
Sets the reverse change flag to the value of the given Element. | |
void | setStatus (const NameChangeStatus value) |
Sets the request status to the given value. | |
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. | |
std::string | toJSON () const |
Instance method for marshalling the contents of the request into a string of JSON text. | |
std::string | toText () const |
Returns a text rendition of the contents of the request. | |
void | translateUseConflictResolution (isc::data::ConstElementPtr element) |
Sets the conflict resolution mode based on the value of the given boolean Element. | |
void | validateContent () |
Validates the content of a populated request. | |
Static Public Member Functions | |
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 given format. | |
static NameChangeRequestPtr | fromJSON (const std::string &json) |
Static method for creating a NameChangeRequest from a string containing a JSON rendition of a request. | |
Represents a DHCP-DDNS client request.
This class is used by DHCP-DDNS clients (e.g. DHCP4, DHCP6) to request DNS updates. Each message contains a single DNS change (either an add/update or a remove) for a single FQDN. It provides marshalling services for moving instances to and from the wire. Currently, the only format supported is JSON detailed here isc::dhcp_ddns::NameChangeRequest::fromJSON The class provides an interface such that other formats can be readily supported.
isc::dhcp_ddns::NameChangeRequest::NameChangeRequest | ( | ) |
Default Constructor.
Definition at line 265 of file ncr_msg.cc.
Referenced by fromJSON().
isc::dhcp_ddns::NameChangeRequest::NameChangeRequest | ( | const NameChangeType | change_type, |
const bool | forward_change, | ||
const bool | reverse_change, | ||
const std::string & | fqdn, | ||
const std::string & | ip_address, | ||
const D2Dhcid & | dhcid, | ||
const uint64_t | lease_expires_on, | ||
const uint32_t | lease_length, | ||
const ConflictResolutionMode | conflict_resolution_mode = CHECK_WITH_DHCID ) |
Constructor.
Full constructor, which provides parameters for all of the class members, except status.
change_type | the type of change (Add or Update) |
forward_change | indicates if this change should be sent to forward DNS servers. |
reverse_change | indicates if this change should be sent to reverse DNS servers. |
fqdn | the domain name whose pointer record(s) should be updated. |
ip_address | the ip address leased to the given FQDN. |
dhcid | the lease client's unique DHCID. |
lease_expires_on | a timestamp containing the date/time the lease expires. |
lease_length | the amount of time in seconds for which the lease is valid (TTL). |
conflict_resolution_mode | conflict resolution mode to use, defaults to CHECK_WITH_DHCID. (per RFC 4703) is enabled. |
Definition at line 273 of file ncr_msg.cc.
References setFqdn(), setIpAddress(), and validateContent().
|
static |
Static method for creating a NameChangeRequest from a buffer containing a marshalled request in a given format.
When the format is:
JSON: The buffer is expected to contain a two byte unsigned integer which specified the length of the JSON text; followed by the JSON text itself. This method attempts to extract "length" characters from the buffer. This data is used to create a character string that is than treated as JSON which is then parsed into the data needed to create a request instance.
(NOTE currently only JSON is supported.)
format | indicates the data format to use |
buffer | is the input buffer containing the marshalled request |
NcrMessageError | if an error occurs creating new request. |
Definition at line 299 of file ncr_msg.cc.
References isc::dhcp_ddns::FMT_JSON, fromJSON(), isc_throw, isc::util::InputBuffer::readUint16(), isc::util::InputBuffer::readVector(), and isc::Exception::what().
Referenced by isc::dhcp_ddns::NameChangeUDPListener::receiveCompletionHandler().
|
static |
Static method for creating a NameChangeRequest from a string containing a JSON rendition of a request.
The JSON expected is described below. Note that a request must be enclosed within curly brackets "{..}" and that whitespace is optional (it is used in the following examples for clarity).
Examples:
Removal of an IPv4 address from the forward DNS zone only:
Addition of an IPv6 address to both forward and reverse DNS zones:
json | is a string containing the JSON text |
NcrMessageError | if an error occurs creating new request. |
Definition at line 363 of file ncr_msg.cc.
References NameChangeRequest(), isc::dhcp_ddns::CHECK_WITH_DHCID, isc::data::Element::fromJSON(), isc_throw, and isc::Exception::what().
Referenced by fromFormat().
|
inline |
|
inline |
|
inline |
isc::data::ConstElementPtr isc::dhcp_ddns::NameChangeRequest::getElement | ( | const std::string & | name, |
const ElementMap & | element_map ) const |
Given a name, finds and returns an element from a map of elements.
name | is the name of the desired element |
element_map | is the map of elements to search |
NcrMessageError | if the element cannot be found within the map |
Definition at line 485 of file ncr_msg.cc.
References isc_throw.
|
inline |
|
inline |
|
inline |
Fetches the request IP address as an IOAddress.
|
inline |
std::string isc::dhcp_ddns::NameChangeRequest::getLeaseExpiresOnStr | ( | ) | const |
Fetches the request lease expiration as string.
The format of the string returned is:
YYYYMMDDHHmmSS
Example: 18:54:54 June 26, 2013 would be: 20130626185455 NOTE This is always UTC time.
Definition at line 615 of file ncr_msg.cc.
References isc::util::timeToText64().
Referenced by toJSON(), and toText().
|
inline |
|
inline |
Fetches the request ID.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
bool isc::dhcp_ddns::NameChangeRequest::operator!= | ( | const NameChangeRequest & | b | ) | const |
Definition at line 749 of file ncr_msg.cc.
bool isc::dhcp_ddns::NameChangeRequest::operator== | ( | const NameChangeRequest & | b | ) | const |
Definition at line 736 of file ncr_msg.cc.
void isc::dhcp_ddns::NameChangeRequest::setChangeType | ( | const NameChangeType | value | ) |
Sets the change type to the given value.
value | is the NameChangeType value to assign to the request. |
Definition at line 500 of file ncr_msg.cc.
Referenced by setChangeType().
void isc::dhcp_ddns::NameChangeRequest::setChangeType | ( | isc::data::ConstElementPtr | element | ) |
Sets the change type to the value of the given Element.
element | is an integer Element containing the change type value. |
NcrMessageError | if the element is not an integer Element or contains an invalid value. |
Definition at line 506 of file ncr_msg.cc.
References isc::dhcp_ddns::CHG_ADD, isc::dhcp_ddns::CHG_REMOVE, isc_throw, setChangeType(), and isc::Exception::what().
void isc::dhcp_ddns::NameChangeRequest::setConflictResolutionMode | ( | const ConflictResolutionMode | value | ) |
Sets the conflict resolution mode to the given value.
value | contains the new value to assign to the conflict resolution mode |
Definition at line 680 of file ncr_msg.cc.
Referenced by setConflictResolutionMode(), and translateUseConflictResolution().
void isc::dhcp_ddns::NameChangeRequest::setConflictResolutionMode | ( | isc::data::ConstElementPtr | element | ) |
Sets the conflict resolution mode to the value of the given Element.
element | is a enum Element containing the conflict resolution mode value. |
NcrMessageError | if the element is not an enum Element. |
Definition at line 685 of file ncr_msg.cc.
References isc_throw, setConflictResolutionMode(), isc::dhcp_ddns::StringToConflictResolutionMode(), and isc::Exception::what().
void isc::dhcp_ddns::NameChangeRequest::setDhcid | ( | const std::string & | value | ) |
Sets the DHCID based on the given string value.
value | is a string of hexadecimal digits. The format is simply a contiguous stream of digits, with no delimiters. For example a string containing "14A3" converts to a byte array containing: 0x14, 0xA3. |
NcrMessageError | if the input data contains non-digits or there is an odd number of digits. |
Definition at line 605 of file ncr_msg.cc.
References isc::dhcp_ddns::D2Dhcid::fromStr().
void isc::dhcp_ddns::NameChangeRequest::setDhcid | ( | isc::data::ConstElementPtr | element | ) |
Sets the DHCID based on the value of the given Element.
element | is a string Element containing the string of hexadecimal digits. (See setDhcid(std::string&) above.) |
NcrMessageError | if the input data contains non-digits or there is an odd number of digits. |
Definition at line 610 of file ncr_msg.cc.
References setDhcid().
Referenced by setDhcid().
void isc::dhcp_ddns::NameChangeRequest::setForwardChange | ( | const bool | value | ) |
Sets the forward change flag to the given value.
value | contains the new value to assign to the forward change flag |
Definition at line 528 of file ncr_msg.cc.
Referenced by setForwardChange().
void isc::dhcp_ddns::NameChangeRequest::setForwardChange | ( | isc::data::ConstElementPtr | element | ) |
Sets the forward change flag to the value of the given Element.
element | is a boolean Element containing the forward change flag value. |
NcrMessageError | if the element is not a boolean Element |
Definition at line 533 of file ncr_msg.cc.
References isc_throw, setForwardChange(), and isc::Exception::what().
void isc::dhcp_ddns::NameChangeRequest::setFqdn | ( | const std::string & | value | ) |
Sets the FQDN to the given value.
value | contains the new value to assign to the FQDN |
Definition at line 576 of file ncr_msg.cc.
References isc_throw, and isc::dns::Name::toText().
Referenced by NameChangeRequest(), and setFqdn().
void isc::dhcp_ddns::NameChangeRequest::setFqdn | ( | isc::data::ConstElementPtr | element | ) |
Sets the FQDN to the value of the given Element.
element | is a string Element containing the FQDN |
NcrMessageError | if the element is not a string Element |
Definition at line 571 of file ncr_msg.cc.
References setFqdn().
void isc::dhcp_ddns::NameChangeRequest::setIpAddress | ( | const std::string & | value | ) |
Sets the IP address to the given value.
value | contains the new value to assign to the IP address |
Definition at line 588 of file ncr_msg.cc.
References isc_throw.
Referenced by NameChangeRequest(), and setIpAddress().
void isc::dhcp_ddns::NameChangeRequest::setIpAddress | ( | isc::data::ConstElementPtr | element | ) |
Sets the IP address to the value of the given Element.
element | is a string Element containing the IP address |
NcrMessageError | if the element is not a string Element |
Definition at line 599 of file ncr_msg.cc.
References setIpAddress().
void isc::dhcp_ddns::NameChangeRequest::setLeaseExpiresOn | ( | const std::string & | value | ) |
Sets the lease expiration based on the given string.
value | is an date-time string from which to set the lease expiration. The format of the input is: |
YYYYMMDDHHmmSS
Example: 18:54:54 June 26, 2013 would be: 20130626185455 NOTE This is always UTC time.
NcrMessageError | if the ISO string is invalid. |
Definition at line 620 of file ncr_msg.cc.
References isc_throw, and isc::util::timeFromText64().
Referenced by setLeaseExpiresOn().
void isc::dhcp_ddns::NameChangeRequest::setLeaseExpiresOn | ( | isc::data::ConstElementPtr | element | ) |
Sets the lease expiration based on the given Element.
element | is string Element containing a date-time string. |
NcrMessageError | if the element is not a string Element, or if the element value is an invalid date-time string. |
Definition at line 631 of file ncr_msg.cc.
References setLeaseExpiresOn().
void isc::dhcp_ddns::NameChangeRequest::setLeaseLength | ( | const uint32_t | value | ) |
Sets the lease length to the given value.
value | contains the new value to assign to the lease length |
Definition at line 637 of file ncr_msg.cc.
Referenced by setLeaseLength().
void isc::dhcp_ddns::NameChangeRequest::setLeaseLength | ( | isc::data::ConstElementPtr | element | ) |
Sets the lease length to the value of the given Element.
element | is a integer Element containing the lease length |
NcrMessageError | if the element is not a string Element |
Definition at line 642 of file ncr_msg.cc.
References isc_throw, setLeaseLength(), and isc::Exception::what().
void isc::dhcp_ddns::NameChangeRequest::setReverseChange | ( | const bool | value | ) |
Sets the reverse change flag to the given value.
value | contains the new value to assign to the reverse change flag |
Definition at line 549 of file ncr_msg.cc.
Referenced by setReverseChange().
void isc::dhcp_ddns::NameChangeRequest::setReverseChange | ( | isc::data::ConstElementPtr | element | ) |
Sets the reverse change flag to the value of the given Element.
element | is a boolean Element containing the reverse change flag value. |
NcrMessageError | if the element is not a boolean Element |
Definition at line 554 of file ncr_msg.cc.
References isc_throw, setReverseChange(), and isc::Exception::what().
void isc::dhcp_ddns::NameChangeRequest::setStatus | ( | const NameChangeStatus | value | ) |
Sets the request status to the given value.
value | contains the new value to assign to request status |
Definition at line 698 of file ncr_msg.cc.
void isc::dhcp_ddns::NameChangeRequest::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.
When the format is:
JSON: Upon completion, the buffer will contain a two byte unsigned integer which specifies the length of the JSON text; followed by the JSON text itself. The JSON text contains the names and values for all the request data needed to reassemble the request on the receiving end. The JSON text in the buffer is NOT null-terminated. The format is identical that described under isc::dhcp_ddns::NameChangeRequest::fromJSON
(NOTE currently only JSON is supported.)
format | indicates the data format to use |
buffer | is the output buffer to which the request should be marshalled. |
Definition at line 339 of file ncr_msg.cc.
References isc::dhcp_ddns::FMT_JSON, isc_throw, toJSON(), isc::util::OutputBuffer::writeData(), and isc::util::OutputBuffer::writeUint16().
std::string isc::dhcp_ddns::NameChangeRequest::toJSON | ( | ) | const |
Instance method for marshalling the contents of the request into a string of JSON text.
Definition at line 439 of file ncr_msg.cc.
References isc::dhcp_ddns::ConflictResolutionModeToString(), getChangeType(), getConflictResolutionMode(), getDhcid(), getFqdn(), getIpAddress(), getLeaseExpiresOnStr(), getLeaseLength(), isForwardChange(), isReverseChange(), and isc::dhcp_ddns::D2Dhcid::toStr().
Referenced by toFormat().
std::string isc::dhcp_ddns::NameChangeRequest::toText | ( | ) | const |
Returns a text rendition of the contents of the request.
This method is primarily for logging purposes.
Definition at line 703 of file ncr_msg.cc.
References isc::dhcp_ddns::CHG_ADD, isc::dhcp_ddns::CHG_REMOVE, isc::dhcp_ddns::ConflictResolutionModeToString(), getConflictResolutionMode(), getLeaseExpiresOnStr(), and isc::dhcp_ddns::D2Dhcid::toStr().
void isc::dhcp_ddns::NameChangeRequest::translateUseConflictResolution | ( | isc::data::ConstElementPtr | element | ) |
Sets the conflict resolution mode based on the value of the given boolean Element.
This function is used to translate use-conflict-resolution sent by older versions of Kea.
element | is a boolean Element containing the conflict resolution flag value. |
NcrMessageError | if the element is not a boolean Element |
Definition at line 668 of file ncr_msg.cc.
References isc::dhcp_ddns::CHECK_WITH_DHCID, isc_throw, isc::dhcp_ddns::NO_CHECK_WITH_DHCID, setConflictResolutionMode(), and isc::Exception::what().
void isc::dhcp_ddns::NameChangeRequest::validateContent | ( | ) |
Validates the content of a populated request.
This method is used by both the full constructor and from-wire marshalling to ensure that the request is content valid. Currently it enforces the following rules:
NcrMessageError | if the request content violates any of the validation rules. |
Definition at line 464 of file ncr_msg.cc.
References isc::dhcp_ddns::D2Dhcid::getBytes(), and isc_throw.
Referenced by NameChangeRequest().