OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
nexthop_server.h
Go to the documentation of this file.
1 /*
2  * NexthopDBServer class: represents the master server interface that
3  * has a Nexthop DB store and a list of clients.
4  */
5 #ifndef _AGENT_NHS_NEXTHOP_SERVER_H_
6 #define _AGENT_NHS_NEXTHOP_SERVER_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/scoped_ptr.hpp>
14 #include <boost/shared_ptr.hpp>
15 #include <cstdio>
16 #include <iostream>
17 #include "io/usock_server.h"
18 #include "nexthop_client.h"
19 #include "nexthop_entry.h"
20 #include <tbb/mutex.h>
21 
22 /*
23  * The main server object for serving nexthops to connected clients.
24  */
26 {
27  public:
28 
29  typedef std::map <uint64_t, NexthopDBClient::ClientPtr> ClientDB;
30  typedef std::map <uint64_t, NexthopDBClient::ClientPtr>::iterator
32  typedef std::map <std::string, NexthopDBEntry::NexthopPtr> NexthopDB;
33  typedef std::map <std::string, NexthopDBEntry::NexthopPtr>::iterator
35 
36  NexthopDBServer(boost::asio::io_context &io, const std::string &path);
37 
38  NexthopDBEntry::NexthopPtr FindOrCreateNexthop(const std::string &str);
39  void FindAndRemoveNexthop(const std::string &str);
40  void Run();
41  void EventHandler(UnixDomainSocketServer *, UnixDomainSocketSession *,
43  void RemoveClient(uint64_t);
44 
45  private:
47  void TriggerClients();
50 
51  boost::asio::io_context &io_service_;
52  std::string endpoint_path_;
53  boost::scoped_ptr<UnixDomainSocketServer> io_server_;
56  tbb::mutex mutex_;
57 };
58 
59 #endif
ClientDB client_table_
void AddClient(NexthopDBClient::ClientPtr cl)
boost::scoped_ptr< UnixDomainSocketServer > io_server_
boost::shared_ptr< NexthopDBEntry > NexthopPtr
Definition: nexthop_entry.h:25
void FindAndRemoveNexthop(const std::string &str)
std::map< std::string, NexthopDBEntry::NexthopPtr > NexthopDB
void AddNexthop(NexthopDBEntry::NexthopPtr nh)
boost::shared_ptr< NexthopDBClient > ClientPtr
void EventHandler(UnixDomainSocketServer *, UnixDomainSocketSession *, UnixDomainSocketServer::Event)
std::map< uint64_t, NexthopDBClient::ClientPtr >::iterator ClientIterator
Event
Definition: http_client.h:27
NexthopDBEntry::NexthopPtr FindOrCreateNexthop(const std::string &str)
void RemoveNexthop(NexthopDBEntry::NexthopPtr nh)
std::map< uint64_t, NexthopDBClient::ClientPtr > ClientDB
std::string endpoint_path_
NexthopDB nexthop_table_
boost::asio::io_context & io_service_
void RemoveClient(uint64_t)
std::map< std::string, NexthopDBEntry::NexthopPtr >::iterator NexthopIterator
NexthopDBServer(boost::asio::io_context &io, const std::string &path)
tbb::mutex mutex_