BIND 10 trac3316, updated. 87f58c5dd3b8555dc0ecb449f1f39e2cc0198806 [3316] Use OptionVendorClass to encapsulate DHCPv4 option 124.
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Feb 13 15:46:10 UTC 2014
The branch, trac3316 has been updated
via 87f58c5dd3b8555dc0ecb449f1f39e2cc0198806 (commit)
from 2027fa4cd4d38923038e04a3c766097eaa0da5fb (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 87f58c5dd3b8555dc0ecb449f1f39e2cc0198806
Author: Marcin Siodelski <marcin at isc.org>
Date: Thu Feb 13 16:45:57 2014 +0100
[3316] Use OptionVendorClass to encapsulate DHCPv4 option 124.
-----------------------------------------------------------------------
Summary of changes:
src/lib/dhcp/option_definition.cc | 13 ++++++++++++-
src/lib/dhcp/option_definition.h | 7 ++++++-
src/lib/dhcp/std_option_defs.h | 11 ++++++++---
src/lib/dhcp/tests/libdhcp++_unittest.cc | 12 +++++++++---
4 files changed, 35 insertions(+), 8 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/option_definition.cc b/src/lib/dhcp/option_definition.cc
index c8c836f..4f16c66 100644
--- a/src/lib/dhcp/option_definition.cc
+++ b/src/lib/dhcp/option_definition.cc
@@ -401,6 +401,14 @@ OptionDefinition::haveVendor6Format() const {
}
bool
+OptionDefinition::haveVendorClass4Format() const {
+ return (haveType(OPT_RECORD_TYPE) &&
+ (record_fields_.size() == 2) &&
+ (record_fields_[0] == OPT_UINT32_TYPE) &&
+ (record_fields_[1] == OPT_BINARY_TYPE));
+}
+
+bool
OptionDefinition::haveVendorClass6Format() const {
return (haveType(OPT_RECORD_TYPE) &&
(record_fields_.size() == 2) &&
@@ -669,7 +677,10 @@ OptionDefinition::factorySpecialFormatOption(Option::Universe u,
} else {
if ((getCode() == DHO_FQDN) && haveFqdn4Format()) {
return (OptionPtr(new Option4ClientFqdn(begin, end)));
-
+ // V-I VendorClass
+ } else if ((getCode() == DHO_VIVCO_SUBOPTIONS) &&
+ haveVendorClass4Format()) {
+ return (OptionPtr(new OptionVendorClass(Option::V4, begin, end)));
} else if (getCode() == DHO_VIVSO_SUBOPTIONS && haveVendor4Format()) {
// Vendor-Specific Information.
return (OptionPtr(new OptionVendor(Option::V4, begin, end)));
diff --git a/src/lib/dhcp/option_definition.h b/src/lib/dhcp/option_definition.h
index 68f4036..3664d9d 100644
--- a/src/lib/dhcp/option_definition.h
+++ b/src/lib/dhcp/option_definition.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
@@ -324,6 +324,11 @@ public:
/// Vendor-Specific Information %Option.
bool haveVendor6Format() const;
+ /// @brief Check if the option has format of DHCPv4 V-I Vendor Class option.
+ ///
+ /// @return true if the option has the format of DHCPv4 Vendor Class option.
+ bool haveVendorClass4Format() const;
+
/// @brief Check if the option has format of DHCPv6 Vendor Class option.
///
/// @return true if option has the format of DHCPv6 Vendor Class option.
diff --git a/src/lib/dhcp/std_option_defs.h b/src/lib/dhcp/std_option_defs.h
index 865407e..d55d2f0 100644
--- a/src/lib/dhcp/std_option_defs.h
+++ b/src/lib/dhcp/std_option_defs.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
@@ -67,6 +67,11 @@ struct OptionDefParams {
RECORD_DECL(FQDN_RECORDS, OPT_UINT8_TYPE, OPT_UINT8_TYPE, OPT_UINT8_TYPE,
OPT_FQDN_TYPE);
+// V-I Vendor Class record fields.
+//
+// Opaque data is represented here by the binary data field.
+RECORD_DECL(VIVCO_RECORDS, OPT_UINT32_TYPE, OPT_BINARY_TYPE);
+
/// @brief Definitions of standard DHCPv4 options.
const OptionDefParams OPTION_DEF_PARAMS4[] = {
{ "subnet-mask", DHO_SUBNET_MASK, OPT_IPV4_ADDRESS_TYPE, false, NO_RECORD_DEF, "" },
@@ -191,8 +196,8 @@ const OptionDefParams OPTION_DEF_PARAMS4[] = {
// dedicated classes to handle them. Until that happens
// let's treat them as 'binary' options.
{ "domain-search", DHO_DOMAIN_SEARCH, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
- { "vivco-suboptions", DHO_VIVCO_SUBOPTIONS,
- OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
+ { "vivco-suboptions", DHO_VIVCO_SUBOPTIONS, OPT_RECORD_TYPE,
+ false, RECORD_DEF(VIVCO_RECORDS), "" },
{ "vivso-suboptions", DHO_VIVSO_SUBOPTIONS, OPT_BINARY_TYPE,
false, NO_RECORD_DEF, "" }
diff --git a/src/lib/dhcp/tests/libdhcp++_unittest.cc b/src/lib/dhcp/tests/libdhcp++_unittest.cc
index f0bd282..f40067f 100644
--- a/src/lib/dhcp/tests/libdhcp++_unittest.cc
+++ b/src/lib/dhcp/tests/libdhcp++_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
@@ -942,8 +942,14 @@ TEST_F(LibDhcpTest, stdOptionDefs4) {
LibDhcpTest::testStdOptionDefs4(DHO_DOMAIN_SEARCH, begin, end,
typeid(Option));
- LibDhcpTest::testStdOptionDefs4(DHO_VIVCO_SUBOPTIONS, begin, end,
- typeid(Option));
+ // V-I Vendor option requires specially crafted data.
+ const char vivco_data[] = {
+ 1, 2, 3, 4, // enterprise id
+ 3, 1, 2, 3 // first byte is opaque data length, the rest is opaque data
+ };
+ std::vector<uint8_t> vivco_buf(vivco_data, vivco_data + sizeof(vivco_data));
+ LibDhcpTest::testStdOptionDefs4(DHO_VIVCO_SUBOPTIONS, vivco_buf.begin(),
+ vivco_buf.end(), typeid(OptionVendorClass));
LibDhcpTest::testStdOptionDefs4(DHO_VIVSO_SUBOPTIONS, begin, end,
typeid(OptionVendor));
More information about the bind10-changes
mailing list