OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
nexthop_manager.h
Go to the documentation of this file.
1 /*
2  * A generic server interface to send notification about tunnel nexthops
3  * to interested clients. The server supports any number of clients. The
4  * communication occurs over a UNIX socket. The message is really a JSON
5  * frame:
6  *
7  0 1 2 3
8  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
9  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
10  | Length |
11  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
12  | |
13  | JSON text (variable) |
14  | |
15  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
16  *
17  * where the JSON text follows the format:
18  *
19  * {
20  * "<next hop 1 IP address>": {
21  * "action": <operation>
22  * },
23  * "<next hop 2 IP address>": {
24  * "action": <operation>
25  * },
26  * ...
27  * }
28  *
29  * <operation> can take one of the two values: "add" or "del", indicating
30  * whether the next hop has been added or deleted.
31  *
32  * One can test a sample client by running:
33  * sudo socat -s - UNIX-CONNECT:/var/run/contrail-nhserv.socket
34  */
35 #ifndef __AGENT_NHS_NEXTHOP_MANAGER_H__
36 #define __AGENT_NHS_NEXTHOP_MANAGER_H__
37 
38 #include "base/queue_task.h"
39 #include <boost/asio.hpp>
40 #include "cmn/agent_signal.h"
41 #include "db/db_entry.h"
42 #include "db/db_table.h"
43 #include "nexthop_server.h"
44 #include "oper/nexthop.h"
45 #include <queue>
46 
47 class DB;
48 class EventManager;
49 
50 /*
51  * Register for nexthop events from the global nexthop table.
52  * Receive nexthop notifications from the nexthop table and send to
53  * registered clients.
54  */
56 {
57  public:
58 
59  NexthopManager(EventManager *evm, const std::string &endpoint);
61 
62  void Initialize(DB *database);
63  void Terminate();
64 
65  private:
66 
67  /*
68  * Event observer for changes in the "db.nexthop.0" table.
69  */
70  void EventObserver(DBTablePartBase * db_part, DBEntryBase * entry);
71 
75 
76  boost::scoped_ptr<NexthopDBServer> nh_server_;
78 };
79 
80 #endif
void EventObserver(DBTablePartBase *db_part, DBEntryBase *entry)
NexthopManager(EventManager *evm, const std::string &endpoint)
int ListenerId
Definition: db_table.h:62
DISALLOW_COPY_AND_ASSIGN(NexthopManager)
boost::scoped_ptr< NexthopDBServer > nh_server_
Definition: db.h:24
void Initialize(DB *database)
DBTableBase::ListenerId nh_listener_
DBTableBase * nh_table_
EventManager * evm_
static EventManager evm