OpenSDN source code
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< TcpServerTcpServerPtr
 
typedef boost::intrusive_ptr< TcpSessionTcpSessionPtr
 

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, TcpSessionPtrCmpSessionSet
 
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

◆ Endpoint

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

Definition at line 30 of file tcp_server.h.

◆ NativeSocketType

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

Definition at line 32 of file tcp_server.h.

◆ SessionMap

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

Definition at line 156 of file tcp_server.h.

◆ SessionSet

Definition at line 155 of file tcp_server.h.

◆ Socket

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

Definition at line 31 of file tcp_server.h.

◆ TcpServerPtr

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

Definition at line 110 of file tcp_server.h.

◆ TcpSessionPtr

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

Definition at line 111 of file tcp_server.h.

Constructor & Destructor Documentation

◆ TcpServer()

TcpServer::TcpServer ( EventManager evm)
explicit

Definition at line 31 of file tcp_server.cc.

Here is the call graph for this function:

◆ ~TcpServer()

TcpServer::~TcpServer ( )
virtual

Definition at line 42 of file tcp_server.cc.

Member Function Documentation

◆ accept_socket()

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

Reimplemented in SslServer.

Definition at line 336 of file tcp_server.cc.

◆ AcceptHandlerComplete()

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:

◆ AcceptHandlerInternal()

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:

◆ AcceptSession()

bool TcpServer::AcceptSession ( TcpSession session)
protectedvirtual

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

Definition at line 344 of file tcp_server.cc.

◆ AllocSession() [1/2]

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:

◆ AllocSession() [2/2]

virtual TcpSession* TcpServer::AllocSession ( Socket socket)
protectedpure virtual

◆ AsyncAccept()

void TcpServer::AsyncAccept ( )
private

Definition at line 261 of file tcp_server.cc.

Here is the call graph for this function:

◆ ClearSessions()

void TcpServer::ClearSessions ( )

Definition at line 159 of file tcp_server.cc.

Here is the call graph for this function:

◆ Connect()

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:

◆ ConnectHandler()

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:

◆ ConnectHandlerComplete()

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:

◆ CreateSession()

TcpSession * TcpServer::CreateSession ( )
virtual

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

Definition at line 188 of file tcp_server.cc.

Here is the call graph for this function:

◆ DeleteSession()

void TcpServer::DeleteSession ( TcpSession session)
virtual

Definition at line 197 of file tcp_server.cc.

Here is the call graph for this function:

◆ DisableSandeshLogMessages()

virtual bool TcpServer::DisableSandeshLogMessages ( ) const
inlinevirtual

Reimplemented in SandeshServer.

Definition at line 64 of file tcp_server.h.

◆ DISALLOW_COPY_AND_ASSIGN()

TcpServer::DISALLOW_COPY_AND_ASSIGN ( TcpServer  )
private

◆ event_manager()

EventManager* TcpServer::event_manager ( )
inline

Definition at line 76 of file tcp_server.h.

◆ GetDscpValue()

uint8_t TcpServer::GetDscpValue ( NativeSocketType  fd) const

Definition at line 552 of file tcp_server.cc.

Here is the call graph for this function:

◆ GetPort()

int TcpServer::GetPort ( ) const

Definition at line 272 of file tcp_server.cc.

◆ GetRxSocketStats() [1/2]

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:

◆ GetRxSocketStats() [2/2]

void TcpServer::GetRxSocketStats ( SocketIOStats *  socket_stats) const

Definition at line 639 of file tcp_server.cc.

Here is the call graph for this function:

◆ GetSession()

TcpSession * TcpServer::GetSession ( Endpoint  remote)

Definition at line 430 of file tcp_server.cc.

◆ GetSessionCount()

size_t TcpServer::GetSessionCount ( ) const
inline

Definition at line 72 of file tcp_server.h.

◆ GetSocketStats()

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

Definition at line 67 of file tcp_server.h.

◆ GetTxSocketStats() [1/2]

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:

◆ GetTxSocketStats() [2/2]

void TcpServer::GetTxSocketStats ( SocketIOStats *  socket_stats) const

Definition at line 643 of file tcp_server.cc.

Here is the call graph for this function:

◆ HasSessionReadAvailable()

bool TcpServer::HasSessionReadAvailable ( ) const

Definition at line 290 of file tcp_server.cc.

Here is the call graph for this function:

◆ HasSessions()

bool TcpServer::HasSessions ( ) const

