OpenSDN source code
|
#include <tcp_session.h>
Classes | |
class | Reader |
Public Types | |
enum | Event { EVENT_NONE, ACCEPT, CONNECT_COMPLETE, CONNECT_FAILED, CLOSE } |
enum | Direction { ACTIVE, PASSIVE } |
typedef boost::asio::ip::tcp::socket | Socket |
typedef boost::asio::ip::tcp::socket::native_handle_type | NativeSocketType |
typedef boost::asio::ip::tcp::endpoint | Endpoint |
typedef boost::function< void(TcpSession *, Event)> | EventObserver |
typedef boost::asio::const_buffer | Buffer |
Public Member Functions | |
TcpSession (TcpServer *server, Socket *socket, bool async_read_ready=true, size_t buffer_send_size=TcpSession::kDefaultWriteBufferSize) | |
virtual bool | Send (const uint8_t *data, size_t size, size_t *sent) |
virtual bool | Connected (Endpoint remote) |
virtual void | Accepted () |
void | ConnectFailed () |
void | Close () |
virtual std::string | ToString () const |
virtual Socket * | socket () const |
NativeSocketType | sock_descriptor () |
TcpServer * | server () |
int32_t | local_port () const |
int32_t | remote_port () const |
void | set_observer (EventObserver observer) |
virtual void | ReleaseBuffer (Buffer buffer) |
virtual int | GetSessionInstance () const |
bool | IsEstablished () const |
bool | IsClosed () const |
bool | IsServerSession () |
Endpoint | remote_endpoint () const |
const std::string & | remote_addr_string () const |
Endpoint | local_endpoint () const |
const boost::system::error_code & | close_reason () const |
virtual boost::system::error_code | SetSocketOptions () |
void | set_read_on_connect (bool read) |
void | SessionEstablished (Endpoint remote, Direction direction) |
virtual void | AsyncReadStart () |
virtual void | SetDeferReader (bool defer_reader) |
virtual bool | IsReaderDeferred () const |
const io::SocketStats & | GetSocketStats () const |
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 (uint32_t peer_ip, const std::string &md5_password) |
int | ClearMd5SocketOption (uint32_t peer_ip) |
int | SetDscpSocketOption (uint8_t value) |
uint8_t | GetDscpValue () const |
const std::string & | ToUVEKey () const |
boost::system::error_code | SetTcpNoDelay () |
boost::system::error_code | SetTcpSendBufSize (uint32_t size) |
boost::system::error_code | SetTcpRecvBufSize (uint32_t size) |
Static Public Member Functions | |
static const uint8_t * | BufferData (const Buffer &buffer) |
static size_t | BufferSize (const Buffer &buffer) |
static bool | IsSocketErrorHard (const boost::system::error_code &ec) |
Static Public Attributes | |
static const int | kDefaultBufferSize = 16 * 1024 |
static const int | kDefaultWriteBufferSize = 32 * 1024 |
Protected Types | |
typedef boost::intrusive_ptr < TcpSession > | TcpSessionPtr |
typedef boost::asio::strand < boost::asio::io_context::executor_type > | Strand |
Protected Member Functions | |
void | AsyncReadStartInternal (TcpSessionPtr session) |
virtual Task * | CreateReaderTask (boost::asio::mutable_buffer, size_t) |
virtual | ~TcpSession () |
virtual void | OnRead (Buffer buffer)=0 |
virtual void | WriteReady (const boost::system::error_code &error) |
void | AsyncWriteInternal (TcpSessionPtr session) |
virtual void | AsyncReadSome () |
virtual size_t | GetReadBufferSize () const |
virtual size_t | ReadSome (boost::asio::mutable_buffer buffer, boost::system::error_code *error) |
virtual void | AsyncWrite (const uint8_t *data, std::size_t size) |
virtual int | reader_task_id () const |
bool | established () const |
EventObserver | observer () |
boost::system::error_code | SetSocketKeepaliveOptions (int keepalive_time, int keepalive_intvl, int keepalive_probes, int tcp_user_timeout_val=0) |
void | CloseInternal (const boost::system::error_code &ec, bool call_observer, bool notify_server=true) |
void | TriggerAsyncReadHandler () |
Static Protected Member Functions | |
static void | AsyncReadHandler (TcpSessionPtr session) |
static void | AsyncWriteHandler (TcpSessionPtr session, const boost::system::error_code &error, std::size_t bytes_transferred) |
Protected Attributes | |
tbb::mutex | mutex_ |
io::SocketStats | stats_ |
boost::scoped_ptr< Strand > | io_strand_ |
Private Types | |
typedef std::list < boost::asio::mutable_buffer > | BufferQueue |
Private Member Functions | |
void | ReleaseBufferLocked (Buffer buffer) |
void | SetEstablished (Endpoint remote, Direction dir) |
bool | IsClosedLocked () const |
bool | IsEstablishedLocked () const |
void | SetName () |
boost::asio::mutable_buffer | AllocateBuffer (size_t buffer_size) |
void | DeleteBuffer (boost::asio::mutable_buffer buffer) |
DISALLOW_COPY_AND_ASSIGN (TcpSession) | |
Static Private Member Functions | |
static void | WriteReadyInternal (TcpSessionPtr session, const boost::system::error_code &error, uint64_t block_start_time) |
Private Attributes | |
TcpServerPtr | server_ |
boost::scoped_ptr< Socket > | socket_ |
bool | read_on_connect_ |
bool | established_ |
bool | closed_ |
Endpoint | remote_ |
std::string | remote_addr_str_ |
Direction | direction_ |
BufferQueue | buffer_queue_ |
boost::system::error_code | close_reason_ |
tbb::mutex | obs_mutex_ |
EventObserver | observer_ |
boost::scoped_ptr < TcpMessageWriter > | writer_ |
tbb::atomic< int > | refcount_ |
std::string | name_ |
tbb::atomic< bool > | defer_reader_ |
std::string | uve_key_str_ |
tbb::atomic< bool > | write_blocked_ |
tbb::atomic< bool > | tcp_close_in_progress_ |
Static Private Attributes | |
static int | reader_task_id_ = -1 |
Friends | |
class | TcpServer |
class | TcpMessageWriter |
void | intrusive_ptr_add_ref (TcpSession *session) |
void | intrusive_ptr_release (TcpSession *session) |
Definition at line 42 of file tcp_session.h.
typedef boost::asio::const_buffer TcpSession::Buffer |
Definition at line 64 of file tcp_session.h.
|
private |
Definition at line 238 of file tcp_session.h.
typedef boost::asio::ip::tcp::endpoint TcpSession::Endpoint |
Definition at line 62 of file tcp_session.h.
typedef boost::function<void(TcpSession *, Event)> TcpSession::EventObserver |
Definition at line 63 of file tcp_session.h.
typedef boost::asio::ip::tcp::socket::native_handle_type TcpSession::NativeSocketType |
Definition at line 61 of file tcp_session.h.
typedef boost::asio::ip::tcp::socket TcpSession::Socket |
Definition at line 60 of file tcp_session.h.
|
protected |
Definition at line 229 of file tcp_session.h.
|
protected |
Definition at line 184 of file tcp_session.h.
Enumerator | |
---|---|
ACTIVE | |
PASSIVE |
Definition at line 55 of file tcp_session.h.
enum TcpSession::Event |
Enumerator | |
---|---|
EVENT_NONE | |
ACCEPT | |
CONNECT_COMPLETE | |
CONNECT_FAILED | |
CLOSE |
Definition at line 47 of file tcp_session.h.
TcpSession::TcpSession | ( | TcpServer * | server, |
Socket * | socket, | ||
bool | async_read_ready = true , |
||
size_t | buffer_send_size = TcpSession::kDefaultWriteBufferSize |
||
) |
|
protectedvirtual |
|
virtual |
|
private |
Definition at line 119 of file tcp_session.cc.
|
staticprotected |
|
protectedvirtual |
Reimplemented in SslSession.
Definition at line 192 of file tcp_session.cc.
|
virtual |
|
protected |
|
protectedvirtual |
Reimplemented in SslSession.
Definition at line 199 of file tcp_session.cc.
|
staticprotected |
Definition at line 378 of file tcp_session.cc.
|
protected |
Definition at line 417 of file tcp_session.cc.
|
inlinestatic |
Definition at line 113 of file tcp_session.h.
|
inlinestatic |
Definition at line 116 of file tcp_session.h.
int TcpSession::ClearMd5SocketOption | ( | uint32_t | peer_ip | ) |
void TcpSession::Close | ( | ) |
|
inline |
Definition at line 145 of file tcp_session.h.
|
protected |
|
virtual |
void TcpSession::ConnectFailed | ( | ) |
Definition at line 297 of file tcp_session.cc.
|
protectedvirtual |
Reimplemented in SslSession.
Definition at line 460 of file tcp_session.cc.
|
private |
Definition at line 126 of file tcp_session.cc.
|
private |
|
inlineprotected |
Definition at line 212 of file tcp_session.h.
uint8_t TcpSession::GetDscpValue | ( | ) | const |
|
protectedvirtual |
Reimplemented in SslSession.
Definition at line 475 of file tcp_session.cc.
void TcpSession::GetRxSocketStats | ( | SocketIOStats * | socket_stats | ) | const |
|
inline |
|
virtual |
Reimplemented in SandeshSession, BgpSession, XmppSession, MetadataClientSession, and MetadataServerSession.
Definition at line 530 of file tcp_session.cc.
|
inline |
Definition at line 162 of file tcp_session.h.
void TcpSession::GetTxSocketStats | ( | SocketIOStats * | socket_stats | ) | const |
|
inline |
|
inline |
Definition at line 125 of file tcp_session.h.
|
inlineprivate |
Definition at line 246 of file tcp_session.h.
|
inline |
Definition at line 120 of file tcp_session.h.
|
inlineprivate |
Definition at line 250 of file tcp_session.h.
|
inlinevirtual |
Definition at line 158 of file tcp_session.h.
|
inline |
Definition at line 130 of file tcp_session.h.
|
static |
Definition at line 742 of file tcp_session.cc.
TcpSession::Endpoint TcpSession::local_endpoint | ( | ) | const |
int32_t TcpSession::local_port | ( | ) | const |
|
inlineprotected |
Definition at line 214 of file tcp_session.h.
|
protectedpure virtual |
|
inlineprotectedvirtual |
Reimplemented in SandeshSession, OVSDB::OvsdbClientTcpSession, and OVSDB::OvsdbClientSslSession.
Definition at line 208 of file tcp_session.h.
|
protectedvirtual |
Reimplemented in SslSession.
Definition at line 468 of file tcp_session.cc.
|
virtual |
|
private |
|
inline |
Definition at line 139 of file tcp_session.h.
|
inline |
Definition at line 135 of file tcp_session.h.
int32_t TcpSession::remote_port | ( | ) | const |
|
virtual |
|
inline |
Definition at line 88 of file tcp_session.h.
void TcpSession::set_observer | ( | EventObserver | observer | ) |
|
inline |
Definition at line 151 of file tcp_session.h.
|
virtual |
int TcpSession::SetDscpSocketOption | ( | uint8_t | value | ) |
int TcpSession::SetMd5SocketOption | ( | uint32_t | peer_ip, |
const std::string & | md5_password | ||
) |
|
private |
|
protected |
|
virtual |
Reimplemented in SandeshSession.
Definition at line 868 of file tcp_session.cc.
error_code TcpSession::SetTcpNoDelay | ( | ) |
error_code TcpSession::SetTcpRecvBufSize | ( | uint32_t | size | ) |
error_code TcpSession::SetTcpSendBufSize | ( | uint32_t | size | ) |
|
inline |
Definition at line 87 of file tcp_session.h.
|
inlinevirtual |
Reimplemented in SslSession.
Definition at line 86 of file tcp_session.h.
|
inlinevirtual |
Reimplemented in SandeshSession.
Definition at line 83 of file tcp_session.h.
|
inline |
Definition at line 178 of file tcp_session.h.
|
protected |
|
protectedvirtual |
Reimplemented in SandeshSession, BgpSession, and XmppSession.
Definition at line 375 of file tcp_session.cc.
|
staticprivate |
|
friend |
Definition at line 292 of file tcp_session.h.
|
friend |
Definition at line 296 of file tcp_session.h.
|
friend |
Definition at line 235 of file tcp_session.h.
|
friend |
Definition at line 233 of file tcp_session.h.
|
private |
Definition at line 271 of file tcp_session.h.
|
private |
Definition at line 272 of file tcp_session.h.
|
private |
Definition at line 267 of file tcp_session.h.
|
private |
Definition at line 284 of file tcp_session.h.
|
private |
Definition at line 270 of file tcp_session.h.
|
private |
Definition at line 266 of file tcp_session.h.
|
protected |
Definition at line 230 of file tcp_session.h.
|
static |
Definition at line 44 of file tcp_session.h.
|
static |
Definition at line 45 of file tcp_session.h.
|
mutableprotected |
Definition at line 225 of file tcp_session.h.
|
private |
Definition at line 283 of file tcp_session.h.
|
private |
Definition at line 277 of file tcp_session.h.
|
private |
Definition at line 278 of file tcp_session.h.
|
private |
Definition at line 263 of file tcp_session.h.
|
staticprivate |
Definition at line 259 of file tcp_session.h.
|
private |
Definition at line 282 of file tcp_session.h.
|
private |
Definition at line 268 of file tcp_session.h.
|
private |
Definition at line 269 of file tcp_session.h.
|
private |
Definition at line 261 of file tcp_session.h.
|
private |
Definition at line 262 of file tcp_session.h.
|
protected |
Definition at line 226 of file tcp_session.h.
|
private |
Definition at line 287 of file tcp_session.h.
|
private |
Definition at line 285 of file tcp_session.h.
|
private |
Definition at line 286 of file tcp_session.h.
|
private |
Definition at line 280 of file tcp_session.h.