#include <Connection.h>

Inheritance diagram for Comm::Connection:
Collaboration diagram for Comm::Connection:

Public Types

typedef RefCount< CodeContextPointer
 

Public Member Functions

 Connection ()
 
virtual ~Connection ()
 
 Connection (const Connection &&)=delete
 
ConnectionPointer cloneProfile () const
 Create a new closed Connection with the same configuration as this one. More...
 
void enterOrphanage ()
 close the still-open connection when its last reference is gone More...
 
void leaveOrphanage ()
 resume relying on owner(s) to initiate an explicit connection closure More...
 
void close ()
 
void noteClosure ()
 
bool isOpen () const
 
void setAddrs (const Ip::Address &aLocal, const Ip::Address &aRemote)
 
CachePeergetPeer () const
 
void setPeer (CachePeer *p)
 
time_t startTime () const
 
time_t lifeTime () const
 
time_t timeLeft (const time_t idleTimeout) const
 
time_t connectTimeout (const time_t fwdStart) const
 
void noteStart ()
 
Security::NegotiationHistorytlsNegotiations ()
 
const Security::NegotiationHistoryhasTlsNegotiations () const
 
virtual ScopedId codeContextGist () const override
 
virtual std::ostream & detailCodeContext (std::ostream &os) const override
 appends human-friendly context description line(s) to a cache.log record More...
 

Static Public Member Functions

static const PointerCurrent ()
 
static void Reset ()
 forgets the current context, setting it to nil/unknown More...
 
static void Reset (const Pointer)
 changes the current context; nil argument sets it to nil/unknown More...
 

Public Attributes

Ip::Address local
 
Ip::Address remote
 
hier_code peerType
 
int fd
 
tos_t tos
 
nfmark_t nfmark
 
nfmark_t nfConnmark = 0
 
int flags
 
char rfc931 [USER_IDENT_SZ]
 
Eui::Eui48 remoteEui48
 
Eui::Eui64 remoteEui64
 
InstanceId< Connection, uint64_t > id
 

Private Member Functions

 MEMPROXY_CLASS (Comm::Connection)
 

Static Private Member Functions

static void ForgetCurrent ()
 
static void Entering (const Pointer &codeCtx)
 
static void Leaving ()
 

Private Attributes

CachePeerpeer_
 
time_t startTime_
 
Security::NegotiationHistorytlsHistory
 

Detailed Description

Store data about the physical and logical attributes of a connection.

Some link state can be inferred from the data, however this is not an object for state data. But a semantic equivalent for FD with easily accessible cached properties not requiring repeated complex lookups.

Connection properties may be changed until the connection is opened. Properties should be considered read-only outside of the Comm layer code once the connection is open.

These objects should not be passed around directly, but a Comm::ConnectionPointer should be passed instead.

Definition at line 70 of file Connection.h.

Member Typedef Documentation

◆ Pointer

Definition at line 54 of file CodeContext.h.

Constructor & Destructor Documentation

◆ Connection() [1/2]

Comm::Connection::Connection ( )

Definition at line 32 of file Connection.cc.

References rfc931.

◆ ~Connection()

Comm::Connection::~Connection ( )
virtual

Clear the connection properties and close any open socket.

Definition at line 45 of file Connection.cc.

References cbdataReferenceDone, COMM_ORPHANED, debugs, and CachePeer::flags.

◆ Connection() [2/2]

Comm::Connection::Connection ( const Connection &&  )
delete

To prevent accidental copying of Connection objects that we started to open or that are open, use cloneProfile() instead.

Member Function Documentation

◆ cloneProfile()

Comm::ConnectionPointer Comm::Connection::cloneProfile ( ) const

◆ close()

void Comm::Connection::close ( )

Close any open socket.

Definition at line 105 of file Connection.cc.

References comm_close, and isOpen().

