reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
resip::Connection Class Reference

Connection implements, via sockets, ConnectionBase for managed connections. More...

#include <Connection.hxx>

Inheritance diagram for resip::Connection:
[legend]

Public Member Functions

 Connection (Transport *transport, const Tuple &who, Socket socket, Compression &compression, bool isServer)
 
virtual ~Connection ()
 
Socket getSocket () const
 
virtual bool hasDataToRead ()
 always true – always add to fdset as read ready
 
virtual bool isGood ()
 has valid connection
 
virtual bool checkConnectionTimedout ()
 
virtual bool isWritable ()
 
virtual bool transportWrite ()
 
void requestWrite (SendData *sendData)
 queue data to write and add this to writable list
 
int performWrite ()
 send some or all of a queued data; remove from writable if completely written
 
bool performWrites (unsigned int max=0)
 Call performWrite() repeatedly, until either the send queue is exhausted, the write() call fails (probably because the fd is no longer ready to write), or a set number of writes has been performed.
 
void ensureWritable ()
 ensure that we are on the writeable list if required
 
int read ()
 move data from the connection to the buffer; move this to front of least recently used list.
 
bool performReads (unsigned int max=0)
 Call read() repeatedly, until an error occurs (because the fd is not ready to read, most likely).
 
void enableFlowTimer ()
 Ensures this connection is in the FlowTimer LRU list in the connection manager.
 
bool isFlowTimerEnabled ()
 
bool isServer () const
 
- Public Member Functions inherited from resip::ConnectionBase
 ConnectionBase (Transport *transport, const Tuple &who, Compression &compression=Compression::Disabled)
 
FlowKey getFlowKey () const
 
virtual Transport * transport () const
 
Tuple & who ()
 
const uint64_t & whenLastUsed ()
 
void resetLastUsed ()
 
void addAdditionalFailureString (const Data &additionalFailureString)
 
- Public Member Functions inherited from resip::IntrusiveListElement< P >
 IntrusiveListElement ()
 
virtual ~IntrusiveListElement ()
 
bool empty () const
 
iterator begin ()
 
iterator end ()
 
void push_front (P elem)
 
void push_back (P elem)
 
void remove ()
 
- Public Member Functions inherited from resip::IntrusiveListElement1< P >
 IntrusiveListElement1 ()
 
virtual ~IntrusiveListElement1 ()
 
bool empty () const
 
iterator begin ()
 
iterator end ()
 
void push_front (P elem)
 
void push_back (P elem)
 
void remove ()
 
- Public Member Functions inherited from resip::IntrusiveListElement2< P >
 IntrusiveListElement2 ()
 
virtual ~IntrusiveListElement2 ()
 
bool empty () const
 
iterator begin ()
 
iterator end ()
 
void push_front (P elem)
 
void push_back (P elem)
 
void remove ()
 
- Public Member Functions inherited from resip::IntrusiveListElement3< P >
 IntrusiveListElement3 ()
 
virtual ~IntrusiveListElement3 ()
 
bool empty () const
 
iterator begin ()
 
iterator end ()
 
void push_front (P elem)
 
void push_back (P elem)
 
void remove ()
 
- Public Member Functions inherited from resip::FdPollItemIf
 FdPollItemIf ()
 
virtual ~FdPollItemIf ()
 

Static Public Member Functions

static void setEnablePostConnectSocketFuncCall (bool enabled=true)
 
- Static Public Member Functions inherited from resip::ConnectionBase
static void setMessageSizeMax (size_t max)
 
- Static Public Member Functions inherited from resip::IntrusiveListElement< P >
static P makeList (P elem)
 
- Static Public Member Functions inherited from resip::IntrusiveListElement1< P >
static P makeList (P elem)
 
- Static Public Member Functions inherited from resip::IntrusiveListElement2< P >
static P makeList (P elem)
 
- Static Public Member Functions inherited from resip::IntrusiveListElement3< P >
static P makeList (P elem)
 

Public Attributes

bool mFirstWriteAfterConnectedPending
 

Static Public Attributes

static volatile bool mEnablePostConnectSocketFuncCall = false
 

Protected Member Functions

virtual int read (char *, const int)
 pure virtual, but need concrete Connection for book-ends of lists
 
virtual int write (const char *, const int)
 pure virtual, but need concrete Connection for book-ends of lists
 
virtual void onDoubleCRLF ()
 
virtual void onSingleCRLF ()
 
virtual void onWsClose (const Data &payload)
 
virtual void onWsPing (const Data &payload)
 
