OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
nexthop_client.h
Go to the documentation of this file.
1 /*
2  * NexthopDBClient class: represents a client connecting to the nexthop-server
3  * interface for nexthop notifications.
4  */
5 #ifndef _AGENT_NHS_NEXTHOP_CLIENT_H_
6 #define _AGENT_NHS_NEXTHOP_CLIENT_H_
7 
8 #include <boost/array.hpp>
9 #include <boost/asio.hpp>
10 #include <boost/asio/signal_set.hpp>
11 #include <boost/bind.hpp>
12 #include <boost/enable_shared_from_this.hpp>
13 #include <boost/shared_ptr.hpp>
14 #include <cstdio>
15 #include <iostream>
16 #include "io/usock_server.h"
17 #include "nexthop_entry.h"
18 #include <tbb/mutex.h>
19 
20 class NexthopDBServer;
21 
22 /*
23  * Class to represent each client that connects to nexthop-server to
24  * receive nexthop notifications.
25  */
27 {
28  public:
29 
30  typedef boost::shared_ptr <NexthopDBClient> ClientPtr;
31  typedef std::vector <NexthopDBEntry::NexthopPtr> NexthopList;
32  typedef std::vector <NexthopDBEntry::NexthopPtr>::iterator
34 
35  NexthopDBClient(UnixDomainSocketSession *session, NexthopDBServer *server);
37 
41 
42  /*
43  * Handle events from the underlying (unix socket) session to this client
44  */
45  void EventHandler(UnixDomainSocketSession *,
47 
48  protected:
49  friend class NexthopDBServer;
50 
51  private:
52  UnixDomainSocketSession *session_;
54 
55  /*
56  * Each client object maintains its own vector of nexthops that need to be
57  * dispatched. The nexthop pointer is removed from the vector after the
58  * dispatch.
59  */
61 
62  void WriteMessage();
63  uint8_t *NextMessage(int *length);
64 };
65 
66 #endif
std::vector< NexthopDBEntry::NexthopPtr >::iterator NexthopListIterator
boost::shared_ptr< NexthopDBEntry > NexthopPtr
Definition: nexthop_entry.h:25
uint8_t * NextMessage(int *length)
std::vector< NexthopDBEntry::NexthopPtr > NexthopList
boost::shared_ptr< NexthopDBClient > ClientPtr
void RemoveNexthop(NexthopDBEntry::NexthopPtr nh)
NexthopDBServer * server_
Event
Definition: http_client.h:27
void EventHandler(UnixDomainSocketSession *, UnixDomainSocketSession::Event)
void AddNexthop(NexthopDBEntry::NexthopPtr nh)
bool FindNexthop(NexthopDBEntry::NexthopPtr nh)
NexthopList nexthop_list_
NexthopDBClient(UnixDomainSocketSession *session, NexthopDBServer *server)
UnixDomainSocketSession * session_