Referenced by Ftp::Server::acceptDataConnection(), ConnStateData::afterClientRead(), ConnStateData::clientAfterReadingRequests(), TunnelStateData::clientClosed(), ConnStateData::clientPinnedConnectionClosed(), ConnStateData::clientPinnedConnectionRead(), TunnelStateData::closeConnections(), HelperServerBase::closePipesSafely(), HttpStateData::closeServer(), FwdState::closeServerConnection(), HelperServerBase::closeWritePipeSafely(), FwdState::dispatch(), ConnStateData::endingShutdown(), Ftp::Gateway::ftpAcceptDataConnection(), ConnStateData::getSslContextDone(), gopherReadReply(), gopherSendComplete(), gopherTimeout(), PeerPoolMgr::handleOpenedConnection(), ConnStateData::handleRequestBodyData(), PeerPoolMgr::handleSecuredPeer(), ConnStateData::handleSslBumpHandshakeError(), Mgr::StoreToCommWriter::HandleStoreAbort(), httpsSslBumpAccessCheckDone(), httpsSslBumpStep2AccessCheckDone(), TunnelStateData::keepGoingAfterRead(), ConnStateData::kick(), ClientHttpRequest::noteBodyProducerAborted(), ConnStateData::parseTlsHandshake(), ConnStateData::requestTimeout(), TunnelStateData::retryOrBail(), ConnStateData::sendControlMsg(), ClientRequestContext::sslBumpAccessCheckDone(), ClientHttpRequest::sslBumpEstablish(), ConnStateData::stopReceiving(), ConnStateData::stopSending(), Server::swanSong(), ConnStateData::terminateAll(), tunnelErrorComplete(), whoisTimeout(), TunnelStateData::writeClientDone(), TunnelStateData::writeServerDone(), HttpControlMsgSink::wroteControlMsg(), Ftp::Server::wroteEarlyReply(), and Ftp::Server::wroteReply().

◆ codeContextGist()

ScopedId Comm::Connection::codeContextGist ( ) const
overridevirtual
Returns
a small, permanent ID of the current context gists persist forever and are suitable for passing to other SMP workers

Implements CodeContext.

Definition at line 184 of file Connection.cc.

◆ connectTimeout()

time_t Comm::Connection::connectTimeout ( const time_t  fwdStart) const

Connection establishment timeout for callers that have already decided to connect(2), either for the first time or after checking EnoughTimeToReForward() during any re-forwarding attempts.

Returns
the time left for this connection to become connected
Parameters
fwdStartThe start time of the peer selection/connection process.

Definition at line 164 of file Connection.cc.

References Config, SquidConfig::connect, CachePeer::connectTimeout(), FwdState::ForwardTimeout(), min(), and SquidConfig::Timeout.

Referenced by HappyConnOpener::openFreshConnection().

◆ Current()

◆ detailCodeContext()

std::ostream & Comm::Connection::detailCodeContext ( std::ostream &  os) const
overridevirtual

Implements CodeContext.

Definition at line 189 of file Connection.cc.

References Debug::Extra().

◆ Entering()

void CodeContext::Entering ( const Pointer codeCtx)
staticprivateinherited

Switches the current context to the given known context. Improves debugging output by replacing omni-directional "Reset" with directional "Entering".

Definition at line 54 of file CodeContext.cc.

References CodeContext::codeContextGist(), debugs, CodeContext::ForgetCurrent(), and Instance().

Referenced by CodeContext::Reset().

◆ enterOrphanage()

void Comm::Connection::enterOrphanage ( )
inline

◆ ForgetCurrent()

void CodeContext::ForgetCurrent ( )
staticprivateinherited

Forgets the current known context, possibly triggering its destruction. Preserves the gist of the being-forgotten context during its destruction. Knows nothing about the next context – the caller must set it.

Definition at line 42 of file CodeContext.cc.

References assert, FadingCodeContext::gist, and Instance().

Referenced by CodeContext::Entering(), and CodeContext::Leaving().

◆ getPeer()

◆ hasTlsNegotiations()

const Security::NegotiationHistory* Comm::Connection::hasTlsNegotiations ( ) const
inline

Definition at line 136 of file Connection.h.

References tlsHistory.

Referenced by Format::Format::assemble().

◆ isOpen()

bool Comm::Connection::isOpen ( ) const
inline

◆ leaveOrphanage()