virtual void processPollEvent (FdPollEventMask mask)
 Virtual function of FdPollItemIf, called to process io events.
 
virtual void invokeAfterSocketCreationFunc () const
 
- Protected Member Functions inherited from resip::ConnectionBase
ConnState getCurrentState () const
 
bool preparseNewBytes (int bytesRead)
 
bool wsProcessHandshake (int bytesRead, bool &dropConnection)
 
bool wsProcessData (int bytesRead)
 
void wsParseCookies (CookieList &cookieList, const SipMessage *message)
 
void decompressNewBytes (int bytesRead)
 
std::pair< char *, size_t > getWriteBuffer ()
 
std::pair< char *, size_t > getCurrentWriteBuffer ()
 
char * getWriteBufferForExtraBytes (int bytesRead, int extraBytes)
 
void setBuffer (char *bytes, int count)
 
void setFailureReason (TransportFailure::FailureReason failReason, int subCode, const Data &failureString)
 
virtual ~ConnectionBase ()
 

Friends

class ConnectionManager
 
EncodeStream & operator<< (EncodeStream &strm, const resip::Connection &c)
 

Additional Inherited Members

- Public Types inherited from resip::ConnectionBase
enum  { ChunkSize = 8192 }
 
- Protected Types inherited from resip::ConnectionBase
enum  ConnState {
  NewMessage = 0 , ReadingHeaders , PartialBody , SigComp ,
  WebSocket , MAX
}
 
enum  TransmissionFormat {
  Unknown , Uncompressed , Compressed , WebSocketHandshake ,
  WebSocketData
}
 
- Protected Attributes inherited from resip::ConnectionBase
Data::size_type mSendPos
 
std::list< SendData * > mOutstandingSends
 
Transport * mTransport
 
Tuple mWho
 
TransportFailure::FailureReason mFailureReason
 
int mFailureSubCode
 
Data mFailureString
 
std::list< Data > mAdditionalFailureStrings
 
Compression & mCompression
 
osc::Stack * mSigcompStack
 
osc::TcpStream * mSigcompFramer
 
TransmissionFormat mSendingTransmissionFormat
 
TransmissionFormat mReceivingTransmissionFormat
 
- Protected Attributes inherited from resip::IntrusiveListElement< P >
P mNext
 
P mPrev
 
- Protected Attributes inherited from resip::IntrusiveListElement1< P >
P mNext
 
P mPrev
 
- Protected Attributes inherited from resip::IntrusiveListElement2< P >
P mNext
 
P mPrev
 
- Protected Attributes inherited from resip::IntrusiveListElement3< P >
P mNext
 
P mPrev
 

Detailed Description

Connection implements, via sockets, ConnectionBase for managed connections.

Connections are managed for approximate fairness and least recently used garbage collection. Connection inherits three different instantiations of intrusive lists.

Definition at line 36 of file Connection.hxx.

Constructor & Destructor Documentation

◆ Connection()

Connection::Connection ( Transport *  transport,
const Tuple &  who,
Socket  socket,
Compression &  compression,
bool  isServer 
)

Definition at line 34 of file Connection.cxx.

◆ ~Connection()

Connection::~Connection ( )
virtual

Definition at line 59 of file Connection.cxx.

Member Function Documentation

◆ checkConnectionTimedout()

bool Connection::checkConnectionTimedout ( )
virtual

Definition at line 549 of file Connection.cxx.

◆ enableFlowTimer()

void Connection::enableFlowTimer ( )

Ensures this connection is in the FlowTimer LRU list in the connection manager.

Definition at line 484 of file Connection.cxx.

◆ ensureWritable()

void Connection::ensureWritable ( )

ensure that we are on the writeable list if required

Definition at line 348 of file Connection.cxx.

◆ getSocket()

Socket resip::Connection::getSocket ( ) const
inline
Note
Right now, Connection is assumed to be a TCP connection. This means that there is a 1-1 correspondence between FD and Connection. If this changes down the line (say, if we use this class to do SCTP connections), we can just remove this function.

Definition at line 57 of file Connection.hxx.

◆ hasDataToRead()

bool Connection::hasDataToRead ( )
virtual

always true – always add to fdset as read ready

Reimplemented in resip::TlsConnection, and resip::TcpConnection.

Definition at line 537 of file Connection.cxx.

◆ invokeAfterSocketCreationFunc()

void Connection::invokeAfterSocketCreationFunc ( ) const
protectedvirtual

Definition at line 633 of file Connection.cxx.

◆ isFlowTimerEnabled()

bool resip::Connection::isFlowTimerEnabled ( )
inline

