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/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
/// 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;
#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>
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;
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();
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
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;
#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;
}
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));
}
///
/// \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
///
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({
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
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
}
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) {
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 ) {
}
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) {
/// 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);
/// @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_);
}
-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)
}
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_) {
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;
}
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 ) {
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);
}
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) {
}
unsigned int
-Option::unpack4(boost::shared_array<char>,
+Option::unpack4(boost::shared_array<uint8_t>,
unsigned int ,
unsigned int ,
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 offset,
unsigned int parse_len) {
tmp << ":";
}
tmp << setfill('0') << setw(2) << hex
- << (unsigned short)(unsigned char)data_[offset_+i];
+ << (unsigned short)(unsigned uint8_t)data_[offset_+i];
}
// print suboptions
return type_;
}
-char*
+uint8_t*
Option::getData() {
if (data_len_) {
return (&data_[offset_]);
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);
// 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);
/// @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);
///
/// @return pointer to actual data (or NULL if there is no data)
///
- virtual char*
+ virtual uint8_t*
getData();
/// Adds a sub-option.
/// @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);
/// @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);
/// @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);
/// @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);
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
}
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)
}
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) {
}
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) {
/// @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);
/// @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
/// @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);
}
-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;
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");
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);
}
unsigned short Option6IA::len() {
-
+
unsigned short length = 4/*header*/ + 12 /* option content */; // header
// length of all suboptions
}
return (length);
}
-
// 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);
// 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
///
}
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)
}
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) {
}
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) {
}
// 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]);
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);
} // isc::dhcp namespace
} // isc namespace
-
+
#endif /* OPTION_IA_H_ */
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()
}
-Pkt6::Pkt6(unsigned char msg_type,
+Pkt6::Pkt6(uint8_t msg_type,
unsigned int transid,
DHCPv6Proto_ proto /*= UDP*/)
:local_addr_("::"),
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;
<< 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:"
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_,
*
* @return message type.
*/
-unsigned char
+uint8_t
Pkt6::getType() {
return (msg_type_);
}
/// 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_;
}
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
// 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;
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,
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,
};
- 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
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
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;
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
}
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;
// 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;
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
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
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);
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;
// 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
// 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;
// +----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
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
// +----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
// 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,
}
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