#include <CLConnection.h>
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< CLMsg > | cmdqueue_ |
Daemon/CLConnection command queue. | |
ConnectionConvergenceLayer * | cl_ |
Pointer to the CL. | |
LinkParams * | params_ |
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 |
Definition at line 38 of file CLConnection.h.
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 std::list<InFlightBundle*> dtn::CLConnection::InFlightList [protected] |
Definition at line 43 of file CLConnection.h.
enum dtn::CLConnection::clmsg_t [protected] |
Enum for messages from the daemon thread to the connection thread.
Definition at line 145 of file CLConnection.h.
dtn::CLConnection::CLConnection | ( | const char * | classname, | |
const char * | logpath, | |||
ConnectionConvergenceLayer * | cl, | |||
LinkParams * | params, | |||
bool | active_connector | |||
) |
Constructor.
Definition at line 32 of file CLConnection.cc.
References params_, recvbuf_, dtn::ConnectionConvergenceLayer::ConnectionConvergenceLayer::LinkParams::recvbuf_len_, sendbuf_, and dtn::ConnectionConvergenceLayer::ConnectionConvergenceLayer::LinkParams::sendbuf_len_.
dtn::CLConnection::~CLConnection | ( | ) | [virtual] |
Definition at line 55 of file CLConnection.cc.
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] |
Utility functions, all virtual so subclasses could override them
Reimplemented in dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection.
Definition at line 234 of file CLConnection.cc.
References dtn::ContactEvent::BROKEN, dtn::Link::CLOSED, contact_, contact_broken_, disconnect(), dtn::BundleDaemon::post(), dtn::ContactEvent::reason_to_str(), and dtn::ContactEvent::USER.
Referenced by process_command(), and run().
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] |
Initiate a connection to the remote side.
Implemented in dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection, and dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection.
Referenced by run().
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] |
Shut down the connection.
Implemented in dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection, and dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection.
Referenced by break_contact().
bool dtn::CLConnection::find_contact | ( | const EndpointID & | peer_eid | ) | [protected, virtual] |
Utility functions, all virtual so subclasses could override them
Definition at line 261 of file CLConnection.cc.
References ASSERT, dtn::Link::AVAILABLE, cl_, contact_, dtn::ContactManager::find_link_to(), dtn::ContactManager::lock(), dtn::ContactManager::new_opportunistic_link(), nexthop_, dtn::Link::OPPORTUNISTIC, params_, and dtn::Link::UNAVAILABLE.
Referenced by dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_contact_initiation().
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] |
Handle network activity from the remote side.
Implemented in dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection, and dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection.
Referenced by run().
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] |
Utility functions, all virtual so subclasses could override them
Definition at line 193 of file CLConnection.cc.
References ASSERT, break_contact(), dtn::CLConnection::CLConnection::CLMsg::bundle_, CLMSG_BREAK_CONTACT, CLMSG_BUNDLES_QUEUED, CLMSG_CANCEL_BUNDLE, cmdqueue_, handle_bundles_queued(), handle_cancel_bundle(), dtn::CLConnection::CLConnection::CLMsg::type_, and dtn::ContactEvent::USER.
Referenced by run().
void dtn::CLConnection::run | ( | ) | [protected] |
Main run loop.
Definition at line 61 of file CLConnection.cc.
References accept(), active_connector_, break_contact(), dtn::ContactEvent::BROKEN, cmdqueue_, connect(), contact_broken_, handle_poll_activity(), handle_poll_timeout(), initialize_pollfds(), num_pollfds_, params_, poll_timeout_, pollfds_, process_command(), send_pending_data(), and dtn::ConnectionConvergenceLayer::ConnectionConvergenceLayer::LinkParams::test_write_delay_.
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.
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] |
Assignment function for the nexthop identifier.
Definition at line 81 of file CLConnection.h.
References nexthop_.
Referenced by dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::Connection(), and dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::Connection().
friend class ConnectionConvergenceLayer [friend] |
Definition at line 42 of file CLConnection.h.
bool dtn::CLConnection::active_connector_ [protected] |
Should we connect() or accept().
Definition at line 263 of file CLConnection.h.
Referenced by run().
ConnectionConvergenceLayer* dtn::CLConnection::cl_ [protected] |
Pointer to the CL.
Definition at line 259 of file CLConnection.h.
Referenced by dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::connect(), find_contact(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_contact_initiation(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::initialize_pollfds(), and dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::initiate_contact().
oasys::MsgQueue<CLMsg> dtn::CLConnection::cmdqueue_ [protected] |
Daemon/CLConnection command queue.
Definition at line 258 of file CLConnection.h.
Referenced by dtn::ConnectionConvergenceLayer::bundle_queued(), dtn::ConnectionConvergenceLayer::cancel_bundle(), dtn::ConnectionConvergenceLayer::close_contact(), process_command(), and run().
oasys::SpinLock dtn::CLConnection::cmdqueue_lock_ [protected] |
ContactRef dtn::CLConnection::contact_ [protected] |
Ref to the Contact.
Definition at line 255 of file CLConnection.h.
Referenced by break_contact(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::check_completed(), dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::connect(), contact_up(), find_contact(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_ack_segment(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_bundles_queued(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_cancel_bundle(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_contact_initiation(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_poll_timeout(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::initialize_pollfds(), set_contact(), and dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::start_next_bundle().
volatile bool dtn::CLConnection::contact_broken_ [protected] |
Contact has been broken.
Definition at line 273 of file CLConnection.h.
Referenced by break_contact(), dtn::ConnectionConvergenceLayer::close_contact(), dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::handle_poll_activity(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::handle_poll_activity(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::process_data(), dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::recv_data(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::recv_data(), run(), dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::send_data(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::send_data(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::send_data_todo(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::send_pending_acks(), and dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::send_pending_data().
bool dtn::CLConnection::contact_up_ [protected] |
Has contact_up been called.
Definition at line 256 of file CLConnection.h.
Referenced by contact_up(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_contact_initiation(), dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::handle_poll_activity(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::handle_poll_activity(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::process_data(), and dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::start_next_bundle().
IncomingList dtn::CLConnection::incoming_ [protected] |
Bundles arriving on the wire.
Definition at line 272 of file CLConnection.h.
Referenced by dtn::ConnectionConvergenceLayer::close_contact(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_data_segment(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_data_todo(), and dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::send_pending_acks().
InFlightList dtn::CLConnection::inflight_ [protected] |
Bundles going out the wire.
Definition at line 271 of file CLConnection.h.
Referenced by dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::check_completed(), dtn::ConnectionConvergenceLayer::close_contact(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_ack_segment(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_cancel_bundle(), and dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::start_next_bundle().
const int dtn::CLConnection::MAXPOLL = 8 [static, protected] |
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] |
int dtn::CLConnection::num_pollfds_ [protected] |
Number of pollfds in use.
Definition at line 265 of file CLConnection.h.
Referenced by dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::initialize_pollfds(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::initialize_pollfds(), and run().
LinkParams* dtn::CLConnection::params_ [protected] |
Pointer to Link parameters, or to defaults until Link is bound.
Definition at line 261 of file CLConnection.h.
Referenced by dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::check_keepalive(), CLConnection(), dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::connect(), find_contact(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_poll_timeout(), dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::initialize_pollfds(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::initialize_pollfds(), dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::recv_data(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::recv_data(), run(), dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::send_data(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::send_data(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::send_data_todo(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::send_pending_data(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::serial_lparams(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::stream_lparams(), and dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::tcp_lparams().
int dtn::CLConnection::poll_timeout_ [protected] |
Timeout to wait for poll data.
Definition at line 268 of file CLConnection.h.
Referenced by dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_contact_initiation(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_poll_timeout(), dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::initialize_pollfds(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::initialize_pollfds(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::recv_data(), and run().
struct pollfd dtn::CLConnection::pollfds_[MAXPOLL] [read, protected] |
Array of pollfds.
Definition at line 267 of file CLConnection.h.
Referenced by dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::initialize_pollfds(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::initialize_pollfds(), and run().
oasys::StreamBuffer dtn::CLConnection::recvbuf_ [protected] |
Buffer for incoming data.
Definition at line 270 of file CLConnection.h.
Referenced by CLConnection(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_ack_segment(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_contact_initiation(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_data_segment(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_data_todo(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_keepalive(), dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::handle_poll_activity(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::handle_poll_activity(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::handle_shutdown(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::process_data(), dtn::ConnectionConvergenceLayer::reconfigure_link(), dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::recv_data(), and dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::recv_data().
oasys::StreamBuffer dtn::CLConnection::sendbuf_ [protected] |
Buffer for outgoing data.
Definition at line 269 of file CLConnection.h.
Referenced by dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::break_contact(), CLConnection(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::connect(), dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::handle_poll_activity(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::initiate_contact(), dtn::ConnectionConvergenceLayer::reconfigure_link(), dtn::TCPConvergenceLayer::TCPConvergenceLayer::Connection::send_data(), dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::send_data(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::send_data_todo(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::send_keepalive(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::send_next_segment(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::send_pending_acks(), dtn::StreamConvergenceLayer::StreamConvergenceLayer::Connection::send_pending_data(), and dtn::SerialConvergenceLayer::SerialConvergenceLayer::Connection::send_sync().