BIND 10 dhcp-vendoropts, updated. 73ab9c6c43eb46eb3c093678e561e47265a84fb2 [dhcp-vendorptos] DOCSIS3 V6 option space initialized and parsed.
BIND 10 source code commits
bind10-changes at lists.isc.org
Sat Oct 12 10:56:55 UTC 2013
The branch, dhcp-vendoropts has been updated
via 73ab9c6c43eb46eb3c093678e561e47265a84fb2 (commit)
from d1a691d898010d4231b9e46aabe90202137500b0 (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 73ab9c6c43eb46eb3c093678e561e47265a84fb2
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Sat Oct 12 12:56:40 2013 +0200
[dhcp-vendorptos] DOCSIS3 V6 option space initialized and parsed.
- DOCSIS3 V6 option definitions initialized properly.
- Incoming packets are parsed properly.
- Several simple unit-tests added.
-----------------------------------------------------------------------
Summary of changes:
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc | 23 +++++++++++
src/lib/dhcp/docsis3_option_defs.h | 2 +
src/lib/dhcp/libdhcp++.cc | 60 ++++++++++++++++++++---------
src/lib/dhcp/libdhcp++.h | 2 +
4 files changed, 69 insertions(+), 18 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index b97c93d..908ef12 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -2052,6 +2052,29 @@ TEST_F(Dhcpv6SrvTest, docsisVendorOptionsParse) {
EXPECT_FALSE(vendor->getOption(17));
}
+// Checks if server is able to parse incoming docsis option and extract suboption 1 (docsis ORO)
+TEST_F(Dhcpv6SrvTest, docsisVendorORO) {
+
+ NakedDhcpv6Srv srv(0);
+
+ // Let's get a traffic capture from DOCSIS3.0 modem
+ Pkt6Ptr sol = captureDocsisRelayedSolicit();
+ EXPECT_NO_THROW(sol->unpack());
+
+ // Check if the packet contain
+ OptionPtr opt = sol->getOption(D6O_VENDOR_OPTS);
+ ASSERT_TRUE(opt);
+
+ boost::shared_ptr<OptionVendor> vendor = boost::dynamic_pointer_cast<OptionVendor>(opt);
+ ASSERT_TRUE(vendor);
+
+ opt = vendor->getOption(DOCSIS3_V6_ORO);
+ ASSERT_TRUE(opt);
+
+ OptionUint16ArrayPtr oro = boost::dynamic_pointer_cast<OptionUint16Array>(opt);
+ EXPECT_TRUE(oro);
+}
+
// This test verifies that the following option structure can be parsed:
// - option (option space 'foobar')
// - sub option (option space 'foo')
diff --git a/src/lib/dhcp/docsis3_option_defs.h b/src/lib/dhcp/docsis3_option_defs.h
index dfb95c2..14068a8 100644
--- a/src/lib/dhcp/docsis3_option_defs.h
+++ b/src/lib/dhcp/docsis3_option_defs.h
@@ -20,6 +20,8 @@
namespace {
+#define VENDOR_ID_CABLE_LABS 4491
+
#define DOCSIS3_V4_TFTP_SERVERS 125
/// @brief Definitions of standard DHCPv4 options.
diff --git a/src/lib/dhcp/libdhcp++.cc b/src/lib/dhcp/libdhcp++.cc
index d4cdfb4..a3f33f7 100644
--- a/src/lib/dhcp/libdhcp++.cc
+++ b/src/lib/dhcp/libdhcp++.cc
@@ -52,6 +52,12 @@ VendorOptionDefContainers LibDHCP::vendor4_defs_;
VendorOptionDefContainers LibDHCP::vendor6_defs_;
+// Let's keep it in .cc file. Moving it to .h would require including optionDefParams
+// definitions there
+void initOptionSpace6(OptionDefContainer& defs,
+ const OptionDefParams* params,
+ size_t params_size);
+
const OptionDefContainer&
LibDHCP::getOptionDefs(const Option::Universe u) {
switch (u) {
@@ -82,6 +88,12 @@ LibDHCP::getVendorOption4Defs(uint32_t vendor_id) {
const OptionDefContainer*
LibDHCP::getVendorOption6Defs(uint32_t vendor_id) {
+
+ if (vendor_id == VENDOR_ID_CABLE_LABS &&
+ vendor6_defs_.find(VENDOR_ID_CABLE_LABS) == vendor6_defs_.end()) {
+ initVendorOptsDocsis6();
+ }
+
VendorOptionDefContainers::const_iterator def = vendor6_defs_.find(vendor_id);
if (def == vendor6_defs_.end()) {
// No such vendor-id space
@@ -596,13 +608,25 @@ LibDHCP::initStdOptionDefs4() {
void
LibDHCP::initStdOptionDefs6() {
- v6option_defs_.clear();
+ initOptionSpace6(v6option_defs_, OPTION_DEF_PARAMS6, OPTION_DEF_PARAMS_SIZE6);
+}
- for (int i = 0; i < OPTION_DEF_PARAMS_SIZE6; ++i) {
- std::string encapsulates(OPTION_DEF_PARAMS6[i].encapsulates);
- if (!encapsulates.empty() && OPTION_DEF_PARAMS6[i].array) {
+void
+LibDHCP::initVendorOptsDocsis6() {
+ vendor6_defs_[VENDOR_ID_CABLE_LABS] = OptionDefContainer();
+ initOptionSpace6(vendor6_defs_[VENDOR_ID_CABLE_LABS], DOCSIS3_V6_DEFS, DOCSIS3_V6_DEFS_SIZE);
+}
+
+void initOptionSpace6(OptionDefContainer& defs,
+ const OptionDefParams* params,
+ size_t params_size) {
+ defs.clear();
+
+ for (int i = 0; i < params_size; ++i) {
+ std::string encapsulates(params[i].encapsulates);
+ if (!encapsulates.empty() && params[i].array) {
isc_throw(isc::BadValue, "invalid standard option definition: "
- << "option with code '" << OPTION_DEF_PARAMS6[i].code
+ << "option with code '" << params[i].code
<< "' may not encapsulate option space '"
<< encapsulates << "' because the definition"
<< " indicates that this option comprises an array"
@@ -615,33 +639,33 @@ LibDHCP::initStdOptionDefs6() {
OptionDefinitionPtr definition;
if (encapsulates.empty()) {
// Option does not encapsulate any option space.
- definition.reset(new OptionDefinition(OPTION_DEF_PARAMS6[i].name,
- OPTION_DEF_PARAMS6[i].code,
- OPTION_DEF_PARAMS6[i].type,
- OPTION_DEF_PARAMS6[i].array));
+ definition.reset(new OptionDefinition(params[i].name,
+ params[i].code,
+ params[i].type,
+ params[i].array));
} else {
// Option does encapsulate an option space.
- definition.reset(new OptionDefinition(OPTION_DEF_PARAMS6[i].name,
- OPTION_DEF_PARAMS6[i].code,
- OPTION_DEF_PARAMS6[i].type,
- OPTION_DEF_PARAMS6[i].encapsulates));
+ definition.reset(new OptionDefinition(params[i].name,
+ params[i].code,
+ params[i].type,
+ params[i].encapsulates));
}
- for (int rec = 0; rec < OPTION_DEF_PARAMS6[i].records_size; ++rec) {
- definition->addRecordField(OPTION_DEF_PARAMS6[i].records[rec]);
+ for (int rec = 0; rec < params[i].records_size; ++rec) {
+ definition->addRecordField(params[i].records[rec]);
}
try {
definition->validate();
- } catch (const Exception& ex) {
+ } catch (const isc::Exception& ex) {
// This is unlikely event that validation fails and may
// be only caused by programming error. To guarantee the
// data consistency we clear all option definitions that
// have been added so far and pass the exception forward.
- v6option_defs_.clear();
+ defs.clear();
throw;
}
- v6option_defs_.push_back(definition);
+ defs.push_back(definition);
}
}
diff --git a/src/lib/dhcp/libdhcp++.h b/src/lib/dhcp/libdhcp++.h
index 563aa22..a05d927 100644
--- a/src/lib/dhcp/libdhcp++.h
+++ b/src/lib/dhcp/libdhcp++.h
@@ -183,6 +183,8 @@ private:
/// is incorrect. This is a programming error.
static void initStdOptionDefs6();
+ static void initVendorOptsDocsis6();
+
/// pointers to factories that produce DHCPv6 options
static FactoryMap v4factories_;
More information about the bind10-changes
mailing list