OpenSDN source code
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/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 
19 using namespace boost::placeholders;
20 
21 class NexthopDBServer;
22 
23 /*
24  * Class to represent each client that connects to nexthop-server to
25  * receive nexthop notifications.
26  */
28 {
29  public:
30 
31  typedef boost::shared_ptr <NexthopDBClient> ClientPtr;
32  typedef std::vector <NexthopDBEntry::NexthopPtr> NexthopList;
33  typedef std::vector <NexthopDBEntry::NexthopPtr>::iterator
35 
36  NexthopDBClient(UnixDomainSocketSession *session, NexthopDBServer *server);
37  ~NexthopDBClient();
38 
39  void AddNexthop(NexthopDBEntry::NexthopPtr nh);
40  void RemoveNexthop(NexthopDBEntry::NexthopPtr nh);
41  bool FindNexthop(NexthopDBEntry::NexthopPtr nh);
42 
43  /*
44  * Handle events from the underlying (unix socket) session to this client
45  */
46  void EventHandler(UnixDomainSocketSession *,
48 
49  protected:
50  friend class NexthopDBServer;
51 
52  private:
53  UnixDomainSocketSession *session_;
55 
56  /*
57  * Each client object maintains its own vector of nexthops that need to be
58  * dispatched. The nexthop pointer is removed from the vector after the
59  * dispatch.
60  */
62 
63  void WriteMessage();
64  uint8_t *NextMessage(int *length);
65 };
66 
67 #endif
NexthopList nexthop_list_
std::vector< NexthopDBEntry::NexthopPtr >::iterator NexthopListIterator
boost::shared_ptr< NexthopDBClient > ClientPtr
UnixDomainSocketSession * session_
NexthopDBServer * server_
std::vector< NexthopDBEntry::NexthopPtr > NexthopList
boost::shared_ptr< NexthopDBEntry > NexthopPtr
Definition: nexthop_entry.h:26
Event
Definition: http_client.h:29