![]() |
Kea 2.7.3
|
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. | |
typedef boost::bimap< std::string, uint16_t > | SvcParamsMap |
A Type defined for boost Bimap holding SvcParamKeys. | |
Public Member Functions | |
DnrInstance (Option::Universe universe) | |
Constructor of the empty DNR Instance. | |
virtual | ~DnrInstance ()=default |
Default destructor. | |
void | addIpAddress (const asiolink::IOAddress &ip_address) |
Adds IP address to ip_addresses_ container. | |
AddressContainer | getAddresses () const |
Returns vector with addresses. | |
uint16_t | getAddrLength () const |
Getter of the addr_length_ . | |
uint8_t | getAddrLengthSize () const |
Returns size in octets of Addr Length field. | |
std::string | getAdnAsText () const |
Returns the Authentication domain name in the text format. | |
uint16_t | getAdnLength () const |
Getter of the adn_length_ . | |
uint8_t | getAdnLengthSize () const |
Returns size in octets of ADN Length field. | |
std::string | getDnrInstanceAsText () const |
Returns string representation of the DNR instance. | |
uint16_t | getDnrInstanceDataLength () const |
Getter of the dnr_instance_data_length_ . | |
uint8_t | getDnrInstanceDataLengthSize () const |
Returns size in octets of DNR Instance Data Length field. | |
std::string | getLogPrefix () const |
Returns Log prefix depending on V4/V6 Option universe. | |
uint8_t | getMinimalLength () const |
Returns minimal length of the DNR instance data (without headers) in octets. | |
uint16_t | getServicePriority () const |
Getter of the service_priority_ . | |
const OptionBuffer & | getSvcParams () const |
Returns a reference to the buffer holding SvcParam data. | |
uint16_t | getSvcParamsLength () const |
Getter of the svc_params_length_ . | |
bool | isAdnOnlyMode () const |
Returns whether ADN only mode is enabled or disabled. | |
virtual void | packAddresses (isc::util::OutputBuffer &buf) const |
Writes the IP address(es) in the wire format into a buffer. | |
void | packAdn (isc::util::OutputBuffer &buf) const |
Writes the ADN FQDN in the wire format into a buffer. | |
void | packSvcParams (isc::util::OutputBuffer &buf) const |
Writes the Service Parameters in the wire format into a buffer. | |
void | parseDnrInstanceConfigData (const std::string &config_txt) |
Parses a convenient notation of the option data, which may be used in config. | |
void | setAdnOnlyMode (bool adn_only_mode) |
Setter of the adn_only_mode_ field. | |
void | setDnrInstanceDataLength () |
Setter of the dnr_instance_data_length_ field. | |
virtual void | unpackAddresses (OptionBufferConstIter &begin, OptionBufferConstIter end) |
Unpacks IP address(es) from wire data and stores it/them in ip_addresses_ . | |
void | unpackAdn (OptionBufferConstIter &begin, OptionBufferConstIter end) |
Unpacks the ADN from given wire data buffer and stores it in adn_ field. | |
void | unpackDnrInstanceDataLength (OptionBufferConstIter &begin, OptionBufferConstIter end) |
Unpacks DNR Instance Data Length from wire data buffer and stores it in dnr_instance_data_length_ . | |
void | unpackServicePriority (OptionBufferConstIter &begin) |
Unpacks Service Priority from wire data buffer and stores it in service_priority_ . | |
void | unpackSvcParams (OptionBufferConstIter &begin, OptionBufferConstIter end) |
Unpacks Service Parameters from wire data buffer and stores it in svc_params_buf_ . | |
Static Public Attributes | |
static const std::unordered_set< std::string > | ALPN_IDS |
Possible ALPN protocol IDs. | |
static const std::unordered_set< std::string > | FORBIDDEN_SVC_PARAMS = {"ipv4hint", "ipv6hint"} |
Set of forbidden SvcParams. | |
static const uint8_t | SERVICE_PRIORITY_SIZE = 2 |
Size in octets of Service Priority field. | |
static const std::set< uint8_t > | SUPPORTED_SVC_PARAMS = {1, 3, 7} |
Ordered set of supported SvcParamKeys. | |
static const SvcParamsMap | SVC_PARAMS |
Service parameters, used in DNR options in DHCPv4 and DHCPv6, but also in RA and DNS. | |
Protected Member Functions | |
uint16_t | dnrInstanceLen () const |
Calculates and returns length of DNR Instance data in octets. | |
Protected Attributes | |
uint16_t | addr_length_ |
Length of included IP addresses in octets. | |
boost::shared_ptr< isc::dns::Name > | adn_ |
Authentication domain name field of variable length. | |
uint16_t | adn_length_ |
Length of the authentication-domain-name data in octets. | |
bool | adn_only_mode_ |
Flag stating whether ADN only mode is used or not. | |
bool | alpn_http_ |
Indicates whether the "alpn" SvcParam contains support for HTTP. | |
uint16_t | dnr_instance_data_length_ |
Length of all following data inside this DNR instance in octets. | |
AddressContainer | ip_addresses_ |
Vector container holding one or more IP addresses. | |
uint16_t | service_priority_ |
The priority of this instance compared to other DNR instances. | |
OptionBuffer | svc_params_buf_ |
Service Parameters (SvcParams) (variable length) as on-wire data buffer. | |
uint16_t | svc_params_length_ |
Length of Service Parameters field in octets. | |
std::map< uint16_t, OpaqueDataTuple > | svc_params_map_ |
Service Parameters stored in a map. | |
Option::Universe | universe_ |
Either V4 or V6 Option universe. | |
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 RFC9463
.
Definition at line 55 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 58 of file option4_dnr.h.
typedef boost::bimap<std::string, uint16_t> isc::dhcp::DnrInstance::SvcParamsMap |
A Type defined for boost Bimap holding SvcParamKeys.
Definition at line 61 of file option4_dnr.h.
|
explicit |
Constructor of the empty DNR Instance.
universe | either V4 or V6 Option universe |
Definition at line 212 of file option4_dnr.cc.
|
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 387 of file option4_dnr.cc.
References ip_addresses_.
Referenced by unpackAddresses(), and isc::dhcp::Option6Dnr::unpackAddresses().
|
protected |
Calculates and returns length of DNR Instance data in octets.
Definition at line 377 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 setDnrInstanceDataLength().
|
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 162 of file option4_dnr.h.
References ip_addresses_.
|
inline |
Getter of the addr_length_
.
Definition at line 143 of file option4_dnr.h.
References addr_length_.
|
inline |
Returns size in octets of Addr Length field.
Definition at line 181 of file option4_dnr.h.
Referenced by dnrInstanceLen(), unpackAddresses(), 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 255 of file option4_dnr.cc.
References adn_.
Referenced by getDnrInstanceAsText().
|
inline |
Getter of the adn_length_
.
Definition at line 124 of file option4_dnr.h.
References adn_length_.
|
inline |
Returns size in octets of ADN Length field.
Definition at line 191 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 345 of file option4_dnr.cc.
References addr_length_, adn_length_, adn_only_mode_, getAdnAsText(), ip_addresses_, service_priority_, SVC_PARAMS, svc_params_length_, and svc_params_map_.
Referenced by isc::dhcp::Option6Dnr::toText().
|
inline |
Getter of the dnr_instance_data_length_
.
Definition at line 110 of file option4_dnr.h.
References dnr_instance_data_length_.
|
inline |
Returns size in octets of DNR Instance Data Length field.
Definition at line 186 of file option4_dnr.h.
Referenced by unpackDnrInstanceDataLength().
|
inline |
Returns Log prefix depending on V4/V6 Option universe.
Definition at line 198 of file option4_dnr.h.
Referenced by isc::dhcp::Option6Dnr::packAddresses(), packAdn(), parseDnrInstanceConfigData(), isc::dhcp::Option6Dnr::unpack(), unpackAddresses(), isc::dhcp::Option6Dnr::unpackAddresses(), unpackAdn(), unpackDnrInstanceDataLength(), and unpackSvcParams().
|
inline |
Returns minimal length of the DNR instance data (without headers) in octets.
Definition at line 176 of file option4_dnr.h.
Referenced by isc::dhcp::Option6Dnr::unpack().
|
inline |
Getter of the service_priority_
.
Definition at line 117 of file option4_dnr.h.
References service_priority_.
|
inline |
Returns a reference to the buffer holding SvcParam data.
Definition at line 169 of file option4_dnr.h.
References svc_params_buf_.
|
inline |
Getter of the svc_params_length_
.
Definition at line 150 of file option4_dnr.h.
References svc_params_length_.
|
inline |
Returns whether ADN only mode is enabled or disabled.
Definition at line 203 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 239 of file option4_dnr.cc.
References ip_addresses_.
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 221 of file option4_dnr.cc.
References adn_, getLogPrefix(), and isc_throw.
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 248 of file option4_dnr.cc.
References svc_params_buf_, and svc_params_length_.
Referenced by isc::dhcp::Option6Dnr::pack().
void isc::dhcp::DnrInstance::parseDnrInstanceConfigData | ( | const std::string & | config_txt | ) |
Parses a convenient notation of the option data, which may be used in config.
As an alternative to the binary format, we provide convenience option definition as a string in format: (for DNRv6) "100, dot1.example.org., 2001:db8::1 2001:db8::2, alpn=dot\\,doq\\,h2\\,h3 port=8530 dohpath=/q{?dns}" "200, resolver.example." - ADN only mode (for DNRv4) "100, dot1.example.org., 10.0.3.4 10.1.5.6, alpn=dot\\,doq\\,h2\\,h3 port=8530 dohpath=/q{?dns}" "200, resolver.example." - ADN only mode
Note that comma and pipe chars ("," 0x2C and "|" 0x7C) are used as separators in this syntax. That's why whenever they are used in config in fields' values, they must be escaped with double backslash as in example.
Note that this function parses single DnrInstance. For DNRv4 it is possible to have more than one DnrInstance per one Option. In that case this function must be called for each DnrInstance config.
config_txt | convenient notation of the option data received as string |
BadValue | Thrown in case parser found wrong format of received string. |
InvalidOptionDnrDomainName | Thrown in case parser had problems with extracting ADN FQDN. |
Definition at line 551 of file option4_dnr.cc.
References adn_, adn_length_, getLogPrefix(), isc_throw, service_priority_, setAdnOnlyMode(), isc::util::str::tokens(), and isc::util::str::trim().
Referenced by isc::dhcp::Option6Dnr::unpack().
|
inline |
Setter of the adn_only_mode_
field.
adn_only_mode | enabled/disabled setting |
Definition at line 210 of file option4_dnr.h.
References adn_only_mode_.
Referenced by parseDnrInstanceConfigData().
|
inline |
Setter of the dnr_instance_data_length_
field.
Size is calculated basing on set Service Priority, ADN, IP address(es) and SvcParams. This should be called after all fields are set. This is only used for DHCPv4 Encrypted DNS Option.
Definition at line 219 of file option4_dnr.h.
References dnr_instance_data_length_, and dnrInstanceLen().
|
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 410 of file option4_dnr.cc.
References addIpAddress(), addr_length_, getAddrLengthSize(), getLogPrefix(), isc_throw, isc::dhcp::OpaqueDataTuple::LENGTH_1_BYTE, and isc::util::readUint32().
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 260 of file option4_dnr.cc.
References adn_, adn_length_, getAdnLengthSize(), getLogPrefix(), isc::dhcp::OptionDataTypeUtil::getTupleLenFieldType(), isc_throw, and universe_.
Referenced by 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 392 of file option4_dnr.cc.
References dnr_instance_data_length_, getDnrInstanceDataLengthSize(), getLogPrefix(), isc_throw, and isc::util::readUint16().
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 404 of file option4_dnr.cc.
References isc::util::readUint16(), service_priority_, and SERVICE_PRIORITY_SIZE.
Referenced by 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_buf_
.
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 when truncated data is detected. |
InvalidOptionDnrSvcParams | Thrown when invalid SvcParams syntax is detected. |
Definition at line 448 of file option4_dnr.cc.
References FORBIDDEN_SVC_PARAMS, getLogPrefix(), isc_throw, isc::dhcp::OpaqueDataTuple::LENGTH_2_BYTES, isc::util::readUint16(), SUPPORTED_SVC_PARAMS, SVC_PARAMS, svc_params_buf_, svc_params_length_, and svc_params_map_.
Referenced by isc::dhcp::Option6Dnr::unpack().
|
protected |
Length of included IP addresses in octets.
Definition at line 352 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 338 of file option4_dnr.h.
Referenced by getAdnAsText(), packAdn(), parseDnrInstanceConfigData(), and unpackAdn().
|
protected |
Length of the authentication-domain-name data in octets.
Definition at line 349 of file option4_dnr.h.
Referenced by dnrInstanceLen(), getAdnLength(), getDnrInstanceAsText(), isc::dhcp::Option6Dnr::pack(), parseDnrInstanceConfigData(), 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 369 of file option4_dnr.h.
Referenced by dnrInstanceLen(), getDnrInstanceAsText(), isAdnOnlyMode(), isc::dhcp::Option6Dnr::pack(), setAdnOnlyMode(), and isc::dhcp::Option6Dnr::unpack().
|
protected |
Indicates whether the "alpn" SvcParam contains support for HTTP.
Defaults to false.
Definition at line 394 of file option4_dnr.h.
|
static |
Possible ALPN protocol IDs.
The IANA registry is maintained at https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids
Definition at line 97 of file option4_dnr.h.
|
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 343 of file option4_dnr.h.
Referenced by getDnrInstanceDataLength(), setDnrInstanceDataLength(), 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 71 of file option4_dnr.h.
Referenced by unpackSvcParams().
|
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 360 of file option4_dnr.h.
Referenced by addIpAddress(), getAddresses(), getDnrInstanceAsText(), packAddresses(), and isc::dhcp::Option6Dnr::packAddresses().
|
protected |
The priority of this instance compared to other DNR instances.
Definition at line 346 of file option4_dnr.h.
Referenced by getDnrInstanceAsText(), getServicePriority(), isc::dhcp::Option6Dnr::pack(), parseDnrInstanceConfigData(), and unpackServicePriority().
|
static |
Size in octets of Service Priority field.
Definition at line 64 of file option4_dnr.h.
Referenced by dnrInstanceLen(), and unpackServicePriority().
|
static |
Ordered set of supported SvcParamKeys.
As per RFC9463 Section 3.1.5: The following service parameters MUST be supported by a DNR implementation: SvcParamKey=1 alpn: Used to indicate the set of supported protocols (Section 7.1 of [RFC9460]). SvcParamKey=3 port: Used to indicate the target port number for the encrypted DNS connection (Section 7.2 of [RFC9460]).
In addition, the following service parameter is RECOMMENDED to be supported by a DNR implementation: SvcParamKey=7 dohpath: Used to supply a relative DoH URI Template (Section 5.1 of [RFC9461]).
Definition at line 91 of file option4_dnr.h.
Referenced by unpackSvcParams().
|
static |
Service parameters, used in DNR options in DHCPv4 and DHCPv6, but also in RA and DNS.
The IANA registry is maintained at https://www.iana.org/assignments/dns-svcb/dns-svcb.xhtml
Definition at line 76 of file option4_dnr.h.
Referenced by getDnrInstanceAsText(), and unpackSvcParams().
|
protected |
Service Parameters (SvcParams) (variable length) as on-wire data buffer.
Specifies a set of service parameters that are encoded following the rules in Section 2.2 of RFC9460.
Definition at line 375 of file option4_dnr.h.
Referenced by getSvcParams(), packSvcParams(), and unpackSvcParams().
|
protected |
Length of Service Parameters field in octets.
Definition at line 363 of file option4_dnr.h.
Referenced by dnrInstanceLen(), getDnrInstanceAsText(), getSvcParamsLength(), packSvcParams(), and unpackSvcParams().
|
protected |
Service Parameters stored in a map.
A set of service parameters that are encoded following the same rules for encoding SvcParams using the wire format specified in Section 2.2 of RFC9460. SvcParams are stored here in a map where the key is the SvcParamKey as an uint_16. (Defined values are in Section 14.3.2 of RFC9460 - listed in SVC_PARAMS
). The value is an OpaqueDataTuple containing:
Definition at line 386 of file option4_dnr.h.
Referenced by getDnrInstanceAsText(), and unpackSvcParams().
|
protected |
Either V4 or V6 Option universe.
Definition at line 331 of file option4_dnr.h.
Referenced by unpackAdn().