mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 05:55:28 +00:00
[#3245] addressed review
This commit is contained in:
committed by
Thomas Markwalder
parent
88bbd44e0d
commit
aa15c5af6e
@@ -30,21 +30,21 @@ public:
|
|||||||
///
|
///
|
||||||
/// @param family protocol family AF_INET or AF_INET6
|
/// @param family protocol family AF_INET or AF_INET6
|
||||||
/// @param query_type message type of the query packet
|
/// @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 start_event_label label of the start event
|
||||||
/// @param end_event_label label of the end event
|
/// @param end_event_label label of the end event
|
||||||
/// @param SubnetID subnet_id id of the selected subnet
|
/// @param SubnetID subnet_id id of the selected subnet
|
||||||
/// @param low_water threshold below which the average duration must fall to clear 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 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.
|
/// @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,
|
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);
|
const Duration& low_water, const Duration& high_water, bool enabled = true);
|
||||||
|
|
||||||
/// @brief Constructor
|
/// @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
|
/// @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 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.
|
/// @brief enabled true sets state to CLEAR, otherwise DISABLED, defaults to true.
|
||||||
|
@@ -63,7 +63,7 @@ public:
|
|||||||
/// @brief Get the number of occurrences that have contributed to the
|
/// @brief Get the number of occurrences that have contributed to the
|
||||||
/// interval.
|
/// interval.
|
||||||
///
|
///
|
||||||
/// @return uint64_t containing the number of occurrences.
|
/// @return the number of occurrences.
|
||||||
uint64_t getOccurrences() const {
|
uint64_t getOccurrences() const {
|
||||||
return (occurrences_);
|
return (occurrences_);
|
||||||
};
|
};
|
||||||
@@ -126,13 +126,13 @@ public:
|
|||||||
///
|
///
|
||||||
/// @param family protocol family AF_INET or AF_INET6
|
/// @param family protocol family AF_INET or AF_INET6
|
||||||
/// @param query_type message type of the query packet
|
/// @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 start_event_label label of the start event
|
||||||
/// @param end_event_label label of the end event
|
/// @param end_event_label label of the end event
|
||||||
/// @param SubnetID subnet_id id of the selected subnet
|
/// @param subnet_id id of the selected subnet
|
||||||
DurationKey(uint16_t family, uint8_t query_type_, uint8_t response_type_,
|
DurationKey(uint16_t family, uint8_t query_type, uint8_t response_type,
|
||||||
const std::string& start_event_label, const std::string& end_event_label,
|
const std::string& start_event_label, const std::string& end_event_label,
|
||||||
dhcp::SubnetID subnet_id_);
|
dhcp::SubnetID subnet_id);
|
||||||
|
|
||||||
/// @brief Destructor
|
/// @brief Destructor
|
||||||
virtual ~DurationKey() = default;
|
virtual ~DurationKey() = default;
|
||||||
@@ -146,28 +146,28 @@ public:
|
|||||||
|
|
||||||
/// @brief Get the query packet type.
|
/// @brief Get the query packet type.
|
||||||
///
|
///
|
||||||
/// @return uint8_t containing the query packet type.
|
/// @return the query packet type.
|
||||||
uint8_t getQueryType() const {
|
uint8_t getQueryType() const {
|
||||||
return (query_type_);
|
return (query_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Get the response packet type.
|
/// @brief Get the response packet type.
|
||||||
///
|
///
|
||||||
/// @return uint8_t containing the response packet type.
|
/// @return the response packet type.
|
||||||
uint8_t getResponseType() const {
|
uint8_t getResponseType() const {
|
||||||
return (response_type_);
|
return (response_type_);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief Get the start event label.
|
/// @brief Get the start event label.
|
||||||
///
|
///
|
||||||
/// @return String containing the start event label.
|
/// @return the start event label.
|
||||||
std::string getStartEventLabel() const {
|
std::string getStartEventLabel() const {
|
||||||
return (start_event_label_);
|
return (start_event_label_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Get the end event label.
|
/// @brief Get the end event label.
|
||||||
///
|
///
|
||||||
/// @return String containing the end event label.
|
/// @return the end event label.
|
||||||
std::string getEndEventLabel() const {
|
std::string getEndEventLabel() const {
|
||||||
return (end_event_label_);
|
return (end_event_label_);
|
||||||
}
|
}
|
||||||
@@ -197,7 +197,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// @endcode
|
/// @endcode
|
||||||
///
|
///
|
||||||
/// @return String containing the composite label.
|
/// @return the composite label.
|
||||||
std::string getLabel() const;
|
std::string getLabel() const;
|
||||||
|
|
||||||
/// @brief Validates that a query and response message type pair is sane.
|
/// @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)
|
/// @param family Protocol family of the key (AF_INET or AF_INET6)
|
||||||
/// The format of the string:
|
/// The format of the string:
|
||||||
/// @param query_type message type of the query packet
|
/// @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.
|
/// @throw BadValue is the pairing does not make sense.
|
||||||
static void validateMessagePair(uint16_t family, uint8_t query_type, uint8_t response_type);
|
static void validateMessagePair(uint16_t family, uint8_t query_type, uint8_t response_type);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// @brief Protocol family AF_INET or AF_INET6
|
/// @brief Protocol family AF_INET or AF_INET6.
|
||||||
uint16_t family_;
|
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_;
|
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_;
|
uint8_t response_type_;
|
||||||
|
|
||||||
/// @brief Label of the start event which begins the duration.
|
/// @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 family protocol family AF_INET or AF_INET6
|
||||||
/// @param query_type message type of the query packet
|
/// @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 start_event_label label of the start event
|
||||||
/// @param end_event_label label of the end event
|
/// @param end_event_label label of the end event
|
||||||
/// @param SubnetID subnet_id id of the selected subnet
|
/// @param subnet_id id of the selected subnet
|
||||||
/// @param Duration interval_duration_;
|
/// @param interval_duration the interval duration
|
||||||
MonitoredDuration(uint16_t family, uint8_t query_type_, uint8_t response_type_,
|
MonitoredDuration(uint16_t family, uint8_t query_type, uint8_t response_type,
|
||||||
const std::string& start_event_label, const std::string& end_event_label,
|
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
|
/// @brief Constructor
|
||||||
///
|
///
|
||||||
/// param key composite key that identifies the alarm
|
/// @param key composite key that identifies the alarm
|
||||||
/// @param Duration interval_duration_;
|
/// @param interval_duration the interval duration
|
||||||
MonitoredDuration(const DurationKey& key, const Duration& interval_duration_);
|
MonitoredDuration(const DurationKey& key, const Duration& interval_duration);
|
||||||
|
|
||||||
/// @brief Destructor
|
/// @brief Destructor
|
||||||
virtual ~MonitoredDuration() = default;
|
virtual ~MonitoredDuration() = default;
|
||||||
|
|
||||||
/// @brief Get the interval duration
|
/// @brief Get the interval duration.
|
||||||
///
|
///
|
||||||
/// @return Duration containing the interval duration.
|
/// @return Duration containing the interval duration.
|
||||||
Duration getIntervalDuration() const {
|
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.
|
/// @return Pointer to the previous interval if it exists or an empty pointer.
|
||||||
DurationDataIntervalPtr getPreviousInterval() const {
|
DurationDataIntervalPtr getPreviousInterval() const {
|
||||||
return (previous_interval_);
|
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.
|
/// @return Pointer to the current interval if it exists or an empty pointer.
|
||||||
DurationDataIntervalPtr getCurrentInterval() const {
|
DurationDataIntervalPtr getCurrentInterval() const {
|
||||||
|
@@ -148,7 +148,7 @@ TEST(DurationKey, validateMessagePairs4) {
|
|||||||
{DHCPTLS, {}},
|
{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
|
// type as a response type. If the response type is in the scenario's valid list, the pair
|
||||||
// should validate, otherwise it should throw.
|
// should validate, otherwise it should throw.
|
||||||
for (auto const& scenario : scenarios) {
|
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) {
|
TEST(DurationKey, validateMessagePairs6) {
|
||||||
// Defines a test scenario.
|
// Defines a test scenario.
|
||||||
struct Scenario {
|
struct Scenario {
|
||||||
@@ -284,7 +284,7 @@ TEST(MonitoredDuration, invalidConstructors) {
|
|||||||
BadValue,
|
BadValue,
|
||||||
"Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER");
|
"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();
|
interval_duration = DurationDataInterval::ZERO_DURATION();
|
||||||
ASSERT_THROW_MSG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER,
|
ASSERT_THROW_MSG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER,
|
||||||
"process_started", "process_completed",
|
"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,
|
ASSERT_NO_THROW_LOG(key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE,
|
||||||
"mt_queued", "process_started", 77)));
|
"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)),
|
ASSERT_THROW_MSG(mond.reset(new MonitoredDuration(*key, interval_duration)),
|
||||||
BadValue,
|
BadValue,
|
||||||
"MonitoredDuration - interval_duration 00:00:00,"
|
"MonitoredDuration - interval_duration 00:00:00,"
|
||||||
|
@@ -192,7 +192,7 @@ PktFilterLPF::openSocket(Iface& iface,
|
|||||||
int enable = 1;
|
int enable = 1;
|
||||||
if (setsockopt(sock, SOL_SOCKET, SO_TIMESTAMP, &enable, sizeof(enable))) {
|
if (setsockopt(sock, SOL_SOCKET, SO_TIMESTAMP, &enable, sizeof(enable))) {
|
||||||
const char* errmsg = strerror(errno);
|
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);
|
<< ", error: " << errmsg);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user