Kea: option4_client_fqdn.h Source File

| Kea 3.2.0-git

option4_client_fqdn.h
Go to the documentation of this file.
1// Copyright (C) 2013-2025 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
21 class InvalidOption4FqdnFlags : public Exception {
22public:
23 InvalidOption4FqdnFlags(const char* file, size_t line, const char* what) :
24 isc::Exception(file, line, what) {}
25};
26
28 class InvalidOption4FqdnDomainName : public Exception {
29public:
30 InvalidOption4FqdnDomainName(const char* file, size_t line,
31 const char* what) :
32 isc::Exception(file, line, what) {}
33};
34
36class Option4ClientFqdnImpl;
37
110 class 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 : uint16_t {
149 PARTIAL,
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
220 explicit Option4ClientFqdn(OptionBufferConstIter first,
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
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 }
363
364
365private:
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
isc::Exception::Exception
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
Definition exceptions/exceptions.cc:17
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition exceptions/exceptions.cc:32
isc::dhcp::InvalidOption4FqdnDomainName::InvalidOption4FqdnDomainName
InvalidOption4FqdnDomainName(const char *file, size_t line, const char *what)
Definition option4_client_fqdn.h:30
isc::dhcp::InvalidOption4FqdnFlags::InvalidOption4FqdnFlags
InvalidOption4FqdnFlags(const char *file, size_t line, const char *what)
Definition option4_client_fqdn.h:23
isc::dhcp::Option4ClientFqdnImpl
Implements the logic for the Option4ClientFqdn class.
Definition option4_client_fqdn.cc:29
isc::dhcp::Option4ClientFqdn::Rcode
Represents the value of one of the RCODE1 or RCODE2 fields.
Definition option4_client_fqdn.h:129
isc::dhcp::Option4ClientFqdn::Rcode::getCode
uint8_t getCode() const
Returns the value of the RCODE.
Definition option4_client_fqdn.h:138
isc::dhcp::Option4ClientFqdn::Rcode::Rcode
Rcode(const uint8_t rcode)
Definition option4_client_fqdn.h:131
isc::dhcp::Option4ClientFqdn::FIXED_FIELDS_LEN
static const uint16_t FIXED_FIELDS_LEN
The size in bytes of the fixed fields within DHCPv4 Client Fqdn Option.
Definition option4_client_fqdn.h:160
isc::dhcp::Option4ClientFqdn::setRcode
void setRcode(const Rcode &rcode)
Set Rcode value.
Definition option4_client_fqdn.cc:434
isc::dhcp::Option4ClientFqdn::len
virtual uint16_t len() const
Returns length of the complete option (data length + DHCPv4 option header).
Definition option4_client_fqdn.cc:549
isc::dhcp::Option4ClientFqdn::RCODE_SERVER
static const Rcode & RCODE_SERVER()
Rcode being set by the server.
Definition option4_client_fqdn.h:353
isc::dhcp::Option4ClientFqdn::FLAG_N
static const uint8_t FLAG_N
Bit N.
Definition option4_client_fqdn.h:119
isc::dhcp::Option4ClientFqdn::getFlag
bool getFlag(const uint8_t flag) const
Checks if the specified flag of the DHCPv4 Client FQDN Option is set.
Definition option4_client_fqdn.cc:390
isc::dhcp::Option4ClientFqdn::FLAG_S
static const uint8_t FLAG_S
Bit S.
Definition option4_client_fqdn.h:116
isc::dhcp::Option4ClientFqdn::getDomainNameType
DomainNameType getDomainNameType() const
Returns enumerator value which indicates whether domain-name is partial or full.
Definition option4_client_fqdn.cc:495
isc::dhcp::Option4ClientFqdn::unpack
virtual void unpack(OptionBufferConstIter first, OptionBufferConstIter last)
Parses option from the received buffer.
Definition option4_client_fqdn.cc:513
isc::dhcp::Option4ClientFqdn::packDomainName
void packDomainName(isc::util::OutputBuffer &buf) const
Writes domain-name in the wire format into a buffer.
Definition option4_client_fqdn.cc:456
isc::dhcp::Option4ClientFqdn::operator=
Option4ClientFqdn & operator=(const Option4ClientFqdn &source)
Assignment operator.
Definition option4_client_fqdn.cc:381
isc::dhcp::Option4ClientFqdn::setDomainName
void setDomainName(const std::string &domain_name, const DomainNameType domain_name_type)
Set new domain-name.
Definition option4_client_fqdn.cc:484
isc::dhcp::Option4ClientFqdn::FLAG_MASK
static const uint8_t FLAG_MASK
Mask which zeroes MBZ flag bits.
Definition option4_client_fqdn.h:123
isc::dhcp::Option4ClientFqdn::Option4ClientFqdn
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.
Definition option4_client_fqdn.cc:348
isc::dhcp::Option4ClientFqdn::~Option4ClientFqdn
virtual ~Option4ClientFqdn()
Destructor.
Definition option4_client_fqdn.cc:363
isc::dhcp::Option4ClientFqdn::getRcode
std::pair< Rcode, Rcode > getRcode() const
Returns Rcode objects representing value of RCODE1 and RCODE2.
Definition option4_client_fqdn.cc:429
isc::dhcp::Option4ClientFqdn::resetDomainName
void resetDomainName()
Set empty domain-name.
Definition option4_client_fqdn.cc:490
isc::dhcp::Option4ClientFqdn::setFlag
void setFlag(const uint8_t flag, const bool set)
Modifies the value of the specified DHCPv4 Client Fqdn Option flag.
Definition option4_client_fqdn.cc:402
isc::dhcp::Option4ClientFqdn::FLAG_O
static const uint8_t FLAG_O
Bit O.
Definition option4_client_fqdn.h:117
isc::dhcp::Option4ClientFqdn::pack
virtual void pack(isc::util::OutputBuffer &buf, bool check=true) const
Writes option in the wire format into a buffer.
Definition option4_client_fqdn.cc:500
isc::dhcp::Option4ClientFqdn::RCODE_CLIENT
static const Rcode & RCODE_CLIENT()
Rcode being set by the client.
Definition option4_client_fqdn.h:359
isc::dhcp::Option4ClientFqdn::clone
virtual OptionPtr clone() const
Copies this option and returns a pointer to the copy.
Definition option4_client_fqdn.cc:373
isc::dhcp::Option4ClientFqdn::DomainNameType
DomainNameType
Type of the domain-name: partial or full.
Definition option4_client_fqdn.h:148
isc::dhcp::Option4ClientFqdn::FULL
@ FULL
Definition option4_client_fqdn.h:150
isc::dhcp::Option4ClientFqdn::PARTIAL
@ PARTIAL
Definition option4_client_fqdn.h:149
isc::dhcp::Option4ClientFqdn::resetFlags
void resetFlags()
Sets the flag field value to 0.
Definition option4_client_fqdn.cc:440
isc::dhcp::Option4ClientFqdn::FLAG_E
static const uint8_t FLAG_E
Bit E.
Definition option4_client_fqdn.h:118
isc::dhcp::Option4ClientFqdn::getDomainName
std::string getDomainName() const
Returns the domain-name in the text format.
Definition option4_client_fqdn.cc:445
isc::dhcp::Option4ClientFqdn::toText
virtual std::string toText(int indent=0) const
Returns string representation of the option.
Definition option4_client_fqdn.cc:532
isc::dhcp::Option::Option
Option(Universe u, uint16_t type)
ctor, used for options constructed, usually during transmission
Definition option.cc:39
isc::dhcp::Option::check
void check() const
A protected method used for option correctness.
Definition option.cc:90
isc::util::OutputBuffer
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition buffer.h:346
name.h
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::OptionBufferConstIter
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
Definition option.h:30
isc::dhcp::Option4ClientFqdnPtr
boost::shared_ptr< Option4ClientFqdn > Option4ClientFqdnPtr
A pointer to the Option4ClientFqdn object.
Definition option4_client_fqdn.h:372
isc::dhcp::OptionPtr
boost::shared_ptr< Option > OptionPtr
Definition option.h:37
isc::util::file
Definition filesystem.cc:29
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
option.h