dtn::CLConnection Class Reference

Helper class (and thread) that manages an established connection with a peer daemon. More...

#include <CLConnection.h>

Inheritance diagram for dtn::CLConnection:

dtn::CLInfo dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection

List of all members.

Classes

struct  CLMsg
 struct used for messages going from the daemon thread to the connection thread. More...
class  IncomingBundle
 Struct used to record bundles that are in the process of being received along with their transmission state and relevant acknowledgement data. More...
class  InFlightBundle
 Struct used to record bundles that are in-flight along with their transmission state and optionally acknowledgement data. More...

Public Types

typedef
ConnectionConvergenceLayer::LinkParams 
LinkParams

Public Member Functions

 CLConnection (const char *classname, const char *logpath, ConnectionConvergenceLayer *cl, LinkParams *params, bool active_connector)
 Constructor.
virtual ~CLConnection ()
void set_contact (const ContactRef &contact)
 Attach to the given contact.

Protected Types

enum  clmsg_t { CLMSG_INVALID = 0, CLMSG_BUNDLES_QUEUED = 1, CLMSG_CANCEL_BUNDLE = 2, CLMSG_BREAK_CONTACT = 3 }
 Enum for messages from the daemon thread to the connection thread. More...
typedef oasys::SparseBitmap
< u_int32_t > 
DataBitmap
 Typedef for bitmaps used to record sent/received/acked data.
typedef std::list
< InFlightBundle * > 
InFlightList
 Typedef for the list of in-flight bundles.
typedef std::list
< IncomingBundle * > 
IncomingList
 Typedef for the list of in-flight bundles.

Protected Member Functions

void run ()
 Main run loop.
void set_nexthop (const std::string &nexthop)
 Assignment function for the nexthop identifier.
virtual void connect ()=0
 Initiate a connection to the remote side.
virtual void accept ()
 Accept a connection from the remote side.
virtual void disconnect ()=0
 Shut down the connection.
virtual void initialize_pollfds ()=0
 Fill in the pollfds array with any file descriptors that should be waited on for activity from the peer.
virtual void handle_bundles_queued ()=0
 Handle notification that bundle(s) may be queued on the link.
virtual void handle_cancel_bundle (Bundle *b)=0
 Handle a cancel bundle request.
virtual bool send_pending_data ()=0
 Start or continue transmission of bundle data or cl acks.
virtual void handle_poll_activity ()=0
 Handle network activity from the remote side.
virtual void handle_poll_timeout ()=0
 Handle network activity from the remote side.
const char * clmsg_to_str (clmsg_t type)
 Message to string conversion.
virtual void contact_up ()
virtual void break_contact (ContactEvent::reason_t reason)
virtual void process_command ()
virtual bool find_contact (const EndpointID &peer_eid)

Protected Attributes

ContactRef contact_
 Ref to the Contact.
bool contact_up_
 Has contact_up been called.
oasys::SpinLock cmdqueue_lock_
 Lock for command queue.
oasys::MsgQueue< CLMsgcmdqueue_
 Daemon/CLConnection command queue.
ConnectionConvergenceLayercl_
 Pointer to the CL.
LinkParamsparams_
 Pointer to Link parameters, or to defaults until Link is bound.
bool active_connector_
 Should we connect() or accept().
std::string nexthop_
 Nexthop identifier set by CL.
int num_pollfds_
 Number of pollfds in use.
struct pollfd pollfds_ [MAXPOLL]
 Array of pollfds.
int poll_timeout_
 Timeout to wait for poll data.
oasys::StreamBuffer sendbuf_
 Buffer for outgoing data.
oasys::StreamBuffer recvbuf_
 Buffer for incoming data.
InFlightList inflight_
 Bundles going out the wire.
IncomingList incoming_
 Bundles arriving on the wire.
volatile bool contact_broken_
 Contact has been broken.
oasys::atomic_t num_pending_
 Bundles pending transmission.

Static Protected Attributes

static const int MAXPOLL = 8
 Maximum number of pollfds.

Friends

class ConnectionConvergenceLayer


Detailed Description

Helper class (and thread) that manages an established connection with a peer daemon.

Definition at line 38 of file CLConnection.h.


Member Typedef Documentation

typedef oasys::SparseBitmap<u_int32_t> dtn::CLConnection::DataBitmap [protected]

Typedef for bitmaps used to record sent/received/acked data.

Definition at line 189 of file CLConnection.h.

typedef std::list<IncomingBundle*> dtn::CLConnection::IncomingList [protected]

Typedef for the list of in-flight bundles.

Definition at line 253 of file CLConnection.h.

typedef std::list<InFlightBundle*> dtn::CLConnection::InFlightList [protected]

Typedef for the list of in-flight bundles.

Definition at line 223 of file CLConnection.h.

Definition at line 43 of file CLConnection.h.


Member Enumeration Documentation

enum dtn::CLConnection::clmsg_t [protected]

Enum for messages from the daemon thread to the connection thread.

Enumerator:
CLMSG_INVALID 
CLMSG_BUNDLES_QUEUED 
CLMSG_CANCEL_BUNDLE 
CLMSG_BREAK_CONTACT 

