OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TcpServer Class Referenceabstract

#include <tcp_server.h>

Inheritance diagram for TcpServer:
Collaboration diagram for TcpServer:

Classes

struct  TcpSessionPtrCmp
 

Public Types

typedef
boost::asio::ip::tcp::endpoint 
Endpoint
 
typedef
boost::asio::ip::tcp::socket 
Socket
 
typedef
boost::asio::ip::tcp::socket::native_handle_type 
NativeSocketType
 

Public Member Functions

 TcpServer (EventManager *evm)
 
virtual ~TcpServer ()
 
virtual bool Initialize (unsigned short port)
 
virtual bool Initialize (unsigned short port, const IpAddress &host_ip, int intf_id=-1)
 
bool InitializeInternal (boost::asio::ip::tcp::endpoint localaddr)
 
const std::string ToString () const
 
void SetAcceptor ()
 
void ResetAcceptor ()
 
void Shutdown ()
 
void ClearSessions ()
 
void UpdateSessionsDscp (uint8_t dscp)
 
virtual TcpSessionCreateSession ()
 
virtual void DeleteSession (TcpSession *session)
 
virtual void Connect (TcpSession *session, Endpoint remote)
 
virtual bool DisableSandeshLogMessages () const
 
int GetPort () const
 
const io::SocketStatsGetSocketStats () const
 
size_t GetSessionCount () const
 
EventManagerevent_manager ()
 
bool HasSessionReadAvailable () const
 
bool HasSessions () const
 
TcpSessionGetSession (Endpoint remote)
 
void WaitForEmpty ()
 
void GetRxSocketStats (SocketIOStats *socket_stats) const
 
void GetTxSocketStats (SocketIOStats *socket_stats) const
 
void GetRxSocketStats (SocketIOStats &socket_stats) const
 
void GetTxSocketStats (SocketIOStats &socket_stats) const
 
int SetMd5SocketOption (NativeSocketType fd, uint32_t peer_ip, const std::string &md5_password)
 
int SetListenSocketMd5Option (uint32_t peer_ip, const std::string &md5_password)
 
int SetDscpSocketOption (NativeSocketType fd, uint8_t value)
 
uint8_t GetDscpValue (NativeSocketType fd) const
 
int SetListenSocketDscp (uint8_t value)
 
int SetSocketOptions (const SandeshConfig &sandesh_config)
 
int SetKeepAliveSocketOption (int fd, const SandeshConfig &sandesh_config)
 

Protected Types

typedef boost::intrusive_ptr
< TcpServer
TcpServerPtr
 
typedef boost::intrusive_ptr
< TcpSession
TcpSessionPtr
 

Protected Member Functions

virtual TcpSessionAllocSession (Socket *socket)=0
 
virtual TcpSessionAllocSession (bool server_session)
 
virtual Socketaccept_socket () const
 
virtual void set_accept_socket ()
 
virtual bool AcceptSession (TcpSession *session)
 
void set_socket_open_failure (bool flag)
 
bool socket_open_failure () const
 
Endpoint LocalEndpoint () const
 
virtual void AcceptHandlerComplete (TcpSessionPtr session)
 
virtual void ConnectHandlerComplete (TcpSessionPtr session)
 

Private Types

typedef std::set
< TcpSessionPtr,
TcpSessionPtrCmp
SessionSet
 
typedef std::multimap
< Endpoint, TcpSession * > 
SessionMap
 

Private Member Functions

void InsertSessionToMap (Endpoint remote, TcpSession *session)
 
bool RemoveSessionFromMap (Endpoint remote, TcpSession *session)
 
void AcceptHandlerInternal (TcpServerPtr server, const boost::system::error_code &error)
 
void ConnectHandler (TcpServerPtr server, TcpSessionPtr session, const boost::system::error_code &error)
 
void AsyncAccept ()
 
void OnSessionClose (TcpSession *session)
 
void SetName (Endpoint local_endpoint)
 
 DISALLOW_COPY_AND_ASSIGN (TcpServer)
 

