-// Copyright (C) 2013-2024 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2025 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// this is unexpected so we will treat it as a receive error.
// This is most likely an unforeseen programmatic issue.
LOG_ERROR(dhcp_to_d2_logger, DHCP_DDNS_QUEUE_MGR_UNEXPECTED_STOP)
- .arg(mgr_state_);
+ .arg(D2QueueMgr::stateToText(mgr_state_));
stopListening(STOPPED_RECV_ERROR);
}
/// @file d2_queue_mgr.h This file defines the class D2QueueMgr.
#include <asiolink/io_service.h>
-#include <exceptions/exceptions.h>
-#include <dhcp_ddns/ncr_msg.h>
#include <dhcp_ddns/ncr_io.h>
+#include <dhcp_ddns/ncr_msg.h>
+#include <exceptions/exceptions.h>
-#include <boost/noncopyable.hpp>
#include <deque>
+#include <boost/noncopyable.hpp>
+
namespace isc {
namespace d2 {
STOPPED = 6,
};
+ /// @brief Convert enum to string.
+ ///
+ /// @param state input enum
+ ///
+ /// @return reference to static string
+ static std::string const& stateToText(State const& state) {
+ static std::vector<std::string> const text_vector {
+ "NOT_INITTED",
+ "INITTED",
+ "RUNNING",
+ "STOPPING",
+ "STOPPED_QUEUE_FULL",
+ "STOPPED_RECV_ERROR",
+ "STOPPED",
+ };
+ static std::string const unknown("UNKNOWN");
+ return (state < text_vector.size() ? text_vector[state] : unknown);
+ }
+
/// @brief Constructor
///
/// Creates a D2QueueMgr instance. Note that the listener is not created
}
void
-Dhcpv4Srv::d2ClientErrorHandler(const
- dhcp_ddns::NameChangeSender::Result result,
+Dhcpv4Srv::d2ClientErrorHandler(const dhcp_ddns::NameChangeSender::Result result,
dhcp_ddns::NameChangeRequestPtr& ncr) {
- LOG_ERROR(ddns4_logger, DHCP4_DDNS_REQUEST_SEND_FAILED).
- arg(result).arg((ncr ? ncr->toText() : " NULL "));
+ LOG_ERROR(ddns4_logger, DHCP4_DDNS_REQUEST_SEND_FAILED)
+ .arg(NameChangeSender::resultToText(result))
+ .arg((ncr ? ncr->toText() : " NULL "));
// We cannot communicate with kea-dhcp-ddns, suspend further updates.
/// @todo We may wish to revisit this, but for now we will simply turn
/// them off.
}
void
-Dhcpv6Srv::d2ClientErrorHandler(const
- dhcp_ddns::NameChangeSender::Result result,
+Dhcpv6Srv::d2ClientErrorHandler(const dhcp_ddns::NameChangeSender::Result result,
dhcp_ddns::NameChangeRequestPtr& ncr) {
- LOG_ERROR(ddns6_logger, DHCP6_DDNS_REQUEST_SEND_FAILED).
- arg(result).arg((ncr ? ncr->toText() : " NULL "));
+ LOG_ERROR(ddns6_logger, DHCP6_DDNS_REQUEST_SEND_FAILED)
+ .arg(NameChangeSender::resultToText(result))
+ .arg((ncr ? ncr->toText() : " NULL "));
// We cannot communicate with kea-dhcp-ddns, suspend further updates.
/// @todo We may wish to revisit this, but for now we will simply turn
/// them off.
default:
LOG_ERROR(gss_tsig_logger, TKEY_EXCHANGE_FAIL_IO_ERROR)
- .arg(result);
+ .arg(IOFetch::resultToText(result));
incrStats("tkey-error");
callCallback(TKeyExchange::OTHER);
return;
MySqlLeaseMgr::addLease(const Lease6Ptr& lease) {
LOG_DEBUG(mysql_lb_logger, MYSQL_LB_DBG_TRACE_DETAIL, MYSQL_LB_ADD_ADDR6)
.arg(lease->addr_.toText())
- .arg(lease->type_);
+ .arg(Lease::typeToText(lease->type_));
lease->extended_info_action_ = Lease6::ACTION_IGNORE;
const IOAddress& addr) const {
LOG_DEBUG(mysql_lb_logger, MYSQL_LB_DBG_TRACE_DETAIL, MYSQL_LB_GET_ADDR6)
.arg(addr.toText())
- .arg(lease_type);
+ .arg(Lease::typeToText(lease_type));
// Set up the WHERE clause value
MYSQL_BIND inbind[2];
LOG_DEBUG(mysql_lb_logger, MYSQL_LB_DBG_TRACE_DETAIL, MYSQL_LB_GET_IAID_DUID)
.arg(iaid)
.arg(duid.toText())
- .arg(lease_type);
+ .arg(Lease::typeToText(lease_type));
// Set up the WHERE clause value
MYSQL_BIND inbind[3];
.arg(iaid)
.arg(subnet_id)
.arg(duid.toText())
- .arg(lease_type);
+ .arg(Lease::typeToText(lease_type));
// Set up the WHERE clause value
MYSQL_BIND inbind[4];
LOG_DEBUG(mysql_lb_logger, MYSQL_LB_DBG_TRACE_DETAIL, MYSQL_LB_UPDATE_ADDR6)
.arg(lease->addr_.toText())
- .arg(lease->type_);
+ .arg(Lease::typeToText(lease->type_));
// Get the recorded action and reset it.
Lease6::ExtendedInfoAction recorded_action = lease->extended_info_action_;
PgSqlLeaseMgr::addLease(const Lease6Ptr& lease) {
LOG_DEBUG(pgsql_lb_logger, PGSQL_LB_DBG_TRACE_DETAIL, PGSQL_LB_ADD_ADDR6)
.arg(lease->addr_.toText())
- .arg(lease->type_);
+ .arg(Lease::typeToText(lease->type_));
lease->extended_info_action_ = Lease6::ACTION_IGNORE;
const IOAddress& addr) const {
LOG_DEBUG(pgsql_lb_logger, PGSQL_LB_DBG_TRACE_DETAIL, PGSQL_LB_GET_ADDR6)
.arg(addr.toText())
- .arg(lease_type);
+ .arg(Lease::typeToText(lease_type));
// Set up the WHERE clause value
PsqlBindArray bind_array;
LOG_DEBUG(pgsql_lb_logger, PGSQL_LB_DBG_TRACE_DETAIL, PGSQL_LB_GET_IAID_DUID)
.arg(iaid)
.arg(duid.toText())
- .arg(lease_type);
+ .arg(Lease::typeToText(lease_type));
// Set up the WHERE clause value
PsqlBindArray bind_array;
.arg(iaid)
.arg(subnet_id)
.arg(duid.toText())
- .arg(lease_type);
+ .arg(Lease::typeToText(lease_type));
// Set up the WHERE clause value
PsqlBindArray bind_array;
LOG_DEBUG(pgsql_lb_logger, PGSQL_LB_DBG_TRACE_DETAIL, PGSQL_LB_UPDATE_ADDR6)
.arg(lease->addr_.toText())
- .arg(lease->type_);
+ .arg(Lease::typeToText(lease->type_));
// Get the recorded action and reset it.
Lease6::ExtendedInfoAction recorded_action = lease->extended_info_action_;
#include <boost/asio/coroutine.hpp>
#include <boost/asio/deadline_timer.hpp>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/shared_array.hpp>
#include <boost/shared_ptr.hpp>
-#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/system/error_code.hpp>
namespace isc {
SUCCESS = 0, // Success, fetch completed
TIME_OUT = 1, // Failure, fetch timed out
STOPPED = 2, // Control code, fetch has been stopped
- NOTSET = 3 // For testing, indicates value not set
+ NOTSET = 3, // For testing, indicates value not set
};
+ /// @brief Convert enum to string.
+ ///
+ /// @param result input enum
+ ///
+ /// @return reference to static string
+ static std::string const& resultToText(Result const& result) {
+ static std::vector<std::string> const text_vector {
+ "SUCCESS",
+ "TIME_OUT",
+ "STOPPED",
+ "NOTSET",
+ };
+ static std::string const unknown("UNKNOWN");
+ return (result < text_vector.size() ? text_vector[result] : unknown);
+ }
+
/// @note The next enum is a "trick" to allow constants to be defined in a class
/// declaration.
SHA256 = 3, // SHA-256
SHA224 = 4, // SHA-224
SHA384 = 5, // SHA-384
- SHA512 = 6 // SHA-512
+ SHA512 = 6, // SHA-512
};
/// @brief Forward declaration for createHash().
-// Copyright (C) 2011-2024 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2025 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
#include <config.h>
+#include <cryptolink/crypto_hmac.h>
+#include <cryptolink/cryptolink.h>
+#include <exceptions/exceptions.h>
+#include <util/buffer.h>
+#include <util/encode/encode.h>
+
#include <string>
#include <vector>
#include <boost/lexical_cast.hpp>
+#include <boost/shared_ptr.hpp>
#include <gtest/gtest.h>
-#include <util/encode/encode.h>
-
-#include <cryptolink/cryptolink.h>
-#include <cryptolink/crypto_hmac.h>
-
-#include <util/buffer.h>
-#include <exceptions/exceptions.h>
-
-#include <boost/shared_ptr.hpp>
-
using boost::lexical_cast;
using namespace isc::util;
using namespace isc::util::encode;
using namespace isc::cryptolink;
namespace {
+ /// @brief Convert enum to string.
+ ///
+ /// @param algorithm input enum
+ ///
+ /// @return reference to static string
+ static std::string const& hashAlgorithmToText(HashAlgorithm const& algorithm) {
+ static std::vector<std::string> const text_vector {
+ "UNKNOWN_HASH",
+ "MD5",
+ "SHA1",
+ "SHA256",
+ "SHA224",
+ "SHA384",
+ "SHA512",
+ };
+ static std::string const unknown("UNKNOWN");
+ return (algorithm < text_vector.size() ? text_vector[algorithm] : unknown);
+ }
+
/// @brief Fill a string with copies of an out of char range value
/// @param data String to fill
/// @param len Number of copies
for (std::vector<std::string>::size_type i = 0;
i < data_list.size(); ++i) {
- SCOPED_TRACE("RFC4231 HMAC test for algorithm ID: " +
- lexical_cast<std::string>(hash_algorithm) +
+ SCOPED_TRACE("RFC4231 HMAC test for algorithm " +
+ hashAlgorithmToText(hash_algorithm) +
", data ID: " + lexical_cast<std::string>(i));
// Until #920 is resolved we have to skip truncation cases.
if (data_list[i] == "Test With Truncation") {
OTHER = 4, ///< Other, unclassified error.
};
+ /// @brief Convert enum to string.
+ ///
+ /// @param status input enum
+ ///
+ /// @return reference to static string
+ static std::string const& statusToText(Status const& status) {
+ static std::vector<std::string> const text_vector {
+ "SUCCESS",
+ "TIMEOUT",
+ "IO_STOPPED",
+ "INVALID_RESPONSE",
+ "OTHER",
+ };
+ static std::string const unknown("UNKNOWN");
+ return (status < text_vector.size() ? text_vector[status] : unknown);
+ }
+
/// @brief Callback for the @c DNSClient class.
///
/// This is an abstract class which represents the external callback for the
#include <dhcp_ddns/ncr_msg.h>
#include <exceptions/exceptions.h>
-#include <boost/scoped_ptr.hpp>
-#include <boost/enable_shared_from_this.hpp>
-
#include <deque>
#include <mutex>
+#include <boost/enable_shared_from_this.hpp>
+#include <boost/scoped_ptr.hpp>
+
namespace isc {
namespace dhcp_ddns {
ERROR = 3,
};
+ /// @brief Convert enum to string.
+ ///
+ /// @param result input enum
+ ///
+ /// @return reference to static string
+ static std::string const& resultToText(Result const& result) {
+ static std::vector<std::string> const text_vector {
+ "SUCCESS",
+ "TIME_OUT",
+ "STOPPED",
+ "ERROR",
+ };
+ static std::string const unknown("UNKNOWN");
+ return (result < text_vector.size() ? text_vector[result] : unknown);
+ }
+
/// @brief Abstract class for defining application layer send callbacks.
///
/// Applications which will send NameChangeRequests must provide a
IDENT_DUID = 1,
IDENT_CIRCUIT_ID = 2,
IDENT_CLIENT_ID = 3,
- IDENT_FLEX = 4, ///< Flexible host identifier.
+ IDENT_FLEX = 4, ///< Flexible host identifier.
};
/// @brief Constant pointing to the last identifier of the