BIND 10 trac1186, updated. 9ed40007c0befb247ee1570b49aff02a6784e04e [1186] Tests for libdhcp::packOptions6 implemented.
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Sep 5 15:28:24 UTC 2011
The branch, trac1186 has been updated
via 9ed40007c0befb247ee1570b49aff02a6784e04e (commit)
from aa9f334d23197b8b546aa3f18aa2ed73c87ffd50 (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 9ed40007c0befb247ee1570b49aff02a6784e04e
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Mon Sep 5 17:27:31 2011 +0200
[1186] Tests for libdhcp::packOptions6 implemented.
-----------------------------------------------------------------------
Summary of changes:
src/lib/dhcp/libdhcp.cc | 2 +-
src/lib/dhcp/libdhcp.h | 7 +++--
src/lib/dhcp/tests/libdhcp_unittest.cc | 42 ++++++++++++++++++++++++++++++++
3 files changed, 47 insertions(+), 4 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/libdhcp.cc b/src/lib/dhcp/libdhcp.cc
index 90605f4..cc0663d 100644
--- a/src/lib/dhcp/libdhcp.cc
+++ b/src/lib/dhcp/libdhcp.cc
@@ -25,7 +25,7 @@
using namespace std;
using namespace isc::dhcp;
-// static array with factory
+// static array with factories for options
std::map<unsigned short, Option::Factory*> LibDHCP::v6factories_;
std::string
diff --git a/src/lib/dhcp/libdhcp.h b/src/lib/dhcp/libdhcp.h
index 0dda6d8..f1773db 100644
--- a/src/lib/dhcp/libdhcp.h
+++ b/src/lib/dhcp/libdhcp.h
@@ -75,9 +75,10 @@ public:
///
/// @return true, if registration was successful, false otherwise
///
- bool OptionFactoryRegister(Option::Universe u,
- unsigned short type,
- Option::Factory * factory);
+ static bool
+ OptionFactoryRegister(Option::Universe u,
+ unsigned short type,
+ Option::Factory * factory);
protected:
// pointers to factories that produce DHCPv6 options
static std::map<unsigned short, Option::Factory*> v6factories_;
diff --git a/src/lib/dhcp/tests/libdhcp_unittest.cc b/src/lib/dhcp/tests/libdhcp_unittest.cc
index 116f91b..0354f64 100644
--- a/src/lib/dhcp/tests/libdhcp_unittest.cc
+++ b/src/lib/dhcp/tests/libdhcp_unittest.cc
@@ -39,4 +39,46 @@ TEST_F(LibDhcpTest, basic) {
EXPECT_EQ(LibDHCP::version(), PACKAGE_VERSION);
}
+TEST_F(LibDhcpTest, packOptions6) {
+ boost::shared_array<char> buf(new char[512]);
+ isc::dhcp::Option::Option6Lst opts; // list of options
+
+ // generate content for options
+ for (int i=0;i<64;i++) {
+ buf[i]=i+100;
+ }
+
+ boost::shared_ptr<Option> opt1(new Option(Option::V6, 12, buf, 0, 5));
+ boost::shared_ptr<Option> opt2(new Option(Option::V6, 13, buf, 5, 3));
+ boost::shared_ptr<Option> opt3(new Option(Option::V6, 14, buf, 8, 2));
+ boost::shared_ptr<Option> opt4(new Option(Option::V6,256, buf,10, 4));
+ boost::shared_ptr<Option> opt5(new Option(Option::V6,257, buf,14, 1));
+
+ char expected[] = {
+ 0, 12, 0, 5, 100, 101, 102, 103, 104, // opt1
+ 0, 13, 0, 3, 105, 106, 107, // opt2
+ 0, 14, 0, 2, 108, 109, // opt3
+ 1, 0, 0, 4, 110, 111, 112, 113, // opt4
+ 1, 1, 0, 1, 114
+ };
+
+ opts.insert(pair<int, boost::shared_ptr<Option> >(opt1->getType(), opt1));
+ opts.insert(pair<int, boost::shared_ptr<Option> >(opt1->getType(), opt2));
+ opts.insert(pair<int, boost::shared_ptr<Option> >(opt1->getType(), opt3));
+ opts.insert(pair<int, boost::shared_ptr<Option> >(opt1->getType(), opt4));
+ opts.insert(pair<int, boost::shared_ptr<Option> >(opt1->getType(), opt5));
+
+ unsigned int offset;
+ EXPECT_NO_THROW (
+ {
+ offset = LibDHCP::packOptions6(buf, 512, 100, opts);
+ });
+ EXPECT_EQ(135, offset); // options should take 35 bytes
+ EXPECT_EQ(0, memcmp(&buf[100], expected, 35) );
+}
+
+TEST_F(LibDhcpTest, unpackOptions6) {
+
+}
+
}
More information about the bind10-changes
mailing list