BIND 10 trac1186, updated. 071661c3064767f3dfc3699bdae32cf10bd2d2f9 [1186] Part 3 of review changes

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Oct 11 16:57:42 UTC 2011


The branch, trac1186 has been updated
       via  071661c3064767f3dfc3699bdae32cf10bd2d2f9 (commit)
      from  8fdcf2aa39b5fdb224f5e57f9605090409abc4a1 (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 071661c3064767f3dfc3699bdae32cf10bd2d2f9
Author: Tomek Mrugalski <tomasz at isc.org>
Date:   Tue Oct 11 18:57:19 2011 +0200

    [1186] Part 3 of review changes
    
    - buffer type changed: char => uint8_t
    - removed unnecessary statements in Makefile.am

-----------------------------------------------------------------------

Summary of changes:
 src/bin/dhcp6/Makefile.am                      |    2 -
 src/bin/dhcp6/dhcp6_srv.cc                     |    2 +-
 src/bin/dhcp6/main.cc                          |    9 ++-----
 src/bin/dhcp6/tests/Makefile.am                |    2 -
 src/bin/dhcp6/tests/dhcp6_srv_unittest.cc      |    2 +-
 src/lib/asiolink/io_address.cc                 |   11 +++++----
 src/lib/asiolink/io_address.h                  |    2 +-
 src/lib/asiolink/tests/io_address_unittest.cc  |    4 +-
 src/lib/dhcp/Makefile.am                       |   11 +--------
 src/lib/dhcp/libdhcp.cc                        |   10 +++-----
 src/lib/dhcp/libdhcp.h                         |    4 +-
 src/lib/dhcp/option.cc                         |   22 +++++++++---------
 src/lib/dhcp/option.h                          |   20 ++++++++--------
 src/lib/dhcp/option6_addrlst.cc                |    6 ++--
 src/lib/dhcp/option6_addrlst.h                 |    6 ++--
 src/lib/dhcp/option6_ia.cc                     |   27 +++++++++++------------
 src/lib/dhcp/option6_ia.h                      |    8 +++---
 src/lib/dhcp/option6_iaaddr.cc                 |   11 +++------
 src/lib/dhcp/option6_iaaddr.h                  |   26 +++++++++++-----------
 src/lib/dhcp/pkt6.cc                           |   14 ++++++------
 src/lib/dhcp/pkt6.h                            |    2 +-
 src/lib/dhcp/tests/libdhcp_unittest.cc         |    4 +-
 src/lib/dhcp/tests/option6_addrlst_unittest.cc |   10 ++++----
 src/lib/dhcp/tests/option6_ia_unittest.cc      |   12 +++++-----
 src/lib/dhcp/tests/option6_iaaddr_unittest.cc  |    2 +-
 src/lib/dhcp/tests/option_unittest.cc          |   14 ++++++------
 26 files changed, 112 insertions(+), 131 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/Makefile.am b/src/bin/dhcp6/Makefile.am
index 6805d15..12e41e9 100644
--- a/src/bin/dhcp6/Makefile.am
+++ b/src/bin/dhcp6/Makefile.am
@@ -34,8 +34,6 @@ b10_dhcp6_SOURCES = main.cc iface_mgr.cc dhcp6_srv.cc
 b10_dhcp6_SOURCES += iface_mgr.h dhcp6_srv.h dhcp6.h
 
 b10_dhcp6_LDADD = $(top_builddir)/src/lib/dhcp/libdhcp.la
-b10_dhcp6_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
-b10_dhcp6_LDADD += $(top_builddir)/src/lib/cc/libcc.la
 b10_dhcp6_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
 b10_dhcp6_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
 b10_dhcp6_LDADD += $(top_builddir)/src/lib/log/liblog.la
diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc
index ad77621..83c20a2 100644
--- a/src/bin/dhcp6/dhcp6_srv.cc
+++ b/src/bin/dhcp6/dhcp6_srv.cc
@@ -118,7 +118,7 @@ Dhcpv6Srv::setServerID() {
     /// TODO implement this for real once interface detection is done.
     /// Use hardcoded server-id for now
 
-    boost::shared_array<char> srvid(new char[14]);
+    boost::shared_array<uint8_t> srvid(new uint8_t[14]);
     srvid[0] = 0;
     srvid[1] = 1; // DUID type 1 = DUID-LLT (see section 9.2 of RFC3315)
     srvid[2] = 0;
diff --git a/src/bin/dhcp6/main.cc b/src/bin/dhcp6/main.cc
index ae3ff06..5323811 100644
--- a/src/bin/dhcp6/main.cc
+++ b/src/bin/dhcp6/main.cc
@@ -26,8 +26,11 @@
 #include <iostream>
 
 #include <exceptions/exceptions.h>
+#if 0
+// TODO cc is not used yet. It should be eventually
 #include <cc/session.h>
 #include <config/ccsession.h>
+#endif
 
 #include <util/buffer.h>
 #include <log/dummylog.h>
@@ -37,10 +40,6 @@
 
 using namespace std;
 using namespace isc::util;
-using namespace isc::data;
-using namespace isc::cc;
-using namespace isc::config;
-using namespace isc::util;
 
 using namespace isc;
 using namespace isc::dhcp;
@@ -98,8 +97,6 @@ main(int argc, char* argv[]) {
             specfile = string(DHCP6_SPECFILE_LOCATION);
         }
 
-        // auth_server = new AuthSrv(cache, xfrout_client);
-        // auth_server->setVerbose(verbose_mode);
         cout << "[b10-dhcp6] Initiating DHCPv6 operation." << endl;
 
         Dhcpv6Srv* srv = new Dhcpv6Srv();
diff --git a/src/bin/dhcp6/tests/Makefile.am b/src/bin/dhcp6/tests/Makefile.am
index 284ebf3..18173fe 100644
--- a/src/bin/dhcp6/tests/Makefile.am
+++ b/src/bin/dhcp6/tests/Makefile.am
@@ -55,8 +55,6 @@ dhcp6_unittests_LDADD = $(GTEST_LDADD)
 dhcp6_unittests_LDADD += $(SQLITE_LIBS)
 dhcp6_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
 dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libdhcp.la
-dhcp6_unittests_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
-dhcp6_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la
 dhcp6_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
 dhcp6_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
 endif
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index 2251168..f4f9dec 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -74,7 +74,7 @@ TEST_F(Dhcpv6SrvTest, Solicit_basic) {
     EXPECT_NO_THROW( srv = new NakedDhcpv6Srv(); );
 
     // a dummy content for client-id
-    boost::shared_array<char> clntDuid(new char[32]);
+    boost::shared_array<uint8_t> clntDuid(new uint8_t[32]);
     for (int i=0; i<32; i++)
         clntDuid[i] = 100+i;
 
diff --git a/src/lib/asiolink/io_address.cc b/src/lib/asiolink/io_address.cc
index 5b2c888..51c0332 100644
--- a/src/lib/asiolink/io_address.cc
+++ b/src/lib/asiolink/io_address.cc
@@ -23,7 +23,7 @@
 #include <exceptions/exceptions.h>
 #include <asiolink/io_address.h>
 #include <asiolink/io_error.h>
-
+#include <boost/static_assert.hpp>
 
 using namespace asio;
 using asio::ip::udp;
@@ -55,17 +55,18 @@ IOAddress::toText() const {
 }
 
 IOAddress
-IOAddress::from_bytes(short family, const char* data) {
-    static char addr_str[INET6_ADDRSTRLEN];
+IOAddress::from_bytes(short family, const uint8_t* data) {
     if (data == NULL) {
         isc_throw(BadValue, "NULL pointer received.");
-    }
+    } else
     if ( (family != AF_INET) && (family != AF_INET6) ) {
         isc_throw(BadValue, "Invalid family type. Only AF_INET and AF_INET6"
                   << "are supported");
     }
 
-    inet_ntop(family, data, addr_str,INET6_ADDRSTRLEN);
+    BOOST_STATIC_ASSERT(INET6_ADDRSTRLEN >= INET_ADDRSTRLEN);
+    char addr_str[INET6_ADDRSTRLEN];
+    inet_ntop(family, data, addr_str, INET6_ADDRSTRLEN);
     return IOAddress(string(addr_str));
 }
 
diff --git a/src/lib/asiolink/io_address.h b/src/lib/asiolink/io_address.h
index 5797875..763b02d 100644
--- a/src/lib/asiolink/io_address.h
+++ b/src/lib/asiolink/io_address.h
@@ -100,7 +100,7 @@ public:
     ///
     /// \return Created IOAddress object
     static IOAddress
-    from_bytes(short family, const char* data);
+    from_bytes(short family, const uint8_t* data);
 
     /// \brief Compare addresses for equality
     ///
diff --git a/src/lib/asiolink/tests/io_address_unittest.cc b/src/lib/asiolink/tests/io_address_unittest.cc
index 70c51d0..c12a0ed 100644
--- a/src/lib/asiolink/tests/io_address_unittest.cc
+++ b/src/lib/asiolink/tests/io_address_unittest.cc
@@ -67,11 +67,11 @@ TEST(IOAddressTest, Family) {
 
 TEST(IOAddressTest, from_bytes) {
     // 2001:db8:1::dead:beef
-    char v6[] = {
+    uint8_t v6[] = {
         0x20, 0x01, 0x0d, 0xb8, 0x00, 0x01, 0, 0,
         0, 0, 0, 0, 0xde, 0xad, 0xbe, 0xef };
 
-    char v4[] = { 192, 0 , 2, 3 };
+    uint8_t v4[] = { 192, 0 , 2, 3 };
 
     IOAddress addr("::");
     EXPECT_NO_THROW({
diff --git a/src/lib/dhcp/Makefile.am b/src/lib/dhcp/Makefile.am
index 788a7e0..f87e2b5 100644
--- a/src/lib/dhcp/Makefile.am
+++ b/src/lib/dhcp/Makefile.am
@@ -3,6 +3,8 @@ SUBDIRS = . tests
 AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
 AM_CPPFLAGS += $(BOOST_INCLUDES)
 
+AM_CXXFLAGS = $(B10_CXXFLAGS)
+
 CLEANFILES = *.gcno *.gcda
 
 lib_LTLIBRARIES = libdhcp.la
@@ -18,16 +20,7 @@ libdhcp_la_SOURCES += pkt6.cc pkt6.h
 EXTRA_DIST  = README
 #EXTRA_DIST += log_messages.mes
 
-# Note: the ordering matters: -Wno-... must follow -Wextra (defined in
-# B10_CXXFLAGS)
 libdhcp_la_CXXFLAGS = $(AM_CXXFLAGS)
-if USE_GXX
-libdhcp_la_CXXFLAGS += -Wall
-endif
-if USE_CLANGPP
-# Same for clang++, but we need to turn off -Werror completely.
-libdhcp_la_CXXFLAGS += -Wall
-endif
 libdhcp_la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
 libdhcp_la_LDFLAGS  = $(LOG4CPLUS_LDFLAGS)
 libdhcp_la_LIBADD   = $(top_builddir)/src/lib/util/libutil.la
diff --git a/src/lib/dhcp/libdhcp.cc b/src/lib/dhcp/libdhcp.cc
index ac6bc2e..62326ba 100644
--- a/src/lib/dhcp/libdhcp.cc
+++ b/src/lib/dhcp/libdhcp.cc
@@ -34,7 +34,7 @@ LibDHCP::version() {
 }
 
 unsigned int
-LibDHCP::unpackOptions6(boost::shared_array<char> buf, unsigned int buf_len,
+LibDHCP::unpackOptions6(boost::shared_array<uint8_t> buf, unsigned int buf_len,
                         unsigned int offset, unsigned int parse_len,
                         isc::dhcp::Option::Option6Lst& options) {
     if (offset + parse_len > buf_len) {
@@ -45,11 +45,9 @@ LibDHCP::unpackOptions6(boost::shared_array<char> buf, unsigned int buf_len,
     unsigned int end = offset + parse_len;
 
     while (offset<end) {
-        unsigned int opt_type = static_cast<unsigned char>(buf[offset])*256
-            + static_cast<unsigned char>(buf[offset+1]);
+        unsigned int opt_type = buf[offset]*256 + buf[offset+1];
         offset += 2;
-        unsigned int opt_len = static_cast<unsigned char>(buf[offset]*256)
-            + static_cast<unsigned char>(buf[offset+1]);
+        unsigned int opt_len = buf[offset]*256 + buf[offset+1];
         offset += 2;
 
         if (offset + opt_len > end ) {
@@ -91,7 +89,7 @@ LibDHCP::unpackOptions6(boost::shared_array<char> buf, unsigned int buf_len,
 }
 
 unsigned int
-LibDHCP::packOptions6(boost::shared_array<char> data,
+LibDHCP::packOptions6(boost::shared_array<uint8_t> data,
                       unsigned int data_len,
                       unsigned int offset,
                       isc::dhcp::Option::Option6Lst& options) {
diff --git a/src/lib/dhcp/libdhcp.h b/src/lib/dhcp/libdhcp.h
index f1773db..e1fc10f 100644
--- a/src/lib/dhcp/libdhcp.h
+++ b/src/lib/dhcp/libdhcp.h
@@ -44,7 +44,7 @@ public:
     ///         used byte)
     ///
     static unsigned int
-    packOptions6(boost::shared_array<char> buf, unsigned int buf_len,
+    packOptions6(boost::shared_array<uint8_t> buf, unsigned int buf_len,
                  unsigned int offset,
                  isc::dhcp::Option::Option6Lst& options);
 
@@ -62,7 +62,7 @@ public:
     /// @return offset to first byte after last parsed option
     ///
     static unsigned int
-    unpackOptions6(boost::shared_array<char> buf, unsigned int buf_len,
+    unpackOptions6(boost::shared_array<uint8_t> buf, unsigned int buf_len,
                    unsigned int offset, unsigned int parse_len,
                    isc::dhcp::Option::Option6Lst& options_);
 
diff --git a/src/lib/dhcp/option.cc b/src/lib/dhcp/option.cc
index 1d7a16a..fcd2f4a 100644
--- a/src/lib/dhcp/option.cc
+++ b/src/lib/dhcp/option.cc
@@ -32,7 +32,7 @@ Option::Option(Universe u, unsigned short type)
 
 }
 
-Option::Option(Universe u, unsigned short type, boost::shared_array<char> buf,
+Option::Option(Universe u, unsigned short type, boost::shared_array<uint8_t> buf,
                unsigned int offset, unsigned int len)
     :universe_(u), type_(type), data_(buf),
      data_len_(len), offset_(offset)
@@ -43,7 +43,7 @@ Option::Option(Universe u, unsigned short type, boost::shared_array<char> buf,
 }
 
 unsigned int
-Option::pack(boost::shared_array<char> buf,
+Option::pack(boost::shared_array<uint8_t> buf,
              unsigned int buf_len,
              unsigned int offset) {
     switch (universe_) {
@@ -58,14 +58,14 @@ Option::pack(boost::shared_array<char> buf,
 
 
 unsigned int
-Option::pack4(boost::shared_array<char> buf,
+Option::pack4(boost::shared_array<uint8_t> buf,
              unsigned int buf_len,
              unsigned int offset) {
     if ( offset+len() > buf_len ) {
         isc_throw(OutOfRange, "Failed to pack v4 option=" <<
                   type_ << ",len=" << data_len_ << ": too small buffer.");
     }
-    char *ptr = &buf[offset];
+    uint8_t *ptr = &buf[offset];
     ptr[0] = type_;
     ptr[1] = data_len_;
     ptr += 2;
@@ -75,7 +75,7 @@ Option::pack4(boost::shared_array<char> buf,
 }
 
 unsigned int
-Option::pack6(boost::shared_array<char> buf,
+Option::pack6(boost::shared_array<uint8_t> buf,
              unsigned int buf_len,
              unsigned int offset) {
     if ( offset+len() > buf_len ) {
@@ -85,7 +85,7 @@ Option::pack6(boost::shared_array<char> buf,
 
     int length = len() - getHeaderLen();
 
-    char * ptr = &buf[offset];
+    uint8_t * ptr = &buf[offset];
     *(uint16_t*)ptr = htons(type_);
     ptr += 2;
     *(uint16_t*)ptr = htons(length);
@@ -99,7 +99,7 @@ Option::pack6(boost::shared_array<char> buf,
 }
 
 unsigned int
-Option::unpack(boost::shared_array<char> buf,
+Option::unpack(boost::shared_array<uint8_t> buf,
                unsigned int buf_len,
                unsigned int offset,
                unsigned int parse_len) {
@@ -116,7 +116,7 @@ Option::unpack(boost::shared_array<char> buf,
 }
 
 unsigned int
-Option::unpack4(boost::shared_array<char>,
+Option::unpack4(boost::shared_array<uint8_t>,
                 unsigned int ,
                 unsigned int ,
                 unsigned int ) {
@@ -125,7 +125,7 @@ Option::unpack4(boost::shared_array<char>,
 }
 
 unsigned int
-Option::unpack6(boost::shared_array<char> buf,
+Option::unpack6(boost::shared_array<uint8_t> buf,
                 unsigned int buf_len,
                 unsigned int offset,
                 unsigned int parse_len) {
@@ -209,7 +209,7 @@ std::string Option::toText(int indent /* =0 */ ) {
             tmp << ":";
         }
         tmp << setfill('0') << setw(2) << hex
-            << (unsigned short)(unsigned char)data_[offset_+i];
+            << (unsigned short)(unsigned uint8_t)data_[offset_+i];
     }
 
     // print suboptions
@@ -226,7 +226,7 @@ Option::getType() {
     return type_;
 }
 
-char*
+uint8_t*
 Option::getData() {
     if (data_len_) {
         return (&data_[offset_]);
diff --git a/src/lib/dhcp/option.h b/src/lib/dhcp/option.h
index 65f1ba8..f8343b5 100644
--- a/src/lib/dhcp/option.h
+++ b/src/lib/dhcp/option.h
@@ -29,7 +29,7 @@ public:
     typedef std::multimap<unsigned int, boost::shared_ptr<Option> > Option6Lst;
     typedef boost::shared_ptr<Option> Factory(Option::Universe u,
                                               unsigned short type,
-                                              boost::shared_array<char> buf,
+                                              boost::shared_array<uint8_t> buf,
                                               unsigned int offset,
                                               unsigned int len);
 
@@ -42,14 +42,14 @@ public:
     // to different elements in shared array. Therefore we need to share
     // pointer to the whole array and remember offset where data for
     // this option begins
-    Option(Universe u, unsigned short type, boost::shared_array<char> buf,
+    Option(Universe u, unsigned short type, boost::shared_array<uint8_t> buf,
            unsigned int offset,
            unsigned int len);
 
     // writes option in wire-format to buf, returns pointer to first unused
     // byte after stored option
     virtual unsigned int
-    pack(boost::shared_array<char> buf,
+    pack(boost::shared_array<uint8_t> buf,
          unsigned int buf_len,
          unsigned int offset);
 
@@ -67,7 +67,7 @@ public:
     /// @return offset after last parsed option
     ///
     virtual unsigned int
-    unpack(boost::shared_array<char> buf,
+    unpack(boost::shared_array<uint8_t> buf,
            unsigned int buf_len,
            unsigned int offset,
            unsigned int parse_len);
@@ -113,7 +113,7 @@ public:
     ///
     /// @return pointer to actual data (or NULL if there is no data)
     ///
-    virtual char*
+    virtual uint8_t*
     getData();
 
     /// Adds a sub-option.
@@ -160,7 +160,7 @@ protected:
     /// @return offset to the next byte after last used byte
     ///
     virtual unsigned int
-    pack4(boost::shared_array<char> buf,
+    pack4(boost::shared_array<uint8_t> buf,
           unsigned int buf_len,
           unsigned int offset);
 
@@ -175,7 +175,7 @@ protected:
     /// @return offset to the next byte after last used byte
     ///
     virtual unsigned int
-    pack6(boost::shared_array<char> buf,
+    pack6(boost::shared_array<uint8_t> buf,
           unsigned int buf_len,
           unsigned int offset);
 
@@ -189,7 +189,7 @@ protected:
     /// @return offset to the next byte after last parsed byte
     ///
     virtual unsigned int
-    unpack4(boost::shared_array<char> buf,
+    unpack4(boost::shared_array<uint8_t> buf,
             unsigned int buf_len,
             unsigned int offset,
             unsigned int parse_len);
@@ -204,7 +204,7 @@ protected:
     /// @return offset to the next byte after last parsed byte
     ///
     virtual unsigned int
-    unpack6(boost::shared_array<char> buf,
+    unpack6(boost::shared_array<uint8_t> buf,
             unsigned int buf_len,
             unsigned int offset,
             unsigned int parse_len);
@@ -212,7 +212,7 @@ protected:
     Universe universe_; // option universe (V4 or V6)
     unsigned short type_; // option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
 
-    boost::shared_array<char> data_;
+    boost::shared_array<uint8_t> data_;
     unsigned int data_len_; // length of data only. Use len() if you want to
                             // know proper length with option header overhead
     unsigned int offset_; // data is a shared_pointer that points out to the
diff --git a/src/lib/dhcp/option6_addrlst.cc b/src/lib/dhcp/option6_addrlst.cc
index 79fb720..525cde4 100644
--- a/src/lib/dhcp/option6_addrlst.cc
+++ b/src/lib/dhcp/option6_addrlst.cc
@@ -41,7 +41,7 @@ Option6AddrLst::Option6AddrLst(unsigned short type,
 }
 
 Option6AddrLst::Option6AddrLst(unsigned short type,
-                               boost::shared_array<char> buf,
+                               boost::shared_array<uint8_t> buf,
                                unsigned int buf_len,
                                unsigned int offset,
                                unsigned int option_len)
@@ -61,7 +61,7 @@ Option6AddrLst::setAddresses(std::vector<isc::asiolink::IOAddress>& addrs) {
 }
 
 unsigned int
-Option6AddrLst::pack(boost::shared_array<char> buf,
+Option6AddrLst::pack(boost::shared_array<uint8_t> buf,
                     unsigned int buf_len,
                     unsigned int offset) {
     if (len() > buf_len) {
@@ -88,7 +88,7 @@ Option6AddrLst::pack(boost::shared_array<char> buf,
 }
 
 unsigned int
-Option6AddrLst::unpack(boost::shared_array<char> buf,
+Option6AddrLst::unpack(boost::shared_array<uint8_t> buf,
                   unsigned int buf_len,
                   unsigned int offset,
                   unsigned int option_len) {
diff --git a/src/lib/dhcp/option6_addrlst.h b/src/lib/dhcp/option6_addrlst.h
index 634ef85..119b396 100644
--- a/src/lib/dhcp/option6_addrlst.h
+++ b/src/lib/dhcp/option6_addrlst.h
@@ -57,7 +57,7 @@ public:
     /// @param offset offset to beginning of option data
     /// @param len length of option data
     ///
-    Option6AddrLst(unsigned short type, boost::shared_array<char> buf,
+    Option6AddrLst(unsigned short type, boost::shared_array<uint8_t> buf,
                    unsigned int buf_len,
                    unsigned int offset,
                    unsigned int len);
@@ -71,7 +71,7 @@ public:
     /// @return offset to the next unused char (just after stored option)
     ///
     unsigned int
-    pack(boost::shared_array<char> buf, unsigned int buf_len,
+    pack(boost::shared_array<uint8_t> buf, unsigned int buf_len,
          unsigned int offset);
 
     /// @brief Parses received data
@@ -84,7 +84,7 @@ public:
     /// @return offset to the next unparsed char (just after parsed option)
     ///
     virtual unsigned int
-    unpack(boost::shared_array<char> buf,
+    unpack(boost::shared_array<uint8_t> buf,
            unsigned int buf_len,
            unsigned int offset,
            unsigned int parse_len);
diff --git a/src/lib/dhcp/option6_ia.cc b/src/lib/dhcp/option6_ia.cc
index fd52f37..0b869be 100644
--- a/src/lib/dhcp/option6_ia.cc
+++ b/src/lib/dhcp/option6_ia.cc
@@ -31,31 +31,31 @@ Option6IA::Option6IA(Universe u, unsigned short type, unsigned int iaid)
 }
 
 
-Option6IA::Option6IA(Universe u, unsigned short type, 
-                   boost::shared_array<char> buf, 
+Option6IA::Option6IA(Universe u, unsigned short type,
+                   boost::shared_array<uint8_t> buf,
                    unsigned int buf_len,
-                   unsigned int offset, 
+                   unsigned int offset,
                    unsigned int option_len)
     :Option(u, type) {
     unpack(buf, buf_len, offset, option_len);
 }
 
 unsigned int
-Option6IA::pack(boost::shared_array<char> buf,
+Option6IA::pack(boost::shared_array<uint8_t> buf,
                 unsigned int buf_len,
                 unsigned int offset) {
     if (offset + len() > buf_len) {
-        isc_throw(OutOfRange, "Failed to pack IA option: len=" << len() 
+        isc_throw(OutOfRange, "Failed to pack IA option: len=" << len()
                   << ", buffer=" << buf_len << ": too small buffer.");
     }
-    
-    char* ptr = &buf[offset];
+
+    uint8_t* ptr = &buf[offset];
     *(uint16_t*)ptr = htons(type_);
     ptr += 2;
     *(uint16_t*)ptr = htons(len() - 4); // len() returns complete option length
     // len field contains length without 4-byte option header
     ptr += 2;
-    
+
     *(uint32_t*)ptr = htonl(iaid_);
     ptr += 4;
 
@@ -69,10 +69,10 @@ Option6IA::pack(boost::shared_array<char> buf,
     return offset;
 }
 
-unsigned int 
-Option6IA::unpack(boost::shared_array<char> buf,
+unsigned int
+Option6IA::unpack(boost::shared_array<uint8_t> buf,
                   unsigned int buf_len,
-                  unsigned int offset, 
+                  unsigned int offset,
                   unsigned int parse_len) {
     if (parse_len<12 || offset+12>buf_len) {
         isc_throw(OutOfRange, "Option " << type_ << " truncated");
@@ -83,7 +83,7 @@ Option6IA::unpack(boost::shared_array<char> buf,
     offset +=4;
     t2_ = ntohl(*(uint32_t*)&buf[offset]);
     offset +=4;
-    offset = LibDHCP::unpackOptions6(buf, buf_len, offset, 
+    offset = LibDHCP::unpackOptions6(buf, buf_len, offset,
                                      parse_len - 12, optionLst_);
 
     return (offset);
@@ -118,7 +118,7 @@ std::string Option6IA::toText(int indent /* = 0*/) {
 }
 
 unsigned short Option6IA::len() {
-    
+
     unsigned short length = 4/*header*/ + 12 /* option content */; // header
 
     // length of all suboptions
@@ -129,4 +129,3 @@ unsigned short Option6IA::len() {
     }
     return (length);
 }
-
diff --git a/src/lib/dhcp/option6_ia.h b/src/lib/dhcp/option6_ia.h
index 12a0430..013fd78 100644
--- a/src/lib/dhcp/option6_ia.h
+++ b/src/lib/dhcp/option6_ia.h
@@ -32,7 +32,7 @@ public:
     // to different elements in shared array. Therefore we need to share
     // pointer to the whole array and remember offset where data for
     // this option begins
-    Option6IA(Universe u, unsigned short type, boost::shared_array<char> buf,
+    Option6IA(Universe u, unsigned short type, boost::shared_array<uint8_t> buf,
               unsigned int buf_len,
               unsigned int offset,
               unsigned int len);
@@ -40,20 +40,20 @@ public:
     // writes option in wire-format to buf, returns pointer to first unused
     // byte after stored option
     unsigned int
-    pack(boost::shared_array<char> buf, unsigned int buf_len,
+    pack(boost::shared_array<uint8_t> buf, unsigned int buf_len,
          unsigned int offset);
 
     // parses received buffer, returns offset to the first unused byte after
     // parsed option
     virtual unsigned int
-    unpack(boost::shared_array<char> buf,
+    unpack(boost::shared_array<uint8_t> buf,
            unsigned int buf_len,
            unsigned int offset,
            unsigned int parse_len);
 
     /// Provides human readable text representation
     ///
-    /// @param indent number of leading space characterss
+    /// @param indent number of leading space characters
     ///
     /// @return string with text represenation
     ///
diff --git a/src/lib/dhcp/option6_iaaddr.cc b/src/lib/dhcp/option6_iaaddr.cc
index edf9069..64cf677 100644
--- a/src/lib/dhcp/option6_iaaddr.cc
+++ b/src/lib/dhcp/option6_iaaddr.cc
@@ -36,7 +36,7 @@ Option6IAAddr::Option6IAAddr(unsigned short type,
 }
 
 Option6IAAddr::Option6IAAddr(unsigned short type,
-                             boost::shared_array<char> buf,
+                             boost::shared_array<uint8_t> buf,
                              unsigned int buf_len,
                              unsigned int offset,
                              unsigned int option_len)
@@ -45,7 +45,7 @@ Option6IAAddr::Option6IAAddr(unsigned short type,
 }
 
 unsigned int
-Option6IAAddr::pack(boost::shared_array<char> buf,
+Option6IAAddr::pack(boost::shared_array<uint8_t> buf,
                     unsigned int buf_len,
                     unsigned int offset) {
     if (len() > buf_len) {
@@ -73,7 +73,7 @@ Option6IAAddr::pack(boost::shared_array<char> buf,
 }
 
 unsigned int
-Option6IAAddr::unpack(boost::shared_array<char> buf,
+Option6IAAddr::unpack(boost::shared_array<uint8_t> buf,
                   unsigned int buf_len,
                   unsigned int offset,
                   unsigned int parse_len) {
@@ -82,10 +82,7 @@ Option6IAAddr::unpack(boost::shared_array<char> buf,
     }
 
     // 16 bytes: IPv6 address
-    /// TODO Implement fromBytes() method in IOAddress
-    char addr_str[INET6_ADDRSTRLEN];
-    inet_ntop(AF_INET6, &buf[offset], addr_str,INET6_ADDRSTRLEN);
-    addr_ = IOAddress(string(addr_str));
+    addr_ = IOAddress::from_bytes(AF_INET6, &buf[offset]);
     offset += 16;
 
     preferred_ = ntohl(*(uint32_t*)&buf[offset]);
diff --git a/src/lib/dhcp/option6_iaaddr.h b/src/lib/dhcp/option6_iaaddr.h
index f1e78e4..1663cf5 100644
--- a/src/lib/dhcp/option6_iaaddr.h
+++ b/src/lib/dhcp/option6_iaaddr.h
@@ -22,37 +22,37 @@ namespace isc {
 namespace dhcp {
 
 class Option6IAAddr: public Option {
-        
+
 public:
     // ctor, used for options constructed, usually during transmission
-    Option6IAAddr(unsigned short type, 
+    Option6IAAddr(unsigned short type,
                   isc::asiolink::IOAddress addr,
                   unsigned int prefered,
-                  unsigned int valid); 
+                  unsigned int valid);
 
     // ctor, used for received options
-    // boost::shared_array allows sharing a buffer, but it requires that 
+    // boost::shared_array allows sharing a buffer, but it requires that
     // different instances share pointer to the whole array, not point
     // to different elements in shared array. Therefore we need to share
     // pointer to the whole array and remember offset where data for
     // this option begins
-    Option6IAAddr(unsigned short type, boost::shared_array<char> buf, 
+    Option6IAAddr(unsigned short type, boost::shared_array<uint8_t> buf,
                   unsigned int buf_len,
-                  unsigned int offset, 
+                  unsigned int offset,
                   unsigned int len);
-    
-    // writes option in wire-format to buf, returns pointer to first unused 
+
+    // writes option in wire-format to buf, returns pointer to first unused
     // byte after stored option
     unsigned int
-    pack(boost::shared_array<char> buf, unsigned int buf_len, 
+    pack(boost::shared_array<uint8_t> buf, unsigned int buf_len,
          unsigned int offset);
 
     // parses received buffer, returns offset to the first unused byte after
     // parsed option
-    virtual unsigned int 
-    unpack(boost::shared_array<char> buf, 
+    virtual unsigned int
+    unpack(boost::shared_array<uint8_t> buf,
            unsigned int buf_len,
-           unsigned int offset, 
+           unsigned int offset,
            unsigned int parse_len);
 
     virtual std::string toText(int indent = 0);
@@ -76,5 +76,5 @@ protected:
 
 } // isc::dhcp namespace
 } // isc namespace
-    
+
 #endif /* OPTION_IA_H_ */
diff --git a/src/lib/dhcp/pkt6.cc b/src/lib/dhcp/pkt6.cc
index 2408ab4..6fe80cf 100644
--- a/src/lib/dhcp/pkt6.cc
+++ b/src/lib/dhcp/pkt6.cc
@@ -37,7 +37,7 @@ Pkt6::Pkt6(unsigned int dataLen, DHCPv6Proto_ proto /* = UDP */)
      proto_(proto)
 {
     try {
-        data_ = boost::shared_array<char>(new char[dataLen]);
+        data_ = boost::shared_array<uint8_t>(new uint8_t[dataLen]);
         data_len_ = dataLen;
     } catch (const std::exception& ex) {
         // TODO move to LOG_FATAL()
@@ -49,7 +49,7 @@ Pkt6::Pkt6(unsigned int dataLen, DHCPv6Proto_ proto /* = UDP */)
 }
 
 
-Pkt6::Pkt6(unsigned char msg_type,
+Pkt6::Pkt6(uint8_t msg_type,
            unsigned int transid,
            DHCPv6Proto_ proto /*= UDP*/)
     :local_addr_("::"),
@@ -59,7 +59,7 @@ Pkt6::Pkt6(unsigned char msg_type,
      transid_(transid) {
 
     try {
-        data_ = boost::shared_array<char>(new char[4]);
+        data_ = boost::shared_array<uint8_t>(new uint8_t[4]);
         data_len_ = 4;
     } catch (Exception e) {
         cout << "Packet creation failed:" << e.what() << endl;
@@ -122,7 +122,7 @@ Pkt6::packUDP() {
              << length << endl;
 
         try {
-            data_ = boost::shared_array<char>(new char[length]);
+            data_ = boost::shared_array<uint8_t>(new uint8_t[length]);
             data_len_ = length;
         } catch (Exception e) {
             cout << "Failed to allocate " << length << "-byte buffer:"
@@ -208,8 +208,8 @@ Pkt6::unpackUDP() {
         return (false);
     }
     msg_type_ = data_[0];
-    transid_ = ( ((unsigned char)data_[1]) << 16 ) + 
-        (((unsigned char)data_[2]) << 8) + ((unsigned char)data_[3]);
+    transid_ = ( (data_[1]) << 16 ) +
+        ((data_[2]) << 8) + (data_[3]);
     transid_ = transid_ & 0xffffff;
 
     unsigned int offset = LibDHCP::unpackOptions6(data_,
@@ -286,7 +286,7 @@ Pkt6::getOption(unsigned short opt_type) {
  *
  * @return message type.
  */
-unsigned char
+uint8_t
 Pkt6::getType() {
     return (msg_type_);
 }
diff --git a/src/lib/dhcp/pkt6.h b/src/lib/dhcp/pkt6.h
index 1e87d85..40cb981 100644
--- a/src/lib/dhcp/pkt6.h
+++ b/src/lib/dhcp/pkt6.h
@@ -56,7 +56,7 @@ namespace isc {
         ///      and hide following fields as protected
         /// buffer that holds memory. It is shared_array as options may
         /// share pointer to this buffer
-        boost::shared_array<char> data_;
+        boost::shared_array<uint8_t> data_;
 
         // length of the data
         unsigned int data_len_;
diff --git a/src/lib/dhcp/tests/libdhcp_unittest.cc b/src/lib/dhcp/tests/libdhcp_unittest.cc
index f9c98c0..0766df9 100644
--- a/src/lib/dhcp/tests/libdhcp_unittest.cc
+++ b/src/lib/dhcp/tests/libdhcp_unittest.cc
@@ -40,7 +40,7 @@ TEST_F(LibDhcpTest, basic) {
 }
 
 TEST_F(LibDhcpTest, packOptions6) {
-    boost::shared_array<char> buf(new char[512]);
+    boost::shared_array<uint8_t> buf(new uint8_t[512]);
     isc::dhcp::Option::Option6Lst opts; // list of options
 
     // generate content for options
@@ -94,7 +94,7 @@ TEST_F(LibDhcpTest, unpackOptions6) {
 
     // we can't use packed directly, as shared_array would try to
     // free it eventually
-    boost::shared_array<char> buf(new char[512]);
+    boost::shared_array<uint8_t> buf(new uint8_t[512]);
     memcpy(&buf[0], packed, 35);
 
     unsigned int offset;
diff --git a/src/lib/dhcp/tests/option6_addrlst_unittest.cc b/src/lib/dhcp/tests/option6_addrlst_unittest.cc
index ce0bc22..e01b743 100644
--- a/src/lib/dhcp/tests/option6_addrlst_unittest.cc
+++ b/src/lib/dhcp/tests/option6_addrlst_unittest.cc
@@ -38,7 +38,7 @@ public:
 
 TEST_F(Option6AddrLstTest, basic) {
 
-    char sampledata[] = {
+    uint8_t sampledata[] = {
         // 2001:db8:1::dead:beef
         0x20, 0x01, 0x0d, 0xb8, 0x00, 0x01, 0, 0,
         0, 0, 0, 0, 0xde, 0xad, 0xbe, 0xef,
@@ -52,7 +52,7 @@ TEST_F(Option6AddrLstTest, basic) {
         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
     };
 
-    char expected1[] = {
+    uint8_t expected1[] = {
         D6O_NAME_SERVERS/256, D6O_NAME_SERVERS%256,//type
         0, 16, // len = 16 (1 address)
         0x20, 0x01, 0x0d, 0xb8, 0x00, 0x01, 0, 0,
@@ -60,7 +60,7 @@ TEST_F(Option6AddrLstTest, basic) {
 
     };
 
-    char expected2[] = {
+    uint8_t expected2[] = {
         D6O_SIP_SERVERS_ADDR/256, D6O_SIP_SERVERS_ADDR%256,
         0, 32, // len = 32 (2 addresses)
         // 2001:db8:1::dead:beef
@@ -76,7 +76,7 @@ TEST_F(Option6AddrLstTest, basic) {
         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
     };
 
-    char expected3[] = {
+    uint8_t expected3[] = {
         D6O_NIS_SERVERS/256, D6O_NIS_SERVERS%256,
         0, 48,
         // 2001:db8:1::dead:beef
@@ -92,7 +92,7 @@ TEST_F(Option6AddrLstTest, basic) {
         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
     };
 
-    boost::shared_array<char> buf(new char[300]);
+    boost::shared_array<uint8_t> buf(new uint8_t[300]);
     for (int i=0; i<300; i++)
         buf[i] = 0;
 
diff --git a/src/lib/dhcp/tests/option6_ia_unittest.cc b/src/lib/dhcp/tests/option6_ia_unittest.cc
index c60a50f..5de8c23 100644
--- a/src/lib/dhcp/tests/option6_ia_unittest.cc
+++ b/src/lib/dhcp/tests/option6_ia_unittest.cc
@@ -38,7 +38,7 @@ public:
 
 TEST_F(Option6IATest, basic) {
 
-    boost::shared_array<char> simple_buf(new char[128]);
+    boost::shared_array<uint8_t> simple_buf(new uint8_t[128]);
     for (int i=0; i<128; i++)
         simple_buf[i] = 0;
     simple_buf[0]=0xa1; // iaid
@@ -109,7 +109,7 @@ TEST_F(Option6IATest, basic) {
 }
 
 TEST_F(Option6IATest, simple) {
-    boost::shared_array<char> simple_buf(new char[128]);
+    boost::shared_array<uint8_t> simple_buf(new uint8_t[128]);
     for (int i=0; i<128; i++)
         simple_buf[i] = 0;
 
@@ -128,7 +128,7 @@ TEST_F(Option6IATest, simple) {
 
 // test if option can build suboptions
 TEST_F(Option6IATest, suboptions_pack) {
-    boost::shared_array<char> buf(new char[128]);
+    boost::shared_array<uint8_t> buf(new uint8_t[128]);
     for (int i=0; i<128; i++)
         buf[i] = 0;
     buf[0] = 0xff;
@@ -154,7 +154,7 @@ TEST_F(Option6IATest, suboptions_pack) {
     ASSERT_EQ(4, sub1->len());
     ASSERT_EQ(48, ia->len());
 
-    char expected[] = {
+    uint8_t expected[] = {
         D6O_IA_NA/256, D6O_IA_NA%256, // type
         0, 44, // length
         0x13, 0x57, 0x9a, 0xce, // iaid
@@ -186,7 +186,7 @@ TEST_F(Option6IATest, suboptions_pack) {
 TEST_F(Option6IATest, suboptions_unpack) {
 
 
-    char expected[] = {
+    uint8_t expected[] = {
         D6O_IA_NA/256, D6O_IA_NA%256, // type
         0, 28, // length
         0x13, 0x57, 0x9a, 0xce, // iaid
@@ -206,7 +206,7 @@ TEST_F(Option6IATest, suboptions_unpack) {
         0, 0 // len
     };
 
-    boost::shared_array<char> buf(new char[128]);
+    boost::shared_array<uint8_t> buf(new uint8_t[128]);
     for (int i=0; i<128; i++)
         buf[i] = 0;
     memcpy(&buf[0], expected, 48);
diff --git a/src/lib/dhcp/tests/option6_iaaddr_unittest.cc b/src/lib/dhcp/tests/option6_iaaddr_unittest.cc
index eae8260..14cb6a4 100644
--- a/src/lib/dhcp/tests/option6_iaaddr_unittest.cc
+++ b/src/lib/dhcp/tests/option6_iaaddr_unittest.cc
@@ -36,7 +36,7 @@ public:
 
 TEST_F(Option6IAAddrTest, basic) {
 
-    boost::shared_array<char> simple_buf(new char[128]);
+    boost::shared_array<uint8_t> simple_buf(new uint8_t[128]);
     for (int i=0; i<128; i++)
         simple_buf[i] = 0;
     simple_buf[0]=0x20;
diff --git a/src/lib/dhcp/tests/option_unittest.cc b/src/lib/dhcp/tests/option_unittest.cc
index f2110db..5e04344 100644
--- a/src/lib/dhcp/tests/option_unittest.cc
+++ b/src/lib/dhcp/tests/option_unittest.cc
@@ -61,7 +61,7 @@ TEST_F(OptionTest, basic6) {
 // tests contructor used in pkt reception
 // option contains actual data
 TEST_F(OptionTest, data1) {
-    boost::shared_array<char> buf(new char[32]);
+    boost::shared_array<uint8_t> buf(new uint8_t[32]);
     for (int i=0; i<32; i++)
         buf[i] = 100+i;
     Option* opt = new Option(Option::V6, 333, //type
@@ -92,7 +92,7 @@ TEST_F(OptionTest, data1) {
 // with different input parameters
 TEST_F(OptionTest, data2) {
 
-    boost::shared_array<char> simple_buf(new char[128]);
+    boost::shared_array<uint8_t> simple_buf(new uint8_t[128]);
     for (int i=0; i<128; i++)
         simple_buf[i] = 0;
     simple_buf[0]=0xa1;
@@ -137,7 +137,7 @@ TEST_F(OptionTest, data2) {
 //  +----opt3
 //
 TEST_F(OptionTest, suboptions1) {
-    boost::shared_array<char> buf(new char[128]);
+    boost::shared_array<uint8_t> buf(new uint8_t[128]);
     for (int i=0; i<128; i++)
         buf[i] = 100+i;
     Option* opt1 = new Option(Option::V6, 65535, //type
@@ -159,7 +159,7 @@ TEST_F(OptionTest, suboptions1) {
     EXPECT_EQ(9, opt3->len());
     EXPECT_EQ(20, opt1->len());
 
-    char expected[] = {
+    uint8_t expected[] = {
         0xff, 0xff, 0, 16, 100, 101, 102,
         0, 7, 0, 5, 103, 104, 105, 106, 107,
         0, 13, 0, 0 // no data at all
@@ -181,7 +181,7 @@ TEST_F(OptionTest, suboptions1) {
 //        +----opt3
 //
 TEST_F(OptionTest, suboptions2) {
-    boost::shared_array<char> buf(new char[128]);
+    boost::shared_array<uint8_t> buf(new uint8_t[128]);
     for (int i=0; i<128; i++)
         buf[i] = 100+i;
     Option* opt1 = new Option(Option::V6, 65535, //type
@@ -199,7 +199,7 @@ TEST_F(OptionTest, suboptions2) {
     // opt2 len = 4 (just header) + len(opt3)
     // opt1 len = 7 + len(opt2)
 
-    char expected[] = {
+    uint8_t expected[] = {
         0xff, 0xff, 0, 16, 100, 101, 102,
         0, 13, 0, 9,
         0, 7, 0, 5, 103, 104, 105, 106, 107,
@@ -215,7 +215,7 @@ TEST_F(OptionTest, suboptions2) {
 }
 
 TEST_F(OptionTest, addgetdel) {
-    boost::shared_array<char> buf(new char[128]);
+    boost::shared_array<uint8_t> buf(new uint8_t[128]);
     for (int i=0; i<128; i++)
         buf[i] = 100+i;
     Option* parent = new Option(Option::V6, 65535); //type




More information about the bind10-changes mailing list