Definition at line 285 of file tcp_server.cc.

◆ Initialize() [1/2]

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:

◆ Initialize() [2/2]

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:

◆ InitializeInternal()

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:

◆ InsertSessionToMap()

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

Definition at line 215 of file tcp_server.cc.

◆ LocalEndpoint()

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

Definition at line 306 of file tcp_server.cc.

◆ OnSessionClose()

void TcpServer::OnSessionClose ( TcpSession session)
private

Definition at line 235 of file tcp_server.cc.

Here is the call graph for this function:

◆ RemoveSessionFromMap()

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

Definition at line 224 of file tcp_server.cc.

◆ ResetAcceptor()

void TcpServer::ResetAcceptor ( )

Definition at line 54 of file tcp_server.cc.

◆ set_accept_socket()

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:

◆ set_socket_open_failure()

void TcpServer::set_socket_open_failure ( bool  flag)
inlineprotected

Definition at line 133 of file tcp_server.h.

◆ SetAcceptor()

void TcpServer::SetAcceptor ( )

◆ SetDscpSocketOption()

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:

◆ SetKeepAliveSocketOption()

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:

◆ SetListenSocketDscp()

int TcpServer::SetListenSocketDscp ( uint8_t  value)

Definition at line 527 of file tcp_server.cc.

Here is the call graph for this function:

◆ SetListenSocketMd5Option()

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:

◆ SetMd5SocketOption()

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:

◆ SetName()

void TcpServer::SetName ( Endpoint  local_endpoint)
private

Definition at line 48 of file tcp_server.cc.

◆ SetSocketOptions()

int TcpServer::SetSocketOptions ( const SandeshConfig sandesh_config)

Definition at line 566 of file tcp_server.cc.

Here is the call graph for this function:

◆ Shutdown()

void TcpServer::Shutdown ( void  )

Definition at line 143 of file tcp_server.cc.

Here is the call graph for this function:

◆ socket_open_failure()

bool TcpServer::socket_open_failure ( ) const
inlineprotected

Definition at line 134 of file tcp_server.h.

◆ ToString()

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

Definition at line 43 of file tcp_server.h.

◆ UpdateSessionsDscp()

void TcpServer::UpdateSessionsDscp ( uint8_t  dscp)

Definition at line 177 of file tcp_server.cc.

Here is the call graph for this function:

◆ WaitForEmpty()

void TcpServer::WaitForEmpty ( )

Definition at line 254 of file tcp_server.cc.

Friends And Related Function Documentation

◆ BgpServerUnitTest

friend class BgpServerUnitTest
friend

Definition at line 145 of file tcp_server.h.

◆ intrusive_ptr_add_ref

void intrusive_ptr_add_ref ( TcpServer server)
friend

Definition at line 193 of file tcp_server.h.

◆ intrusive_ptr_release

void intrusive_ptr_release ( TcpServer server)
friend

Definition at line 197 of file tcp_server.h.

◆ SslSession

friend class SslSession
friend

Definition at line 143 of file tcp_server.h.

◆ TcpMessageWriter

friend class TcpMessageWriter
friend

Definition at line 144 of file tcp_server.h.

◆ TcpSession

friend class TcpSession
friend

Definition at line 142 of file tcp_server.h.

Member Data Documentation

◆ acceptor_

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

Definition at line 182 of file tcp_server.h.

◆ cond_var_

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

Definition at line 178 of file tcp_server.h.

◆ evm_

EventManager* TcpServer::evm_
private

Definition at line 175 of file tcp_server.h.

◆ intf_id_

int TcpServer::intf_id_
private

Definition at line 186 of file tcp_server.h.

◆ mutex_

tbb::mutex TcpServer::mutex_
mutableprivate

Definition at line 177 of file tcp_server.h.

◆ name_

std::string TcpServer::name_
private

Definition at line 184 of file tcp_server.h.

◆ refcount_

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

Definition at line 183 of file tcp_server.h.

◆ session_map_

SessionMap TcpServer::session_map_
private

Definition at line 180 of file tcp_server.h.

◆ session_ref_

SessionSet TcpServer::session_ref_
private

Definition at line 179 of file tcp_server.h.

◆ so_accept_

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

Definition at line 181 of file tcp_server.h.

◆ socket_open_failure_

bool TcpServer::socket_open_failure_
private

Definition at line 185 of file tcp_server.h.

◆ stats_

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: