BIND 10 trac2317, updated. f000b6b54d4abfad7abe39ed0b817a29a1f073f0 [2317] Parse record-types field in DHCPv4 option definition configuration.

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Jan 9 16:07:30 UTC 2013


The branch, trac2317 has been updated
       via  f000b6b54d4abfad7abe39ed0b817a29a1f073f0 (commit)
      from  6b78fee487016e4920ab469448c559752523d474 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f000b6b54d4abfad7abe39ed0b817a29a1f073f0
Author: Marcin Siodelski <marcin at isc.org>
Date:   Wed Jan 9 17:07:21 2013 +0100

    [2317] Parse record-types field in DHCPv4 option definition configuration.

-----------------------------------------------------------------------

Summary of changes:
 src/bin/dhcp4/config_parser.cc                |   27 ++++++++++++++++++++++---
 src/bin/dhcp4/dhcp4.spec                      |   11 ++--------
 src/bin/dhcp4/tests/config_parser_unittest.cc |    2 +-
 3 files changed, 27 insertions(+), 13 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/dhcp4/config_parser.cc b/src/bin/dhcp4/config_parser.cc
index 6fe9030..deacd7c 100644
--- a/src/bin/dhcp4/config_parser.cc
+++ b/src/bin/dhcp4/config_parser.cc
@@ -960,7 +960,8 @@ public:
         BOOST_FOREACH(ConfigPair param, option_def->mapValue()) {
             std::string entry(param.first);
             ParserPtr parser;
-            if (entry == "name" || entry == "type" || entry == "space") {
+            if (entry == "name" || entry == "type" ||
+                entry == "record-types" || entry == "space") {
                 StringParserPtr
                     str_parser(dynamic_cast<StringParser*>(StringParser::factory(entry)));
                 if (str_parser) {
@@ -981,8 +982,6 @@ public:
                     array_parser->setStorage(&boolean_values_);
                     parser = array_parser;
                 }
-            } else if (entry == "record_types") {
-                // do nothing yet
             } else {
                 isc_throw(DhcpConfigError, "invalid parameter: " << entry);
             }
@@ -1050,6 +1049,28 @@ private:
 
         OptionDefinitionPtr def(new OptionDefinition(name, code,
                                                      type, array_type));
+        // The record-types field may carry a list of comma separated names
+        // of data types that form a record.
+        std::string record_types = getParam<std::string>("record-types",
+                                                         string_values_);
+        // Split the list of record types into tokens.
+        std::vector<std::string> record_tokens =
+            isc::util::str::tokens(record_types, ",");
+        // Iterate over each token and add a record typy into
+        // option definition.
+        BOOST_FOREACH(std::string record_type, record_tokens) {
+            try {
+                boost::trim(record_type);
+                if (!record_type.empty()) {
+                    def->addRecordField(record_type);
+                }
+            } catch (const Exception& ex) {
+                isc_throw(DhcpConfigError, "invalid record type values"
+                          << " specified for the option  definition: "
+                          << ex.what());
+            }
+        }
+
         // Check the option definition parameters are valid.
         try {
             def->validate();
diff --git a/src/bin/dhcp4/dhcp4.spec b/src/bin/dhcp4/dhcp4.spec
index d5ac872..0be4da1 100644
--- a/src/bin/dhcp4/dhcp4.spec
+++ b/src/bin/dhcp4/dhcp4.spec
@@ -71,16 +71,9 @@
           },
 
           { "item_name": "record_types",
-            "item_type": "list",
+            "item_type": "string",
             "item_optional": false,
-            "item_default": [],
-            "list_item_spec":
-            {
-              "item_name": "record-type",
-              "item_type": "string",
-              "item_optional": false,
-              "item_default": ""
-            }
+            "item_default": "",
           },
 
           { "item_name": "space",
diff --git a/src/bin/dhcp4/tests/config_parser_unittest.cc b/src/bin/dhcp4/tests/config_parser_unittest.cc
index 2cd8c93..2669552 100644
--- a/src/bin/dhcp4/tests/config_parser_unittest.cc
+++ b/src/bin/dhcp4/tests/config_parser_unittest.cc
@@ -447,7 +447,7 @@ TEST_F(Dhcp4ParserTest, optionDefAdd) {
         "      \"code\": 100,"
         "      \"type\": \"ipv4-address\","
         "      \"array\": False,"
-        //        "      \"record_types\": [ ],"
+        "      \"record-types\": \"\","
         "      \"space\": \"isc\""
         "  } ]"
         "}";



More information about the bind10-changes mailing list