| Kea 3.0.2-git

option_space.h
Go to the documentation of this file.
1// Copyright (C) 2012-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 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
30 class OptionSpace;
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
87 void clearVendorSpace() {
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
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::InvalidOptionSpace::InvalidOptionSpace
InvalidOptionSpace(const char *file, size_t line, const char *what)
Definition option_space.h:25
isc::dhcp::OptionSpace6::OptionSpace6
OptionSpace6(const std::string &name)
Constructor for non-vendor-specific options.
Definition option_space.cc:47
isc::dhcp::OptionSpace6::getEnterpriseNumber
uint32_t getEnterpriseNumber() const
Return enterprise number for the option space.
Definition option_space.h:168
isc::dhcp::OptionSpace::setVendorSpace
void setVendorSpace()
Mark option space as vendor specific.
Definition option_space.h:98
isc::dhcp::OptionSpace::getName
const std::string & getName() const
Return option space name.
Definition option_space.h:84
isc::dhcp::OptionSpace::isVendorSpace
bool isVendorSpace() const
Check if option space is vendor specific.
Definition option_space.h:95
isc::dhcp::OptionSpace::validateName
static bool validateName(const std::string &name)
Checks that the provided option space name is valid.
Definition option_space.cc:26
isc::dhcp::OptionSpace::OptionSpace
OptionSpace(const std::string &name, const bool vendor_space=false)
Constructor.
Definition option_space.cc:16
isc::dhcp::OptionSpace::clearVendorSpace
void clearVendorSpace()
Mark option space as non-vendor space.
Definition option_space.h:87
exceptions.h
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::OptionSpacePtr
boost::shared_ptr< OptionSpace > OptionSpacePtr
A pointer to OptionSpace object.
Definition option_space.h:32
isc::dhcp::OptionSpaceCollection
std::map< std::string, OptionSpacePtr > OptionSpaceCollection
A collection of option spaces.
Definition option_space.h:34
isc::util::file
Definition filesystem.cc:28
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
std_option_defs.h