Commit 552aea12 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[master] Merge branch 'trac3736'

parents 43e2b383 cbdcd8c3
......@@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4macros ${ACLOCAL_FLAGS}
# ^^^^^^^^ This has to be the first line and cannot come later in this
# Makefile.am due to some bork in some versions of autotools.
SUBDIRS = compatcheck doc . ext src tests m4macros
SUBDIRS = compatcheck doc . ext src m4macros
USE_LCOV=@USE_LCOV@
LCOV=@LCOV@
GENHTML=@GENHTML@
......@@ -81,7 +81,6 @@ endif
if HAVE_OPENSSL
openssl/\* \
endif
tests/\* \
unittests/\* \
\*_unittests.cc \
\*_unittest.cc \
......
......@@ -1504,8 +1504,6 @@ AC_CONFIG_FILES([compatcheck/Makefile
src/lib/util/threads/tests/Makefile
src/lib/util/unittests/Makefile
tools/path_replacer.sh
tests/Makefile
tests/tools/Makefile
])
AC_CONFIG_COMMANDS([permissions], [
......
......@@ -1960,12 +1960,6 @@ Dhcpv4Srv::unpackOptions(const OptionBuffer& buf,
return (offset);
}
void
Dhcpv4Srv::ifaceMgrSocket4ErrorHandler(const std::string& errmsg) {
// Log the reason for socket opening failure and return.
LOG_WARN(dhcp4_logger, DHCP4_OPEN_SOCKET_FAIL).arg(errmsg);
}
void Dhcpv4Srv::classifyPacket(const Pkt4Ptr& pkt) {
boost::shared_ptr<OptionString> vendor_class =
boost::dynamic_pointer_cast<OptionString>(pkt->getOption(DHO_VENDOR_CLASS_IDENTIFIER));
......
......@@ -676,15 +676,6 @@ private:
/// @return Option that contains netmask information
static OptionPtr getNetmaskOption(const Subnet4Ptr& subnet);
/// @brief Implements the error handler for socket open failure.
///
/// This callback function is installed on the @c isc::dhcp::IfaceMgr
/// when IPv4 sockets are being open. When socket fails to open for
/// any reason, this function is called. It simply logs the error message.
///
/// @param errmsg An error message containing a cause of the failure.
static void ifaceMgrSocket4ErrorHandler(const std::string& errmsg);
/// @brief Allocation Engine.
/// Pointer to the allocation engine that we are currently using
/// It must be a pointer, because we will support changing engines
......
......@@ -199,26 +199,6 @@ protected:
return (parser);
}
/// @brief Determines if the given option space name and code describe
/// a standard option for the DHCP4 server.
///
/// @param option_space is the name of the option space to consider
/// @param code is the numeric option code to consider
/// @return returns true if the space and code are part of the server's
/// standard options.
bool isServerStdOption(std::string option_space, uint32_t code) {
return ((option_space.compare("dhcp4") == 0)
&& LibDHCP::isStandardOption(Option::V4, code));
}
/// @brief Returns the option definition for a given option code from
/// the DHCP4 server's standard set of options.
/// @param code is the numeric option code of the desired option definition.
/// @return returns a pointer the option definition
OptionDefinitionPtr getServerStdOptionDefinition (uint32_t code) {
return (LibDHCP::getOptionDef(Option::V4, code));
}
/// @brief Issues a DHCP4 server specific warning regarding duplicate subnet
/// options.
///
......
......@@ -73,9 +73,19 @@ TEST(Dhcp4SpecTest, basicSpec) {
}
class Dhcp4ParserTest : public ::testing::Test {
protected:
// Check that no hooks libraries are loaded. This is a pre-condition for
// a number of tests, so is checked in one place. As this uses an
// ASSERT call - and it is not clear from the documentation that Gtest
// predicates can be used in a constructor - the check is placed in SetUp.
virtual void SetUp() {
std::vector<std::string> libraries = HooksManager::getLibraryNames();
ASSERT_TRUE(libraries.empty());
}
public:
Dhcp4ParserTest()
:rcode_(-1) {
: rcode_(-1) {
// Open port 0 means to not do anything at all. We don't want to
// deal with sockets here, just check if configuration handling
// is sane.
......@@ -85,15 +95,7 @@ public:
resetConfiguration();
}
// Check that no hooks libraries are loaded. This is a pre-condition for
// a number of tests, so is checked in one place. As this uses an
// ASSERT call - and it is not clear from the documentation that Gtest
// predicates can be used in a constructor - the check is placed in SetUp.
void SetUp() {
std::vector<std::string> libraries = HooksManager::getLibraryNames();
ASSERT_TRUE(libraries.empty());
}
public:
// Checks if global parameter of name have expected_value
void checkGlobalUint32(string name, uint32_t expected_value) {
const Uint32StoragePtr uint32_defaults =
......
......@@ -1815,22 +1815,6 @@ public:
return buffer4_receive_callout(callout_handle);
}
/// Test callback that deletes MAC address
/// @param callout_handle handle passed by the hooks framework
/// @return always 0
static int
buffer4_receive_delete_hwaddr(CalloutHandle& callout_handle) {
Pkt4Ptr pkt;
callout_handle.getArgument("query4", pkt);
pkt->data_[2] = 0; // offset 2 is hlen, let's set it to zero
memset(&pkt->data_[28], 0, Pkt4::MAX_CHADDR_LEN); // Clear CHADDR content
// carry on as usual
return buffer4_receive_callout(callout_handle);
}
/// Test callback that sets skip flag
/// @param callout_handle handle passed by the hooks framework
/// @return always 0
......
......@@ -388,7 +388,9 @@ Dhcpv4SrvTest::createPacketFromBuffer(const Pkt4Ptr& src_pkt,
return (::testing::AssertionSuccess());
}
void Dhcpv4SrvTest::TearDown() {
void
// cppcheck-suppress unusedFunction
Dhcpv4SrvTest::TearDown() {
CfgMgr::instance().clear();
......
......@@ -291,37 +291,6 @@ public:
}
// Test that the client message holding an FQDN is processed and
// that the response packet is as expected.
void testProcessMessageWithFqdn(const uint8_t msg_type,
const std::string& hostname) {
Pkt4Ptr req = generatePktWithFqdn(msg_type, Option4ClientFqdn::FLAG_S |
Option4ClientFqdn::FLAG_E, hostname,
Option4ClientFqdn::FULL, true);
Pkt4Ptr reply;
if (msg_type == DHCPDISCOVER) {
ASSERT_NO_THROW(reply = srv_->processDiscover(req));
} else if (msg_type == DHCPREQUEST) {
ASSERT_NO_THROW(reply = srv_->processRequest(req));
} else if (msg_type == DHCPRELEASE) {
ASSERT_NO_THROW(srv_->processRelease(req));
return;
} else {
return;
}
if (msg_type == DHCPDISCOVER) {
checkResponse(reply, DHCPOFFER, 1234);
} else {
checkResponse(reply, DHCPACK, 1234);
}
}
// Verify that NameChangeRequest holds valid values.
void verifyNameChangeRequest(const isc::dhcp_ddns::NameChangeType type,
const bool reverse, const bool forward,
......
......@@ -2582,12 +2582,6 @@ Dhcpv6Srv::unpackOptions(const OptionBuffer& buf,
return (offset);
}
void
Dhcpv6Srv::ifaceMgrSocket6ErrorHandler(const std::string& errmsg) {
// Log the reason for socket opening failure and return.
LOG_WARN(dhcp6_logger, DHCP6_OPEN_SOCKET_FAIL).arg(errmsg);
}
void Dhcpv6Srv::classifyPacket(const Pkt6Ptr& pkt) {
OptionVendorClassPtr vclass = boost::dynamic_pointer_cast<
OptionVendorClass>(pkt->getOption(D6O_VENDOR_CLASS));
......
......@@ -616,15 +616,6 @@ protected:
private:
/// @brief Implements the error handler for socket open failure.
///
/// This callback function is installed on the @c isc::dhcp::IfaceMgr
/// when IPv6 sockets are being open. When socket fails to open for
/// any reason, this function is called. It simply logs the error message.
///
/// @param errmsg An error message containing a cause of the failure.
static void ifaceMgrSocket6ErrorHandler(const std::string& errmsg);
/// @brief Generate FQDN to be sent to a client if none exists.
///
/// This function is meant to be called by the functions which process
......
......@@ -408,27 +408,6 @@ protected:
return (parser);
}
/// @brief Determines if the given option space name and code describe
/// a standard option for the DHCP6 server.
///
/// @param option_space is the name of the option space to consider
/// @param code is the numeric option code to consider
/// @return returns true if the space and code are part of the server's
/// standard options.
bool isServerStdOption(std::string option_space, uint32_t code) {
return ((option_space.compare("dhcp6") == 0)
&& LibDHCP::isStandardOption(Option::V6, code));
}
/// @brief Returns the option definition for a given option code from
/// the DHCP6 server's standard set of options.
/// @param code is the numeric option code of the desired option definition.
/// @return returns a pointer the option definition
OptionDefinitionPtr getServerStdOptionDefinition (uint32_t code) {
return (LibDHCP::getOptionDef(Option::V6, code));
}
/// @brief Issues a DHCP6 server specific warning regarding duplicate subnet
/// options.
///
......
......@@ -71,6 +71,16 @@ TEST(Dhcp6SpecTest, basicSpec) {
}
class Dhcp6ParserTest : public ::testing::Test {
protected:
// Check that no hooks libraries are loaded. This is a pre-condition for
// a number of tests, so is checked in one place. As this uses an
// ASSERT call - and it is not clear from the documentation that Gtest
// predicates can be used in a constructor - the check is placed in SetUp.
virtual void SetUp() {
std::vector<std::string> libraries = HooksManager::getLibraryNames();
ASSERT_TRUE(libraries.empty());
}
public:
Dhcp6ParserTest() :rcode_(-1), srv_(0) {
// srv_(0) means to not open any sockets. We don't want to
......@@ -99,15 +109,6 @@ public:
resetConfiguration();
}
// Check that no hooks libraries are loaded. This is a pre-condition for
// a number of tests, so is checked in one place. As this uses an
// ASSERT call - and it is not clear from the documentation that Gtest
// predicates can be used in a constructor - the check is placed in SetUp.
void SetUp() {
std::vector<std::string> libraries = HooksManager::getLibraryNames();
ASSERT_TRUE(libraries.empty());
}
~Dhcp6ParserTest() {
// Reset configuration database after each test.
resetConfiguration();
......
......@@ -526,13 +526,12 @@ CommandOptions::initClientsNum() {
const std::string errmsg =
"value of -R <value> must be non-negative integer";
// Declare clients_num as as 64-bit signed value to
// be able to detect negative values provided
// by user. We would not detect negative values
// if we casted directly to unsigned value.
long long clients_num = 0;
try {
clients_num = boost::lexical_cast<long long>(optarg);
// Declare clients_num as as 64-bit signed value to
// be able to detect negative values provided
// by user. We would not detect negative values
// if we casted directly to unsigned value.
long long clients_num = boost::lexical_cast<long long>(optarg);
check(clients_num < 0, errmsg);
clients_num_ = boost::lexical_cast<uint32_t>(optarg);
} catch (boost::bad_lexical_cast&) {
......
......@@ -589,7 +589,7 @@ TestControl::getRequestedIpOffset() const {
}
uint64_t
TestControl::getRcvdPacketsNum(const ExchangeType xchg_type) const {
TestControl::getRcvdPacketsNum(ExchangeType xchg_type) const {
uint8_t ip_version = CommandOptions::instance().getIpVersion();
if (ip_version == 4) {
return (stats_mgr4_->getRcvdPacketsNum(xchg_type));
......@@ -599,7 +599,7 @@ TestControl::getRcvdPacketsNum(const ExchangeType xchg_type) const {
}
uint64_t
TestControl::getSentPacketsNum(const ExchangeType xchg_type) const {
TestControl::getSentPacketsNum(ExchangeType xchg_type) const {
uint8_t ip_version = CommandOptions::instance().getIpVersion();
if (ip_version == 4) {
return (stats_mgr4_->getSentPacketsNum(xchg_type));
......
......@@ -989,18 +989,30 @@ protected:
/// Get the number of received packets from the Statistics Manager.
/// Function may throw if Statistics Manager object is not
/// initialized.
///
/// \note The method parameter is non-const to suppress the cppcheck
/// warning about the object being passed by value. However, passing
/// an enum by reference doesn't make much sense. At the same time,
/// removing the constness should be pretty safe for this function.
///
/// \param xchg_type packet exchange type.
/// \return number of received packets.
uint64_t getRcvdPacketsNum(const ExchangeType xchg_type) const;
uint64_t getRcvdPacketsNum(ExchangeType xchg_type) const;
/// \brief Get number of sent packets.
///
/// Get the number of sent packets from the Statistics Manager.
/// Function may throw if Statistics Manager object is not
/// initialized.
///
/// \note The method parameter is non-const to suppress the cppcheck
/// warning about the object being passed by value. However, passing
/// an enum by reference doesn't make much sense. At the same time,
/// removing the constness should be pretty safe for this function.
///
/// \param xchg_type packet exchange type.
/// \return number of sent packets.
uint64_t getSentPacketsNum(const ExchangeType xchg_type) const;
uint64_t getSentPacketsNum(ExchangeType xchg_type) const;
/// \brief Handle child signal.
///
......
// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2009,2015 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -75,11 +75,11 @@ public:
io_service_(io_service),
ep_(file),
acceptor_(io_service_, ep_),
socket_(io_service_)
socket_(io_service_),
data_buf_(1024)
{
acceptor_.async_accept(socket_,
boost::bind(&TestDomainSocket::acceptHandler,
this, _1));
acceptor_.async_accept(socket_, boost::bind(&TestDomainSocket::acceptHandler,
_1));
}
~TestDomainSocket() {
......@@ -87,7 +87,7 @@ public:
unlink(BUNDY_TEST_SOCKET_FILE);
}
void acceptHandler(const asio::error_code&) const {
static void acceptHandler(const asio::error_code&) {
}
void sendmsg(isc::data::ElementPtr& env, isc::data::ElementPtr& msg) {
......@@ -116,7 +116,7 @@ public:
void setSendLname() {
// ignore whatever data we get, send back an lname
asio::async_read(socket_, asio::buffer(data_buf, 0),
asio::async_read(socket_, asio::buffer(&data_buf_[0], 0),
boost::bind(&TestDomainSocket::sendLname, this));
}
......@@ -125,7 +125,7 @@ private:
asio::local::stream_protocol::endpoint ep_;
asio::local::stream_protocol::acceptor acceptor_;
asio::local::stream_protocol::socket socket_;
char data_buf[1024];
std::vector<char> data_buf_;
};
/// \brief Pair holding header and data of a message sent over the connection.
......
......@@ -1132,23 +1132,6 @@ protected:
/// Control-buffer, used in transmission and reception.
boost::scoped_array<char> control_buf_;
/// @brief A wrapper for OS-specific operations before sending IPv4 packet
///
/// @param m message header (will be later used for sendmsg() call)
/// @param control_buf buffer to be used during transmission
/// @param control_buf_len buffer length
/// @param pkt packet to be sent
void os_send4(struct msghdr& m, boost::scoped_array<char>& control_buf,
size_t control_buf_len, const Pkt4Ptr& pkt);
/// @brief OS-specific operations during IPv4 packet reception
///
/// @param m message header (was used during recvmsg() call)
/// @param pkt packet received (some fields will be set here)
///
/// @return true if successful, false otherwise
bool os_receive4(struct msghdr& m, Pkt4Ptr& pkt);
private:
/// @brief Identifies local network address to be used to
/// connect to remote address.
......
......@@ -129,21 +129,6 @@ void Iface::setFlags(uint64_t flags) {
flag_broadcast_ = flags & IFF_BROADCAST;
}
void IfaceMgr::os_send4(struct msghdr& /*m*/,
boost::scoped_array<char>& /*control_buf*/,
size_t /*control_buf_len*/,
const Pkt4Ptr& /*pkt*/) {
// @todo: Are there any specific actions required before sending IPv4 packet
// on BSDs? See iface_mgr_linux.cc for working Linux implementation.
}
bool IfaceMgr::os_receive4(struct msghdr& /*m*/, Pkt4Ptr& /*pkt*/) {
// @todo: Are there any specific actions required before receiving IPv4 packet
// on BSDs? See iface_mgr_linux.cc for working Linux implementation.
return (true); // pretend that we have everything set up for reception.
}
void
IfaceMgr::setMatchingPacketFilter(const bool direct_response_desired) {
// If direct response is desired we have to use BPF. If the direct
......
......@@ -524,16 +524,6 @@ IfaceMgr::setMatchingPacketFilter(const bool direct_response_desired) {
}
}
void IfaceMgr::os_send4(struct msghdr&, boost::scoped_array<char>&,
size_t, const Pkt4Ptr&) {
return;
}
bool IfaceMgr::os_receive4(struct msghdr&, Pkt4Ptr&) {
return (true);
}
bool
IfaceMgr::openMulticastSocket(Iface& iface,
const isc::asiolink::IOAddress& addr,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment