Public Member Functions | Data Fields | Protected Attributes

NetVConnection Class Reference

A VConnection for a network socket. More...

#include <I_NetVConnection.h>

Inherits VConnection.

Inherited by PluginVC, and UnixNetVConnection.

Collaboration diagram for NetVConnection:
Collaboration graph
[legend]

Public Member Functions

virtual VIOdo_io_read (Continuation *c, int64_t nbytes, MIOBuffer *buf)=0
 Initiates read.
virtual VIOdo_io_write (Continuation *c, int64_t nbytes, IOBufferReader *buf, bool owner=false)=0
 Initiates write.
virtual void do_io_close (int lerrno=-1)=0
 Closes the vconnection.
virtual void do_io_shutdown (ShutdownHowTo_t howto)=0
 Shuts down read side, write side, or both.
virtual Actionsend_OOB (Continuation *cont, char *buf, int len)
 Sends out of band messages over the connection.
virtual void cancel_OOB ()
 Cancels a scheduled send_OOB.
virtual void set_active_timeout (ink_hrtime timeout_in)=0
 Sets time after which SM should be notified.
virtual void set_inactivity_timeout (ink_hrtime timeout_in)=0
 Sets time after which SM should be notified if the requested IO could not be performed.
virtual void cancel_active_timeout ()=0
 Clears the active timeout.
virtual void cancel_inactivity_timeout ()=0
 Clears the inactivity timeout.
virtual ink_hrtime get_active_timeout ()=0
virtual ink_hrtime get_inactivity_timeout ()=0
sockaddr const * get_local_addr ()
 Returns local sockaddr storage.
in_addr_t get_local_ip ()
 Returns local ip.
uint16_t get_local_port ()
 Returns local port.
sockaddr const * get_remote_addr ()
 Returns remote sockaddr storage.
in_addr_t get_remote_ip ()
 Returns remote ip.
uint16_t get_remote_port ()
 Returns remote port.
virtual void apply_options ()=0
 Attempt to push any changed options down.
virtual void reenable (VIO *vio)=0
 PRIVATE: The public interface is VIO::reenable().
virtual void reenable_re (VIO *vio)=0
 PRIVATE: The public interface is VIO::reenable().
virtual ~NetVConnection ()
 PRIVATE.
 NetVConnection ()
 PRIVATE: instances of NetVConnection cannot be created directly by the state machines.
virtual SOCKET get_socket ()=0
virtual int set_tcp_init_cwnd (int init_cwnd)=0
 Set the TCP initial congestion window.
virtual void set_local_addr ()=0
 Set local sock addr struct.
virtual void set_remote_addr ()=0
 Set remote sock addr struct.
bool get_is_internal_request () const
void set_is_internal_request (bool val=false)
bool get_is_transparent () const
 Get the transparency state.
void set_is_transparent (bool state=true)
 Set the transparency state.

Data Fields

NetVCOptions options
 Structure holding user options.
SocksAddrType socks_addr
unsigned int attributes
EThreadthread

Protected Attributes

IpEndpoint local_addr
IpEndpoint remote_addr
bool got_local_addr
bool got_remote_addr
bool is_internal_request
bool is_transparent
 Set if this connection is transparent.

Detailed Description

A VConnection for a network socket.

Abstraction for a net connection. Similar to a socket descriptor VConnections are IO handles to streams. In one sense, they serve a purpose similar to file descriptors. Unlike file descriptors, VConnections allow for a stream IO to be done based on a single read or write call.

Definition at line 218 of file I_NetVConnection.h.


Constructor & Destructor Documentation

virtual NetVConnection::~NetVConnection (  )  [inline, virtual]

PRIVATE.

Definition at line 478 of file I_NetVConnection.h.

NetVConnection::NetVConnection (  )  [inline]

PRIVATE: instances of NetVConnection cannot be created directly by the state machines.

The objects are created by NetProcessor calls like accept connect_re() etc. The constructor is public just to avoid compile errors.

Definition at line 535 of file I_NetVConnection.h.

References local_addr, and remote_addr.


Member Function Documentation

virtual void NetVConnection::apply_options (  )  [pure virtual]
virtual void NetVConnection::cancel_active_timeout (  )  [pure virtual]

Clears the active timeout.

No active timeouts will be sent until set_active_timeout() is used to reset the active timeout.

Implemented in UnixNetVConnection.

Referenced by HttpClientSession::attach_server_session(), HttpClientSession::release(), and TSVConnActiveTimeoutCancel().

virtual void NetVConnection::cancel_inactivity_timeout (  )  [pure virtual]

Clears the inactivity timeout.

No inactivity timeouts will be sent until set_inactivity_timeout() is used to reset the inactivity timeout.

Implemented in UnixNetVConnection.

Referenced by HttpClientSession::attach_server_session(), HttpSM::set_next_state(), HttpSM::state_read_server_response_header(), and TSVConnInactivityTimeoutCancel().

void NetVConnection::cancel_OOB (  )  [virtual]

Cancels a scheduled send_OOB.

Part of the message could have been sent already. Not callbacks to the cont are made after this call. The Action returned by send_OOB should not be accessed after cancel_OOB.

Reimplemented in UnixNetVConnection.

Definition at line 42 of file NetVConnection.cc.

virtual void NetVConnection::do_io_close ( int  lerrno = -1  )  [pure virtual]

Closes the vconnection.

A state machine MUST call do_io_close() when it has finished with a VConenction. do_io_close() indicates that the VConnection can be deallocated. After a close has been called, the VConnection and underlying processor must NOT send any more events related to this VConnection to the state machine. Likeswise, state machine must not access the VConnectuion or any returned VIOs after calling close. lerrno indicates whether a close is a normal close or an abort. The difference between a normal close and an abort depends on the underlying type of the VConnection. Passing VIO::CLOSE for lerrno indicates a normal close while passing VIO::ABORT indicates an abort.

Parameters:
lerrno VIO:CLOSE for regular close or VIO::ABORT for aborts

Implements VConnection.

Implemented in UnixNetVConnection.

Referenced by HttpSessionAccept::accept(), HttpServerSession::do_io_close(), HttpClientSession::do_io_close(), Http2ClientSession::do_io_close(), KeepAliveConn::free(), NetTesterSM::handle_read(), NetTesterSM::handle_write(), ProtocolProbeTrampoline::ioCompletionEvent(), SocksProxy::mainEvent(), NetVCTest::read_finished(), NetVCTest::record_error(), and NetVCTest::write_finished().

virtual VIO* NetVConnection::do_io_read ( Continuation c,
int64_t  nbytes,
MIOBuffer buf 
) [pure virtual]

Initiates read.

Thread safe, may be called when not handling an event from the NetVConnection, or the NetVConnection creation callback.

Callbacks: non-reentrant, c's lock taken during callbacks.

c->handleEvent(VC_EVENT_READ_READY, vio)data added to buffer
c->handleEvent(VC_EVENT_READ_COMPLETE, vio)finished reading nbytes of data
c->handleEvent(VC_EVENT_EOS, vio)the stream has been shutdown
c->handleEvent(VC_EVENT_ERROR, vio)error

The vio returned during callbacks is the same as the one returned by do_io_read(). The vio can be changed only during call backs from the vconnection.

Parameters:
c continuation to be called back after (partial) read
nbytes no of bytes to read, if unknown set to INT64_MAX
buf buffer to put the data into
Returns:
vio

Implements VConnection.

Implemented in UnixNetVConnection.

Referenced by HttpClientSession::do_io_close(), HttpServerSession::do_io_read(), HttpClientSession::do_io_read(), Http2ClientSession::do_io_read(), ClusterState::doIO(), KeepAliveConn::handleEvent(), ProtocolProbeTrampoline::ioCompletionEvent(), SocksProxy::mainEvent(), NetTesterSM::NetTesterSM(), ObjectReloadCont::ObjectReloadEvent(), NetVCTest::start_test(), and HttpSM::state_read_client_request_header().

virtual void NetVConnection::do_io_shutdown ( ShutdownHowTo_t  howto  )  [pure virtual]

Shuts down read side, write side, or both.

do_io_shutdown() can be used to terminate one or both sides of the VConnection. The howto is one of IO_SHUTDOWN_READ, IO_SHUTDOWN_WRITE, IO_SHUTDOWN_READWRITE. Once a side of a VConnection is shutdown, no further I/O can be done on that side of the connections and the underlying processor MUST NOT send any further events (INCLUDING TIMOUT EVENTS) to the state machine. The state machine MUST NOT use any VIOs from a shutdown side of a connection. Even if both sides of a connection are shutdown, the state machine MUST still call do_io_close() when it wishes the VConnection to be deallocated.

Parameters:
howto IO_SHUTDOWN_READ, IO_SHUTDOWN_WRITE, IO_SHUTDOWN_READWRITE

Implements VConnection.

Implemented in UnixNetVConnection.

Referenced by HttpClientSession::do_io_close(), HttpServerSession::do_io_shutdown(), HttpClientSession::do_io_shutdown(), Http2ClientSession::do_io_shutdown(), NetVCTest::read_finished(), and NetVCTest::write_finished().

virtual VIO* NetVConnection::do_io_write ( Continuation c,
int64_t  nbytes,
IOBufferReader buf,
bool  owner = false 
) [pure virtual]