Private Attributes

io::SocketStats stats_
 
EventManagerevm_
 
tbb::mutex mutex_
 
tbb::interface5::condition_variable cond_var_
 
SessionSet session_ref_
 
SessionMap session_map_
 
std::unique_ptr< Socketso_accept_
 
boost::scoped_ptr
< boost::asio::ip::tcp::acceptor > 
acceptor_
 
tbb::atomic< int > refcount_
 
std::string name_
 
bool socket_open_failure_
 
int intf_id_
 

Friends

class TcpSession
 
class SslSession
 
class TcpMessageWriter
 
class BgpServerUnitTest
 
void intrusive_ptr_add_ref (TcpServer *server)
 
void intrusive_ptr_release (TcpServer *server)
 

Detailed Description

Definition at line 28 of file tcp_server.h.

Member Typedef Documentation

typedef boost::asio::ip::tcp::endpoint TcpServer::Endpoint

Definition at line 30 of file tcp_server.h.

typedef boost::asio::ip::tcp::socket::native_handle_type TcpServer::NativeSocketType

Definition at line 32 of file tcp_server.h.

typedef std::multimap<Endpoint, TcpSession *> TcpServer::SessionMap
private

Definition at line 156 of file tcp_server.h.

Definition at line 155 of file tcp_server.h.

typedef boost::asio::ip::tcp::socket TcpServer::Socket

Definition at line 31 of file tcp_server.h.

typedef boost::intrusive_ptr<TcpServer> TcpServer::TcpServerPtr
protected

Definition at line 110 of file tcp_server.h.

typedef boost::intrusive_ptr<TcpSession> TcpServer::TcpSessionPtr
protected

Definition at line 111 of file tcp_server.h.

Constructor & Destructor Documentation

TcpServer::TcpServer ( EventManager evm)
explicit

Definition at line 31 of file tcp_server.cc.

Here is the call graph for this function:

TcpServer::~TcpServer ( )
virtual

Definition at line 42 of file tcp_server.cc.

Member Function Documentation

TcpServer::Socket * TcpServer::accept_socket ( ) const
protectedvirtual

Reimplemented in SslServer.

Definition at line 336 of file tcp_server.cc.

void TcpServer::AcceptHandlerComplete ( TcpSessionPtr  session)
protectedvirtual

Reimplemented in SslServer.

Definition at line 405 of file tcp_server.cc.

Here is the call graph for this function:

void TcpServer::AcceptHandlerInternal ( TcpServerPtr  server,
const boost::system::error_code &  error 
)
private

Definition at line 354 of file tcp_server.cc.

Here is the call graph for this function:

bool TcpServer::AcceptSession ( TcpSession session)
protectedvirtual

Reimplemented in OVSDB::OvsdbClientSsl, XmppServer, SandeshServer, HttpServer, and BgpSessionManager.

Definition at line 344 of file tcp_server.cc.

virtual TcpSession* TcpServer::AllocSession ( Socket socket)
protectedpure virtual
TcpSession * TcpServer::AllocSession ( bool  server_session)
protectedvirtual

Reimplemented in SslServer.

Definition at line 319 of file tcp_server.cc.

Here is the call graph for this function:

void TcpServer::AsyncAccept ( )
private

Definition at line 261 of file tcp_server.cc.

Here is the call graph for this function:

void TcpServer::ClearSessions ( )

Definition at line 159 of file tcp_server.cc.

Here is the call graph for this function:

void TcpServer::Connect ( TcpSession session,
Endpoint  remote 
)
virtual

Definition at line 474 of file tcp_server.cc.

Here is the call graph for this function:

void TcpServer::ConnectHandler ( TcpServerPtr  server,
TcpSessionPtr  session,
const boost::system::error_code &  error 
)
private

Definition at line 439 of file tcp_server.cc.

Here is the call graph for this function:

void TcpServer::ConnectHandlerComplete ( TcpSessionPtr  session)
protectedvirtual

