![]() |
Kea 3.1.1
|
Embodies the life cycle of a ping check test for a single address for a single DHCPDISCOVER. More...
#include <ping_context.h>
Public Types | |
enum | State { NEW , WAITING_TO_SEND , SENDING , WAITING_FOR_REPLY , TARGET_FREE , TARGET_IN_USE } |
Defines PingContext life cycle states. More... | |
Public Member Functions | |
PingContext (isc::dhcp::Lease4Ptr &lease, isc::dhcp::Pkt4Ptr &query, uint32_t min_echos=1, uint32_t reply_timeout=100, isc::hooks::ParkingLotHandlePtr &parking_lot=EMPTY_LOT()) | |
Constructor. | |
virtual | ~PingContext ()=default |
Destructor. | |
void | beginWaitingForReply (const TimeStamp &begin_time=PingContext::now()) |
Enters WAITING_TO_REPLY state. | |
void | beginWaitingToSend (const TimeStamp &begin_time=PingContext::now()) |
Enters WAITING_TO_SEND state. | |
const TimeStamp & | getCreatedTime () const |
Fetches the time at which the context was created. | |
uint32_t | getEchosSent () const |
Fetches the number of ECHO REQUESTs sent. | |
const TimeStamp & | getLastEchoSentTime () const |
Fetches the timestamp of when the most recent ECHO REQUEST was sent. | |
isc::dhcp::Lease4Ptr | getLease () const |
Returns the candidate lease whose address is the target to check. | |
uint32_t | getMinEchos () const |
Fetches the minimum number of ECHO REQUESTs. | |
const TimeStamp & | getNextExpiry () const |
Fetches the time at which the WAITING_FOR_REPLY state expires(ed) | |
isc::hooks::ParkingLotHandlePtr | getParkingLot () |
Fetches the parking lot used for this context. | |
isc::dhcp::Pkt4Ptr | getQuery () const |
Returns the query that instigated this check. | |
uint32_t | getReplyTimeout () const |
Fetches the reply timeout (milliseconds) | |
const TimeStamp & | getSendWaitStart () const |
Fetches the time the context went into WAITING_TO_SEND state. | |
State | getState () const |
Fetches the current state. | |
const isc::asiolink::IOAddress & | getTarget () const |
Fetches the IP address that is under test. | |
bool | isWaitingForReply () const |
Returns true if state is WAITING_FOR_REPLY. | |
bool | isWaitingToSend () const |
Returns true if state is WAITING_TO_SEND. | |
void | setEchosSent (uint32_t value) |
Sets the number of ECHO REQUESTs sent. | |
void | setLastEchoSentTime (const TimeStamp &value) |
Sets the timestamp the most recent ECHO REQUEST was sent. | |
void | setMinEchos (uint32_t value) |
Sets the minimum number of ECHO REQUESTs. | |
void | setNextExpiry (const TimeStamp &value) |
Sets the timestamp which specifies the time at which the WAITING_FOR_REPLY state expires. | |
void | setReplyTimeout (uint32_t value) |
Sets the reply timeout. | |
void | setSendWaitStart (const TimeStamp &value) |
Sets the send wait start timestamp. | |
void | setState (const State &value) |
Sets the state. | |
Static Public Member Functions | |
static hooks::ParkingLotHandlePtr & | EMPTY_LOT () |
Fetches an empty parking lot handle. | |
static const TimeStamp & | EMPTY_TIME () |
Fetches an empty timestamp. | |
static const TimeStamp & | MIN_TIME () |
Fetches the minimum timestamp. | |
static TimeStamp | now () |
Fetches the current timestamp (UTC/milliseconds precision) | |
static std::string | stateToString (const State &state) |
Converts a State to a string. | |
static State | stringToState (const std::string &state_str) |
Converts a string to State. | |
Embodies the life cycle of a ping check test for a single address for a single DHCPDISCOVER.
The class uses a state-model to direct the tasks needed to execute one or more ECHO REQUEST SEND/WAIT FOR REPLY cycles until the address is either deemed free to offer or in-use and should not be offered. The number of cycles conducted is dictated by the minimum number of echos (min_echos_
) and whether or not either an ECHO REPLY or DESTINATION UNREACHABLE are received.
Definition at line 31 of file ping_context.h.
Defines PingContext life cycle states.
Enumerator | |
---|---|
NEW | |
WAITING_TO_SEND | |
SENDING | |
WAITING_FOR_REPLY | |
TARGET_FREE | |
TARGET_IN_USE |
Definition at line 35 of file ping_context.h.
isc::ping_check::PingContext::PingContext | ( | isc::dhcp::Lease4Ptr & | lease, |
isc::dhcp::Pkt4Ptr & | query, | ||
uint32_t | min_echos = 1, | ||
uint32_t | reply_timeout = 100, | ||
isc::hooks::ParkingLotHandlePtr & | parking_lot = EMPTY_LOT() ) |
Constructor.
lease | pointer to the lease whose address needs to be checked |
query | DHCPDISCOVER that instigated the check |
min_echos | minimum number of ECHO REQUESTs sent without replies received required to declare an address free to offer. Defaults to 1, must be greater than zero. |
reply_timeout | maximum number of milliseconds to wait for an ECHO REPLY after an ECHO REQUEST has been sent. Defaults to 100, must be greater than 0. |
parking_lot | parking lot in which the query is parked. Defaults to an empty pointer. |
BadValue | if either lease or query are empty, or if the lease address is 0.0.0.0 |
Definition at line 25 of file ping_context.cc.
References PingContext(), EMPTY_TIME(), getTarget(), isc::asiolink::IOAddress::IPV4_ZERO_ADDRESS(), isc_throw, NEW, and now().
Referenced by PingContext().
|
virtualdefault |
Destructor.
void isc::ping_check::PingContext::beginWaitingForReply | ( | const TimeStamp & | begin_time = PingContext::now() | ) |
Enters WAITING_TO_REPLY state.
begin_time | timestamp of when the state began. Defaults to time now. Provided for testing purposes. |
Definition at line 228 of file ping_context.cc.
References WAITING_FOR_REPLY.
void isc::ping_check::PingContext::beginWaitingToSend | ( | const TimeStamp & | begin_time = PingContext::now() | ) |
Enters WAITING_TO_SEND state.
begin_time | timestamp of when the state began. Defaults to time now. Provided for testing purposes. |
Definition at line 222 of file ping_context.cc.
References WAITING_TO_SEND.
|
inlinestatic |
Fetches an empty parking lot handle.
Definition at line 104 of file ping_context.h.
Referenced by isc::ping_check::PingContextStore::~PingContextStore().
|
inlinestatic |
Fetches an empty timestamp.
Definition at line 88 of file ping_context.h.
Referenced by PingContext(), isc::ping_check::PingCheckMgr::cancelExpirationTimerInternal(), isc::ping_check::PingCheckMgr::expirationTimedOut(), and isc::ping_check::PingCheckMgr::setNextExpirationInternal().
const TimeStamp & isc::ping_check::PingContext::getCreatedTime | ( | ) | const |
Fetches the time at which the context was created.
Definition at line 197 of file ping_context.cc.
uint32_t isc::ping_check::PingContext::getEchosSent | ( | ) | const |
Fetches the number of ECHO REQUESTs sent.
Definition at line 147 of file ping_context.cc.
const TimeStamp & isc::ping_check::PingContext::getLastEchoSentTime | ( | ) | const |
Fetches the timestamp of when the most recent ECHO REQUEST was sent.
Definition at line 157 of file ping_context.cc.
Lease4Ptr isc::ping_check::PingContext::getLease | ( | ) | const |
Returns the candidate lease whose address is the target to check.
Definition at line 217 of file ping_context.cc.
uint32_t isc::ping_check::PingContext::getMinEchos | ( | ) | const |
Fetches the minimum number of ECHO REQUESTs.
Definition at line 127 of file ping_context.cc.
const TimeStamp & isc::ping_check::PingContext::getNextExpiry | ( | ) | const |
Fetches the time at which the WAITING_FOR_REPLY state expires(ed)
The value returned is only meaningful when the context state is WAITING_FOR_REPLY.
Definition at line 182 of file ping_context.cc.
|
inline |
Fetches the parking lot used for this context.
Definition at line 233 of file ping_context.h.
Pkt4Ptr isc::ping_check::PingContext::getQuery | ( | ) | const |
Returns the query that instigated this check.
Definition at line 212 of file ping_context.cc.
uint32_t isc::ping_check::PingContext::getReplyTimeout | ( | ) | const |
Fetches the reply timeout (milliseconds)
Definition at line 137 of file ping_context.cc.
const TimeStamp & isc::ping_check::PingContext::getSendWaitStart | ( | ) | const |
Fetches the time the context went into WAITING_TO_SEND state.
The value returned is only meaningful when the context state is WAITING_TO_SEND.
Definition at line 167 of file ping_context.cc.
PingContext::State isc::ping_check::PingContext::getState | ( | ) | const |
Fetches the current state.
Definition at line 202 of file ping_context.cc.
const IOAddress & isc::ping_check::PingContext::getTarget | ( | ) | const |
Fetches the IP address that is under test.
Definition at line 122 of file ping_context.cc.
Referenced by PingContext().
bool isc::ping_check::PingContext::isWaitingForReply | ( | ) | const |
Returns true if state is WAITING_FOR_REPLY.
Definition at line 187 of file ping_context.cc.
References WAITING_FOR_REPLY.
bool isc::ping_check::PingContext::isWaitingToSend | ( | ) | const |
Returns true if state is WAITING_TO_SEND.
Definition at line 172 of file ping_context.cc.
References WAITING_TO_SEND.
|
inlinestatic |
Fetches the minimum timestamp.
Definition at line 96 of file ping_context.h.
Referenced by isc::ping_check::PingContextStore::getExpiredSince(), and isc::ping_check::PingContextStore::getNextToSend().
|
static |
Fetches the current timestamp (UTC/milliseconds precision)
Definition at line 91 of file ping_context.cc.
Referenced by PingContext(), isc::ping_check::PingContextStore::~PingContextStore(), isc::ping_check::PingContextStore::getExpiresNext(), and isc::ping_check::PingCheckMgr::setNextExpirationInternal().
void isc::ping_check::PingContext::setEchosSent | ( | uint32_t | value | ) |
Sets the number of ECHO REQUESTs sent.
value | new value |
Definition at line 152 of file ping_context.cc.
void isc::ping_check::PingContext::setLastEchoSentTime | ( | const TimeStamp & | value | ) |
Sets the timestamp the most recent ECHO REQUEST was sent.
value | new value |
Definition at line 162 of file ping_context.cc.
void isc::ping_check::PingContext::setMinEchos | ( | uint32_t | value | ) |
Sets the minimum number of ECHO REQUESTs.
value | new value, must be greater than 0 |
BadValue | if the given value is 0 |
Definition at line 132 of file ping_context.cc.
void isc::ping_check::PingContext::setNextExpiry | ( | const TimeStamp & | value | ) |
Sets the timestamp which specifies the time at which the WAITING_FOR_REPLY state expires.
value | new value |
Definition at line 192 of file ping_context.cc.
void isc::ping_check::PingContext::setReplyTimeout | ( | uint32_t | value | ) |
Sets the reply timeout.
value | new value in milliseconds, must be greater than 0 |
BadValue | if the given value is 0. |
Definition at line 142 of file ping_context.cc.
void isc::ping_check::PingContext::setSendWaitStart | ( | const TimeStamp & | value | ) |
Sets the send wait start timestamp.
value | new value |
Definition at line 177 of file ping_context.cc.
void isc::ping_check::PingContext::setState | ( | const State & | value | ) |
|
static |
Converts a State to a string.
state | State to convert |
Definition at line 96 of file ping_context.cc.
References NEW, SENDING, TARGET_FREE, TARGET_IN_USE, WAITING_FOR_REPLY, and WAITING_TO_SEND.
|
static |
Converts a string to State.
state_str | Upper case string label to convert |
BadValue | if the string is not a valid state label |
Definition at line 62 of file ping_context.cc.
References isc_throw, NEW, SENDING, TARGET_FREE, TARGET_IN_USE, WAITING_FOR_REPLY, and WAITING_TO_SEND.