Browse Source

[1186] Part 3 of review changes

- buffer type changed: char => uint8_t
- removed unnecessary statements in Makefile.am
Tomek Mrugalski 13 years ago
parent
commit
6b9d28f760

+ 0 - 2
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
 b10_dhcp6_SOURCES += iface_mgr.h dhcp6_srv.h
 
 
 b10_dhcp6_LDADD = $(top_builddir)/src/lib/dhcp/libdhcp.la
 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/exceptions/libexceptions.la
 b10_dhcp6_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
 b10_dhcp6_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
 b10_dhcp6_LDADD += $(top_builddir)/src/lib/log/liblog.la
 b10_dhcp6_LDADD += $(top_builddir)/src/lib/log/liblog.la

+ 1 - 1
src/bin/dhcp6/dhcp6_srv.cc

@@ -118,7 +118,7 @@ Dhcpv6Srv::setServerID() {
     /// TODO implement this for real once interface detection is done.
     /// TODO implement this for real once interface detection is done.
     /// Use hardcoded server-id for now
     /// 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[0] = 0;
     srvid[1] = 1; // DUID type 1 = DUID-LLT (see section 9.2 of RFC3315)
     srvid[1] = 1; // DUID type 1 = DUID-LLT (see section 9.2 of RFC3315)
     srvid[2] = 0;
     srvid[2] = 0;

+ 3 - 6
src/bin/dhcp6/main.cc

@@ -26,8 +26,11 @@
 #include <iostream>
 #include <iostream>
 
 
 #include <exceptions/exceptions.h>
 #include <exceptions/exceptions.h>
+#if 0
+// TODO cc is not used yet. It should be eventually
 #include <cc/session.h>
 #include <cc/session.h>
 #include <config/ccsession.h>
 #include <config/ccsession.h>
+#endif
 
 
 #include <util/buffer.h>
 #include <util/buffer.h>
 #include <log/dummylog.h>
 #include <log/dummylog.h>
@@ -37,10 +40,6 @@
 
 
 using namespace std;
 using namespace std;
 using namespace isc::util;
 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;
 using namespace isc::dhcp;
 using namespace isc::dhcp;
@@ -98,8 +97,6 @@ main(int argc, char* argv[]) {
             specfile = string(DHCP6_SPECFILE_LOCATION);
             specfile = string(DHCP6_SPECFILE_LOCATION);
         }
         }
 
 
-        // auth_server = new AuthSrv(cache, xfrout_client);
-        // auth_server->setVerbose(verbose_mode);
         cout << "[b10-dhcp6] Initiating DHCPv6 operation." << endl;
         cout << "[b10-dhcp6] Initiating DHCPv6 operation." << endl;
 
 
         Dhcpv6Srv* srv = new Dhcpv6Srv();
         Dhcpv6Srv* srv = new Dhcpv6Srv();

+ 0 - 2
src/bin/dhcp6/tests/Makefile.am

@@ -57,8 +57,6 @@ dhcp6_unittests_LDADD = $(GTEST_LDADD)
 dhcp6_unittests_LDADD += $(SQLITE_LIBS)
 dhcp6_unittests_LDADD += $(SQLITE_LIBS)
 dhcp6_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
 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/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/exceptions/libexceptions.la
 dhcp6_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
 dhcp6_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
 endif
 endif

+ 1 - 1
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc

