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));
38class ClientHandler :
public boost::noncopyable {
58 std::vector<uint8_t> client_id_;
64 std::vector<uint8_t> hwaddr_;
67 std::thread::id thread_;
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::client_id_
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 ClientIdPtr& client_id);
145 static ClientPtr lookup(
const HWAddrPtr& hwaddr);
152 static void addById(
const ClientPtr& client);
159 static void addByHWAddr(
const ClientPtr& client);
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();
virtual ~ClientHandler()
Destructor.
bool tryLock(Pkt4Ptr query, ContinuationPtr cont=ContinuationPtr())
Tries to acquires a client.
ClientHandler()
Public interface.
std::function< void()> Continuation
Define the type of packet processing continuation.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
ContinuationPtr makeContinuation(Continuation &&cont)
Continuation factory.
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
boost::shared_ptr< ClientId > ClientIdPtr
Shared pointer to a Client ID.
boost::shared_ptr< Continuation > ContinuationPtr
Define the type of shared pointers to continuations.
Defines the logger used by the top-level component of kea-lfc.