Definition at line 145 of file CLConnection.h.


Constructor & Destructor Documentation

dtn::CLConnection::CLConnection ( const char *  classname,
const char *  logpath,
ConnectionConvergenceLayer cl,
LinkParams params,
bool  active_connector 
)

dtn::CLConnection::~CLConnection (  )  [virtual]

Definition at line 55 of file CLConnection.cc.


Member Function Documentation

virtual void dtn::CLConnection::accept (  )  [inline, protected, virtual]

Accept a connection from the remote side.

For variants that don't implement interfaces, but require a link to be configured on both ends (e.g. serial), this will never be called, so the base class simple asserts NOTREACHED.

Reimplemented in dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection.

Definition at line 96 of file CLConnection.h.

Referenced by run().

void dtn::CLConnection::break_contact ( ContactEvent::reason_t  reason  )  [protected, virtual]

const char* dtn::CLConnection::clmsg_to_str ( clmsg_t  type  )  [inline, protected]

Message to string conversion.

Definition at line 155 of file CLConnection.h.

References CLMSG_BREAK_CONTACT, CLMSG_BUNDLES_QUEUED, CLMSG_CANCEL_BUNDLE, and CLMSG_INVALID.

virtual void dtn::CLConnection::connect (  )  [protected, pure virtual]

void dtn::CLConnection::contact_up (  )  [protected, virtual]

Utility functions, all virtual so subclasses could override them

Definition at line 221 of file CLConnection.cc.

References ASSERT, contact_, contact_up_, and dtn::BundleDaemon::post().

Referenced by dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_contact_initiation().

virtual void dtn::CLConnection::disconnect (  )  [protected, pure virtual]

bool dtn::CLConnection::find_contact ( const EndpointID peer_eid  )  [protected, virtual]

virtual void dtn::CLConnection::handle_bundles_queued (  )  [protected, pure virtual]

Handle notification that bundle(s) may be queued on the link.

Implemented in dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection.

Referenced by process_command().

virtual void dtn::CLConnection::handle_cancel_bundle ( Bundle b  )  [protected, pure virtual]

Handle a cancel bundle request.

Implemented in dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection.

Referenced by process_command().

virtual void dtn::CLConnection::handle_poll_activity (  )  [protected, pure virtual]

Handle network activity from the remote side.

Implemented in dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection, and dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection.

Referenced by run().

virtual void dtn::CLConnection::handle_poll_timeout (  )  [protected, pure virtual]

virtual void dtn::CLConnection::initialize_pollfds (  )  [protected, pure virtual]

Fill in the pollfds array with any file descriptors that should be waited on for activity from the peer.

Implemented in dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection, and dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection.

Referenced by run().

void dtn::CLConnection::process_command (  )  [protected, virtual]

void dtn::CLConnection::run (  )  [protected]

virtual bool dtn::CLConnection::send_pending_data (  )  [protected, pure virtual]

Start or continue transmission of bundle data or cl acks.

This is called each time through the main run loop. Note that in general, this function should send one "unit" of data, i.e. a chunk of bundle data, a packet, etc.

Returns:
true if some data was sent, which will trigger another call, or false if the main loop should poll() on the socket before calling again.

Implemented in dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection.

Referenced by run().

void dtn::CLConnection::set_contact ( const ContactRef contact  )  [inline]

Attach to the given contact.

Definition at line 62 of file CLConnection.h.

References contact_.

Referenced by dtn::ConnectionConvergenceLayer::open_contact().

void dtn::CLConnection::set_nexthop ( const std::string &  nexthop  )  [inline, protected]


Friends And Related Function Documentation

friend class ConnectionConvergenceLayer [friend]

Definition at line 42 of file CLConnection.h.


Member Data Documentation

Should we connect() or accept().

Definition at line 263 of file CLConnection.h.

Referenced by run().

oasys::MsgQueue<CLMsg> dtn::CLConnection::cmdqueue_ [protected]

oasys::SpinLock dtn::CLConnection::cmdqueue_lock_ [protected]

Lock for command queue.

Definition at line 257 of file CLConnection.h.

const int dtn::CLConnection::MAXPOLL = 8 [static, protected]

Maximum number of pollfds.

Definition at line 266 of file CLConnection.h.

std::string dtn::CLConnection::nexthop_ [protected]

Nexthop identifier set by CL.

Definition at line 264 of file CLConnection.h.

Referenced by find_contact(), and set_nexthop().

oasys::atomic_t dtn::CLConnection::num_pending_ [protected]

Bundles pending transmission.

Definition at line 274 of file CLConnection.h.

struct pollfd dtn::CLConnection::pollfds_[MAXPOLL] [read, protected]

oasys::StreamBuffer dtn::CLConnection::recvbuf_ [protected]

oasys::StreamBuffer dtn::CLConnection::sendbuf_ [protected]


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

Generated on Fri Jan 30 09:43:14 2009 for DTN Reference Implementation by  doxygen 1.5.8