51 const std::string& domain_name,
92 static void checkFlags(
const uint8_t flags,
const bool check_mbz);
122 const std::string& domain_name,
133 domain_name_type_(name_type) {
156 : flags_(source.flags_),
157 rcode1_(source.rcode1_),
158 rcode2_(source.rcode2_),
160 domain_name_type_(source.domain_name_type_) {
161 if (source.domain_name_) {
171 if (source.domain_name_) {
202 "fully qualified domain-name must not be empty"
203 <<
" when setting new domain-name for DHCPv4 Client"
218 "invalid domain-name value '"
219 << domain_name <<
"' when setting new domain-name for"
220 <<
" DHCPv4 Client FQDN Option");
233 "invalid DHCPv4 Client FQDN Option flags: 0x"
234 << std::hex <<
static_cast<int>(flags) << std::dec);
242 "both N and S flag of the DHCPv4 Client FQDN Option are set."
243 <<
" According to RFC 4702, if the N bit is 1 the S bit"
275 std::ostringstream errmsg;
276 errmsg <<
"failed to parse the domain-name in DHCPv4 Client FQDN "
277 <<
" Option: " << ex.what();
290 if (std::distance(first, last) > 0) {
294 if (*(last - 1) != 0) {
311 std::distance(first, last));
324 if (std::distance(first, last) > 0) {
325 std::string domain_name(first, last);
341 const std::string& domain_name,
365 return (cloneInternal<Option4ClientFqdn>());
386 <<
" Option flag specified, expected E, N, S or O");
389 return ((impl_->
flags_ & flag) != 0);
397 if (((flag & ~
FLAG_MASK) != 0) || (flag == 0)) {
399 <<
" Option flag 0x" << std::hex
400 <<
static_cast<int>(flag) << std::dec
401 <<
" is being set. Expected combination of E, N, S and O");
406 uint8_t new_flag = impl_->
flags_;
419std::pair<Option4ClientFqdn::Rcode, Option4ClientFqdn::Rcode>
456 if (labels.getDataLength() > 0) {
458 const uint8_t* data = labels.getData(&read_len);
462 buf.writeData(data, read_len);
467 if (!domain_name.empty()) {
468 buf.writeData(&domain_name[0], domain_name.size());
495 buf.writeUint8(impl_->
flags_);
516 std::ostringstream stream;
517 std::string in(indent,
' ');
518 stream << in <<
"type=" <<
type_ <<
" (CLIENT_FQDN), "
528 return (stream.str());
533 uint16_t domain_name_length = 0;
This is a base class for exceptions thrown from the DNS library module.
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
Exception thrown when invalid domain name is specified.
Exception thrown when invalid flags have been specified for DHCPv4 Client FQDN Option.
Implements the logic for the Option6ClientFqdn class.
Option4ClientFqdn::DomainNameType domain_name_type_
Indicates whether domain name is partial or fully qualified.
Option4ClientFqdn::Rcode rcode1_
Holds RCODE1 and RCODE2 values.
Option4ClientFqdnImpl(const uint8_t flags, const Option4ClientFqdn::Rcode &rcode, const std::string &domain_name, const Option4ClientFqdn::DomainNameType name_type)
Constructor, from domain name.
static void checkFlags(const uint8_t flags, const bool check_mbz)
Check if flags are valid.
void setDomainName(const std::string &domain_name, const Option4ClientFqdn::DomainNameType name_type)
Set a new domain name for the option.
void parseWireData(OptionBufferConstIter first, OptionBufferConstIter last)
Parse the Option provided in the wire format.
boost::shared_ptr< isc::dns::Name > domain_name_
Holds the pointer to a domain name carried in the option.
void parseCanonicalDomainName(OptionBufferConstIter first, OptionBufferConstIter last)
Parse domain-name encoded in the canonical format.
Option4ClientFqdn::Rcode rcode2_
Option4ClientFqdnImpl & operator=(const Option4ClientFqdnImpl &source)
Assignment operator.
uint8_t flags_
Holds flags carried by the option.
void parseASCIIDomainName(OptionBufferConstIter first, OptionBufferConstIter last)
Parse domain-name encoded in the deprecated ASCII format.
Represents the value of one of the RCODE1 or RCODE2 fields.
uint8_t getCode() const
Returns the value of the RCODE.
Represents DHCPv4 Client FQDN Option (code 81).
static const uint16_t FIXED_FIELDS_LEN
The size in bytes of the fixed fields within DHCPv4 Client Fqdn Option.
void setRcode(const Rcode &rcode)
Set Rcode value.
virtual uint16_t len() const
Returns length of the complete option (data length + DHCPv4 option header).
static const uint8_t FLAG_N
Bit N.
bool getFlag(const uint8_t flag) const
Checks if the specified flag of the DHCPv4 Client FQDN Option is set.
static const uint8_t FLAG_S
Bit S.
DomainNameType getDomainNameType() const
Returns enumerator value which indicates whether domain-name is partial or full.
virtual void unpack(OptionBufferConstIter first, OptionBufferConstIter last)
Parses option from the received buffer.
void packDomainName(isc::util::OutputBuffer &buf) const
Writes domain-name in the wire format into a buffer.
Option4ClientFqdn & operator=(const Option4ClientFqdn &source)
Assignment operator.
void setDomainName(const std::string &domain_name, const DomainNameType domain_name_type)
Set new domain-name.
static const uint8_t FLAG_MASK
Mask which zeroes MBZ flag bits.
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.
DomainNameType
Type of the domain-name: partial or full.
virtual ~Option4ClientFqdn()
Destructor.
std::pair< Rcode, Rcode > getRcode() const
Returns Rcode objects representing value of RCODE1 and RCODE2.
void resetDomainName()
Set empty domain-name.
void setFlag(const uint8_t flag, const bool set)
Modifies the value of the specified DHCPv4 Client Fqdn Option flag.
static const uint8_t FLAG_O
Bit O.
virtual void pack(isc::util::OutputBuffer &buf, bool check=true) const
Writes option in the wire format into a buffer.
virtual OptionPtr clone() const
Copies this option and returns a pointer to the copy.
void resetFlags()
Sets the flag field value to 0.
static const uint8_t FLAG_E
Bit E.
std::string getDomainName() const
Returns the domain-name in the text format.
virtual std::string toText(int indent=0) const
Returns string representation of the option.
uint16_t type_
option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
static bool lenient_parsing_
Governs whether options should be parsed less strictly.
virtual uint16_t getHeaderLen() const
Returns length of header (2 for v4, 4 for v6)
Option & operator=(const Option &rhs)
Assignment operator.
void setData(InputIterator first, InputIterator last)
Sets content of this option from buffer.
void packHeader(isc::util::OutputBuffer &buf, bool check=true) const
Store option's header in a buffer.
void check() const
A protected method used for option correctness.
Exception thrown during option unpacking This exception is thrown when an error has occurred unpackin...
Light-weight Accessor to Name data.
The Name class encapsulates DNS names.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
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
string trim(const string &input)
Trim leading and trailing spaces.
Defines the logger used by the top-level component of kea-lfc.