Kea  2.3.4-git
option4_client_fqdn.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2022 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef OPTION4_CLIENT_FQDN_H
8 #define OPTION4_CLIENT_FQDN_H
9 
10 #include <dhcp/option.h>
11 #include <dns/name.h>
12 
13 #include <string>
14 #include <utility>
15 
16 namespace isc {
17 namespace dhcp {
18 
22 public:
23  InvalidOption4FqdnFlags(const char* file, size_t line, const char* what) :
24  isc::Exception(file, line, what) {}
25 };
26 
29 public:
30  InvalidOption4FqdnDomainName(const char* file, size_t line,
31  const char* what) :
32  isc::Exception(file, line, what) {}
33 };
34 
37 
110 class Option4ClientFqdn : public Option {
111 public:
112 
115 
116  static const uint8_t FLAG_S = 0x01;
117  static const uint8_t FLAG_O = 0x02;
118  static const uint8_t FLAG_E = 0x04;
119  static const uint8_t FLAG_N = 0x08;
120 
121 
123  static const uint8_t FLAG_MASK = 0xF;
124 
129  class Rcode {
130  public:
131  Rcode(const uint8_t rcode)
132  : rcode_(rcode) { }
133 
138  uint8_t getCode() const {
139  return (rcode_);
140  }
141 
142  private:
143  uint8_t rcode_;
144  };
145 
146 
150  FULL
151  };
152 
160  static const uint16_t FIXED_FIELDS_LEN = 3;
161 
189  explicit Option4ClientFqdn(const uint8_t flags,
190  const Rcode& rcode,
191  const std::string& domain_name,
192  const DomainNameType domain_name_type = FULL);
193 
204  Option4ClientFqdn(const uint8_t flags, const Rcode& rcode);
205 
221  OptionBufferConstIter last);
222 
224  Option4ClientFqdn(const Option4ClientFqdn& source);
225 
227  virtual OptionPtr clone() const;
228 
230  virtual ~Option4ClientFqdn();
231 
233  Option4ClientFqdn& operator=(const Option4ClientFqdn& source);
234 
246  bool getFlag(const uint8_t flag) const;
247 
257  void setFlag(const uint8_t flag, const bool set);
258 
260  void resetFlags();
261 
266  std::pair<Rcode, Rcode> getRcode() const;
267 
272  void setRcode(const Rcode& rcode);
273 
281  std::string getDomainName() const;
282 
288  void packDomainName(isc::util::OutputBuffer& buf) const;
289 
297  void setDomainName(const std::string& domain_name,
298  const DomainNameType domain_name_type);
299 
304  void resetDomainName();
305 
311  DomainNameType getDomainNameType() const;
312 
317  virtual void pack(isc::util::OutputBuffer& buf, bool check = true) const;
318 
329  virtual void unpack(OptionBufferConstIter first,
330  OptionBufferConstIter last);
331 
340  virtual std::string toText(int indent = 0) const;
341 
346  virtual uint16_t len() const;
347 
351 
352  inline static const Rcode& RCODE_SERVER() {
354  static Rcode rcode(255);
355  return (rcode);
356  }
357 
359  inline static const Rcode& RCODE_CLIENT() {
360  static Rcode rcode(0);
361  return (rcode);
362  }
364 
365 private:
366 
368  Option4ClientFqdnImpl* impl_;
369 };
370 
372 typedef boost::shared_ptr<Option4ClientFqdn> Option4ClientFqdnPtr;
373 
374 } // namespace isc::dhcp
375 } // namespace isc
376 
377 #endif // OPTION4_CLIENT_FQDN_H
DomainNameType
Type of the domain-name: partial or full.
Represents the value of one of the RCODE1 or RCODE2 fields.
boost::shared_ptr< Option > OptionPtr
Definition: option.h:36
boost::shared_ptr< Option4ClientFqdn > Option4ClientFqdnPtr
A pointer to the Option4ClientFqdn object.
Represents DHCPv4 Client FQDN Option (code 81).
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
InvalidOption4FqdnFlags(const char *file, size_t line, const char *what)
InvalidOption4FqdnDomainName(const char *file, size_t line, const char *what)
Implements the logic for the Option6ClientFqdn class.
Exception thrown when invalid flags have been specified for DHCPv4 Client FQDN Option.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition: buffer.h:294
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
Definition: option.h:30
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-lfc.
Exception thrown when invalid domain name is specified.
uint8_t getCode() const
Returns the value of the RCODE.
static const Rcode & RCODE_CLIENT()
Rcode being set by the client.