Reimplemented in SslServer.

Definition at line 451 of file tcp_server.cc.

Here is the call graph for this function:

TcpSession * TcpServer::CreateSession ( )
virtual

Reimplemented in HttpClient, XmppServer, XmppClient, SandeshServer, and BgpSessionManager.

Definition at line 188 of file tcp_server.cc.

Here is the call graph for this function:

void TcpServer::DeleteSession ( TcpSession session)
virtual

Definition at line 197 of file tcp_server.cc.

Here is the call graph for this function:

virtual bool TcpServer::DisableSandeshLogMessages ( ) const
inlinevirtual

Reimplemented in SandeshServer.

Definition at line 64 of file tcp_server.h.

TcpServer::DISALLOW_COPY_AND_ASSIGN ( TcpServer  )
private
EventManager* TcpServer::event_manager ( )
inline

Definition at line 76 of file tcp_server.h.

uint8_t TcpServer::GetDscpValue ( NativeSocketType  fd) const

Definition at line 552 of file tcp_server.cc.

Here is the call graph for this function:

int TcpServer::GetPort ( ) const

Definition at line 272 of file tcp_server.cc.

void TcpServer::GetRxSocketStats ( SocketIOStats *  socket_stats) const

Definition at line 639 of file tcp_server.cc.

Here is the call graph for this function:

void TcpServer::GetRxSocketStats ( SocketIOStats &  socket_stats) const
inline

Definition at line 91 of file tcp_server.h.

Here is the call graph for this function:

TcpSession * TcpServer::GetSession ( Endpoint  remote)

Definition at line 430 of file tcp_server.cc.

size_t TcpServer::GetSessionCount ( ) const
inline

Definition at line 72 of file tcp_server.h.

const io::SocketStats& TcpServer::GetSocketStats ( ) const
inline

Definition at line 67 of file tcp_server.h.

void TcpServer::GetTxSocketStats ( SocketIOStats *  socket_stats) const

Definition at line 643 of file tcp_server.cc.

Here is the call graph for this function:

void TcpServer::GetTxSocketStats ( SocketIOStats &  socket_stats) const
inline

Definition at line 95 of file tcp_server.h.

Here is the call graph for this function:

bool TcpServer::HasSessionReadAvailable ( ) const

Definition at line 290 of file tcp_server.cc.

Here is the call graph for this function:

bool TcpServer::HasSessions ( ) const

Definition at line 285 of file tcp_server.cc.

bool TcpServer::Initialize ( unsigned short  port)
virtual

Reimplemented in BgpSessionManager.

Definition at line 59 of file tcp_server.cc.

Here is the call graph for this function:

bool TcpServer::Initialize ( unsigned short  port,
const IpAddress host_ip,
int  intf_id = -1 
)
virtual

Definition at line 65 of file tcp_server.cc.

Here is the call graph for this function:

bool TcpServer::InitializeInternal ( boost::asio::ip::tcp::endpoint  localaddr)

Definition at line 81 of file tcp_server.cc.

Here is the call graph for this function:

void TcpServer::InsertSessionToMap ( Endpoint  remote,
TcpSession session 
)
private

Definition at line 215 of file tcp_server.cc.

TcpServer::Endpoint TcpServer::LocalEndpoint ( ) const
protected

Definition at line 306 of file tcp_server.cc.

void TcpServer::OnSessionClose ( TcpSession session)
private

Definition at line 235 of file tcp_server.cc.

Here is the call graph for this function:

bool TcpServer::RemoveSessionFromMap ( Endpoint  remote,
TcpSession session 
)
private

Definition at line 224 of file tcp_server.cc.

void TcpServer::ResetAcceptor ( )

Definition at line 54 of file tcp_server.cc.

void TcpServer::set_accept_socket ( )
protectedvirtual

Reimplemented in SslServer.

Definition at line 340 of file tcp_server.cc.

Here is the call graph for this function:

