Kea
1.9.9-git
|
Represents a DHCP-DDNS client request. More...
#include <ncr_msg.h>
Public Member Functions | |
NameChangeRequest () | |
Default Constructor. More... | |
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 bool conflict_resolution=true) | |
Constructor. More... | |
NameChangeType | getChangeType () const |
Fetches the request change type. More... | |
const D2Dhcid & | getDhcid () const |
Fetches the request DHCID. More... | |
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. More... | |
const std::string | getFqdn () const |
Fetches the request FQDN. More... | |
std::string | getIpAddress () const |
Fetches the request IP address string. More... | |
const asiolink::IOAddress & | getIpIoAddress () const |
Fetches the request IP address as an IOAddress. More... | |
uint64_t | getLeaseExpiresOn () const |
Fetches the request lease expiration. More... | |
std::string | getLeaseExpiresOnStr () const |
Fetches the request lease expiration as string. More... | |
uint32_t | getLeaseLength () const |
Fetches the request lease length. More... | |
std::string | getRequestId () const |
Fetches the request ID. More... | |
NameChangeStatus | getStatus () const |
Fetches the request status. More... | |
bool | isForwardChange () const |
Checks forward change flag. More... | |
bool | isReverseChange () const |
Checks reverse change flag. More... | |
bool | isV4 () const |
Returns true if the lease address is a IPv4 lease. More... | |
bool | isV6 () const |
Returns true if the lease address is a IPv6 lease. More... | |
bool | operator!= (const NameChangeRequest &b) |
bool | operator== (const NameChangeRequest &b) |
void | setChangeType (const NameChangeType value) |
Sets the change type to the given value. More... | |
void | setChangeType (isc::data::ConstElementPtr element) |
Sets the change type to the value of the given Element. More... | |
void | setConflictResolution (const bool value) |
Sets the conflict resolution flag to the given value. More... | |
void | setConflictResolution (isc::data::ConstElementPtr element) |
Sets the conflict resolution flag to the value of the given Element. More... | |
void | setDhcid (const std::string &value) |
Sets the DHCID based on the given string value. More... | |
void | setDhcid (isc::data::ConstElementPtr element) |
Sets the DHCID based on the value of the given Element. More... | |
void | setForwardChange (const bool value) |
Sets the forward change flag to the given value. More... | |
void | setForwardChange (isc::data::ConstElementPtr element) |
Sets the forward change flag to the value of the given Element. More... | |
void | setFqdn (const std::string &value) |
Sets the FQDN to the given value. More... | |
void | setFqdn (isc::data::ConstElementPtr element) |
Sets the FQDN to the value of the given Element. More... | |
void | setIpAddress (const std::string &value) |
Sets the IP address to the given value. More... | |
void | setIpAddress (isc::data::ConstElementPtr element) |
Sets the IP address to the value of the given Element. More... | |
void | setLeaseExpiresOn (const std::string &value) |
Sets the lease expiration based on the given string. More... | |
void | setLeaseExpiresOn (isc::data::ConstElementPtr element) |
Sets the lease expiration based on the given Element. More... | |
void | setLeaseLength (const uint32_t value) |
Sets the lease length to the given value. More... | |
void | setLeaseLength (isc::data::ConstElementPtr element) |
Sets the lease length to the value of the given Element. More... | |
void | setReverseChange (const bool value) |
Sets the reverse change flag to the given value. More... | |
void | setReverseChange (isc::data::ConstElementPtr element) |
Sets the reverse change flag to the value of the given Element. More... | |
void | setStatus (const NameChangeStatus value) |
Sets the request status to the given value. More... | |
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. More... | |
std::string | toJSON () const |
Instance method for marshalling the contents of the request into a string of JSON text. More... | |
std::string | toText () const |
Returns a text rendition of the contents of the request. More... | |
bool | useConflictResolution () const |
Checks if conflict resolution is enabled. More... | |
void | validateContent () |
Validates the content of a populated request. More... | |
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. More... | |
static NameChangeRequestPtr | fromJSON (const std::string &json) |
Static method for creating a NameChangeRequest from a string containing a JSON rendition of a request. More... | |
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 200 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 bool | conflict_resolution = true |
||
) |
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 | indicates whether or not conflict resolution (per RFC 4703) is enabled. |
Definition at line 207 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 232 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 296 of file ncr_msg.cc.
References isc::data::Element::fromJSON(), isc_throw, NameChangeRequest(), and isc::Exception::what().
Referenced by fromFormat().
|
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 411 of file ncr_msg.cc.
References isc_throw.
|
inline |
|
inline |
Fetches the request IP address string.
Definition at line 521 of file ncr_msg.h.
References isc::asiolink::IOAddress::toText().
Referenced by toJSON().
|
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 541 of file ncr_msg.cc.
References isc::util::timeToText64().
Referenced by toJSON(), and toText().
|
inline |
|
inline |
Fetches the request ID.
Definition at line 595 of file ncr_msg.h.
References isc::dhcp_ddns::D2Dhcid::toStr().
|
inline |
|
inline |
|
inline |
|
inline |
Returns true if the lease address is a IPv4 lease.
Definition at line 535 of file ncr_msg.h.
References isc::asiolink::IOAddress::isV4().
|
inline |
Returns true if the lease address is a IPv6 lease.
Definition at line 542 of file ncr_msg.h.
References isc::asiolink::IOAddress::isV6().
bool isc::dhcp_ddns::NameChangeRequest::operator!= | ( | const NameChangeRequest & | b | ) |
Definition at line 665 of file ncr_msg.cc.
bool isc::dhcp_ddns::NameChangeRequest::operator== | ( | const NameChangeRequest & | b | ) |
Definition at line 652 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 426 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 432 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::setConflictResolution | ( | const bool | value | ) |
Sets the conflict resolution flag to the given value.
value | contains the new value to assign to the conflict resolution flag |
Definition at line 594 of file ncr_msg.cc.
Referenced by setConflictResolution().
void isc::dhcp_ddns::NameChangeRequest::setConflictResolution | ( | isc::data::ConstElementPtr | element | ) |
Sets the conflict resolution flag to the value of the given Element.
element | is a boolean Element containing the conflict resolution flag value. |
NcrMessageError | if the element is not a boolean Element |
Definition at line 599 of file ncr_msg.cc.
References isc_throw, setConflictResolution(), 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 531 of file ncr_msg.cc.
References isc::dhcp_ddns::D2Dhcid::fromStr().
Referenced by setDhcid().
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 536 of file ncr_msg.cc.
References 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 454 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 459 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 502 of file ncr_msg.cc.
References isc_throw, isc::dns::Name::toText(), and isc::Exception::what().
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 497 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 514 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 525 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 546 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 557 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 563 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 568 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 475 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 480 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 615 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 272 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 366 of file ncr_msg.cc.
References getChangeType(), getDhcid(), getFqdn(), getIpAddress(), getLeaseExpiresOnStr(), getLeaseLength(), isForwardChange(), isReverseChange(), isc::dhcp_ddns::D2Dhcid::toStr(), and useConflictResolution().
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 620 of file ncr_msg.cc.
References isc::dhcp_ddns::CHG_ADD, isc::dhcp_ddns::CHG_REMOVE, getLeaseExpiresOnStr(), and isc::dhcp_ddns::D2Dhcid::toStr().
|
inline |
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 390 of file ncr_msg.cc.
References isc::dhcp_ddns::D2Dhcid::getBytes(), and isc_throw.
Referenced by NameChangeRequest().