OpenSDN source code
bgp_session_manager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 #ifndef SRC_BGP_BGP_SESSION_MANAGER_H_
7 #define SRC_BGP_BGP_SESSION_MANAGER_H_
8 
9 #include <boost/asio/ip/tcp.hpp>
10 #include <boost/dynamic_bitset.hpp>
11 
12 #include "base/queue_task.h"
13 #include "base/address.h"
14 #include "io/tcp_server.h"
15 
16 class BgpPeer;
17 class BgpServer;
18 class BgpSession;
19 class TcpSession;
20 
21 class BgpSessionManager : public TcpServer {
22 public:
24  virtual ~BgpSessionManager();
25 
26  virtual TcpSession *CreateSession();
27  virtual bool Initialize(unsigned short port);
28  virtual bool Initialize(unsigned short port, const IpAddress &ip);
29  void Shutdown();
30  void Terminate();
31  bool MayDelete() const;
32 
33  void EnqueueWriteReady(BgpSession *session);
34 
35  BgpServer *server() { return server_; }
36 
37 protected:
38  virtual TcpSession *AllocSession(Socket *socket);
39  virtual bool AcceptSession(TcpSession *session);
40 
41 private:
42  friend class BgpServerUnitTest;
43 
44  BgpPeer *FindPeer(Endpoint remote);
45  bool ProcessSession(BgpSession *session);
46  bool ProcessWriteReady(TcpSessionPtr tcp_session);
47  void WorkQueueExitCallback(bool done);
48  size_t GetSessionQueueSize() const;
49  void SetSessionQueueDisable(bool disabled);
50 
54 
56 
58 };
59 
60 #endif // SRC_BGP_BGP_SESSION_MANAGER_H_
boost::asio::ip::address IpAddress
Definition: address.h:14
WorkQueue< TcpSessionPtr > write_ready_queue_
WorkQueue< BgpSession * > session_queue_
virtual TcpSession * AllocSession(Socket *socket)
bool ProcessWriteReady(TcpSessionPtr tcp_session)
DISALLOW_COPY_AND_ASSIGN(BgpSessionManager)
void WorkQueueExitCallback(bool done)
virtual TcpSession * CreateSession()
friend class BgpServerUnitTest
BgpSessionManager(EventManager *evm, BgpServer *server)
virtual bool Initialize(unsigned short port)
size_t GetSessionQueueSize() const
bool ProcessSession(BgpSession *session)
void SetSessionQueueDisable(bool disabled)
void EnqueueWriteReady(BgpSession *session)
BgpPeer * FindPeer(Endpoint remote)
virtual bool AcceptSession(TcpSession *session)
boost::asio::ip::tcp::endpoint Endpoint
Definition: tcp_server.h:31
boost::asio::ip::tcp::socket Socket
Definition: tcp_server.h:32
static EventManager evm
boost::intrusive_ptr< HttpClientSession > TcpSessionPtr
Definition: http_curl.cc:105