Definition at line 102 of file Connection.hxx.

◆ isGood()

bool Connection::isGood ( )
virtual

has valid connection

Reimplemented in resip::TlsConnection, and resip::TcpConnection.

Definition at line 543 of file Connection.cxx.

◆ isServer()

bool Connection::isServer ( ) const

Definition at line 627 of file Connection.cxx.

◆ isWritable()

bool Connection::isWritable ( )
virtual

Reimplemented in resip::TlsConnection, and resip::TcpConnection.

Definition at line 577 of file Connection.cxx.

◆ onDoubleCRLF()

void Connection::onDoubleCRLF ( )
protectedvirtual

Reimplemented from resip::ConnectionBase.

Definition at line 496 of file Connection.cxx.

◆ onSingleCRLF()

void Connection::onSingleCRLF ( )
protectedvirtual

Reimplemented from resip::ConnectionBase.

Definition at line 508 of file Connection.cxx.

◆ onWsClose()

void Connection::onWsClose ( const Data &  payload)
protectedvirtual

Reimplemented from resip::ConnectionBase.

Definition at line 515 of file Connection.cxx.

◆ onWsPing()

void Connection::onWsPing ( const Data &  payload)
protectedvirtual

Reimplemented from resip::ConnectionBase.

Definition at line 528 of file Connection.cxx.

◆ performReads()

bool Connection::performReads ( unsigned int  max = 0)

Call read() repeatedly, until an error occurs (because the fd is not ready to read, most likely).

Parameters
maxThe maximum number of reads to perform. 0 indicates that there is no limit.
Returns
false iff this connection has deleted itself.

Definition at line 464 of file Connection.cxx.

◆ performWrite()

int Connection::performWrite ( )

send some or all of a queued data; remove from writable if completely written

Definition at line 94 of file Connection.cxx.

◆ performWrites()

bool Connection::performWrites ( unsigned int  max = 0)

Call performWrite() repeatedly, until either the send queue is exhausted, the write() call fails (probably because the fd is no longer ready to write), or a set number of writes has been performed.

Parameters
maxThe maximum number of writes to perform. 0 indicates that there is no limit.
Returns
false iff this connection has deleted itself.

Definition at line 332 of file Connection.cxx.

◆ processPollEvent()

void Connection::processPollEvent ( FdPollEventMask  mask)
protectedvirtual

Virtual function of FdPollItemIf, called to process io events.

Implements resip::FdPollItemIf.

Definition at line 586 of file Connection.cxx.

◆ read() [1/2]

int Connection::read ( )

move data from the connection to the buffer; move this to front of least recently used list.

when the message is complete, it is delivered via mTransport->pushRxMsgUp() which generally puts it on a fifo

Definition at line 375 of file Connection.cxx.

◆ read() [2/2]

virtual int resip::Connection::read ( char *  ,
const int   
)
inlineprotectedvirtual

pure virtual, but need concrete Connection for book-ends of lists

Reimplemented in resip::TlsConnection, and resip::TcpConnection.

Definition at line 115 of file Connection.hxx.

◆ requestWrite()

void Connection::requestWrite ( SendData *  sendData)

queue data to write and add this to writable list

Definition at line 70 of file Connection.cxx.

◆ setEnablePostConnectSocketFuncCall()

static void resip::Connection::setEnablePostConnectSocketFuncCall ( bool  enabled = true)
inlinestatic

Definition at line 107 of file Connection.hxx.

◆ transportWrite()

virtual bool resip::Connection::transportWrite ( )
inlinevirtual

Reimplemented in resip::TlsConnection.

Definition at line 65 of file Connection.hxx.

◆ write()

virtual int resip::Connection::write ( const char *  ,
const int   
)
inlineprotectedvirtual

pure virtual, but need concrete Connection for book-ends of lists

Reimplemented in resip::TlsConnection, and resip::TcpConnection.

Definition at line 117 of file Connection.hxx.

Friends And Related Symbol Documentation

◆ ConnectionManager

friend class ConnectionManager
friend

Definition at line 43 of file Connection.hxx.

◆ operator<<

EncodeStream & operator<< ( EncodeStream &  strm,
const resip::Connection &  c 
)
friend

Member Data Documentation

◆ mEnablePostConnectSocketFuncCall

volatile bool Connection::mEnablePostConnectSocketFuncCall = false
static

Definition at line 105 of file Connection.hxx.

◆ mFirstWriteAfterConnectedPending

bool resip::Connection::mFirstWriteAfterConnectedPending

Definition at line 104 of file Connection.hxx.


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