BIND 10 trac3036, updated. a8dfa35d56e421fa565efb4de12bff2ee2813aa5 [3036] Test creating on-wire data from an option with empty domain name.
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Aug 16 14:38:23 UTC 2013
The branch, trac3036 has been updated
via a8dfa35d56e421fa565efb4de12bff2ee2813aa5 (commit)
from ef9de155bd156391ed1e21a024fa9bd3835bad18 (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 a8dfa35d56e421fa565efb4de12bff2ee2813aa5
Author: Marcin Siodelski <marcin at isc.org>
Date: Fri Aug 16 16:38:10 2013 +0200
[3036] Test creating on-wire data from an option with empty domain name.
-----------------------------------------------------------------------
Summary of changes:
src/lib/dhcp/option6_client_fqdn.cc | 13 +++++----
src/lib/dhcp/tests/option6_client_fqdn_unittest.cc | 28 ++++++++++++++++++++
2 files changed, 36 insertions(+), 5 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/option6_client_fqdn.cc b/src/lib/dhcp/option6_client_fqdn.cc
index c5fe419..ff2efe6 100644
--- a/src/lib/dhcp/option6_client_fqdn.cc
+++ b/src/lib/dhcp/option6_client_fqdn.cc
@@ -437,11 +437,14 @@ Option6ClientFqdn::toText(int indent) {
uint16_t
Option6ClientFqdn::len() {
- // If domain name is partial, the NULL terminating character
- // is not included and the option length have to be adjusted.
- uint16_t domain_name_length = impl_->domain_name_type_ == FULL ?
- impl_->domain_name_->getLength() : impl_->domain_name_->getLength() - 1;
-
+ uint16_t domain_name_length = 0;
+ if (impl_->domain_name_) {
+ // If domain name is partial, the NULL terminating character
+ // is not included and the option. Length has to be adjusted.
+ domain_name_length = impl_->domain_name_type_ == FULL ?
+ impl_->domain_name_->getLength() :
+ impl_->domain_name_->getLength() - 1;
+ }
return (getHeaderLen() + FLAG_FIELD_LEN + domain_name_length);
}
diff --git a/src/lib/dhcp/tests/option6_client_fqdn_unittest.cc b/src/lib/dhcp/tests/option6_client_fqdn_unittest.cc
index 64bd525..d644a2e 100644
--- a/src/lib/dhcp/tests/option6_client_fqdn_unittest.cc
+++ b/src/lib/dhcp/tests/option6_client_fqdn_unittest.cc
@@ -622,6 +622,34 @@ TEST(Option6ClientFqdnTest, packPartial) {
EXPECT_EQ(0, memcmp(ref_data, buf.getData(), buf.getLength()));
}
+// This test verifies that it is possible to encode the option which carries
+// empty domain-name in the wire format.
+TEST(Option6ClientFqdnTest, packEmpty) {
+ // Create option instance. Check that constructor doesn't throw.
+ const uint8_t flags = Option6ClientFqdn::FLAG_S;
+ boost::scoped_ptr<Option6ClientFqdn> option;
+ ASSERT_NO_THROW(
+ option.reset(new Option6ClientFqdn(flags))
+ );
+ ASSERT_TRUE(option);
+
+ // Prepare on-wire format of the option.
+ isc::util::OutputBuffer buf(5);
+ ASSERT_NO_THROW(option->pack(buf));
+
+ // Prepare reference data.
+ const uint8_t ref_data[] = {
+ 0, 39, 0, 1, // header
+ Option6ClientFqdn::FLAG_S // flags
+ };
+ size_t ref_data_size = sizeof(ref_data) / sizeof(ref_data[0]);
+
+ // Check if the buffer has the same length as the reference data,
+ // so as they can be compared directly.
+ ASSERT_EQ(ref_data_size, buf.getLength());
+ EXPECT_EQ(0, memcmp(ref_data, buf.getData(), buf.getLength()));
+}
+
// This test verifies that on-wire option data holding fully qualified domain
// name is parsed correctly.
TEST(Option6ClientFqdnTest, unpack) {
More information about the bind10-changes
mailing list