7#ifndef PING_CONTEXT_STORE_H
8#define PING_CONTEXT_STORE_H
13#include <boost/multi_index/indexed_by.hpp>
14#include <boost/multi_index/member.hpp>
15#include <boost/multi_index/mem_fun.hpp>
16#include <boost/multi_index/ordered_index.hpp>
17#include <boost/multi_index_container.hpp>
18#include <boost/multi_index/composite_key.hpp>
19#include <boost/scoped_ptr.hpp>
61typedef boost::multi_index_container<
64 boost::multi_index::indexed_by<
69 boost::multi_index::ordered_unique<
70 boost::multi_index::tag<AddressIndexTag>,
77 boost::multi_index::ordered_unique<
78 boost::multi_index::tag<QueryIndexTag>,
85 boost::multi_index::ordered_non_unique<
86 boost::multi_index::tag<NextToSendIndexTag>,
87 boost::multi_index::composite_key<
90 boost::multi_index::const_mem_fun<
PingContext, bool,
100 boost::multi_index::ordered_non_unique<
101 boost::multi_index::tag<ExpirationIndexTag>,
102 boost::multi_index::composite_key<
105 boost::multi_index::const_mem_fun<
PingContext, bool,
115 boost::multi_index::ordered_non_unique<
116 boost::multi_index::tag<StateIndexTag>,
164 uint32_t reply_timeout,
234 const boost::scoped_ptr<std::mutex> mutex_;
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The IOAddress class represents an IP addresses (version agnostic)
DuplicateContext(const char *file, size_t line, const char *what)
void clear()
Removes all contexts from the store.
PingContextPtr getContextByQuery(isc::dhcp::Pkt4Ptr &query)
Fetches the context with a given query packet.
PingContextStore()
Constructor.
PingContextPtr getContextByAddress(const isc::asiolink::IOAddress &address)
Fetches the context with a given target address.
PingContextPtr addContext(isc::dhcp::Lease4Ptr &lease, isc::dhcp::Pkt4Ptr &query, uint32_t min_echos, uint32_t reply_timeout, isc::hooks::ParkingLotHandlePtr &parking_lot=PingContext::EMPTY_LOT())
Creates a new PingContext and adds it to the store.
PingContextCollectionPtr getAll()
Fetches all of the contexts (in order by target)
~PingContextStore()=default
Destructor.
PingContextCollectionPtr getExpiredSince(const TimeStamp &since=PingContext::now())
Fetches the contexts in WAITING_FOR_REPLY that expired since a given time.
void deleteContext(const PingContextPtr &context)
Removes the context from the store.
PingContextPtr getNextToSend()
Fetches the context in WAITING_TO_SEND with the oldest send wait start time.
PingContextPtr getExpiresNext()
Fetches the context in WAITING_FOR_REPLY with the oldest expiration time that has not already passed ...
void updateContext(const PingContextPtr &context)
Updates a context in the store.
Embodies the life cycle of a ping check test for a single address for a single DHCPDISCOVER.
const TimeStamp & getNextExpiry() const
Fetches the time at which the WAITING_FOR_REPLY state expires(ed)
State getState() const
Fetches the current state.
bool isWaitingForReply() const
Returns true if state is WAITING_FOR_REPLY.
isc::dhcp::Pkt4Ptr getQuery() const
Returns the query that instigated this check.
bool isWaitingToSend() const
Returns true if state is WAITING_TO_SEND.
static TimeStamp now()
Fetches the current timestamp (UTC/milliseconds precision)
State
Defines PingContext life cycle states.
const TimeStamp & getSendWaitStart() const
Fetches the time the context went into WAITING_TO_SEND state.
static hooks::ParkingLotHandlePtr & EMPTY_LOT()
Fetches an empty parking lot handle.
const isc::asiolink::IOAddress & getTarget() const
Fetches the IP address that is under test.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
boost::shared_ptr< ParkingLotHandle > ParkingLotHandlePtr
Pointer to the parking lot handle.
boost::shared_ptr< PingContextCollection > PingContextCollectionPtr
Type for a pointer to a collection of PingContextPtrs.
std::vector< PingContextPtr > PingContextCollection
Type for a collection of PingContextPtrs.
std::chrono::time_point< std::chrono::system_clock > TimeStamp
Specifies the type for time stamps.
boost::multi_index_container< PingContextPtr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< AddressIndexTag >, boost::multi_index::const_mem_fun< PingContext, const isc::asiolink::IOAddress &, &PingContext::getTarget > >, boost::multi_index::ordered_unique< boost::multi_index::tag< QueryIndexTag >, boost::multi_index::const_mem_fun< PingContext, isc::dhcp::Pkt4Ptr, &PingContext::getQuery > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< NextToSendIndexTag >, boost::multi_index::composite_key< PingContext, boost::multi_index::const_mem_fun< PingContext, bool, &PingContext::isWaitingToSend >, boost::multi_index::const_mem_fun< PingContext, const TimeStamp &, &PingContext::getSendWaitStart > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ExpirationIndexTag >, boost::multi_index::composite_key< PingContext, boost::multi_index::const_mem_fun< PingContext, bool, &PingContext::isWaitingForReply >, boost::multi_index::const_mem_fun< PingContext, const TimeStamp &, &PingContext::getNextExpiry > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< StateIndexTag >, boost::multi_index::const_mem_fun< PingContext, PingContext::State, &PingContext::getState > > > > PingContextContainer
A multi index container holding pointers to PingContexts.
boost::shared_ptr< PingContext > PingContextPtr
Defines a shared pointer to a PingContext.
Defines the logger used by the top-level component of kea-lfc.
Tag for index by target address.
Tag for index by expiration time.
Tag for index by send wait start time.
Tag for index by the query packet.