Initiates write.

Thread-safe, may be called when not handling an event from the NetVConnection, or the NetVConnection creation callback.

Callbacks: non-reentrant, c's lock taken during callbacks.

c->handleEvent(VC_EVENT_WRITE_READY, vio) signifies data has written from the reader or there are no bytes available for the reader to write.
c->handleEvent(VC_EVENT_WRITE_COMPLETE, vio) signifies the amount of data indicated by nbytes has been read from the buffer
c->handleEvent(VC_EVENT_ERROR, vio) signified that error occured during write.

The vio returned during callbacks is the same as the one returned by do_io_write(). The vio can be changed only during call backs from the vconnection. The vconnection deallocates the reader when it is destroyed.

Parameters:
c continuation to be called back after (partial) write
nbytes no of bytes to write, if unknown msut be set to INT64_MAX
buf source of data
owner 
Returns:
vio pointer

Implements VConnection.

Implemented in UnixNetVConnection.

Referenced by HttpServerSession::do_io_write(), HttpClientSession::do_io_write(), Http2ClientSession::do_io_write(), ClusterState::doIO(), NetTesterSM::handle_read(), KeepAliveConn::handleEvent(), SocksProxy::mainEvent(), ObjectReloadCont::ObjectReloadEvent(), SocksProxy::sendResp(), and NetVCTest::start_test().

virtual ink_hrtime NetVConnection::get_active_timeout (  )  [pure virtual]
Returns:
the current active_timeout value in nanosecs

Implemented in UnixNetVConnection.

Referenced by ServerSessionPool::eventHandler(), and ServerSessionPool::releaseSession().

virtual ink_hrtime NetVConnection::get_inactivity_timeout (  )  [pure virtual]
Returns:
current inactivity_timeout value in nanosecs

Implemented in UnixNetVConnection.

Referenced by ServerSessionPool::eventHandler(), and ServerSessionPool::releaseSession().

bool NetVConnection::get_is_internal_request (  )  const [inline]

Definition at line 501 of file I_NetVConnection.h.

References is_internal_request.

Referenced by TSHttpIsInternalSession().

bool NetVConnection::get_is_transparent (  )  const [inline]

Get the transparency state.

Definition at line 510 of file I_NetVConnection.h.

References is_transparent.

Referenced by HttpSM::attach_client_session().

TS_INLINE sockaddr const * NetVConnection::get_local_addr (  ) 
TS_INLINE in_addr_t NetVConnection::get_local_ip (  ) 

Returns local ip.

Deprecated:
get_local_addr() should be used instead for AF_INET6 compatibility.

Definition at line 70 of file P_NetVConnection.h.

References ats_ip4_addr_cast(), ats_is_ip4(), and get_local_addr().

TS_INLINE uint16_t NetVConnection::get_local_port (  ) 

Returns local port.

Returns:
The local port in host order.

Definition at line 80 of file P_NetVConnection.h.

References ats_ip_port_host_order(), and get_local_addr().

Referenced by HttpSM::attach_client_session(), HttpTransact::HandleBlindTunnel(), and HttpTransact::initialize_state_variables_from_request().

TS_INLINE sockaddr const * NetVConnection::get_remote_addr (  ) 
TS_INLINE in_addr_t NetVConnection::get_remote_ip (  ) 

Returns remote ip.

Deprecated:
get_remote_addr() should be used instead for AF_INET6 compatibility.

Definition at line 37 of file P_NetVConnection.h.

References ats_ip4_addr_cast(), ats_is_ip4(), and get_remote_addr().

Referenced by ClusterAccept::ClusterAcceptMachine(), and LogCollationHostSM::LogCollationHostSM().

TS_INLINE uint16_t NetVConnection::get_remote_port (  ) 

Returns remote port.

Returns:
The remote port in host order.

Definition at line 48 of file P_NetVConnection.h.

References ats_ip_port_host_order(), and get_remote_addr().

Referenced by HttpSM::do_http_server_open(), and LogCollationHostSM::LogCollationHostSM().

virtual SOCKET NetVConnection::get_socket (  )  [pure virtual]
virtual void NetVConnection::reenable ( VIO vio  )  [pure virtual]

PRIVATE: The public interface is VIO::reenable().

Reimplemented from VConnection.

Implemented in UnixNetVConnection.

Referenced by HttpServerSession::reenable(), HttpClientSession::reenable(), and Http2ClientSession::reenable().

virtual void NetVConnection::reenable_re ( VIO vio  )  [pure virtual]

PRIVATE: The public interface is VIO::reenable().

Reimplemented from VConnection.

Implemented in UnixNetVConnection.

