BIND 10 master, updated. d0b0208ae8f3de712fa1329c8b01d16e3eaf8ac4 [master] Use std::copy to write IP address to buffer.
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Oct 23 18:08:05 UTC 2012
The branch, master has been updated
via d0b0208ae8f3de712fa1329c8b01d16e3eaf8ac4 (commit)
via ebdd232061e3d9ced4660541cd3ad1c2ca8ed645 (commit)
from 5fd4177340e6abaec9f8ca6a1194900001671665 (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 d0b0208ae8f3de712fa1329c8b01d16e3eaf8ac4
Author: Marcin Siodelski <marcin at isc.org>
Date: Tue Oct 23 20:07:28 2012 +0200
[master] Use std::copy to write IP address to buffer.
This fix resolves build issues on Fedora 17. Okayed on jabber.
commit ebdd232061e3d9ced4660541cd3ad1c2ca8ed645
Author: Marcin Siodelski <marcin at isc.org>
Date: Tue Oct 23 20:06:52 2012 +0200
[master] Remove narrowing conversion from int to uint8_t.
This fix eliminates build failure on Fedora17 and Debian7. Okayed on jabber.
-----------------------------------------------------------------------
Summary of changes:
src/lib/dhcp/tests/option6_int_unittest.cc | 13 +++++---
src/lib/dhcp/tests/option_definition_unittest.cc | 37 +++++++++++-----------
2 files changed, 27 insertions(+), 23 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/tests/option6_int_unittest.cc b/src/lib/dhcp/tests/option6_int_unittest.cc
index 2aceed8..3d39a1a 100644
--- a/src/lib/dhcp/tests/option6_int_unittest.cc
+++ b/src/lib/dhcp/tests/option6_int_unittest.cc
@@ -303,7 +303,9 @@ TEST_F(Option6IntTest, setValueint32) {
}
TEST_F(Option6IntTest, packSuboptions) {
- uint16_t opt_code = 80;
+ // option code is really uint16_t, but using uint8_t
+ // for easier conversion to uint8_t array.
+ uint8_t opt_code = 80;
boost::shared_ptr<Option6Int<uint32_t> > opt(new Option6Int<uint32_t>(opt_code, 0x01020304));
OptionPtr sub1(new Option(Option::V6, 0xcafe));
@@ -319,7 +321,7 @@ TEST_F(Option6IntTest, packSuboptions) {
ASSERT_EQ(40, opt->len());
uint8_t expected[] = {
- opt_code / 256, opt_code % 256, // type
+ 0, opt_code, // type
0, 36, // length
0x01, 0x02, 0x03, 0x04, // uint32_t value
@@ -345,11 +347,12 @@ TEST_F(Option6IntTest, packSuboptions) {
TEST_F(Option6IntTest, unpackSuboptions) {
- // Create some dummy option.
- const uint16_t opt_code = 80;
+ // option code is really uint16_t, but using uint8_t
+ // for easier conversion to uint8_t array.
+ const uint8_t opt_code = 80;
// Prepare reference data.
uint8_t expected[] = {
- opt_code / 256, opt_code % 256, // type
+ 0, opt_code, // type
0, 34, // length
0x01, 0x02, // uint16_t value
diff --git a/src/lib/dhcp/tests/option_definition_unittest.cc b/src/lib/dhcp/tests/option_definition_unittest.cc
index 692bfa9..4b83517 100644
--- a/src/lib/dhcp/tests/option_definition_unittest.cc
+++ b/src/lib/dhcp/tests/option_definition_unittest.cc
@@ -163,11 +163,13 @@ TEST_F(OptionDefinitionTest, factoryAddrList6) {
addrs.push_back(asiolink::IOAddress("::2"));
// Write addresses to the buffer.
- OptionBuffer buf;
+ OptionBuffer buf(addrs.size() * asiolink::V6ADDRESS_LEN);
for (int i = 0; i < addrs.size(); ++i) {
- unsigned char* data = addrs[i].getAddress().to_v6().to_bytes().data();
- // @todo Are there any sanity checks needed here on this raw pointer?
- buf.insert(buf.end(), data, data + asiolink::V6ADDRESS_LEN);
+ asio::ip::address_v6::bytes_type addr_bytes =
+ addrs[i].getAddress().to_v6().to_bytes();
+ ASSERT_EQ(asiolink::V6ADDRESS_LEN, addr_bytes.size());
+ std::copy(addr_bytes.begin(), addr_bytes.end(),
+ buf.begin() + i * asiolink::V6ADDRESS_LEN);
}
// Create DHCPv6 option from this buffer. Once option is created it is
// supposed to have internal list of addresses that it parses out from
@@ -213,11 +215,13 @@ TEST_F(OptionDefinitionTest, factoryAddrList4) {
addrs.push_back(asiolink::IOAddress("213.41.23.12"));
// Write addresses to the buffer.
- OptionBuffer buf;
+ OptionBuffer buf(addrs.size() * asiolink::V4ADDRESS_LEN);
for (int i = 0; i < addrs.size(); ++i) {
- unsigned char* data = addrs[i].getAddress().to_v4().to_bytes().data();
- // @todo Are there any sanity checks needed here on this raw pointer?
- buf.insert(buf.end(), data, data + asiolink::V4ADDRESS_LEN);
+ asio::ip::address_v4::bytes_type addr_bytes =
+ addrs[i].getAddress().to_v4().to_bytes();
+ ASSERT_EQ(asiolink::V4ADDRESS_LEN, addr_bytes.size());
+ std::copy(addr_bytes.begin(), addr_bytes.end(),
+ buf.begin() + i * asiolink::V4ADDRESS_LEN);
}
// Create DHCPv6 option from this buffer. Once option is created it is
// supposed to have internal list of addresses that it parses out from
@@ -339,20 +343,17 @@ TEST_F(OptionDefinitionTest, factoryIAAddr6) {
// Check the positive scenario.
OptionPtr option_v6;
asiolink::IOAddress addr_v6("2001:0db8::ff00:0042:8329");
+ OptionBuffer buf(asiolink::V6ADDRESS_LEN);
ASSERT_TRUE(addr_v6.getAddress().is_v6());
- unsigned char* addr_bytes_v6 = addr_v6.getAddress().to_v6().to_bytes().data();
- ASSERT_TRUE(addr_bytes_v6 != NULL);
- OptionBuffer buf;
- buf.insert(buf.end(), addr_bytes_v6, addr_bytes_v6 + asiolink::V6ADDRESS_LEN);
+ asio::ip::address_v6::bytes_type addr_bytes =
+ addr_v6.getAddress().to_v6().to_bytes();
+ ASSERT_EQ(asiolink::V6ADDRESS_LEN, addr_bytes.size());
+ std::copy(addr_bytes.begin(), addr_bytes.end(), buf.begin());
+
for (int i = 0; i < option6_iaaddr_len - asiolink::V6ADDRESS_LEN; ++i) {
buf.push_back(i);
}
- // ASSERT_NO_THROW(option_v6 = factory(Option::V6, D6O_IAADDR, buf));
- try {
- option_v6 = factory(Option::V6, D6O_IAADDR, buf);
- } catch (const Exception& e) {
- std::cout << e.what() << std::endl;
- }
+ ASSERT_NO_THROW(option_v6 = factory(Option::V6, D6O_IAADDR, buf));
ASSERT_TRUE(typeid(*option_v6) == typeid(Option6IAAddr));
boost::shared_ptr<Option6IAAddr> option_cast_v6 =
boost::static_pointer_cast<Option6IAAddr>(option_v6);
More information about the bind10-changes
mailing list