7 #ifndef CLIENT_HANDLER_H
8 #define CLIENT_HANDLER_H
11 #include <boost/noncopyable.hpp>
12 #include <boost/multi_index_container.hpp>
13 #include <boost/multi_index/composite_key.hpp>
14 #include <boost/multi_index/hashed_index.hpp>
15 #include <boost/multi_index/member.hpp>
16 #include <boost/shared_ptr.hpp>
34 return (boost::make_shared<Continuation>(cont));
58 std::vector<uint8_t> duid_;
64 std::vector<uint8_t> hwaddr_;
67 std::thread::id thread_;
79 ContinuationPtr cont_;
83 typedef boost::shared_ptr<Client> ClientPtr;
86 typedef boost::multi_index_container<
92 boost::multi_index::indexed_by<
95 boost::multi_index::hashed_unique<
98 boost::multi_index::member<
99 Client, std::vector<uint8_t>, &Client::duid_
103 > ClientByIdContainer;
106 typedef boost::multi_index_container<
112 boost::multi_index::indexed_by<
115 boost::multi_index::hashed_unique<
118 boost::multi_index::composite_key<
120 boost::multi_index::member<
121 Client, uint16_t, &Client::htype_
123 boost::multi_index::member<
124 Client, std::vector<uint8_t>, &Client::hwaddr_
129 > ClientByHWAddrContainer;
137 static ClientPtr lookup(
const DuidPtr& duid);
145 static ClientPtr lookup(
const HWAddrPtr& hwaddr);
152 static void addById(
const ClientPtr& client);
159 static void addByHWAddr(
const ClientPtr& client);
166 static void del(
const DuidPtr& duid);
173 static void del(
const HWAddrPtr& hwaddr);
178 static std::mutex mutex_;
181 static ClientByIdContainer clients_client_id_;
184 static ClientByHWAddrContainer clients_hwaddr_;
233 void unLockByHWAddr();
248 #endif // CLIENT_HANDLER_H
boost::shared_ptr< DUID > DuidPtr
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
ClientHandler()
Public interface.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
virtual ~ClientHandler()
Destructor.
Client race avoidance RAII handler.
Defines the logger used by the top-level component of kea-dhcp-ddns.
bool tryLock(Pkt4Ptr query, ContinuationPtr cont=ContinuationPtr())
Tries to acquires a client.
std::function< void()> Continuation
Define the type of packet processing continuation.
boost::shared_ptr< Continuation > ContinuationPtr
Define the type of shared pointers to continuations.
ContinuationPtr makeContinuation(Continuation &&cont)
Continuation factory.