void Comm::Connection::leaveOrphanage ( )
inline

◆ Leaving()

void CodeContext::Leaving ( )
staticprivateinherited

Forgets the current known context. Improves debugging output by replacing omni-directional "Reset" with directional "Leaving".

Definition at line 66 of file CodeContext.cc.

References debugs, CodeContext::ForgetCurrent(), and Instance().

Referenced by CodeContext::Reset().

◆ lifeTime()

time_t Comm::Connection::lifeTime ( ) const
inline

The connection lifetime

Definition at line 121 of file Connection.h.

References squid_curtime, and startTime_.

◆ MEMPROXY_CLASS()

Comm::Connection::MEMPROXY_CLASS ( Comm::Connection  )
private

◆ noteClosure()

void Comm::Connection::noteClosure ( )

◆ noteStart()

void Comm::Connection::noteStart ( )
inline

Definition at line 133 of file Connection.h.

References squid_curtime, and startTime_.

◆ Reset() [1/2]

◆ Reset() [2/2]

void CodeContext::Reset ( const Pointer  codeCtx)
staticinherited

◆ setAddrs()

void Comm::Connection::setAddrs ( const Ip::Address aLocal,
const Ip::Address aRemote 
)
inline

Alter the stored IP address pair. WARNING: Does not ensure matching IPv4/IPv6 are supplied.

Definition at line 104 of file Connection.h.

References local, and remote.

◆ setPeer()

void Comm::Connection::setPeer ( CachePeer p)

alter the stored CachePeer pointer. Perform appropriate CBDATA operations for locking the CachePeer pointer

Definition at line 133 of file Connection.cc.

References cbdataReference, and cbdataReferenceDone.

Referenced by PeerSelector::handlePath().

◆ startTime()

time_t Comm::Connection::startTime ( ) const
inline

The time the connection started

Definition at line 118 of file Connection.h.

References startTime_.

Referenced by PeerPoolMgr::handleOpenedConnection().

◆ timeLeft()

time_t Comm::Connection::timeLeft ( const time_t  idleTimeout) const

The time left for this connection

Definition at line 146 of file Connection.cc.

References Config, min(), SquidConfig::pconnLifetime, and SquidConfig::Timeout.

Referenced by ConnStateData::readNextRequest().

◆ tlsNegotiations()

Security::NegotiationHistory * Comm::Connection::tlsNegotiations ( )

Definition at line 156 of file Connection.cc.

Referenced by ConnStateData::parseTlsHandshake().

Member Data Documentation

◆ fd

int Comm::Connection::fd

Socket used by this connection. Negative if not open.

Definition at line 153 of file Connection.h.

