mysql -N -B "$@" -e "${QUERY}"
retcode=$?
else
- mysql -N -B --database=${db_name} --user=${db_user} --password=${db_password} -e "${QUERY}"
- retcode="$?"
+ mysql -N -B --database="${db_name}" --user="${db_user}" --password="${db_password}" -e "${QUERY}"
+ retcode=$?
+ fi
+
+ return $retcode
+}
+
+mysql_execute_script() {
+ file=$1
+ shift
+ if [ $# -ge 1 ]; then
+ mysql -N -B "$@" < "${file}"
+ retcode=$?
+ else
+ mysql -N -B --database="${db_name}" --user="${db_user}" --password="${db_password}" < "${file}"
+ retcode=$?
fi
return $retcode
QUERY=$1
shift
if [ $# -gt 0 ]; then
- echo "${QUERY}" | psql --set ON_ERROR_STOP=1 -A -t -h localhost -q "#@"
+ echo "${QUERY}" | psql --set ON_ERROR_STOP=1 -A -t -h localhost -q "$@"
retcode=$?
else
export PGPASSWORD=$db_password
using namespace isc::util;
namespace {
-
-// @brief Test fixture class for testing D2UpdateMessage object.
+ /// @brief Test fixture class for testing D2UpdateMessage object.
class D2UpdateMessageTest : public ::testing::Test {
public:
- // @brief Constructor.
+ /// @brief Constructor.
//
// Does nothing.
D2UpdateMessageTest() { }
- // @brief Destructor.
+ /// @brief Destructor.
//
// Does nothing.
~D2UpdateMessageTest() { };
- // @brief Return string representation of the name encoded in wire format.
+ /// @brief Return string representation of the name encoded in wire format.
//
// This function reads the number of bytes specified in the second
// argument from the buffer. It doesn't check if buffer has sufficient
};
// The 'true' argument passed to the constructor turns the
// message into the parse mode in which the fromWire function
- // can be used to decode the binary mesasage data.
+ // can be used to decode the binary message data.
D2UpdateMessage msg(D2UpdateMessage::INBOUND);
// When using invalid Opcode, the fromWire function should
// throw NotUpdateMessage exception.
};
// The 'true' argument passed to the constructor turns the
// message into the parse mode in which the fromWire function
- // can be used to decode the binary mesasage data.
+ // can be used to decode the binary message data.
D2UpdateMessage msg(D2UpdateMessage::INBOUND);
// When using invalid QR flag, the fromWire function should
// throw InvalidQRFlag exception.
// The 'true' argument passed to the constructor turns the
// message into the parse mode in which the fromWire function
- // can be used to decode the binary mesasage data.
+ // can be used to decode the binary message data.
D2UpdateMessage msg(D2UpdateMessage::INBOUND);
// When parsing a message with more than one Zone record,
// exception should be thrown.
// one Zone. toWire function would fail if Zone is not set.
msg.setZone(Name("example.com"), RRClass::IN());
- // Set prerequisities.
+ // Set prerequisites.
// 'Name Is Not In Use' prerequisite (RFC 2136, section 2.4.5)
RRsetPtr prereq1(new RRset(Name("foo.example.com"), RRClass::NONE(),
EXPECT_EQ(1, buf.readUint16());
// PRCOUNT - holds the number of prerequisites. Earlier we have added
- // two prerequisites. Thus, expect that this conter is 2.
+ // two prerequisites. Thus, expect that this counter is 2.
EXPECT_EQ(2, buf.readUint16());
// UPCOUNT - holds the number of RRs in the Update Section. We have
// Check the name first. Message renderer is using compression for domain
// names as described in RFC 1035, section 4.1.4. The name in this RR is
- // foo.example.com. The name of the zone is example.com and it has occured
+ // foo.example.com. The name of the zone is example.com and it has occurred
// in this message already at offset 12 (the size of the header is 12).
// Therefore, name of this RR is encoded as 'foo', followed by a pointer
// to offset in this message where the remainder of this name was used.
// The 'true' argument passed to the constructor turns the
// message into the parse mode in which the fromWire function
- // can be used to decode the binary mesasage data.
+ // can be used to decode the binary message data.
D2UpdateMessage msg(D2UpdateMessage::INBOUND);
ASSERT_NO_THROW(msg.fromWire(bin_msg, sizeof(bin_msg)));
const uint16_t TEST_PORT = 5301;
const size_t MAX_SIZE = 1024;
const long TEST_TIMEOUT = 5 * 1000;
-
-// @brief Test Fixture class.
+/// @brief Test Fixture class.
//
// This test fixture class implements DNSClient::Callback so as it can be
// installed as a completion callback for tests it implements. This callback
int received_;
int expected_;
- // @brief Constructor.
+ /// @brief Constructor.
//
// This constructor overrides the default logging level of asiodns logger to
// prevent it from emitting debug messages from IOFetch class. Such an error
TEST_TIMEOUT);
}
- // @brief Destructor.
+ /// @brief Destructor.
//
// Sets the asiodns logging level back to DEBUG.
virtual ~DNSClientTest() {
asiodns::logger.setSeverity(isc::log::DEBUG);
};
- // @brief Exchange completion callback.
+ /// @brief Exchange completion callback.
//
// This callback is called when the exchange with the DNS server is
// complete or an error occurred. This includes the occurrence of a timeout.
}
}
- // @brief Handler invoked when test timeout is hit.
+ /// @brief Handler invoked when test timeout is hit.
//
// This callback stops all running (hanging) tasks on IO service.
void testTimeoutHandler() {
FAIL() << "Test timeout hit.";
}
- // @brief Handler invoked when test request is received.
+ /// @brief Handler invoked when test request is received.
//
// This callback handler is installed when performing async read on a
// socket to emulate reception of the DNS Update request by a server.
*remote);
}
- // @brief Request handler for testing clients using TSIG
+ /// @brief Request handler for testing clients using TSIG
//
// This callback handler is installed when performing async read on a
// socket to emulate reception of the DNS Update request with TSIG by a
dns::Message request(Message::PARSE);
request.fromWire(received_data_buffer);
- // If contex is not NULL, then we need to verify the message.
+ // If context is not NULL, then we need to verify the message.
if (context) {
TSIGError error = context->verify(request.getTSIGRecord(),
receive_buffer_, receive_length);
// Neither client nor server will attempt to sign or verify.
runTSIGTest(nokey, nokey);
- // Client signs the request, server verfies but doesn't sign.
+ // Client signs the request, server verifies but doesn't sign.
runTSIGTest(key_one, nokey, false);
// Client and server use the same key to sign and verify.
% DHCP4_DHCP4O6_BAD_PACKET received malformed DHCPv4o6 packet: %1
A malformed DHCPv4o6 packet was received.
+% DHCP4_DHCP4O6_PACKET_RECEIVED received DHCPv4o6 packet from DHCPv4 server (type %1) for %2 on interface %3
+This debug message is printed when the server is receiving a DHCPv4o6
+from the DHCPv4 server over inter-process communication.
+
% DHCP4_DHCP4O6_PACKET_SEND %1: trying to send packet %2 (type %3) to %4 on interface %5 encapsulating %6: %7 (type %8)
The arguments specify the client identification information (HW address
and client identifier), DHCPv6 message name and type, source IPv6
% DHCP4_DHCP4O6_RECEIVING receiving DHCPv4o6 packet from DHCPv6 server
This debug message is printed when the server is receiving a DHCPv4o6
-from the DHCPv6 server over inter-process communication socket.
+from the DHCPv4 server over inter-process communication socket.
% DHCP4_DHCP4O6_RESPONSE_DATA %1: responding with packet %2 (type %3), packet details: %4
A debug message including the detailed data about the packet being
and will send DHCPNAK if the received message was DHCPREQUEST.
The argument includes the client and the transaction identification
information.
-
-% DHCP6_DHCP4O6_PACKET_RECEIVED received DHCPv4o6 packet from DHCPv6 server (type %1) for %2 on interface %3
-This debug message is printed when the server is receiving a DHCPv4o6
-from the DHCPv6 server over inter-process communication.
/// @brief returns Kea version on stdout and exit.
/// redeclaration/redefinition. @ref Daemon::getVersion()
static std::string getVersion(bool extended);
-
+
/// @brief Main server processing loop.
///
/// Main server processing loop. Call the processing step routine
// from Dhcpv4Srv::run_one() after receivePacket()
if (pkt) {
- LOG_DEBUG(packet4_logger, DBG_DHCP4_BASIC, DHCP6_DHCP4O6_PACKET_RECEIVED)
+ LOG_DEBUG(packet4_logger, DBG_DHCP4_BASIC, DHCP4_DHCP4O6_PACKET_RECEIVED)
.arg(static_cast<int>(pkt->getType()))
.arg(pkt->getRemoteAddr().toText())
.arg(pkt->getIface());
return;
}
- // Get the DHCPv4 message
+ // Get the DHCPv4 message
OptionPtr msg = msgs.begin()->second;
if (!msg) {
LOG_DEBUG(packet4_logger, DBG_DHCP4_DETAIL, DHCP4_DHCP4O6_BAD_PACKET)
}
}
- // @brief Commits the constructed local pool to the pool storage.
+ /// @brief Commits the constructed local pool to the pool storage.
virtual void commit() {
// Add the local pool to the external storage ptr.
pools_->push_back(pool_);
/// \brief Creates an address from over wire data.
///
- /// \param family AF_NET for IPv4 or AF_NET6 for IPv6.
+ /// \param family AF_INET for IPv4 or AF_INET6 for IPv6.
/// \param data pointer to first char of data
///
/// \return Created IOAddress object
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#include <gtest/gtest.h>
+
#include <log/logger_support.h>
#include <util/unittests/run_all.h>
-#include <gtest/gtest.h>
-
int
main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
#include <config.h>
#include <asiolink/io_address.h>
-#include <exceptions/exceptions.h>
#include <dhcp/dhcp6.h>
#include <dhcp/option6_pdexclude.h>
#include <exceptions/exceptions.h>
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
+
#include <dhcp/dhcp4.h>
#include <dhcp/dhcp6.h>
#include <dhcp/option4_addrlst.h>
namespace isc {
namespace dhcp {
-
OptionDefinition::OptionDefinition(const std::string& name,
const uint16_t code,
const std::string& type,
<< " is not valid.");
}
-
// Write a prefix.
OptionDataTypeUtil::writePrefix(PrefixLen(len), address, buf);
/// it around for the future.
class OptionDefinitionTest : public ::testing::Test {
public:
- // @brief Constructor.
+ /// @brief Constructor.
OptionDefinitionTest() { }
};
result_ = result;
received_ncr_ = ncr;
}
- // @brief Handler invoked when test timeout is hit.
- //
- // This callback stops all running (hanging) tasks on IO service.
+
+ /// @brief Handler invoked when test timeout is hit.
+ ///
+ /// This callback stops all running (hanging) tasks on IO service.
void testTimeoutHandler() {
io_service_.stop();
FAIL() << "Test timeout hit.";
sent_ncrs_.push_back(ncr);
}
- // @brief Handler invoked when test timeout is hit.
- //
- // This callback stops all running (hanging) tasks on IO service.
+ /// @brief Handler invoked when test timeout is hit.
+ ///
+ /// This callback stops all running (hanging) tasks on IO service.
void testTimeoutHandler() {
io_service_.stop();
FAIL() << "Test timeout hit.";
/// @brief Number of consecutive DHCPv6 leases' reclamations after
/// which there are still expired leases in the database.
uint16_t incomplete_v6_reclamations_;
-
};
/// @brief A pointer to the @c AllocEngine object.
typedef boost::shared_ptr<AllocEngine> AllocEnginePtr;
-}; // namespace isc::dhcp
-}; // namespace isc
+} // namespace dhcp
+} // namespace isc
#endif // ALLOC_ENGINE_H
#ifndef BASE_HOST_DATA_SOURCE_H
#define BASE_HOST_DATA_SOURCE_H
-#include <asiolink/io_address.h>
#include <dhcp/duid.h>
#include <dhcp/hwaddr.h>
#include <dhcpsrv/host.h>
+
+#include <asiolink/io_address.h>
#include <exceptions/exceptions.h>
+#include <stdint.h>
+
#include <boost/shared_ptr.hpp>
namespace isc {
/// @brief Specifies the type of an identifier.
///
/// This is currently used only by MySQL host data source for now, but
- /// it is envisagad that it will be used by other host data sources
+ /// it is envisaged that it will be used by other host data sources
/// in the future. Also, this list will grow over time. It is likely
/// that we'll implement other identifiers in the future, e.g. remote-id.
///
/// @param duid client id or NULL if not available, e.g. DHCPv4 client case.
///
/// @return Collection of const @c Host objects.
- virtual ConstHostCollection
- getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid = DuidPtr()) const = 0;
+ virtual ConstHostCollection getAll(const HWAddrPtr& hwaddr,
+ const DuidPtr& duid = DuidPtr()) const = 0;
/// @brief Return all hosts connected to any subnet for which reservations
/// have been made using a specified identifier.
/// because a particular client may have reservations in multiple subnets.
///
/// @param identifier_type Identifier type.
- /// @param identifier_begin Pointer to a begining of a buffer containing
+ /// @param identifier_begin Pointer to a beginning of a buffer containing
/// an identifier.
/// @param identifier_len Identifier length.
///
/// @return Collection of const @c Host objects.
- virtual ConstHostCollection
- getAll(const Host::IdentifierType& identifier_type,
- const uint8_t* identifier_begin,
- const size_t identifier_len) const = 0;
+ virtual ConstHostCollection getAll(const Host::IdentifierType& identifier_type,
+ const uint8_t* identifier_begin,
+ const size_t identifier_len) const = 0;
/// @brief Returns a collection of hosts using the specified IPv4 address.
///
/// @param address IPv4 address for which the @c Host object is searched.
///
/// @return Collection of const @c Host objects.
- virtual ConstHostCollection
- getAll4(const asiolink::IOAddress& address) const = 0;
+ virtual ConstHostCollection getAll4(const asiolink::IOAddress& address) const = 0;
/// @brief Returns a host connected to the IPv4 subnet.
///
/// Implementations of this method should guard against the case when
- /// mutliple instances of the @c Host are present, e.g. when two
+ /// multiple instances of the @c Host are present, e.g. when two
/// @c Host objects are found, one for the DUID, another one for the
/// HW address. In such case, an implementation of this method
/// should throw an exception.
/// @param duid client id or NULL if not available.
///
/// @return Const @c Host object using a specified HW address or DUID.
- virtual ConstHostPtr
- get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
- const DuidPtr& duid = DuidPtr()) const = 0;
+ virtual ConstHostPtr get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
+ const DuidPtr& duid = DuidPtr()) const = 0;
/// @brief Returns a host connected to the IPv4 subnet.
///
/// @param subnet_id Subnet identifier.
/// @param identifier_type Identifier type.
- /// @param identifier_begin Pointer to a begining of a buffer containing
+ /// @param identifier_begin Pointer to a beginning of a buffer containing
/// an identifier.
/// @param identifier_len Identifier length.
///
/// @return Const @c Host object for which reservation has been made using
/// the specified identifier.
- virtual ConstHostPtr
- get4(const SubnetID& subnet_id,
- const Host::IdentifierType& identifier_type,
- const uint8_t* identifier_begin,
- const size_t identifier_len) const = 0;
+ virtual ConstHostPtr get4(const SubnetID& subnet_id,
+ const Host::IdentifierType& identifier_type,
+ const uint8_t* identifier_begin,
+ const size_t identifier_len) const = 0;
/// @brief Returns a host connected to the IPv4 subnet and having
/// a reservation for a specified IPv4 address.
/// @param address reserved IPv4 address.
///
/// @return Const @c Host object using a specified IPv4 address.
- virtual ConstHostPtr
- get4(const SubnetID& subnet_id,
- const asiolink::IOAddress& address) const = 0;
+ virtual ConstHostPtr get4(const SubnetID& subnet_id,
+ const asiolink::IOAddress& address) const = 0;
/// @brief Returns a host connected to the IPv6 subnet.
///
/// Implementations of this method should guard against the case when
- /// mutliple instances of the @c Host are present, e.g. when two
+ /// multiple instances of the @c Host are present, e.g. when two
/// @c Host objects are found, one for the DUID, another one for the
/// HW address. In such case, an implementation of this method
/// should throw an exception.
/// @param duid DUID or NULL if not available.
///
/// @return Const @c Host object using a specified HW address or DUID.
- virtual ConstHostPtr
- get6(const SubnetID& subnet_id, const DuidPtr& duid,
- const HWAddrPtr& hwaddr = HWAddrPtr()) const = 0;
+ virtual ConstHostPtr get6(const SubnetID& subnet_id,
+ const DuidPtr& duid,
+ const HWAddrPtr& hwaddr = HWAddrPtr()) const = 0;
/// @brief Returns a host connected to the IPv6 subnet.
///
/// @param subnet_id Subnet identifier.
/// @param identifier_type Identifier type.
- /// @param identifier_begin Pointer to a begining of a buffer containing
+ /// @param identifier_begin Pointer to a beginning of a buffer containing
/// an identifier.
/// @param identifier_len Identifier length.
///
/// @return Const @c Host object for which reservation has been made using
/// the specified identifier.
- virtual ConstHostPtr
- get6(const SubnetID& subnet_id,
- const Host::IdentifierType& identifier_type,
- const uint8_t* identifier_begin,
- const size_t identifier_len) const = 0;
+ virtual ConstHostPtr get6(const SubnetID& subnet_id,
+ const Host::IdentifierType& identifier_type,
+ const uint8_t* identifier_begin,
+ const size_t identifier_len) const = 0;
/// @brief Returns a host using the specified IPv6 prefix.
///
/// @param prefix_len IPv6 prefix length.
///
/// @return Const @c Host object using a specified HW address or DUID.
- virtual ConstHostPtr
- get6(const asiolink::IOAddress& prefix, const uint8_t prefix_len) const = 0;
+ virtual ConstHostPtr get6(const asiolink::IOAddress& prefix,
+ const uint8_t prefix_len) const = 0;
/// @brief Returns a host connected to the IPv6 subnet and having
/// a reservation for a specified IPv6 address or prefix.
/// @brief HostDataSource pointer
typedef boost::shared_ptr<BaseHostDataSource> HostDataSourcePtr;
-}
-}
+} // namespace dhcp
+} // namespace isc
#endif // BASE_HOST_DATA_SOURCE_H
option_vendor.reset();
}
}
-
+
// Vendor option must exist.
if (!option_vendor) {
LOG_WARN(dhcpsrv_logger, DHCPSRV_DHCP4O6_RECEIVED_BAD_PACKET)
static boost::scoped_ptr<HostMgr>& getHostMgrPtr();
};
-}
-}
+
+} // namespace dhcp
+} // namespace isc
#endif // HOST_MGR_H
Subnet::HRMode
SubnetConfigParser::hrModeFromText(const std::string& txt) {
- if ( (txt.compare("disabled") == 0) ||
- (txt.compare("off") == 0) ) {
+ if ( (txt.compare("disabled") == 0) || (txt.compare("off") == 0) ) {
return (Subnet::HR_DISABLED);
} else if (txt.compare("out-of-pool") == 0) {
return (Subnet::HR_OUT_OF_POOL);
// statement.
const size_t PGSQL_MAX_PARAMETERS_IN_QUERY = 32;
-/// @brief Defines a Postgresql SQL statement
+/// @brief Define a PostgreSQL statement
///
/// Each statement is associated with an index, which is used to reference the
/// associated prepared statement.
const char* text;
};
+/// @{
/// @brief Constants for PostgreSQL data types
-/// This are defined by PostreSQL in <catalog/pg_type.h>, but including
+/// This are defined by PostgreSQL in <catalog/pg_type.h>, but including
/// this file is extraordinarily convoluted, so we'll use these to fill-in.
const size_t OID_NONE = 0; // PostgreSQL infers proper type
const size_t OID_BOOL = 16;
const size_t OID_TEXT = 25;
const size_t OID_VARCHAR = 1043;
const size_t OID_TIMESTAMP = 1114;
-
-//@}
+/// @}
/// @brief RAII wrapper for Posgtresql Result sets
///
/// that use instances of PgSqlConnection.
class PgSqlConnection : public DatabaseConnection {
public:
- /// @brief Defines the PgSql error state for a duplicate key error
+ /// @brief Define the PgSql error state for a duplicate key error.
static const char DUPLICATE_KEY[];
/// @brief Constructor
///
/// @param client_classes list of all classes the client belongs to
/// @return true if client can be supported, false otherwise
- bool
- clientSupported(const isc::dhcp::ClientClasses& client_classes) const;
+ bool clientSupported(const isc::dhcp::ClientClasses& client_classes) const;
/// @brief adds class class_name to the list of supported classes
///
/// Also see explanation note in @ref white_list_.
///
/// @param class_name client class to be supported by this subnet
- void
- allowClientClass(const isc::dhcp::ClientClass& class_name);
+ void allowClientClass(const isc::dhcp::ClientClass& class_name);
/// @brief Specifies what type of Host Reservations are supported.
///
/// performance reasons.
///
/// @return whether in-pool host reservations are allowed.
- HRMode
- getHostReservationMode() const {
+ HRMode getHostReservationMode() const {
return (host_reservation_mode_);
}
///
/// See @ref HRMode type for details.
HRMode host_reservation_mode_;
-private:
+private:
/// @brief Pointer to the option data configuration for this subnet.
CfgOptionPtr cfg_option_;
};
/// @brief Test lease retrieval using client id, HW address and subnet id.
void testGetLease4ClientIdHWAddrSubnetId();
- // @brief Get lease4 by hardware address (2)
- //
- // Check that the system can cope with getting a hardware address of
- // any size.
+ /// @brief Get lease4 by hardware address (2)
+ ///
+ /// Check that the system can cope with getting a hardware address of
+ /// any size.
void testGetLease4HWAddrSize();
/// @brief Check GetLease4 methods - access by Hardware Address & Subnet ID
LeaseMgr* lmptr_;
};
-}; // namespace test
-}; // namespace dhcp
-}; // namespace isc
+} // namespace test
+} // namespace dhcp
+} // namespace isc
#endif
return (option_universe_);
}
- private:
+private:
/// @brief Flag determining scanner debugging.
bool trace_scanning_;
return ("");
}
- // @brief Destructor
+ /// @brief Destructor
virtual ~DStubProcess();
};
/// @}
- private:
+private:
/// @brief Private constructor.
/// StatsMgr is a singleton. It should be accessed using @ref instance