52 const std::string& domain_name,
93 static void checkFlags(
const uint8_t flags,
const bool check_mbz);
123 const std::string& domain_name,
134 domain_name_type_(name_type) {
157 : flags_(source.flags_),
158 rcode1_(source.rcode1_),
159 rcode2_(source.rcode2_),
161 domain_name_type_(source.domain_name_type_) {
203 "fully qualified domain-name must not be empty"
204 <<
" when setting new domain-name for DHCPv4 Client"
219 "invalid domain-name value '"
220 << domain_name <<
"' when setting new domain-name for"
221 <<
" DHCPv4 Client FQDN Option");
234 "invalid DHCPv4 Client FQDN Option flags: 0x"
235 << std::hex << static_cast<int>(flags) << std::dec);
243 "both N and S flag of the DHCPv4 Client FQDN Option are set."
244 <<
" According to RFC 4702, if the N bit is 1 the S bit"
277 "failed to parse the domain-name in DHCPv4 Client FQDN"
278 <<
" Option: " << ex.
what());
286 if (std::distance(first, last) > 0) {
290 if (*(last - 1) != 0) {
307 std::distance(first, last));
320 if (std::distance(first, last) > 0) {
321 std::string domain_name(first, last);
337 const std::string& domain_name,
361 return (cloneInternal<Option4ClientFqdn>());
382 <<
" Option flag specified, expected E, N, S or O");
385 return ((impl_->
flags_ & flag) != 0);
393 if (((flag & ~
FLAG_MASK) != 0) || (flag == 0)) {
395 <<
" Option flag 0x" << std::hex
396 << static_cast<int>(flag) << std::dec
397 <<
" is being set. Expected combination of E, N, S and O");
402 uint8_t new_flag = impl_->
flags_;
415 std::pair<Option4ClientFqdn::Rcode, Option4ClientFqdn::Rcode>
454 const uint8_t* data = labels.
getData(&read_len);
463 if (!domain_name.empty()) {
464 buf.
writeData(&domain_name[0], domain_name.size());
512 std::ostringstream stream;
513 std::string in(indent,
' ');
514 stream << in <<
"type=" <<
type_ <<
" (CLIENT_FQDN), "
524 return (stream.str());
529 uint16_t domain_name_length = 0;
The Name class encapsulates DNS names.
static const uint8_t FLAG_N
Bit N.
uint8_t getCode() const
Returns the value of the RCODE.
DomainNameType
Type of the domain-name: partial or full.
void resetFlags()
Sets the flag field value to 0.
void packHeader(isc::util::OutputBuffer &buf) const
Store option's header in a buffer.
virtual ~Option4ClientFqdn()
Destructor.
Represents the value of one of the RCODE1 or RCODE2 fields.
void resetDomainName()
Set empty domain-name.
void parseASCIIDomainName(OptionBufferConstIter first, OptionBufferConstIter last)
Parse domain-name encoded in the deprecated ASCII format.
std::pair< Rcode, Rcode > getRcode() const
Returns Rcode objects representing value of RCODE1 and RCODE2.
boost::shared_ptr< Option > OptionPtr
Represents DHCPv4 Client FQDN Option (code 81).
void setDomainName(const std::string &domain_name, const DomainNameType domain_name_type)
Set new domain-name.
virtual uint16_t getHeaderLen() const
Returns length of header (2 for v4, 4 for v6)
virtual OptionPtr clone() const
Copies this option and returns a pointer to the copy.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
static const uint16_t FIXED_FIELDS_LEN
The size in bytes of the fixed fields within DHCPv4 Client Fqdn Option.
void writeData(const void *data, size_t len)
Copy an arbitrary length of data into the buffer.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
std::string getDomainName() const
Returns the domain-name in the text format.
static const uint8_t FLAG_S
Bit S.
size_t getDataLength() const
Return the length of the wire-format data of this LabelSequence.
static void checkFlags(const uint8_t flags, const bool check_mbz)
Check if flags are valid.
void packDomainName(isc::util::OutputBuffer &buf) const
Writes domain-name in the wire format into a buffer.
Implements the logic for the Option6ClientFqdn class.
Option4ClientFqdn & operator=(const Option4ClientFqdn &source)
Assignment operator.
virtual void pack(isc::util::OutputBuffer &buf) const
Writes option in the wire format into a buffer.
Option4ClientFqdn::Rcode rcode1_
Holds RCODE1 and RCODE2 values.
Exception thrown when invalid flags have been specified for DHCPv4 Client FQDN Option.
Option4ClientFqdn::Rcode rcode2_
Option4ClientFqdn::DomainNameType domain_name_type_
Indicates whether domain name is partial or fully qualified.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Exception thrown when invalid domain name is specified.
const uint8_t * getData(size_t *len) const
Return the wire-format data for this LabelSequence.
Option & operator=(const Option &rhs)
Assignment operator.
static const uint8_t FLAG_E
Bit E.
static const uint8_t FLAG_O
Bit O.
void setDomainName(const std::string &domain_name, const Option4ClientFqdn::DomainNameType name_type)
Set a new domain name for the option.
virtual void unpack(OptionBufferConstIter first, OptionBufferConstIter last)
Parses option from the received buffer.
void writeUint8(uint8_t data)
Write an unsigned 8-bit integer into the buffer.
void parseWireData(OptionBufferConstIter first, OptionBufferConstIter last)
Parse the Option provided in the wire format.
DomainNameType getDomainNameType() const
Returns enumerator value which indicates whether domain-name is partial or full.
Option4ClientFqdn(const uint8_t flags, const Rcode &rcode, const std::string &domain_name, const DomainNameType domain_name_type=FULL)
Constructor, creates option instance using flags and domain name.
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
Option4ClientFqdnImpl(const uint8_t flags, const Option4ClientFqdn::Rcode &rcode, const std::string &domain_name, const Option4ClientFqdn::DomainNameType name_type)
Constructor, from domain name.
string trim(const string &instring)
Trim Leading and Trailing Spaces.
virtual std::string toText(int indent=0) const
Returns string representation of the option.
bool getFlag(const uint8_t flag) const
Checks if the specified flag of the DHCPv4 Client FQDN Option is set.
uint16_t type_
option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
boost::shared_ptr< isc::dns::Name > domain_name_
Holds the pointer to a domain name carried in the option.
Option4ClientFqdnImpl & operator=(const Option4ClientFqdnImpl &source)
Assignment operator.
virtual uint16_t len() const
Returns length of the complete option (data length + DHCPv4 option header).
void setData(InputIterator first, InputIterator last)
Sets content of this option from buffer.
uint8_t flags_
Holds flags carried by the option.
static const uint8_t FLAG_MASK
Mask which zeroes MBZ flag bits.
void setFlag(const uint8_t flag, const bool set)
Modifies the value of the specified DHCPv4 Client Fqdn Option flag.
Light-weight Accessor to Name data.
void parseCanonicalDomainName(OptionBufferConstIter first, OptionBufferConstIter last)
Parse domain-name encoded in the canonical format.
void setRcode(const Rcode &rcode)
Set Rcode value.