void TcpServer::set_socket_open_failure ( bool  flag)
inlineprotected

Definition at line 133 of file tcp_server.h.

void TcpServer::SetAcceptor ( )
int TcpServer::SetDscpSocketOption ( NativeSocketType  fd,
uint8_t  value 
)

Definition at line 535 of file tcp_server.cc.

Here is the call graph for this function:

int TcpServer::SetKeepAliveSocketOption ( int  fd,
const SandeshConfig sandesh_config 
)

Definition at line 574 of file tcp_server.cc.

Here is the call graph for this function:

int TcpServer::SetListenSocketDscp ( uint8_t  value)

Definition at line 527 of file tcp_server.cc.

Here is the call graph for this function:

int TcpServer::SetListenSocketMd5Option ( uint32_t  peer_ip,
const std::string &  md5_password 
)

Definition at line 517 of file tcp_server.cc.

Here is the call graph for this function:

int TcpServer::SetMd5SocketOption ( NativeSocketType  fd,
uint32_t  peer_ip,
const std::string &  md5_password 
)

Definition at line 482 of file tcp_server.cc.

Here is the call graph for this function:

void TcpServer::SetName ( Endpoint  local_endpoint)
private

Definition at line 48 of file tcp_server.cc.

Here is the call graph for this function:

int TcpServer::SetSocketOptions ( const SandeshConfig sandesh_config)

Definition at line 566 of file tcp_server.cc.

Here is the call graph for this function:

void TcpServer::Shutdown ( void  )

Definition at line 143 of file tcp_server.cc.

Here is the call graph for this function:

bool TcpServer::socket_open_failure ( ) const
inlineprotected

Definition at line 134 of file tcp_server.h.

const std::string TcpServer::ToString ( ) const
inline

Definition at line 43 of file tcp_server.h.

void TcpServer::UpdateSessionsDscp ( uint8_t  dscp)

Definition at line 177 of file tcp_server.cc.

Here is the call graph for this function:

void TcpServer::WaitForEmpty ( )

Definition at line 254 of file tcp_server.cc.

Friends And Related Function Documentation

friend class BgpServerUnitTest
friend

Definition at line 145 of file tcp_server.h.

void intrusive_ptr_add_ref ( TcpServer server)
friend

Definition at line 193 of file tcp_server.h.

void intrusive_ptr_release ( TcpServer server)
friend

Definition at line 197 of file tcp_server.h.

friend class SslSession
friend

Definition at line 143 of file tcp_server.h.

friend class TcpMessageWriter
friend

Definition at line 144 of file tcp_server.h.

friend class TcpSession
friend

Definition at line 142 of file tcp_server.h.

Member Data Documentation

boost::scoped_ptr<boost::asio::ip::tcp::acceptor> TcpServer::acceptor_
private

Definition at line 182 of file tcp_server.h.

tbb::interface5::condition_variable TcpServer::cond_var_
private

Definition at line 178 of file tcp_server.h.

EventManager* TcpServer::evm_
private

Definition at line 175 of file tcp_server.h.

int TcpServer::intf_id_
private

Definition at line 186 of file tcp_server.h.

tbb::mutex TcpServer::mutex_
mutableprivate

Definition at line 177 of file tcp_server.h.

std::string TcpServer::name_
private

Definition at line 184 of file tcp_server.h.

tbb::atomic<int> TcpServer::refcount_
private

Definition at line 183 of file tcp_server.h.

SessionMap TcpServer::session_map_
private

Definition at line 180 of file tcp_server.h.

SessionSet TcpServer::session_ref_
private

Definition at line 179 of file tcp_server.h.

std::unique_ptr<Socket> TcpServer::so_accept_
private

Definition at line 181 of file tcp_server.h.

bool TcpServer::socket_open_failure_
private

Definition at line 185 of file tcp_server.h.

io::SocketStats TcpServer::stats_
private

Definition at line 174 of file tcp_server.h.


The documentation for this class was generated from the following files: