BIND 10 trac2784, updated. 2f3d1fe8c582c75c98b739e0f7b1486b0a9141ca [2784] Added logic to test_control.cc to check for a mismatch between the commnd line arguments for ip version and server. Added test_control unit tests to verify mismatch detection.
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Mar 21 17:35:08 UTC 2013
The branch, trac2784 has been updated
via 2f3d1fe8c582c75c98b739e0f7b1486b0a9141ca (commit)
from 459cdc4a0dd14c3c21a8ce1e51bd99fd53026a21 (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 2f3d1fe8c582c75c98b739e0f7b1486b0a9141ca
Author: Thomas Markwalder <tmark at isc.org>
Date: Thu Mar 21 13:33:51 2013 -0400
[2784] Added logic to test_control.cc to check for a mismatch
between the commnd line arguments for ip version and server.
Added test_control unit tests to verify mismatch detection.
-----------------------------------------------------------------------
Summary of changes:
tests/tools/perfdhcp/test_control.cc | 20 ++++++++++++++++----
.../tools/perfdhcp/tests/test_control_unittest.cc | 12 ++++++++++++
2 files changed, 28 insertions(+), 4 deletions(-)
-----------------------------------------------------------------------
diff --git a/tests/tools/perfdhcp/test_control.cc b/tests/tools/perfdhcp/test_control.cc
index 4a3075a..8762d49 100644
--- a/tests/tools/perfdhcp/test_control.cc
+++ b/tests/tools/perfdhcp/test_control.cc
@@ -594,17 +594,29 @@ TestControl::openSocket() const {
uint16_t port = options.getLocalPort();
uint8_t family = AF_INET;
int sock = 0;
+
+ if (options.getIpVersion() == 6) {
+ family = AF_INET6;
+ }
+
IOAddress remoteaddr(servername);
+
+ // check for mismatch between ip option and server
+ if (family != remoteaddr.getFamily())
+ {
+ isc_throw(InvalidParameter,
+ "Values for Ip version: " << (unsigned int)options.getIpVersion()
+ << " and Server:" << servername << " are mismatched.");
+ }
+
if (port == 0) {
- if (options.getIpVersion() == 6) {
+ if (family == AF_INET6) {
port = DHCP6_CLIENT_PORT;
} else if (options.getIpVersion() == 4) {
port = 67; // TODO: find out why port 68 is wrong here.
}
}
- if (options.getIpVersion() == 6) {
- family = AF_INET6;
- }
+
// Local name is specified along with '-l' option.
// It may point to interface name or local address.
if (!localname.empty()) {
diff --git a/tests/tools/perfdhcp/tests/test_control_unittest.cc b/tests/tools/perfdhcp/tests/test_control_unittest.cc
index f7666ae..3e0145c 100644
--- a/tests/tools/perfdhcp/tests/test_control_unittest.cc
+++ b/tests/tools/perfdhcp/tests/test_control_unittest.cc
@@ -672,6 +672,18 @@ TEST_F(TestControlTest, GenerateDuid) {
testDuid();
}
+TEST_F(TestControlTest, MisMatchVerionServer) {
+ NakedTestControl tc;
+
+ // make sure we catch -6 paired with v4 address
+ ASSERT_NO_THROW(processCmdLine("perfdhcp -l 127.0.0.1 -6 192.168.1.1"));
+ EXPECT_THROW(tc.openSocket(), isc::InvalidParameter);
+
+ // make sure we catch -4 paired with v6 address
+ ASSERT_NO_THROW(processCmdLine("perfdhcp -l 127.0.0.1 -4 ff02::1:2"));
+ EXPECT_THROW(tc.openSocket(), isc::InvalidParameter);
+}
+
TEST_F(TestControlTest, GenerateMacAddress) {
// Simulate one client only. Always the same MAC address will be
// generated.
More information about the bind10-changes
mailing list