11#include <boost/assign.hpp>
12#include <boost/bimap.hpp>
23#include <unordered_set>
97 static const std::unordered_set<std::string>
ALPN_IDS;
177 return (minimal_length_);
182 return (addr_length_size_);
187 return (dnr_instance_data_length_size_);
192 return (adn_length_size_);
199 return (log_prefix_);
338 boost::shared_ptr<isc::dns::Name>
adn_;
400 uint8_t dnr_instance_data_length_size_;
403 uint8_t adn_length_size_;
406 uint8_t addr_length_size_;
415 uint8_t minimal_length_;
418 std::string log_prefix_;
433 std::string svcParamValAsText(
const std::pair<uint16_t, OpaqueDataTuple>& svc_param)
const;
440 void parseIpAddresses(
const std::string& txt_addresses);
448 void parseSvcParams(
const std::string& txt_svc_params);
456 void parseAlpnSvcParam(
const std::string& svc_param_val);
464 void parsePortSvcParam(
const std::string& svc_param_val);
472 void parseDohpathSvcParam(
const std::string& svc_param_val);
513 bool convenient_notation =
false);
561 std::string
toText(
int indent = 0)
const override;
567 uint16_t
len()
const override;
576 bool convenient_notation_;
589 void parseConfigData(
const std::string& config_txt);
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The IOAddress class represents an IP addresses (version agnostic)
Represents DNR Instance which is used both in DHCPv4 and DHCPv6 Encrypted DNS Option.
Option::Universe universe_
Either V4 or V6 Option universe.
std::vector< isc::asiolink::IOAddress > AddressContainer
A Type defined for container holding IP addresses.
static const std::set< uint8_t > SUPPORTED_SVC_PARAMS
Ordered set of supported SvcParamKeys.
std::string getDnrInstanceAsText() const
Returns string representation of the DNR instance.
void unpackSvcParams(OptionBufferConstIter &begin, OptionBufferConstIter end)
Unpacks Service Parameters from wire data buffer and stores it in svc_params_buf_.
void setAdnOnlyMode(bool adn_only_mode)
Setter of the adn_only_mode_ field.
uint16_t getAddrLength() const
Getter of the addr_length_.
std::map< uint16_t, OpaqueDataTuple > svc_params_map_
Service Parameters stored in a map.
uint16_t dnr_instance_data_length_
Length of all following data inside this DNR instance in octets.
uint16_t getDnrInstanceDataLength() const
Getter of the dnr_instance_data_length_.
uint8_t getMinimalLength() const
Returns minimal length of the DNR instance data (without headers) in octets.
OptionBuffer svc_params_buf_
Service Parameters (SvcParams) (variable length) as on-wire data buffer.
AddressContainer ip_addresses_
Vector container holding one or more IP addresses.
uint8_t getAdnLengthSize() const
Returns size in octets of ADN Length field.
void unpackDnrInstanceDataLength(OptionBufferConstIter &begin, OptionBufferConstIter end)
Unpacks DNR Instance Data Length from wire data buffer and stores it in dnr_instance_data_length_.
const OptionBuffer & getSvcParams() const
Returns a reference to the buffer holding SvcParam data.
void packAdn(isc::util::OutputBuffer &buf) const
Writes the ADN FQDN in the wire format into a buffer.
void setDnrInstanceDataLength()
Setter of the dnr_instance_data_length_ field.
uint16_t addr_length_
Length of included IP addresses in octets.
virtual void unpackAddresses(OptionBufferConstIter &begin, OptionBufferConstIter end)
Unpacks IP address(es) from wire data and stores it/them in ip_addresses_.
uint8_t getAddrLengthSize() const
Returns size in octets of Addr Length field.
uint16_t svc_params_length_
Length of Service Parameters field in octets.
void parseDnrInstanceConfigData(const std::string &config_txt)
Parses a convenient notation of the option data, which may be used in config.
void unpackServicePriority(OptionBufferConstIter &begin)
Unpacks Service Priority from wire data buffer and stores it in service_priority_.
uint16_t service_priority_
The priority of this instance compared to other DNR instances.
void packSvcParams(isc::util::OutputBuffer &buf) const
Writes the Service Parameters in the wire format into a buffer.
boost::bimap< std::string, uint16_t > SvcParamsMap
A Type defined for boost Bimap holding SvcParamKeys.
bool isAdnOnlyMode() const
Returns whether ADN only mode is enabled or disabled.
uint16_t getSvcParamsLength() const
Getter of the svc_params_length_.
virtual void packAddresses(isc::util::OutputBuffer &buf) const
Writes the IP address(es) in the wire format into a buffer.
bool alpn_http_
Indicates whether the "alpn" SvcParam contains support for HTTP.
std::string getAdnAsText() const
Returns the Authentication domain name in the text format.
std::string getLogPrefix() const
Returns Log prefix depending on V4/V6 Option universe.
uint16_t getServicePriority() const
Getter of the service_priority_.
static const SvcParamsMap SVC_PARAMS
Service parameters, used in DNR options in DHCPv4 and DHCPv6, but also in RA and DNS.
static const std::unordered_set< std::string > ALPN_IDS
Possible ALPN protocol IDs.
static const std::unordered_set< std::string > FORBIDDEN_SVC_PARAMS
Set of forbidden SvcParams.
bool adn_only_mode_
Flag stating whether ADN only mode is used or not.
uint16_t adn_length_
Length of the authentication-domain-name data in octets.
uint16_t dnrInstanceLen() const
Calculates and returns length of DNR Instance data in octets.
virtual ~DnrInstance()=default
Default destructor.
void addIpAddress(const asiolink::IOAddress &ip_address)
Adds IP address to ip_addresses_ container.
uint16_t getAdnLength() const
Getter of the adn_length_.
void unpackAdn(OptionBufferConstIter &begin, OptionBufferConstIter end)
Unpacks the ADN from given wire data buffer and stores it in adn_ field.
static const uint8_t SERVICE_PRIORITY_SIZE
Size in octets of Service Priority field.
uint8_t getDnrInstanceDataLengthSize() const
Returns size in octets of DNR Instance Data Length field.
boost::shared_ptr< isc::dns::Name > adn_
Authentication domain name field of variable length.
DnrInstance(Option::Universe universe)
Constructor of the empty DNR Instance.
AddressContainer getAddresses() const
Returns vector with addresses.
Exception thrown when invalid domain name is specified.
InvalidOptionDnrDomainName(const char *file, size_t line, const char *what)
Exception thrown when Service parameters have wrong format.
InvalidOptionDnrSvcParams(const char *file, size_t line, const char *what)
Represents DHCPv4 Encrypted DNS Option (code 162).
std::vector< DnrInstance > DnrInstanceContainer
A Type defined for container holding DNR Instances.
OptionPtr clone() const override
Copies this option and returns a pointer to the copy.
void addDnrInstance(DnrInstance &dnr_instance)
Adds given DNR instance to Option's DNR Instance container.
std::string toText(int indent=0) const override
Returns string representation of the option.
Option4Dnr(OptionBufferConstIter begin, OptionBufferConstIter end, bool convenient_notation=false)
Constructor of the Option from on-wire data.
void unpack(OptionBufferConstIter begin, OptionBufferConstIter end) override
Parses received wire data buffer.
DnrInstanceContainer dnr_instances_
Container holding DNR Instances.
const DnrInstanceContainer & getDnrInstances() const
Getter of the dnr_instances_ field.
uint16_t len() const override
Returns length of the complete option (data length + DHCPv4/DHCPv6 option header)
void pack(util::OutputBuffer &buf, bool check=true) const override
Writes option in wire-format to a buffer.
Universe
defines option universe DHCPv4 or DHCPv6
void check() const
A protected method used for option correctness.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
boost::shared_ptr< Option4Dnr > Option4DnrPtr
A pointer to the OptionDnr4 object.
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
boost::shared_ptr< Option > OptionPtr
Defines the logger used by the top-level component of kea-lfc.