![]() |
Kea
2.5.2
|
Represents DNR Instance which is used both in DHCPv4 and DHCPv6 Encrypted DNS Option. More...
#include <option4_dnr.h>
Public Types | |
typedef std::vector< isc::asiolink::IOAddress > | AddressContainer |
A Type defined for container holding IP addresses. More... | |
Public Member Functions | |
DnrInstance (Option::Universe universe) | |
Constructor of the empty DNR Instance. More... | |
DnrInstance (Option::Universe universe, uint16_t service_priority, const std::string &adn) | |
Constructor of the DNR Instance in ADN only mode. More... | |
DnrInstance (Option::Universe universe, uint16_t service_priority, const std::string &adn, const AddressContainer &ip_addresses, const std::string &svc_params) | |
Constructor of the DNR Instance with all fields from params. More... | |
virtual | ~DnrInstance ()=default |
Default destructor. More... | |
void | addIpAddress (const asiolink::IOAddress &ip_address) |
Adds IP address to ip_addresses_ container. More... | |
void | checkFields () |
Checks IP address(es) field if data is correct and throws in case of issue found. More... | |
void | checkSvcParams (bool from_wire_data=true) |
Checks SvcParams field if encoded correctly and throws in case of issue found. More... | |
AddressContainer | getAddresses () const |
Returns vector with addresses. More... | |
uint16_t | getAddrLength () const |
Getter of the addr_length_ . More... | |
uint8_t | getAddrLengthSize () const |
Returns size in octets of Addr Length field. More... | |
std::string | getAdnAsText () const |
Returns the Authentication domain name in the text format. More... | |
uint16_t | getAdnLength () const |
Getter of the adn_length_ . More... | |
uint8_t | getAdnLengthSize () const |
Returns size in octets of ADN Length field. More... | |
std::string | getDnrInstanceAsText () const |
Returns string representation of the DNR instance. More... | |
uint16_t | getDnrInstanceDataLength () const |
Getter of the dnr_instance_data_length_ . More... | |
uint8_t | getDnrInstanceDataLengthSize () const |
Returns size in octets of DNR Instance Data Length field. More... | |
std::string | getLogPrefix () const |
Returns Log prefix depending on V4/V6 Option universe. More... | |
uint8_t | getMinimalLength () const |
Returns minimal length of the DNR instance data (without headers) in octets. More... | |
uint16_t | getServicePriority () const |
Getter of the service_priority_ . More... | |
const std::string & | getSvcParams () const |
Getter of the svc_params_ field. More... | |
uint16_t | getSvcParamsLength () const |
Getter of the svc_params_length_ . More... | |
bool | isAdnOnlyMode () const |
Returns whether ADN only mode is enabled or disabled. More... | |
virtual void | packAddresses (isc::util::OutputBuffer &buf) const |
Writes the IP address(es) in the wire format into a buffer. More... | |
void | packAdn (isc::util::OutputBuffer &buf) const |
Writes the ADN FQDN in the wire format into a buffer. More... | |
void | packSvcParams (isc::util::OutputBuffer &buf) const |
Writes the Service Parameters in the wire format into a buffer. More... | |
void | setAdn (const std::string &adn) |
Sets Authentication domain name from given string. More... | |
void | setAdnOnlyMode (bool adn_only_mode) |
Setter of the adn_only_mode_ field. More... | |
virtual void | unpackAddresses (OptionBufferConstIter &begin, OptionBufferConstIter end) |
Unpacks IP address(es) from wire data and stores it/them in ip_addresses_ . More... | |
void | unpackAdn (OptionBufferConstIter &begin, OptionBufferConstIter end) |
Unpacks the ADN from given wire data buffer and stores it in adn_ field. More... | |
void | unpackDnrInstanceDataLength (OptionBufferConstIter &begin, OptionBufferConstIter end) |
Unpacks DNR Instance Data Length from wire data buffer and stores it in dnr_instance_data_length_ . More... | |
void | unpackServicePriority (OptionBufferConstIter &begin) |
Unpacks Service Priority from wire data buffer and stores it in service_priority_ . More... | |
void | unpackSvcParams (OptionBufferConstIter &begin, OptionBufferConstIter end) |
Unpacks Service Parameters from wire data buffer and stores it in svc_params_ . More... | |
Static Public Attributes | |
static const std::unordered_set< std::string > | FORBIDDEN_SVC_PARAMS = {"ipv4hint", "ipv6hint"} |
Set of forbidden SvcParams. More... | |
static const uint8_t | SERVICE_PRIORITY_SIZE = 2 |
Size in octets of Service Priority field. More... | |
Protected Member Functions | |
uint16_t | dnrInstanceLen () const |
Calculates and returns length of DNR Instance data in octets. More... | |
Protected Attributes | |
uint16_t | addr_length_ |
Length of included IP addresses in octets. More... | |
boost::shared_ptr< isc::dns::Name > | adn_ |
Authentication domain name field of variable length. More... | |
uint16_t | adn_length_ |
Length of the authentication-domain-name data in octets. More... | |
bool | adn_only_mode_ |
Flag stating whether ADN only mode is used or not. More... | |
uint16_t | dnr_instance_data_length_ |
Length of all following data inside this DNR instance in octets. More... | |
AddressContainer | ip_addresses_ |
Vector container holding one or more IP addresses. More... | |
uint16_t | service_priority_ |
The priority of this instance compared to other DNR instances. More... | |
std::string | svc_params_ |
Service Parameters (SvcParams) (variable length). More... | |
uint16_t | svc_params_length_ |
Length of Service Parameters field in octets. More... | |
Option::Universe | universe_ |
Either V4 or V6 Option universe. More... | |
Represents DNR Instance which is used both in DHCPv4 and DHCPv6 Encrypted DNS Option.
DNR Instance includes the configuration data of an encrypted DNS resolver. It is used to build OPTION_V4_DNR (code 162). There may be multiple DNR Instances in one OPTION_V4_DNR Option. OPTION_V6_DNR (code 144) is using very similar structure, only that there must be only one DNR Instance per one OPTION_V6_DNR Option. That's why Option6Dnr
class can derive from this DnrInstance
class, whereas Option4Dnr
class should have a container of DnrInstance's
.
DNR Instance Data Format has been defined in the draft-ietf-add-dnr
(to be replaced with published RFC).
Definition at line 50 of file option4_dnr.h.
typedef std::vector<isc::asiolink::IOAddress> isc::dhcp::DnrInstance::AddressContainer |
A Type defined for container holding IP addresses.
Definition at line 53 of file option4_dnr.h.
|
explicit |
Constructor of the empty DNR Instance.
universe | either V4 or V6 Option universe |
Definition at line 122 of file option4_dnr.cc.
isc::dhcp::DnrInstance::DnrInstance | ( | Option::Universe | universe, |
uint16_t | service_priority, | ||
const std::string & | adn, | ||
const AddressContainer & | ip_addresses, | ||
const std::string & | svc_params | ||
) |
Constructor of the DNR Instance with all fields from params.
Constructor of the DNR Instance where all fields i.e. Service priority, ADN, IP address(es) and Service params are provided as ctor parameters.
universe | either V4 or V6 Option universe |
service_priority | Service priority |
adn | ADN FQDN |
ip_addresses | Container of IP addresses |
svc_params | Service Parameters |
InvalidOptionDnrDomainName | Thrown in case of any issue with parsing ADN |
InvalidOptionDnrSvcParams | Thrown when checkSvcParams(from_wire_data) throws |
OutOfRange | Thrown in case of no IP addresses found or when IP addresses length is too big |
Definition at line 130 of file option4_dnr.cc.
References checkFields(), and setAdn().
isc::dhcp::DnrInstance::DnrInstance | ( | Option::Universe | universe, |
uint16_t | service_priority, | ||
const std::string & | adn | ||
) |
Constructor of the DNR Instance in ADN only mode.
Constructor of the DNR Instance in ADN only mode i.e. only Service priority and ADN FQDN are provided as ctor parameters.
universe | either V4 or V6 Option universe |
service_priority | Service priority |
adn | ADN FQDN |
InvalidOptionDnrDomainName | Thrown in case of any issue with parsing ADN |
Definition at line 146 of file option4_dnr.cc.
References setAdn().
|
virtualdefault |
Default destructor.
void isc::dhcp::DnrInstance::addIpAddress | ( | const asiolink::IOAddress & | ip_address | ) |
Adds IP address to ip_addresses_
container.
ip_address | IP address to be added |
Definition at line 406 of file option4_dnr.cc.
References ip_addresses_.
void isc::dhcp::DnrInstance::checkFields | ( | ) |
Checks IP address(es) field if data is correct and throws in case of issue found.
Fields lengths are also calculated and saved to member variables.
OutOfRange | Thrown in case of no IP addresses found or when IP addresses length is too big |
InvalidOptionDnrSvcParams | Thrown when checkSvcParams(from_wire_data) throws |
Definition at line 341 of file option4_dnr.cc.
References adn_only_mode_, checkSvcParams(), getLogPrefix(), ip_addresses_, isc_throw, svc_params_, universe_, and isc::dhcp::Option::V4.
Referenced by DnrInstance().
void isc::dhcp::DnrInstance::checkSvcParams | ( | bool | from_wire_data = true | ) |
Checks SvcParams field if encoded correctly and throws in case of issue found.
The field should be encoded following the rules in Section 2.1 of [I-D.ietf-dnsop-svcb-https]. SvcParams are a whitespace-separated list, with each SvcParam consisting of a SvcParamKey=SvcParamValue pair or a standalone SvcParamKey.
SvcParams
as described in Section 2.1 of [I-D.ietf-dnsop-svcb-https]. Currently, SvcParamValue is not verified. Proper syntax of SvcParamValue is described in Appendix A of [I-D.ietf-dnsop-svcb-https].from_wire_data | used to determine whether SvcParams data comes from unpacked wire data or from ctor param |
InvalidOptionDnrSvcParams | Thrown in case of any issue found when checking ServiceParams field syntax |
Definition at line 264 of file option4_dnr.cc.
References FORBIDDEN_SVC_PARAMS, getLogPrefix(), isc_throw, svc_params_, svc_params_length_, isc::util::str::tokens(), and isc::util::str::trim().
Referenced by checkFields(), and unpackSvcParams().
|
protected |
Calculates and returns length of DNR Instance data in octets.
Definition at line 396 of file option4_dnr.cc.
References addr_length_, adn_length_, adn_only_mode_, getAddrLengthSize(), getAdnLengthSize(), SERVICE_PRIORITY_SIZE, and svc_params_length_.
Referenced by isc::dhcp::Option6Dnr::len(), and setAdn().
|
inline |
Returns vector with addresses.
We return a copy of our list. Although this includes overhead, it also makes this list safe to use after this option object is no longer available. As options are expected to hold only a few (1-3) addresses, the overhead is not that big.
Definition at line 163 of file option4_dnr.h.
References ip_addresses_.
|
inline |
Getter of the addr_length_
.
Definition at line 144 of file option4_dnr.h.
References addr_length_.
|
inline |
Returns size in octets of Addr Length field.
Definition at line 182 of file option4_dnr.h.
Referenced by dnrInstanceLen(), and isc::dhcp::Option6Dnr::unpackAddresses().
std::string isc::dhcp::DnrInstance::getAdnAsText | ( | ) | const |
Returns the Authentication domain name in the text format.
FQDN data stored in adn_
is converted into text format and returned.
Definition at line 193 of file option4_dnr.cc.
References adn_.
Referenced by getDnrInstanceAsText().
|
inline |
Getter of the adn_length_
.
Definition at line 125 of file option4_dnr.h.
References adn_length_.
|
inline |
Returns size in octets of ADN Length field.
Definition at line 192 of file option4_dnr.h.
Referenced by dnrInstanceLen(), and unpackAdn().
std::string isc::dhcp::DnrInstance::getDnrInstanceAsText | ( | ) | const |
Returns string representation of the DNR instance.
Definition at line 377 of file option4_dnr.cc.
References addr_length_, adn_length_, adn_only_mode_, getAdnAsText(), ip_addresses_, service_priority_, svc_params_, and svc_params_length_.
Referenced by isc::dhcp::Option6Dnr::toText().
|
inline |
Getter of the dnr_instance_data_length_
.
Definition at line 111 of file option4_dnr.h.
References dnr_instance_data_length_.
Referenced by isc::dhcp::Option4Dnr::unpack().
|
inline |
Returns size in octets of DNR Instance Data Length field.
Definition at line 187 of file option4_dnr.h.
Referenced by unpackDnrInstanceDataLength().
|
inline |
Returns Log prefix depending on V4/V6 Option universe.
Definition at line 199 of file option4_dnr.h.
Referenced by checkFields(), checkSvcParams(), isc::dhcp::Option6Dnr::packAddresses(), packAdn(), setAdn(), isc::dhcp::Option4Dnr::unpack(), isc::dhcp::Option6Dnr::unpack(), unpackAddresses(), isc::dhcp::Option6Dnr::unpackAddresses(), unpackAdn(), and unpackDnrInstanceDataLength().
|
inline |
Returns minimal length of the DNR instance data (without headers) in octets.
Definition at line 177 of file option4_dnr.h.
Referenced by isc::dhcp::Option4Dnr::unpack(), and isc::dhcp::Option6Dnr::unpack().
|
inline |
Getter of the service_priority_
.
Definition at line 118 of file option4_dnr.h.
References service_priority_.
|
inline |
Getter of the svc_params_
field.
Definition at line 170 of file option4_dnr.h.
References svc_params_.
|
inline |
Getter of the svc_params_length_
.
Definition at line 151 of file option4_dnr.h.
References svc_params_length_.
|
inline |
Returns whether ADN only mode is enabled or disabled.
Definition at line 204 of file option4_dnr.h.
References adn_only_mode_.
|
virtual |
Writes the IP address(es) in the wire format into a buffer.
The IP address(es) (ip_addresses_
) data is appended at the end of the buffer.
[out] | buf | buffer where IP address(es) will be written. |
Reimplemented in isc::dhcp::Option6Dnr.
Definition at line 177 of file option4_dnr.cc.
References ip_addresses_, and isc::util::OutputBuffer::writeUint32().
void isc::dhcp::DnrInstance::packAdn | ( | isc::util::OutputBuffer & | buf | ) | const |
Writes the ADN FQDN in the wire format into a buffer.
The Authentication Domain Name - fully qualified domain name of the encrypted DNS resolver data is appended at the end of the buffer.
[out] | buf | buffer where ADN FQDN will be written. |
InvalidOptionDnrDomainName | Thrown when mandatory field ADN is empty. |
Definition at line 159 of file option4_dnr.cc.
References adn_, isc::dns::LabelSequence::getData(), isc::dns::LabelSequence::getDataLength(), getLogPrefix(), isc_throw, and isc::util::OutputBuffer::writeData().
Referenced by isc::dhcp::Option6Dnr::pack().
void isc::dhcp::DnrInstance::packSvcParams | ( | isc::util::OutputBuffer & | buf | ) | const |
Writes the Service Parameters in the wire format into a buffer.
The Service Parameters (svc_params_
) data is appended at the end of the buffer.
[out] | buf | buffer where SvcParams will be written. |
Definition at line 186 of file option4_dnr.cc.
References svc_params_, svc_params_length_, and isc::util::OutputBuffer::writeData().
Referenced by isc::dhcp::Option6Dnr::pack().
void isc::dhcp::DnrInstance::setAdn | ( | const std::string & | adn | ) |
Sets Authentication domain name from given string.
Sets FQDN of the encrypted DNS resolver from given string. It may throw an exception if parsing of the FQDN fails or if provided FQDN length is bigger than uint16_t Max. It also calculates and sets value of Addr length field.
adn | string representation of ADN FQDN |
InvalidOptionDnrDomainName | Thrown in case of any issue with parsing ADN from given string. |
Definition at line 198 of file option4_dnr.cc.
References adn_, adn_length_, dnr_instance_data_length_, dnrInstanceLen(), isc::dns::LabelSequence::getData(), getLogPrefix(), isc_throw, isc::util::str::trim(), universe_, isc::dhcp::Option::V4, and isc::Exception::what().
Referenced by DnrInstance().
|
inline |
Setter of the adn_only_mode_
field.
adn_only_mode | enabled/disabled setting |
Definition at line 224 of file option4_dnr.h.
References adn_only_mode_.
Referenced by isc::dhcp::Option4Dnr::unpack().
|
virtual |
Unpacks IP address(es) from wire data and stores it/them in ip_addresses_
.
It may throw in case of malformed data detected during parsing.
begin | beginning of the buffer from which the field will be read |
end | end of the buffer from which the field will be read |
BadValue | Thrown in case of any issue with unpacking opaque data of the IP addresses. |
OutOfRange | Thrown in case of malformed data detected during parsing e.g. Addr Len not divisible by 4, Addr Len is 0. |
Reimplemented in isc::dhcp::Option6Dnr.
Definition at line 429 of file option4_dnr.cc.
References addr_length_, isc::dhcp::OpaqueDataTuple::getLength(), getLogPrefix(), isc_throw, isc::dhcp::OpaqueDataTuple::LENGTH_1_BYTE, isc::dhcp::OpaqueDataTuple::unpack(), and isc::Exception::what().
Referenced by isc::dhcp::Option4Dnr::unpack().
void isc::dhcp::DnrInstance::unpackAdn | ( | OptionBufferConstIter & | begin, |
OptionBufferConstIter | end | ||
) |
Unpacks the ADN from given wire data buffer and stores it in adn_
field.
It may throw in case of malformed data detected during parsing.
begin | beginning of the buffer from which the ADN will be read |
end | end of the buffer from which the ADN will be read |
BadValue | Thrown in case of any issue with unpacking opaque data of the ADN. |
InvalidOptionDnrDomainName | Thrown in case of any issue with parsing ADN from given wire data. |
Definition at line 230 of file option4_dnr.cc.
References adn_, adn_length_, getAdnLengthSize(), isc::dhcp::OpaqueDataTuple::getData(), isc::dhcp::OpaqueDataTuple::getLength(), getLogPrefix(), isc::dhcp::OptionDataTypeUtil::getTupleLenFieldType(), isc_throw, universe_, isc::dhcp::OpaqueDataTuple::unpack(), and isc::Exception::what().
Referenced by isc::dhcp::Option4Dnr::unpack(), and isc::dhcp::Option6Dnr::unpack().
void isc::dhcp::DnrInstance::unpackDnrInstanceDataLength | ( | OptionBufferConstIter & | begin, |
OptionBufferConstIter | end | ||
) |
Unpacks DNR Instance Data Length from wire data buffer and stores it in dnr_instance_data_length_
.
It may throw in case of malformed data detected during parsing.
begin | beginning of the buffer from which the field will be read |
end | end of the buffer from which the field will be read |
OutOfRange | Thrown in case of truncated data detected. |
Definition at line 411 of file option4_dnr.cc.
References dnr_instance_data_length_, getDnrInstanceDataLengthSize(), getLogPrefix(), isc_throw, and isc::util::readUint16().
Referenced by isc::dhcp::Option4Dnr::unpack().
void isc::dhcp::DnrInstance::unpackServicePriority | ( | OptionBufferConstIter & | begin | ) |
Unpacks Service Priority from wire data buffer and stores it in service_priority_
.
begin | beginning of the buffer from which the field will be read |
Definition at line 423 of file option4_dnr.cc.
References isc::util::readUint16(), service_priority_, and SERVICE_PRIORITY_SIZE.
Referenced by isc::dhcp::Option4Dnr::unpack(), and isc::dhcp::Option6Dnr::unpack().
void isc::dhcp::DnrInstance::unpackSvcParams | ( | OptionBufferConstIter & | begin, |
OptionBufferConstIter | end | ||
) |
Unpacks Service Parameters from wire data buffer and stores it in svc_params_
.
It may throw in case of malformed data detected during parsing.
begin | beginning of the buffer from which the field will be read |
end | end of the buffer from which the field will be read |
Definition at line 467 of file option4_dnr.cc.
References checkSvcParams(), svc_params_, and svc_params_length_.
Referenced by isc::dhcp::Option4Dnr::unpack(), and isc::dhcp::Option6Dnr::unpack().
|
protected |
Length of included IP addresses in octets.
Definition at line 358 of file option4_dnr.h.
Referenced by dnrInstanceLen(), getAddrLength(), getDnrInstanceAsText(), isc::dhcp::Option6Dnr::pack(), unpackAddresses(), and isc::dhcp::Option6Dnr::unpackAddresses().
|
protected |
Authentication domain name field of variable length.
Authentication domain name field of variable length holding a fully qualified domain name of the encrypted DNS resolver. This field is formatted as specified in Section 10 of RFC8415.
Definition at line 344 of file option4_dnr.h.
Referenced by getAdnAsText(), packAdn(), setAdn(), and unpackAdn().
|
protected |
Length of the authentication-domain-name data in octets.
Definition at line 355 of file option4_dnr.h.
Referenced by dnrInstanceLen(), getAdnLength(), getDnrInstanceAsText(), isc::dhcp::Option6Dnr::pack(), setAdn(), and unpackAdn().
|
protected |
Flag stating whether ADN only mode is used or not.
"Addr Length", "IP(v4/v6) Address(es)", and "Service Parameters (SvcParams)" fields are not present if the ADN-only mode is used.
Definition at line 375 of file option4_dnr.h.
Referenced by checkFields(), dnrInstanceLen(), getDnrInstanceAsText(), isAdnOnlyMode(), isc::dhcp::Option6Dnr::pack(), setAdnOnlyMode(), and isc::dhcp::Option6Dnr::unpack().
|
protected |
Length of all following data inside this DNR instance in octets.
This field is only used for DHCPv4 Encrypted DNS Option.
Definition at line 349 of file option4_dnr.h.
Referenced by getDnrInstanceDataLength(), setAdn(), and unpackDnrInstanceDataLength().
|
static |
Set of forbidden SvcParams.
The service parameters MUST NOT include "ipv4hint" or "ipv6hint" SvcParams as they are superseded by the included IP addresses.
Definition at line 63 of file option4_dnr.h.
Referenced by checkSvcParams().
|
protected |
Vector container holding one or more IP addresses.
One or more IP addresses to reach the encrypted DNS resolver. In case of DHCPv4, both private and public IPv4 addresses can be included in this field. In case of DHCPv6, an address can be link-local, ULA, or GUA.
Definition at line 366 of file option4_dnr.h.
Referenced by addIpAddress(), checkFields(), getAddresses(), getDnrInstanceAsText(), packAddresses(), and isc::dhcp::Option6Dnr::packAddresses().
|
protected |
The priority of this instance compared to other DNR instances.
Definition at line 352 of file option4_dnr.h.
Referenced by getDnrInstanceAsText(), getServicePriority(), isc::dhcp::Option6Dnr::pack(), and unpackServicePriority().
|
static |
Size in octets of Service Priority field.
Definition at line 56 of file option4_dnr.h.
Referenced by dnrInstanceLen(), and unpackServicePriority().
|
protected |
Service Parameters (SvcParams) (variable length).
Specifies a set of service parameters that are encoded following the rules in Section 2.1 of [I-D.ietf-dnsop-svcb-https].
Definition at line 381 of file option4_dnr.h.
Referenced by checkFields(), checkSvcParams(), getDnrInstanceAsText(), getSvcParams(), packSvcParams(), and unpackSvcParams().
|
protected |
Length of Service Parameters field in octets.
Definition at line 369 of file option4_dnr.h.
Referenced by checkSvcParams(), dnrInstanceLen(), getDnrInstanceAsText(), getSvcParamsLength(), packSvcParams(), and unpackSvcParams().
|
protected |
Either V4 or V6 Option universe.
Definition at line 337 of file option4_dnr.h.
Referenced by checkFields(), setAdn(), and unpackAdn().