Action * NetVConnection::send_OOB ( Continuation cont,
char *  buf,
int  len 
) [virtual]

Sends out of band messages over the connection.

This function is used to send out of band messages (is this still useful?). cont is called back with VC_EVENT_OOB_COMPLETE - on successful send or VC_EVENT_EOS - if the other side has shutdown the connection. These callbacks could be re-entrant. Only one send_OOB can be in progress at any time for a VC.

Parameters:
cont to be called back with events.
buf message buffer.
len length of the message.

Reimplemented in UnixNetVConnection.

Definition at line 36 of file NetVConnection.cc.

virtual void NetVConnection::set_active_timeout ( ink_hrtime  timeout_in  )  [pure virtual]

Sets time after which SM should be notified.

Sets the amount of time (in nanoseconds) after which the state machine using the NetVConnection should receive a VC_EVENT_ACTIVE_TIMEOUT event. The timeout is value is ignored if neither the read side nor the write side of the connection is currently active. The timer is reset if the function is called repeatedly This call can be used by SMs to make sure that it does not keep any connections open for a really long time.

Timeout symantics:

Should a timeout occur, the state machine for the read side of the NetVConnection is signaled first assuming that a read has been initiated on the NetVConnection and that the read side of the NetVConnection has not been shutdown. Should either of the two conditions not be met, the NetProcessor will attempt to signal the write side. If a timeout is sent to the read side state machine and its handler, return EVENT_DONE, a timeout will not be sent to the write side. Should the return from the handler not be EVENT_DONE and the write side state machine is different (in terms of pointer comparison) from the read side state machine, the NetProcessor will try to signal the write side state machine as well. To signal write side, a write must have been initiated on it and the write must not have been shutdown.

Receiving a timeout is only a notification that the timer has expired. The NetVConnection is still usable. Further timeouts of the type signaled will not be generated unless the timeout is reset via the set_active_timeout() or set_inactivity_timeout() interfaces.

Implemented in UnixNetVConnection.

Referenced by HttpSM::attach_client_session(), HttpSM::attach_server_session(), HttpClientSession::do_io_close(), ServerSessionPool::eventHandler(), ServerSessionPool::releaseSession(), NetVCTest::start_test(), HttpSM::state_raw_http_server_open(), and TSVConnActiveTimeoutSet().

virtual void NetVConnection::set_inactivity_timeout ( ink_hrtime  timeout_in  )  [pure virtual]

Sets time after which SM should be notified if the requested IO could not be performed.

Sets the amount of time (in nanoseconds), if the NetVConnection is idle on both the read or write side, after which the state machine using the NetVConnection should receive a VC_EVENT_INACTIVITY_TIMEOUT event. Either read or write traffic will cause timer to be reset. Calling this function again also resets the timer. The timeout is value is ignored if neither the read side nor the write side of the connection is currently active. See section on timeout semantics above.

Implemented in UnixNetVConnection.

Referenced by HttpSM::attach_client_session(), HttpSM::attach_server_session(), ServerSessionPool::eventHandler(), HttpSM::handle_api_return(), KeepAliveConn::handleEvent(), SpdyClientSession::init(), HttpClientSession::release(), ServerSessionPool::releaseSession(), NetVCTest::start_test(), HttpSM::state_raw_http_server_open(), HttpSM::state_read_client_request_header(), HttpSM::state_read_server_response_header(), and TSVConnInactivityTimeoutSet().

void NetVConnection::set_is_internal_request ( bool  val = false  )  [inline]
void NetVConnection::set_is_transparent ( bool  state = true  )  [inline]
virtual void NetVConnection::set_local_addr (  )  [pure virtual]

Set local sock addr struct.

Implemented in UnixNetVConnection.

Referenced by get_local_addr().

virtual void NetVConnection::set_remote_addr (  )  [pure virtual]

Set remote sock addr struct.

Implemented in UnixNetVConnection.

Referenced by get_remote_addr().

virtual int NetVConnection::set_tcp_init_cwnd ( int  init_cwnd  )  [pure virtual]

Set the TCP initial congestion window.

Implemented in UnixNetVConnection.


Field Documentation

Reimplemented in UnixNetVConnection.

Definition at line 526 of file I_NetVConnection.h.

Referenced by get_local_addr().

Definition at line 529 of file I_NetVConnection.h.

Referenced by get_is_internal_request(), and set_is_internal_request().

Set if this connection is transparent.

Definition at line 531 of file I_NetVConnection.h.

Referenced by get_is_transparent(), and set_is_transparent().

Definition at line 466 of file I_NetVConnection.h.

Referenced by SocksProxy::mainEvent(), and SocksProxy::setupHttpRequest().


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