summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcp/option_definition.cc
diff options
context:
space:
mode:
authorMarcin Siodelski <marcin@isc.org>2013-01-11 11:11:31 +0100
committerMarcin Siodelski <marcin@isc.org>2013-01-15 15:06:05 +0100
commit656b5d1cb045b35499ced064fae6bc1962f91ad6 (patch)
tree77e9eb5bc7bc81b12e10146da91cc7c210636bc5 /src/lib/dhcp/option_definition.cc
parent[2314] Validate option space name received in a configuration. (diff)
downloadkea-656b5d1cb045b35499ced064fae6bc1962f91ad6.tar.xz
kea-656b5d1cb045b35499ced064fae6bc1962f91ad6.zip
[2314] Added encapsulated option space name to option definition.
Diffstat (limited to 'src/lib/dhcp/option_definition.cc')
-rw-r--r--src/lib/dhcp/option_definition.cc38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/lib/dhcp/option_definition.cc b/src/lib/dhcp/option_definition.cc
index d2b5aaef46..03583acf1d 100644
--- a/src/lib/dhcp/option_definition.cc
+++ b/src/lib/dhcp/option_definition.cc
@@ -21,6 +21,7 @@
#include <dhcp/option_definition.h>
#include <dhcp/option_int.h>
#include <dhcp/option_int_array.h>
+#include <dhcp/option_space.h>
#include <util/encode/hex.h>
#include <util/strutil.h>
#include <boost/algorithm/string/classification.hpp>
@@ -40,7 +41,8 @@ OptionDefinition::OptionDefinition(const std::string& name,
: name_(name),
code_(code),
type_(OPT_UNKNOWN_TYPE),
- array_type_(array_type) {
+ array_type_(array_type),
+ encapsulated_space_("") {
// Data type is held as enum value by this class.
// Use the provided option type string to get the
// corresponding enum value.
@@ -54,7 +56,34 @@ OptionDefinition::OptionDefinition(const std::string& name,
: name_(name),
code_(code),
type_(type),
- array_type_(array_type) {
+ array_type_(array_type),
+ encapsulated_space_("") {
+}
+
+OptionDefinition::OptionDefinition(const std::string& name,
+ const uint16_t code,
+ const std::string& type,
+ const char* encapsulated_space)
+ : name_(name),
+ code_(code),
+ type_(OPT_UNKNOWN_TYPE),
+ array_type_(false),
+ encapsulated_space_(encapsulated_space) {
+ // Data type is held as enum value by this class.
+ // Use the provided option type string to get the
+ // corresponding enum value.
+ type_ = OptionDataTypeUtil::getDataType(type);
+}
+
+OptionDefinition::OptionDefinition(const std::string& name,
+ const uint16_t code,
+ const OptionDataType type,
+ const char* encapsulated_space)
+ : name_(name),
+ code_(code),
+ type_(type),
+ array_type_(false),
+ encapsulated_space_(encapsulated_space) {
}
void
@@ -228,6 +257,11 @@ OptionDefinition::validate() const {
all(find_tail(name_, 1), boost::is_any_of(std::string("-_")))) {
err_str << "invalid option name '" << name_ << "'";
+ } else if (!encapsulated_space_.empty() &&
+ !OptionSpace::validateName(encapsulated_space_)) {
+ err_str << "invalid encapsulated option space name: '"
+ << encapsulated_space_ << "'";
+
} else if (type_ >= OPT_UNKNOWN_TYPE) {
// Option definition must be of a known type.
err_str << "option type value " << type_ << " is out of range.";