Referenced by ClientHttpRequest::ClientHttpRequest(), Mgr::Forwarder::Forwarder(), HttpStateData::HttpStateData(), Mgr::Inquirer::Inquirer(), Snmp::Inquirer::Inquirer(), Security::PeerConnector::PeerConnector(), Mgr::StoreToCommWriter::StoreToCommWriter(), Ftp::Server::AcceptCtrlConnection(), Ftp::Server::acceptDataConnection(), ConnStateData::acceptTls(), ConnStateData::afterClientRead(), ClientInfo::applyQuota(), ConnStateData::clientAfterReadingRequests(), ClientRequestContext::clientRedirectDone(), Server::clientWriteDone(), HelperServerBase::closePipesSafely(), HttpStateData::closeServer(), FwdState::closeServerConnection(), HelperServerBase::closeWritePipeSafely(), Ftp::Server::connectedForData(), FwdState::connectedToPeer(), DeferredReadManager::delayRead(), FwdState::dispatch(), Server::doClientRead(), ConnStateData::doPeekAndSpliceStep(), ftpOpenListenSocket(), ConnStateData::getSslContextDone(), ConnStateData::getSslContextStart(), gopherStart(), Adaptation::Icap::Xaction::handleSecuredPeer(), PeerPoolMgr::handleSecuredPeer(), Ipc::Coordinator::handleSharedListenRequest(), helperHandleRead(), helperOpenServers(), helperStatefulHandleRead(), helperStatefulOpenServers(), httpAccept(), httpsAccept(), idnsDoSendQueryVC(), ConnStateData::isOpen(), isOpen(), ConnStateData::kick(), DeferredReadManager::kickARead(), ACLServerCertificateStrategy::match(), HttpStateData::maybeReadVirginBody(), Ip::Intercept::NetfilterInterception(), ClientHttpRequest::noteAdaptationAclCheckDone(), Snmp::Inquirer::noteCommClosed(), FwdState::noteConnection(), TunnelStateData::noteConnection(), TunnelStateData::noteSecurityPeerConnectorAnswer(), Comm::TcpAcceptor::oldAccept(), operator<<(), helper::packStatsInto(), ConnStateData::parseTlsHandshake(), ConnStateData::pinConnection(), DeferredReadManager::popHead(), HttpStateData::proceedAfter1xx(), HttpStateData::processReplyBody(), ConnStateData::readNextRequest(), Comm::ReadNow(), HttpStateData::readReply(), Ftp::Server::readUploadData(), ClientInfo::scheduleWrite(), MessageBucket::scheduleWrite(), FwdState::serverClosed(), Ipc::SharedListenJoined(), ConnStateData::splice(), ConnStateData::sslCrtdHandleReply(), ConnStateData::start(), ConnStateData::startPeekAndSplice(), Server::stopReading(), ConnStateData::storeTlsContextToCache(), CommConnectCbParams::syncWithComm(), CommIoCbParams::syncWithComm(), FwdState::syncWithServerConn(), FwdState::tunnelEstablishmentDone(), TunnelStateData::tunnelEstablishmentDone(), ConnStateData::tunnelOnError(), ConnStateData::whenClientIpKnown(), and whoisStart().

◆ flags

◆ id

InstanceId<Connection, uint64_t> Comm::Connection::id

Definition at line 181 of file Connection.h.

Referenced by Format::Format::assemble(), and operator<<().

◆ local

◆ nfConnmark

nfmark_t Comm::Connection::nfConnmark = 0

Netfilter CONNMARK value previously retrieved from this connection In case of FTP, the CONNMARK will NOT be applied to data connections, for one main reason: the CONNMARK could be set by a third party like iptables and overwriting it in squid may cause side effects and break CONNMARK-based policy. In other words, data connection is related to control connection, but it's not the same.

Definition at line 169 of file Connection.h.

Referenced by Comm::TcpAcceptor::oldAccept().

◆ nfmark

nfmark_t Comm::Connection::nfmark

Netfilter MARK values currently sent on this connection In case of FTP, the MARK will be sent on data connections as well.

Definition at line 161 of file Connection.h.

Referenced by Format::Format::assemble().

◆ peer_

CachePeer* Comm::Connection::peer_
private

cache_peer data object (if any)

Definition at line 185 of file Connection.h.

◆ peerType

hier_code Comm::Connection::peerType

Hierarchy code for this connection link

Definition at line 150 of file Connection.h.

Referenced by PeerSelector::handlePath(), and HierarchyLogEntry::resetPeerNotes().

◆ remote

◆ remoteEui48

Eui::Eui48 Comm::Connection::remoteEui48

Definition at line 177 of file Connection.h.

Referenced by Format::Format::assemble(), and Comm::TcpAcceptor::oldAccept().

◆ remoteEui64

Eui::Eui64 Comm::Connection::remoteEui64

Definition at line 178 of file Connection.h.

Referenced by Format::Format::assemble(), and Comm::TcpAcceptor::oldAccept().

◆ rfc931

◆ startTime_

time_t Comm::Connection::startTime_
private

The time the connection object was created

Definition at line 188 of file Connection.h.

Referenced by lifeTime(), noteStart(), and startTime().

◆ tlsHistory

Security::NegotiationHistory* Comm::Connection::tlsHistory
private

TLS connection details

Definition at line 191 of file Connection.h.

Referenced by hasTlsNegotiations().

◆ tos

tos_t Comm::Connection::tos

Quality of Service TOS values currently sent on this connection

Definition at line 156 of file Connection.h.

Referenced by Format::Format::assemble().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors