Kea  2.1.7-git
option_space.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2020 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 OPTION_SPACE_H
8 #define OPTION_SPACE_H
9 
10 #include <dhcp/std_option_defs.h>
11 #include <exceptions/exceptions.h>
12 
13 #include <boost/shared_ptr.hpp>
14 #include <map>
15 #include <stdint.h>
16 #include <string>
17 
18 namespace isc {
19 namespace dhcp {
20 
23 class InvalidOptionSpace : public Exception {
24 public:
25  InvalidOptionSpace(const char* file, size_t line, const char* what) :
26  isc::Exception(file, line, what) { };
27 };
28 
32 typedef boost::shared_ptr<OptionSpace> OptionSpacePtr;
34 typedef std::map<std::string, OptionSpacePtr> OptionSpaceCollection;
35 
66 class OptionSpace {
67 public:
68 
79  OptionSpace(const std::string& name, const bool vendor_space = false);
80 
84  const std::string& getName() const { return (name_); }
85 
88  vendor_space_ = false;
89  }
90 
95  bool isVendorSpace() const { return (vendor_space_); }
96 
98  void setVendorSpace() {
99  vendor_space_ = true;
100  }
101 
112  static bool validateName(const std::string& name);
113 
114 private:
115  std::string name_;
116 
117  bool vendor_space_;
118 
119 };
120 
136 class OptionSpace6 : public OptionSpace {
137 public:
138 
149  OptionSpace6(const std::string& name);
150 
163  OptionSpace6(const std::string& name, const uint32_t enterprise_number);
164 
168  uint32_t getEnterpriseNumber() const { return (enterprise_number_); }
169 
173  void setVendorSpace(const uint32_t enterprise_number);
174 
175 private:
176 
177  uint32_t enterprise_number_;
178 };
179 
180 } // namespace dhcp
181 } // namespace isc
182 
183 #endif // OPTION_SPACE_H
boost::shared_ptr< OptionSpace > OptionSpacePtr
A pointer to OptionSpace object.
Definition: option_space.h:30
uint32_t getEnterpriseNumber() const
Return enterprise number for the option space.
Definition: option_space.h:168
void setVendorSpace()
Mark option space as vendor specific.
Definition: option_space.h:98
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
DHCP option space.
Definition: option_space.h:66
const std::string & getName() const
Return option space name.
Definition: option_space.h:84
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.
void clearVendorSpace()
Mark option space as non-vendor space.
Definition: option_space.h:87
const Name & name_
Definition: dns/message.cc:693
InvalidOptionSpace(const char *file, size_t line, const char *what)
Definition: option_space.h:25
std::map< std::string, OptionSpacePtr > OptionSpaceCollection
A collection of option spaces.
Definition: option_space.h:34
DHCPv6 option space with enterprise number assigned.
Definition: option_space.h:136
Exception to be thrown when invalid option space is specified.
Definition: option_space.h:23
bool isVendorSpace() const
Check if option space is vendor specific.
Definition: option_space.h:95