Kea 2.7.6
option4_client_fqdn.h
Go to the documentation of this file.
1// Copyright (C) 2013-2024 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
16namespace isc {
17namespace dhcp {
18
22public:
23 InvalidOption4FqdnFlags(const char* file, size_t line, const char* what) :
24 isc::Exception(file, line, what) {}
25};
26
29public:
30 InvalidOption4FqdnDomainName(const char* file, size_t line,
31 const char* what) :
32 isc::Exception(file, line, what) {}
33};
34
36class Option4ClientFqdnImpl;
37
110class Option4ClientFqdn : public Option {
111public:
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;
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
148 enum DomainNameType : int {
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
222
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
289
297 void setDomainName(const std::string& domain_name,
298 const DomainNameType domain_name_type);
299
304 void resetDomainName();
305
312
317 virtual void pack(isc::util::OutputBuffer& buf, bool check = true) const;
318
329 virtual void unpack(OptionBufferConstIter first,
331
340 virtual std::string toText(int indent = 0) const;
341
346 virtual uint16_t len() const;
347
351
352
353 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
365private:
366
369};
370
372typedef boost::shared_ptr<Option4ClientFqdn> Option4ClientFqdnPtr;
373
374} // namespace isc::dhcp
375} // namespace isc
376
377#endif // OPTION4_CLIENT_FQDN_H
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.
Exception thrown when invalid domain name is specified.
InvalidOption4FqdnDomainName(const char *file, size_t line, const char *what)
Exception thrown when invalid flags have been specified for DHCPv4 Client FQDN Option.
InvalidOption4FqdnFlags(const char *file, size_t line, const char *what)
Implements the logic for the Option6ClientFqdn class.
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 Rcode & RCODE_SERVER()
Rcode being set by the server.
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.
static const Rcode & RCODE_CLIENT()
Rcode being set by the client.
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.
void check() const
A protected method used for option correctness.
Definition option.cc:90
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition buffer.h:343
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
Definition option.h:30
boost::shared_ptr< Option4ClientFqdn > Option4ClientFqdnPtr
A pointer to the Option4ClientFqdn object.
boost::shared_ptr< Option > OptionPtr
Definition option.h:37
Defines the logger used by the top-level component of kea-lfc.