2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 21:45:37 +00:00

[#3245] addressed review

This commit is contained in:
Razvan Becheriu
2024-02-22 21:23:58 +02:00
committed by Thomas Markwalder
parent 88bbd44e0d
commit aa15c5af6e
6 changed files with 85 additions and 85 deletions

View File

@@ -30,21 +30,21 @@ public:
///
/// @param family protocol family AF_INET or AF_INET6
/// @param query_type message type of the query packet
/// @param response_type_ message type of the response packet
/// @param response_type message type of the response packet
/// @param start_event_label label of the start event
/// @param end_event_label label of the end event
/// @param SubnetID subnet_id id of the selected subnet
/// @param low_water threshold below which the average duration must fall to clear the alarm
/// @brief high_water threshold above which the average duration must rise to trigger the alarm.
/// @brief enabled true sets state to CLEAR, otherwise DISABLED, defaults to true.
Alarm(uint16_t family, uint8_t query_type_, uint8_t response_type_,
Alarm(uint16_t family, uint8_t query_type, uint8_t response_type,
const std::string& start_event_label, const std::string& end_event_label,
dhcp::SubnetID subnet_id_,
dhcp::SubnetID subnet_id,
const Duration& low_water, const Duration& high_water, bool enabled = true);
/// @brief Constructor
///
/// param key composite key that identifies the alarm
/// @param key composite key that identifies the alarm
/// @param low_water threshold below which the average duration must fall to clear the alarm
/// @brief high_water threshold above which the average duration must rise to trigger the alarm.
/// @brief enabled true sets state to CLEAR, otherwise DISABLED, defaults to true.

View File

@@ -63,7 +63,7 @@ public:
/// @brief Get the number of occurrences that have contributed to the
/// interval.
///
/// @return uint64_t containing the number of occurrences.
/// @return the number of occurrences.
uint64_t getOccurrences() const {
return (occurrences_);
};
@@ -126,13 +126,13 @@ public:
///
/// @param family protocol family AF_INET or AF_INET6
/// @param query_type message type of the query packet
/// @param response_type_ message type of the response packet
/// @param response_type message type of the response packet
/// @param start_event_label label of the start event
/// @param end_event_label label of the end event
/// @param SubnetID subnet_id id of the selected subnet
DurationKey(uint16_t family, uint8_t query_type_, uint8_t response_type_,
/// @param subnet_id id of the selected subnet
DurationKey(uint16_t family, uint8_t query_type, uint8_t response_type,
const std::string& start_event_label, const std::string& end_event_label,
dhcp::SubnetID subnet_id_);
dhcp::SubnetID subnet_id);
/// @brief Destructor
virtual ~DurationKey() = default;
@@ -141,33 +141,33 @@ public:
///
/// @return uint16_t containing the family (AF_INET or AF_INET6)
uint16_t getFamily() {
return(family_);
return (family_);
}
/// @brief Get the query packet type.
///
/// @return uint8_t containing the query packet type.
/// @return the query packet type.
uint8_t getQueryType() const {
return (query_type_);
}
/// @brief Get the response packet type.
///
/// @return uint8_t containing the response packet type.
/// @return the response packet type.
uint8_t getResponseType() const {
return (response_type_);
};
/// @brief Get the start event label.
///
/// @return String containing the start event label.
/// @return the start event label.
std::string getStartEventLabel() const {
return (start_event_label_);
}
/// @brief Get the end event label.
///
/// @return String containing the end event label.
/// @return the end event label.
std::string getEndEventLabel() const {
return (end_event_label_);
}
@@ -197,7 +197,7 @@ public:
///
/// @endcode
///
/// @return String containing the composite label.
/// @return the composite label.
std::string getLabel() const;
/// @brief Validates that a query and response message type pair is sane.
@@ -205,19 +205,19 @@ public:
/// @param family Protocol family of the key (AF_INET or AF_INET6)
/// The format of the string:
/// @param query_type message type of the query packet
/// @param response_type_ message type of the response packet
/// @param response_type message type of the response packet
///
/// @throw BadValue is the pairing does not make sense.
static void validateMessagePair(uint16_t family, uint8_t query_type, uint8_t response_type);
protected:
/// @brief Protocol family AF_INET or AF_INET6
/// @brief Protocol family AF_INET or AF_INET6.
uint16_t family_;
/// @brief Query message type (e.g. DHCPDISCOVER, DHCP6_SOLICIT)
/// @brief Query message type (e.g. DHCPDISCOVER, DHCP6_SOLICIT).
uint8_t query_type_;
/// @brief Response message type. (e.g. DHCPOFFER, DHCP6_ADVERTISE)
/// @brief Response message type (e.g. DHCPOFFER, DHCP6_ADVERTISE).
uint8_t response_type_;
/// @brief Label of the start event which begins the duration.
@@ -239,39 +239,39 @@ public:
///
/// @param family protocol family AF_INET or AF_INET6
/// @param query_type message type of the query packet
/// @param response_type_ message type of the response packet
/// @param response_type message type of the response packet
/// @param start_event_label label of the start event
/// @param end_event_label label of the end event
/// @param SubnetID subnet_id id of the selected subnet
/// @param Duration interval_duration_;
MonitoredDuration(uint16_t family, uint8_t query_type_, uint8_t response_type_,
/// @param subnet_id id of the selected subnet
/// @param interval_duration the interval duration
MonitoredDuration(uint16_t family, uint8_t query_type, uint8_t response_type,
const std::string& start_event_label, const std::string& end_event_label,
dhcp::SubnetID subnet_id_, const Duration& interval_duration_);
dhcp::SubnetID subnet_id, const Duration& interval_duration);
/// @brief Constructor
///
/// param key composite key that identifies the alarm
/// @param Duration interval_duration_;
MonitoredDuration(const DurationKey& key, const Duration& interval_duration_);
/// @param key composite key that identifies the alarm
/// @param interval_duration the interval duration
MonitoredDuration(const DurationKey& key, const Duration& interval_duration);
/// @brief Destructor
virtual ~MonitoredDuration() = default;
/// @brief Get the interval duration
/// @brief Get the interval duration.
///
/// @return Duration containing the interval duration.
Duration getIntervalDuration() const {
return(interval_duration_);
return (interval_duration_);
}
/// @brief Get the previous interval
/// @brief Get the previous interval.
///
/// @return Pointer to the previous interval if it exists or an empty pointer.
DurationDataIntervalPtr getPreviousInterval() const {
return (previous_interval_);
}
/// @brief Get the current interval
/// @brief Get the current interval.
///
/// @return Pointer to the current interval if it exists or an empty pointer.
DurationDataIntervalPtr getCurrentInterval() const {

View File

@@ -127,28 +127,28 @@ TEST(DurationKey, validateMessagePairs4) {
// List of scenarios to test, one per v4 message type.
std::list<Scenario> scenarios {
{ DHCP_NOTYPE, {DHCP_NOTYPE, DHCPOFFER, DHCPACK, DHCPNAK}},
{ DHCPDISCOVER, {DHCP_NOTYPE, DHCPOFFER, DHCPNAK}},
{ DHCPOFFER, {}},
{ DHCPREQUEST, {DHCP_NOTYPE, DHCPACK, DHCPNAK}},
{ DHCPDECLINE, {}},
{ DHCPACK, {}},
{ DHCPNAK, {}},
{ DHCPRELEASE, {}},
{ DHCPINFORM, {DHCP_NOTYPE, DHCPACK}},
// { DHCPFORCERENEW, {}}, commented out in dhcp4.h
{ DHCPLEASEQUERY, {}},
{ DHCPLEASEUNASSIGNED, {}},
{ DHCPLEASEUNKNOWN, {}},
{ DHCPLEASEACTIVE, {}},
{ DHCPBULKLEASEQUERY, {}},
{ DHCPLEASEQUERYDONE, {}},
// { DHCPACTIVELEASEQUERY, {}}, commented out in dhcp4.h
{ DHCPLEASEQUERYSTATUS, {}},
{ DHCPTLS, {}},
{DHCP_NOTYPE, {DHCP_NOTYPE, DHCPOFFER, DHCPACK, DHCPNAK}},
{DHCPDISCOVER, {DHCP_NOTYPE, DHCPOFFER, DHCPNAK}},
{DHCPOFFER, {}},
{DHCPREQUEST, {DHCP_NOTYPE, DHCPACK, DHCPNAK}},
{DHCPDECLINE, {}},
{DHCPACK, {}},
{DHCPNAK, {}},
{DHCPRELEASE, {}},
{DHCPINFORM, {DHCP_NOTYPE, DHCPACK}},
// {DHCPFORCERENEW, {}}, commented out in dhcp4.h
{DHCPLEASEQUERY, {}},
{DHCPLEASEUNASSIGNED, {}},
{DHCPLEASEUNKNOWN, {}},
{DHCPLEASEACTIVE, {}},
{DHCPBULKLEASEQUERY, {}},
{DHCPLEASEQUERYDONE, {}},
// {DHCPACTIVELEASEQUERY, {}}, commented out in dhcp4.h
{DHCPLEASEQUERYSTATUS, {}},
{DHCPTLS, {}},
};
// Iterate over the scenarios. Attempt to pair each scenario query type with every v6 message
// Iterate over the scenarios. Attempt to pair each scenario query type with every v4 message
// type as a response type. If the response type is in the scenario's valid list, the pair
// should validate, otherwise it should throw.
for (auto const& scenario : scenarios) {
@@ -165,7 +165,7 @@ TEST(DurationKey, validateMessagePairs4) {
}
}
// Verify v4 message pair validation works.
// Verify v6 message pair validation works.
TEST(DurationKey, validateMessagePairs6) {
// Defines a test scenario.
struct Scenario {
@@ -284,7 +284,7 @@ TEST(MonitoredDuration, invalidConstructors) {
BadValue,
"Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER");
// Interval duration cannot be than zero.
// Interval duration cannot be zero.
interval_duration = DurationDataInterval::ZERO_DURATION();
ASSERT_THROW_MSG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER,
"process_started", "process_completed",
@@ -306,7 +306,7 @@ TEST(MonitoredDuration, invalidConstructors) {
ASSERT_NO_THROW_LOG(key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE,
"mt_queued", "process_started", 77)));
// Interval duration cannot be than zero.
// Interval duration cannot be zero.
ASSERT_THROW_MSG(mond.reset(new MonitoredDuration(*key, interval_duration)),
BadValue,
"MonitoredDuration - interval_duration 00:00:00,"

View File

@@ -192,7 +192,7 @@ PktFilterLPF::openSocket(Iface& iface,
int enable = 1;
if (setsockopt(sock, SOL_SOCKET, SO_TIMESTAMP, &enable, sizeof(enable))) {
const char* errmsg = strerror(errno);
isc_throw(SocketConfigError, "Can't enable SO_TIMESTAMP for " << addr.toText()
isc_throw(SocketConfigError, "Can not enable SO_TIMESTAMP for " << addr.toText()
<< ", error: " << errmsg);
}
#endif