@@ -74,7 +74,7 @@ TEST_F(Dhcpv6SrvTest, Solicit_basic) {
     EXPECT_NO_THROW( srv = new NakedDhcpv6Srv(); );
     EXPECT_NO_THROW( srv = new NakedDhcpv6Srv(); );
 
 
     // a dummy content for client-id
     // 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++)
     for (int i=0; i<32; i++)
         clntDuid[i] = 100+i;
         clntDuid[i] = 100+i;
 
 

+ 6 - 5
src/lib/asiolink/io_address.cc

@@ -23,7 +23,7 @@
 #include <exceptions/exceptions.h>
 #include <exceptions/exceptions.h>
 #include <asiolink/io_address.h>
 #include <asiolink/io_address.h>
 #include <asiolink/io_error.h>
 #include <asiolink/io_error.h>
-
+#include <boost/static_assert.hpp>
 
 
 using namespace asio;
 using namespace asio;
 using asio::ip::udp;
 using asio::ip::udp;
@@ -55,17 +55,18 @@ IOAddress::toText() const {
 }
 }
 
 
 IOAddress
 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) {
     if (data == NULL) {
         isc_throw(BadValue, "NULL pointer received.");
         isc_throw(BadValue, "NULL pointer received.");
-    }
+    } else
     if ( (family != AF_INET) && (family != AF_INET6) ) {
     if ( (family != AF_INET) && (family != AF_INET6) ) {
         isc_throw(BadValue, "Invalid family type. Only AF_INET and AF_INET6"
         isc_throw(BadValue, "Invalid family type. Only AF_INET and AF_INET6"
                   << "are supported");
                   << "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));
     return IOAddress(string(addr_str));
 }
 }
 
 

+ 1 - 1
src/lib/asiolink/io_address.h

@@ -95,7 +95,7 @@ public:
     ///
     ///
     /// \return Created IOAddress object
     /// \return Created IOAddress object
     static IOAddress
     static IOAddress
-    from_bytes(short family, const char* data);
+    from_bytes(short family, const uint8_t* data);
 
 
     /// \brief Compare addresses for equality
     /// \brief Compare addresses for equality
     ///
     ///

+ 2 - 2
src/lib/asiolink/tests/io_address_unittest.cc

@@ -66,11 +66,11 @@ TEST(IOAddressTest, Family) {
 
 
 TEST(IOAddressTest, from_bytes) {
 TEST(IOAddressTest, from_bytes) {
     // 2001:db8:1::dead:beef
     // 2001:db8:1::dead:beef
-    char v6[] = {
+    uint8_t v6[] = {
         0x20, 0x01, 0x0d, 0xb8, 0x00, 0x01, 0, 0,
         0x20, 0x01, 0x0d, 0xb8, 0x00, 0x01, 0, 0,
         0, 0, 0, 0, 0xde, 0xad, 0xbe, 0xef };
         0, 0, 0, 0, 0xde, 0xad, 0xbe, 0xef };
 
 
-    char v4[] = { 192, 0 , 2, 3 };
+    uint8_t v4[] = { 192, 0 , 2, 3 };
 
 
     IOAddress addr("::");
     IOAddress addr("::");
     EXPECT_NO_THROW({
     EXPECT_NO_THROW({

+ 2 - 9
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 = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
 AM_CPPFLAGS += $(BOOST_INCLUDES)
 AM_CPPFLAGS += $(BOOST_INCLUDES)
 
 
+AM_CXXFLAGS = $(B10_CXXFLAGS)
+
 CLEANFILES = *.gcno *.gcda
 CLEANFILES = *.gcno *.gcda
 
 
 lib_LTLIBRARIES = libdhcp.la
 lib_LTLIBRARIES = libdhcp.la
@@ -18,16 +20,7 @@ libdhcp_la_SOURCES += pkt6.cc pkt6.h
 EXTRA_DIST  = README
 EXTRA_DIST  = README
 #EXTRA_DIST += log_messages.mes
 #EXTRA_DIST += log_messages.mes
 
 
-# Note: the ordering matters: -Wno-... must follow -Wextra (defined in
-# B10_CXXFLAGS)
 libdhcp_la_CXXFLAGS = $(AM_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_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
 libdhcp_la_LDFLAGS  = $(LOG4CPLUS_LDFLAGS)
 libdhcp_la_LDFLAGS  = $(LOG4CPLUS_LDFLAGS)
 libdhcp_la_LIBADD   = $(top_builddir)/src/lib/util/libutil.la
 libdhcp_la_LIBADD   = $(top_builddir)/src/lib/util/libutil.la

+ 4 - 6
src/lib/dhcp/libdhcp.cc

@@ -34,7 +34,7 @@ LibDHCP::version() {
 }
 }
 
 
 unsigned int
 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,
                         unsigned int offset, unsigned int parse_len,
                         isc::dhcp::Option::Option6Lst& options) {
                         isc::dhcp::Option::Option6Lst& options) {
     if (offset + parse_len > buf_len) {
     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;
     unsigned int end = offset + parse_len;
 
 
     while (offset<end) {
     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;
         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;
         offset += 2;
 
 
         if (offset + opt_len > end ) {
         if (offset + opt_len > end ) {
@@ -91,7 +89,7 @@ LibDHCP::unpackOptions6(boost::shared_array<char> buf, unsigned int buf_len,
 }
 }
 
 
 unsigned int
 unsigned int
-LibDHCP::packOptions6(boost::shared_array<char> data,
+LibDHCP::packOptions6(boost::shared_array<uint8_t> data,
                       unsigned int data_len,
                       unsigned int data_len,
                       unsigned int offset,
                       unsigned int offset,
                       isc::dhcp::Option::Option6Lst& options) {
                       isc::dhcp::Option::Option6Lst& options) {

+ 2 - 2
src/lib/dhcp/libdhcp.h

@@ -44,7 +44,7 @@ public:
     ///         used byte)
     ///         used byte)
     ///
     ///
     static unsigned int
     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,
                  unsigned int offset,
                  isc::dhcp::Option::Option6Lst& options);
                  isc::dhcp::Option::Option6Lst& options);
 
 
@@ -62,7 +62,7 @@ public:
     /// @return offset to first byte after last parsed option
     /// @return offset to first byte after last parsed option
     ///
     ///
     static unsigned int
     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,
                    unsigned int offset, unsigned int parse_len,
                    isc::dhcp::Option::Option6Lst& options_);
                    isc::dhcp::Option::Option6Lst& options_);
 
 

+ 11 - 11
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)
                unsigned int offset, unsigned int len)
     :universe_(u), type_(type), data_(buf),
     :universe_(u), type_(type), data_(buf),
      data_len_(len), offset_(offset)
      data_len_(len), offset_(offset)
@@ -43,7 +43,7 @@ Option::Option(Universe u, unsigned short type, boost::shared_array<char> buf,
 }
 }
 
 
 unsigned int
 unsigned int
-Option::pack(boost::shared_array<char> buf,
+Option::pack(boost::shared_array<uint8_t> buf,
              unsigned int buf_len,
              unsigned int buf_len,
              unsigned int offset) {
              unsigned int offset) {
     switch (universe_) {
     switch (universe_) {
@@ -58,14 +58,14 @@ Option::pack(boost::shared_array<char> buf,
 
 
 
 
 unsigned int
 unsigned int
-Option::pack4(boost::shared_array<char> buf,
+Option::pack4(boost::shared_array<uint8_t> buf,
              unsigned int buf_len,
              unsigned int buf_len,
              unsigned int offset) {
              unsigned int offset) {
     if ( offset+len() > buf_len ) {
     if ( offset+len() > buf_len ) {
         isc_throw(OutOfRange, "Failed to pack v4 option=" <<
         isc_throw(OutOfRange, "Failed to pack v4 option=" <<
                   type_ << ",len=" << data_len_ << ": too small buffer.");
                   type_ << ",len=" << data_len_ << ": too small buffer.");
     }
     }
-    char *ptr = &buf[offset];
+    uint8_t *ptr = &buf[offset];
     ptr[0] = type_;
     ptr[0] = type_;
     ptr[1] = data_len_;
     ptr[1] = data_len_;
     ptr += 2;
     ptr += 2;
@@ -75,7 +75,7 @@ Option::pack4(boost::shared_array<char> buf,
 }
 }
 
 
 unsigned int
 unsigned int
-Option::pack6(boost::shared_array<char> buf,
+Option::pack6(boost::shared_array<uint8_t> buf,
              unsigned int buf_len,
              unsigned int buf_len,
              unsigned int offset) {
              unsigned int offset) {
     if ( offset+len() > buf_len ) {
     if ( offset+len() > buf_len ) {
@@ -85,7 +85,7 @@ Option::pack6(boost::shared_array<char> buf,
 
 
     int length = len() - getHeaderLen();
     int length = len() - getHeaderLen();
 
 
-    char * ptr = &buf[offset];
+    uint8_t * ptr = &buf[offset];
     *(uint16_t*)ptr = htons(type_);
     *(uint16_t*)ptr = htons(type_);
     ptr += 2;
     ptr += 2;
     *(uint16_t*)ptr = htons(length);
     *(uint16_t*)ptr = htons(length);
@@ -99,7 +99,7 @@ Option::pack6(boost::shared_array<char> buf,
 }
 }
 
 
 unsigned int
 unsigned int
-Option::unpack(boost::shared_array<char> buf,
+Option::unpack(boost::shared_array<uint8_t> buf,
                unsigned int buf_len,
                unsigned int buf_len,
                unsigned int offset,
                unsigned int offset,
                unsigned int parse_len) {
                unsigned int parse_len) {
@@ -116,7 +116,7 @@ Option::unpack(boost::shared_array<char> buf,
 }
 }
 
 
 unsigned int
 unsigned int
-Option::unpack4(boost::shared_array<char>,
+Option::unpack4(boost::shared_array<uint8_t>,
                 unsigned int ,
                 unsigned int ,
                 unsigned int ,
                 unsigned int ,
                 unsigned int ) {
                 unsigned int ) {
@@ -125,7 +125,7 @@ Option::unpack4(boost::shared_array<char>,
 }
 }
 
 
 unsigned int
 unsigned int
-Option::unpack6(boost::shared_array<char> buf,
+Option::unpack6(boost::shared_array<uint8_t> buf,
                 unsigned int buf_len,
                 unsigned int buf_len,
                 unsigned int offset,
                 unsigned int offset,
                 unsigned int parse_len) {
                 unsigned int parse_len) {
@@ -209,7 +209,7 @@ std::string Option::toText(int indent /* =0 */ ) {
             tmp << ":";
             tmp << ":";
         }
         }
         tmp << setfill('0') << setw(2) << hex
         tmp << setfill('0') << setw(2) << hex
-            << (unsigned short)(unsigned char)data_[offset_+i];
+            << (unsigned short)(unsigned uint8_t)data_[offset_+i];
     }
     }
 
 
     // print suboptions
     // print suboptions
@@ -226,7 +226,7 @@ Option::getType() {
     return type_;
     return type_;
 }
 }
 
 
-char*
+uint8_t*
 Option::getData() {
 Option::getData() {
     if (data_len_) {
     if (data_len_) {
         return (&data_[offset_]);
         return (&data_[offset_]);

+ 10 - 10
src/lib/dhcp/option.h

@@ -29,7 +29,7 @@ public:
     typedef std::multimap<unsigned int, boost::shared_ptr<Option> > Option6Lst;
     typedef std::multimap<unsigned int, boost::shared_ptr<Option> > Option6Lst;
     typedef boost::shared_ptr<Option> Factory(Option::Universe u,
     typedef boost::shared_ptr<Option> Factory(Option::Universe u,
                                               unsigned short type,
                                               unsigned short type,
-                                              boost::shared_array<char> buf,
+                                              boost::shared_array<uint8_t> buf,
                                               unsigned int offset,
                                               unsigned int offset,
                                               unsigned int len);
                                               unsigned int len);
 
 
@@ -42,14 +42,14 @@ public:
     // to different elements in shared array. Therefore we need to share
     // to different elements in shared array. Therefore we need to share
     // pointer to the whole array and remember offset where data for
     // pointer to the whole array and remember offset where data for
     // this option begins
     // 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 offset,
            unsigned int len);
            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
     // byte after stored option
     virtual unsigned int
     virtual unsigned int
-    pack(boost::shared_array<char> buf,
+    pack(boost::shared_array<uint8_t> buf,
          unsigned int buf_len,
          unsigned int buf_len,
          unsigned int offset);
          unsigned int offset);
 
 
@@ -67,7 +67,7 @@ public:
     /// @return offset after last parsed option
     /// @return offset after last parsed option
     ///
     ///
     virtual unsigned int
     virtual unsigned int
-    unpack(boost::shared_array<char> buf,
+    unpack(boost::shared_array<uint8_t> buf,
            unsigned int buf_len,
            unsigned int buf_len,
            unsigned int offset,
            unsigned int offset,
            unsigned int parse_len);
            unsigned int parse_len);
@@ -113,7 +113,7 @@ public:
     ///
     ///
     /// @return pointer to actual data (or NULL if there is no data)
     /// @return pointer to actual data (or NULL if there is no data)
     ///
     ///
-    virtual char*
+    virtual uint8_t*
     getData();
     getData();
 
 
     /// Adds a sub-option.
     /// Adds a sub-option.
@@ -160,7 +160,7 @@ protected:
     /// @return offset to the next byte after last used byte
     /// @return offset to the next byte after last used byte
     ///
     ///
     virtual unsigned int
     virtual unsigned int
-    pack4(boost::shared_array<char> buf,
+    pack4(boost::shared_array<uint8_t> buf,
           unsigned int buf_len,
           unsigned int buf_len,
           unsigned int offset);
           unsigned int offset);
 
 
@@ -175,7 +175,7 @@ protected:
     /// @return offset to the next byte after last used byte
     /// @return offset to the next byte after last used byte
     ///
     ///
     virtual unsigned int
     virtual unsigned int
-    pack6(boost::shared_array<char> buf,
+    pack6(boost::shared_array<uint8_t> buf,
           unsigned int buf_len,
           unsigned int buf_len,
           unsigned int offset);
           unsigned int offset);
 
 
@@ -189,7 +189,7 @@ protected:
     /// @return offset to the next byte after last parsed byte
     /// @return offset to the next byte after last parsed byte
     ///
     ///
     virtual unsigned int
     virtual unsigned int
-    unpack4(boost::shared_array<char> buf,
+    unpack4(boost::shared_array<uint8_t> buf,
             unsigned int buf_len,
             unsigned int buf_len,
             unsigned int offset,
             unsigned int offset,
             unsigned int parse_len);
             unsigned int parse_len);
@@ -204,7 +204,7 @@ protected:
     /// @return offset to the next byte after last parsed byte
     /// @return offset to the next byte after last parsed byte
     ///
     ///
     virtual unsigned int
     virtual unsigned int
-    unpack6(boost::shared_array<char> buf,
+    unpack6(boost::shared_array<uint8_t> buf,
             unsigned int buf_len,
             unsigned int buf_len,
             unsigned int offset,
             unsigned int offset,
             unsigned int parse_len);
             unsigned int parse_len);
@@ -212,7 +212,7 @@ protected:
     Universe universe_; // option universe (V4 or V6)
     Universe universe_; // option universe (V4 or V6)
     unsigned short type_; // option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
     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
     unsigned int data_len_; // length of data only. Use len() if you want to
                             // know proper length with option header overhead
                             // know proper length with option header overhead
     unsigned int offset_; // data is a shared_pointer that points out to the
     unsigned int offset_; // data is a shared_pointer that points out to the

+ 3 - 3
src/lib/dhcp/option6_addrlst.cc

@@ -41,7 +41,7 @@ Option6AddrLst::Option6AddrLst(unsigned short type,
 }
 }
 
 
 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 buf_len,
                                unsigned int offset,
                                unsigned int offset,
                                unsigned int option_len)
                                unsigned int option_len)
@@ -61,7 +61,7 @@ Option6AddrLst::setAddresses(std::vector<isc::asiolink::IOAddress>& addrs) {
 }
 }
 
 
 unsigned int
 unsigned int
-Option6AddrLst::pack(boost::shared_array<char> buf,
+Option6AddrLst::pack(boost::shared_array<uint8_t> buf,
                     unsigned int buf_len,
                     unsigned int buf_len,
                     unsigned int offset) {
                     unsigned int offset) {
     if (len() > buf_len) {
     if (len() > buf_len) {
@@ -88,7 +88,7 @@ Option6AddrLst::pack(boost::shared_array<char> buf,
 }
 }
 
 
 unsigned int
 unsigned int
-Option6AddrLst::unpack(boost::shared_array<char> buf,
+Option6AddrLst::unpack(boost::shared_array<uint8_t> buf,
                   unsigned int buf_len,
                   unsigned int buf_len,
                   unsigned int offset,
                   unsigned int offset,
                   unsigned int option_len) {
                   unsigned int option_len) {

+ 3 - 3
src/lib/dhcp/option6_addrlst.h

@@ -57,7 +57,7 @@ public:
     /// @param offset offset to beginning of option data
     /// @param offset offset to beginning of option data
     /// @param len length 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 buf_len,
                    unsigned int offset,
                    unsigned int offset,
                    unsigned int len);
                    unsigned int len);
@@ -71,7 +71,7 @@ public:
     /// @return offset to the next unused char (just after stored option)
     /// @return offset to the next unused char (just after stored option)
     ///
     ///
     unsigned int
     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);
          unsigned int offset);
 
 
     /// @brief Parses received data
     /// @brief Parses received data
@@ -84,7 +84,7 @@ public:
     /// @return offset to the next unparsed char (just after parsed option)
     /// @return offset to the next unparsed char (just after parsed option)
     ///
     ///
     virtual unsigned int
     virtual unsigned int
-    unpack(boost::shared_array<char> buf,
+    unpack(boost::shared_array<uint8_t> buf,
            unsigned int buf_len,
            unsigned int buf_len,
            unsigned int offset,
            unsigned int offset,
            unsigned int parse_len);
            unsigned int parse_len);

+ 13 - 14
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 buf_len,
-                   unsigned int offset, 
+                   unsigned int offset,
                    unsigned int option_len)
                    unsigned int option_len)
     :Option(u, type) {
     :Option(u, type) {
     unpack(buf, buf_len, offset, option_len);
     unpack(buf, buf_len, offset, option_len);
 }
 }
 
 
 unsigned int
 unsigned int
-Option6IA::pack(boost::shared_array<char> buf,
+Option6IA::pack(boost::shared_array<uint8_t> buf,
                 unsigned int buf_len,
                 unsigned int buf_len,
                 unsigned int offset) {
                 unsigned int offset) {
     if (offset + len() > buf_len) {
     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.");
                   << ", buffer=" << buf_len << ": too small buffer.");
     }
     }
-    
-    char* ptr = &buf[offset];
+
+    uint8_t* ptr = &buf[offset];
     *(uint16_t*)ptr = htons(type_);
     *(uint16_t*)ptr = htons(type_);
     ptr += 2;
     ptr += 2;
     *(uint16_t*)ptr = htons(len() - 4); // len() returns complete option length
     *(uint16_t*)ptr = htons(len() - 4); // len() returns complete option length
     // len field contains length without 4-byte option header
     // len field contains length without 4-byte option header
     ptr += 2;
     ptr += 2;
-    
+
     *(uint32_t*)ptr = htonl(iaid_);
     *(uint32_t*)ptr = htonl(iaid_);
     ptr += 4;
     ptr += 4;
 
 
@@ -69,10 +69,10 @@ Option6IA::pack(boost::shared_array<char> buf,
     return offset;
     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 buf_len,
-                  unsigned int offset, 
+                  unsigned int offset,
                   unsigned int parse_len) {
                   unsigned int parse_len) {
     if (parse_len<12 || offset+12>buf_len) {
     if (parse_len<12 || offset+12>buf_len) {
         isc_throw(OutOfRange, "Option " << type_ << " truncated");
         isc_throw(OutOfRange, "Option " << type_ << " truncated");
@@ -83,7 +83,7 @@ Option6IA::unpack(boost::shared_array<char> buf,
     offset +=4;
     offset +=4;
     t2_ = ntohl(*(uint32_t*)&buf[offset]);
     t2_ = ntohl(*(uint32_t*)&buf[offset]);
     offset +=4;
     offset +=4;
-    offset = LibDHCP::unpackOptions6(buf, buf_len, offset, 
+    offset = LibDHCP::unpackOptions6(buf, buf_len, offset,
                                      parse_len - 12, optionLst_);
                                      parse_len - 12, optionLst_);
 
 
     return (offset);
     return (offset);
@@ -118,7 +118,7 @@ std::string Option6IA::toText(int indent /* = 0*/) {
 }
 }
 
 
 unsigned short Option6IA::len() {
 unsigned short Option6IA::len() {
-    
+
     unsigned short length = 4/*header*/ + 12 /* option content */; // header
     unsigned short length = 4/*header*/ + 12 /* option content */; // header
 
 
     // length of all suboptions
     // length of all suboptions
@@ -129,4 +129,3 @@ unsigned short Option6IA::len() {
     }
     }
     return (length);
     return (length);
 }
 }
-

+ 4 - 4
src/lib/dhcp/option6_ia.h

@@ -32,7 +32,7 @@ public:
     // to different elements in shared array. Therefore we need to share
     // to different elements in shared array. Therefore we need to share
     // pointer to the whole array and remember offset where data for
     // pointer to the whole array and remember offset where data for
     // this option begins
     // 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 buf_len,
               unsigned int offset,
               unsigned int offset,
               unsigned int len);
               unsigned int len);
@@ -40,20 +40,20 @@ public:
     // 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
     // byte after stored option
     unsigned int
     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);
          unsigned int offset);
 
 
     // parses received buffer, returns offset to the first unused byte after
     // parses received buffer, returns offset to the first unused byte after
     // parsed option
     // parsed option
     virtual unsigned int
     virtual unsigned int
-    unpack(boost::shared_array<char> buf,
+    unpack(boost::shared_array<uint8_t> buf,
            unsigned int buf_len,
            unsigned int buf_len,
            unsigned int offset,
            unsigned int offset,
            unsigned int parse_len);
            unsigned int parse_len);
 
 
     /// Provides human readable text representation
     /// Provides human readable text representation
     ///
     ///
-    /// @param indent number of leading space characterss
+    /// @param indent number of leading space characters
     ///
     ///
     /// @return string with text represenation
     /// @return string with text represenation
     ///
     ///

+ 4 - 7
src/lib/dhcp/option6_iaaddr.cc

@@ -36,7 +36,7 @@ Option6IAAddr::Option6IAAddr(unsigned short type,
 }
 }
 
 
 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 buf_len,
                              unsigned int offset,
                              unsigned int offset,
                              unsigned int option_len)
                              unsigned int option_len)
@@ -45,7 +45,7 @@ Option6IAAddr::Option6IAAddr(unsigned short type,
 }
 }
 
 
 unsigned int
 unsigned int
-Option6IAAddr::pack(boost::shared_array<char> buf,
+Option6IAAddr::pack(boost::shared_array<uint8_t> buf,
                     unsigned int buf_len,
                     unsigned int buf_len,
                     unsigned int offset) {
                     unsigned int offset) {
     if (len() > buf_len) {
     if (len() > buf_len) {
@@ -73,7 +73,7 @@ Option6IAAddr::pack(boost::shared_array<char> buf,
 }
 }
 
 
 unsigned int
 unsigned int
-Option6IAAddr::unpack(boost::shared_array<char> buf,
+Option6IAAddr::unpack(boost::shared_array<uint8_t> buf,
                   unsigned int buf_len,
                   unsigned int buf_len,
                   unsigned int offset,
                   unsigned int offset,
                   unsigned int parse_len) {
                   unsigned int parse_len) {
@@ -82,10 +82,7 @@ Option6IAAddr::unpack(boost::shared_array<char> buf,
     }
     }
 
 
     // 16 bytes: IPv6 address
     // 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;
     offset += 16;
 
 
     preferred_ = ntohl(*(uint32_t*)&buf[offset]);
     preferred_ = ntohl(*(uint32_t*)&buf[offset]);

+ 13 - 13
src/lib/dhcp/option6_iaaddr.h

@@ -22,37 +22,37 @@ namespace isc {
 namespace dhcp {
 namespace dhcp {
 
 
 class Option6IAAddr: public Option {
 class Option6IAAddr: public Option {
-        
+
 public:
 public:
     // ctor, used for options constructed, usually during transmission
     // ctor, used for options constructed, usually during transmission
-    Option6IAAddr(unsigned short type, 
+    Option6IAAddr(unsigned short type,
                   isc::asiolink::IOAddress addr,
                   isc::asiolink::IOAddress addr,
                   unsigned int prefered,
                   unsigned int prefered,
-                  unsigned int valid); 
+                  unsigned int valid);
 
 
     // ctor, used for received options
     // 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
     // different instances share pointer to the whole array, not point
     // to different elements in shared array. Therefore we need to share
     // to different elements in shared array. Therefore we need to share
     // pointer to the whole array and remember offset where data for
     // pointer to the whole array and remember offset where data for
     // this option begins
     // 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 buf_len,
-                  unsigned int offset, 
+                  unsigned int offset,
                   unsigned int len);
                   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
     // byte after stored option
     unsigned int
     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);
          unsigned int offset);
 
 
     // parses received buffer, returns offset to the first unused byte after
     // parses received buffer, returns offset to the first unused byte after
     // parsed option
     // 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 buf_len,
-           unsigned int offset, 
+           unsigned int offset,
            unsigned int parse_len);
            unsigned int parse_len);
 
 
     virtual std::string toText(int indent = 0);
     virtual std::string toText(int indent = 0);
@@ -76,5 +76,5 @@ protected:
 
 
 } // isc::dhcp namespace
 } // isc::dhcp namespace
 } // isc namespace
 } // isc namespace
-    
+
 #endif /* OPTION_IA_H_ */
 #endif /* OPTION_IA_H_ */

+ 7 - 7
src/lib/dhcp/pkt6.cc

@@ -37,7 +37,7 @@ Pkt6::Pkt6(unsigned int dataLen, DHCPv6Proto_ proto /* = UDP */)
      proto_(proto)
      proto_(proto)
 {
 {
     try {
     try {
-        data_ = boost::shared_array<char>(new char[dataLen]);
+        data_ = boost::shared_array<uint8_t>(new uint8_t[dataLen]);
         data_len_ = dataLen;
         data_len_ = dataLen;
     } catch (const std::exception& ex) {
     } catch (const std::exception& ex) {
         // TODO move to LOG_FATAL()
         // 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,
            unsigned int transid,
            DHCPv6Proto_ proto /*= UDP*/)
            DHCPv6Proto_ proto /*= UDP*/)
     :local_addr_("::"),
     :local_addr_("::"),
@@ -59,7 +59,7 @@ Pkt6::Pkt6(unsigned char msg_type,
      transid_(transid) {
      transid_(transid) {
 
 
     try {
     try {
-        data_ = boost::shared_array<char>(new char[4]);
+        data_ = boost::shared_array<uint8_t>(new uint8_t[4]);
         data_len_ = 4;
         data_len_ = 4;
     } catch (Exception e) {
     } catch (Exception e) {
         cout << "Packet creation failed:" << e.what() << endl;
         cout << "Packet creation failed:" << e.what() << endl;
@@ -122,7 +122,7 @@ Pkt6::packUDP() {
              << length << endl;
              << length << endl;
 
 
         try {
         try {
-            data_ = boost::shared_array<char>(new char[length]);
+            data_ = boost::shared_array<uint8_t>(new uint8_t[length]);
             data_len_ = length;
             data_len_ = length;
         } catch (Exception e) {
         } catch (Exception e) {
             cout << "Failed to allocate " << length << "-byte buffer:"
             cout << "Failed to allocate " << length << "-byte buffer:"
@@ -208,8 +208,8 @@ Pkt6::unpackUDP() {
         return (false);
         return (false);
     }
     }
     msg_type_ = data_[0];
     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;
     transid_ = transid_ & 0xffffff;
 
 
     unsigned int offset = LibDHCP::unpackOptions6(data_,
     unsigned int offset = LibDHCP::unpackOptions6(data_,
@@ -286,7 +286,7 @@ Pkt6::getOption(unsigned short opt_type) {
  *
  *
  * @return message type.
  * @return message type.
  */
  */
-unsigned char
+uint8_t
 Pkt6::getType() {
 Pkt6::getType() {
     return (msg_type_);
     return (msg_type_);
 }
 }

+ 1 - 1
src/lib/dhcp/pkt6.h

@@ -56,7 +56,7 @@ namespace isc {
         ///      and hide following fields as protected
         ///      and hide following fields as protected
         /// buffer that holds memory. It is shared_array as options may
         /// buffer that holds memory. It is shared_array as options may
         /// share pointer to this buffer
         /// share pointer to this buffer
-        boost::shared_array<char> data_;
+        boost::shared_array<uint8_t> data_;
 
 
         // length of the data
         // length of the data
         unsigned int data_len_;
         unsigned int data_len_;

+ 2 - 2
src/lib/dhcp/tests/libdhcp_unittest.cc

@@ -40,7 +40,7 @@ TEST_F(LibDhcpTest, basic) {
 }
 }
 
 
 TEST_F(LibDhcpTest, packOptions6) {
 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
     isc::dhcp::Option::Option6Lst opts; // list of options
 
 
     // generate content for 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
     // we can't use packed directly, as shared_array would try to
     // free it eventually
     // 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);
     memcpy(&buf[0], packed, 35);
 
 
     unsigned int offset;
     unsigned int offset;

+ 5 - 5
src/lib/dhcp/tests/option6_addrlst_unittest.cc

@@ -38,7 +38,7 @@ public:
 
 
 TEST_F(Option6AddrLstTest, basic) {
 TEST_F(Option6AddrLstTest, basic) {
 
 
-    char sampledata[] = {
+    uint8_t sampledata[] = {
         // 2001:db8:1::dead:beef
         // 2001:db8:1::dead:beef
         0x20, 0x01, 0x0d, 0xb8, 0x00, 0x01, 0, 0,
         0x20, 0x01, 0x0d, 0xb8, 0x00, 0x01, 0, 0,
         0, 0, 0, 0, 0xde, 0xad, 0xbe, 0xef,
         0, 0, 0, 0, 0xde, 0xad, 0xbe, 0xef,
@@ -52,7 +52,7 @@ TEST_F(Option6AddrLstTest, basic) {
         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
     };
     };
 
 
-    char expected1[] = {
+    uint8_t expected1[] = {
         D6O_NAME_SERVERS/256, D6O_NAME_SERVERS%256,//type
         D6O_NAME_SERVERS/256, D6O_NAME_SERVERS%256,//type
         0, 16, // len = 16 (1 address)
         0, 16, // len = 16 (1 address)
         0x20, 0x01, 0x0d, 0xb8, 0x00, 0x01, 0, 0,
         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,
         D6O_SIP_SERVERS_ADDR/256, D6O_SIP_SERVERS_ADDR%256,
         0, 32, // len = 32 (2 addresses)
         0, 32, // len = 32 (2 addresses)
         // 2001:db8:1::dead:beef
         // 2001:db8:1::dead:beef
@@ -76,7 +76,7 @@ TEST_F(Option6AddrLstTest, basic) {
         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
     };
     };
 
 
-    char expected3[] = {
+    uint8_t expected3[] = {
         D6O_NIS_SERVERS/256, D6O_NIS_SERVERS%256,
         D6O_NIS_SERVERS/256, D6O_NIS_SERVERS%256,
         0, 48,
         0, 48,
         // 2001:db8:1::dead:beef
         // 2001:db8:1::dead:beef
@@ -92,7 +92,7 @@ TEST_F(Option6AddrLstTest, basic) {
         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
         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++)
     for (int i=0; i<300; i++)
         buf[i] = 0;
         buf[i] = 0;
 
 

+ 6 - 6
src/lib/dhcp/tests/option6_ia_unittest.cc

@@ -38,7 +38,7 @@ public:
 
 
 TEST_F(Option6IATest, basic) {
 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++)
     for (int i=0; i<128; i++)
         simple_buf[i] = 0;
         simple_buf[i] = 0;
     simple_buf[0]=0xa1; // iaid
     simple_buf[0]=0xa1; // iaid
@@ -109,7 +109,7 @@ TEST_F(Option6IATest, basic) {
 }
 }
 
 
 TEST_F(Option6IATest, simple) {
 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++)
     for (int i=0; i<128; i++)
         simple_buf[i] = 0;
         simple_buf[i] = 0;
 
 
@@ -128,7 +128,7 @@ TEST_F(Option6IATest, simple) {
 
 
 // test if option can build suboptions
 // test if option can build suboptions
 TEST_F(Option6IATest, suboptions_pack) {
 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++)
     for (int i=0; i<128; i++)
         buf[i] = 0;
         buf[i] = 0;
     buf[0] = 0xff;
     buf[0] = 0xff;
@@ -154,7 +154,7 @@ TEST_F(Option6IATest, suboptions_pack) {
     ASSERT_EQ(4, sub1->len());
     ASSERT_EQ(4, sub1->len());
     ASSERT_EQ(48, ia->len());
     ASSERT_EQ(48, ia->len());
 
 
-    char expected[] = {
+    uint8_t expected[] = {
         D6O_IA_NA/256, D6O_IA_NA%256, // type
         D6O_IA_NA/256, D6O_IA_NA%256, // type
         0, 44, // length
         0, 44, // length
         0x13, 0x57, 0x9a, 0xce, // iaid
         0x13, 0x57, 0x9a, 0xce, // iaid
@@ -186,7 +186,7 @@ TEST_F(Option6IATest, suboptions_pack) {
 TEST_F(Option6IATest, suboptions_unpack) {
 TEST_F(Option6IATest, suboptions_unpack) {
 
 
 
 
-    char expected[] = {
+    uint8_t expected[] = {
         D6O_IA_NA/256, D6O_IA_NA%256, // type
         D6O_IA_NA/256, D6O_IA_NA%256, // type
         0, 28, // length
         0, 28, // length
         0x13, 0x57, 0x9a, 0xce, // iaid
         0x13, 0x57, 0x9a, 0xce, // iaid
@@ -206,7 +206,7 @@ TEST_F(Option6IATest, suboptions_unpack) {
         0, 0 // len
         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++)
     for (int i=0; i<128; i++)
         buf[i] = 0;
         buf[i] = 0;
     memcpy(&buf[0], expected, 48);
     memcpy(&buf[0], expected, 48);

+ 1 - 1
src/lib/dhcp/tests/option6_iaaddr_unittest.cc

@@ -36,7 +36,7 @@ public:
 
 
 TEST_F(Option6IAAddrTest, basic) {
 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++)
     for (int i=0; i<128; i++)
         simple_buf[i] = 0;
         simple_buf[i] = 0;
     simple_buf[0]=0x20;
     simple_buf[0]=0x20;

+ 7 - 7
src/lib/dhcp/tests/option_unittest.cc

@@ -61,7 +61,7 @@ TEST_F(OptionTest, basic6) {
 // tests contructor used in pkt reception
 // tests contructor used in pkt reception
 // option contains actual data
 // option contains actual data
 TEST_F(OptionTest, data1) {
 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++)
     for (int i=0; i<32; i++)
         buf[i] = 100+i;
         buf[i] = 100+i;
     Option* opt = new Option(Option::V6, 333, //type
     Option* opt = new Option(Option::V6, 333, //type
@@ -92,7 +92,7 @@ TEST_F(OptionTest, data1) {
 // with different input parameters
 // with different input parameters
 TEST_F(OptionTest, data2) {
 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++)
     for (int i=0; i<128; i++)
         simple_buf[i] = 0;
         simple_buf[i] = 0;
     simple_buf[0]=0xa1;
     simple_buf[0]=0xa1;
@@ -137,7 +137,7 @@ TEST_F(OptionTest, data2) {
 //  +----opt3
 //  +----opt3
 //
 //
 TEST_F(OptionTest, suboptions1) {
 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++)
     for (int i=0; i<128; i++)
         buf[i] = 100+i;
         buf[i] = 100+i;
     Option* opt1 = new Option(Option::V6, 65535, //type
     Option* opt1 = new Option(Option::V6, 65535, //type
@@ -159,7 +159,7 @@ TEST_F(OptionTest, suboptions1) {
     EXPECT_EQ(9, opt3->len());
     EXPECT_EQ(9, opt3->len());
     EXPECT_EQ(20, opt1->len());
     EXPECT_EQ(20, opt1->len());
 
 
-    char expected[] = {
+    uint8_t expected[] = {
         0xff, 0xff, 0, 16, 100, 101, 102,
         0xff, 0xff, 0, 16, 100, 101, 102,
         0, 7, 0, 5, 103, 104, 105, 106, 107,
         0, 7, 0, 5, 103, 104, 105, 106, 107,
         0, 13, 0, 0 // no data at all
         0, 13, 0, 0 // no data at all
@@ -181,7 +181,7 @@ TEST_F(OptionTest, suboptions1) {
 //        +----opt3
 //        +----opt3
 //
 //
 TEST_F(OptionTest, suboptions2) {
 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++)
     for (int i=0; i<128; i++)
         buf[i] = 100+i;
         buf[i] = 100+i;
     Option* opt1 = new Option(Option::V6, 65535, //type
     Option* opt1 = new Option(Option::V6, 65535, //type
@@ -199,7 +199,7 @@ TEST_F(OptionTest, suboptions2) {
     // opt2 len = 4 (just header) + len(opt3)
     // opt2 len = 4 (just header) + len(opt3)
     // opt1 len = 7 + len(opt2)
     // opt1 len = 7 + len(opt2)
 
 
-    char expected[] = {
+    uint8_t expected[] = {
         0xff, 0xff, 0, 16, 100, 101, 102,
         0xff, 0xff, 0, 16, 100, 101, 102,
         0, 13, 0, 9,
         0, 13, 0, 9,
         0, 7, 0, 5, 103, 104, 105, 106, 107,
         0, 7, 0, 5, 103, 104, 105, 106, 107,
@@ -215,7 +215,7 @@ TEST_F(OptionTest, suboptions2) {
 }
 }
 
 
 TEST_F(OptionTest, addgetdel) {
 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++)
     for (int i=0; i<128; i++)
         buf[i] = 100+i;
         buf[i] = 100+i;
     Option* parent = new Option(Option::V6, 65535); //type
     Option* parent = new Option(Option::V6, 65535); //type