Kea  1.9.9-git
option4_client_fqdn.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2018 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 
36 class Option4ClientFqdnImpl;
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 
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 
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 
312 
316  virtual void pack(isc::util::OutputBuffer& buf) const;
317 
328  virtual void unpack(OptionBufferConstIter first,
329  OptionBufferConstIter last);
330 
339  virtual std::string toText(int indent = 0) const;
340 
345  virtual uint16_t len() const;
346 
350 
351  inline static const Rcode& RCODE_SERVER() {
353  static Rcode rcode(255);
354  return (rcode);
355  }
356 
358  inline static const Rcode& RCODE_CLIENT() {
359  static Rcode rcode(0);
360  return (rcode);
361  }
363 
364 private:
365 
367  Option4ClientFqdnImpl* impl_;
368 };
369 
371 typedef boost::shared_ptr<Option4ClientFqdn> Option4ClientFqdnPtr;
372 
373 } // namespace isc::dhcp
374 } // namespace isc
375 
376 #endif // OPTION4_CLIENT_FQDN_H
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.
virtual ~Option4ClientFqdn()
Destructor.
Represents the value of one of the RCODE1 or RCODE2 fields.
void resetDomainName()
Set empty domain-name.
std::pair< Rcode, Rcode > getRcode() const
Returns Rcode objects representing value of RCODE1 and RCODE2.
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).
void setDomainName(const std::string &domain_name, const DomainNameType domain_name_type)
Set new domain-name.
virtual OptionPtr clone() const
Copies this option and returns a pointer to the copy.
static const uint16_t FIXED_FIELDS_LEN
The size in bytes of the fixed fields within DHCPv4 Client Fqdn Option.
InvalidOption4FqdnFlags(const char *file, size_t line, const char *what)
std::string getDomainName() const
Returns the domain-name in the text format.
InvalidOption4FqdnDomainName(const char *file, size_t line, const char *what)
static const uint8_t FLAG_S
Bit S.
static const Rcode & RCODE_SERVER()
Rcode being set by the server.
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.
Exception thrown when invalid flags have been specified for DHCPv4 Client FQDN Option.
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.
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-dhcp-ddns.
Exception thrown when invalid domain name is specified.
static const uint8_t FLAG_E
Bit E.
static const uint8_t FLAG_O
Bit O.
virtual void unpack(OptionBufferConstIter first, OptionBufferConstIter last)
Parses option from the received buffer.
DomainNameType getDomainNameType() const
Returns enumerator value which indicates whether domain-name is partial or full.
static const Rcode & RCODE_CLIENT()
Rcode being set by the client.
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.
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.
virtual uint16_t len() const
Returns length of the complete option (data length + DHCPv4 option header).
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.
void setRcode(const Rcode &rcode)
Set Rcode value.