IBR-DTNSuite
0.8
|
#include <TCPConvergenceLayer.h>
Classes | |
class | KeepaliveSender |
class | Sender |
Public Member Functions | |
TCPConnection (TCPConvergenceLayer &tcpsrv, ibrcommon::tcpstream *stream, const dtn::data::EID &name, const size_t timeout=10) | |
TCPConnection (TCPConvergenceLayer &tcpsrv, const dtn::core::Node &node, const dtn::data::EID &name, const size_t timeout=10) | |
virtual | ~TCPConnection () |
virtual void | initialize () |
void | shutdown () |
const StreamContactHeader & | getHeader () const |
const dtn::core::Node & | getNode () const |
virtual void | eventShutdown (StreamConnection::ConnectionShutdownCases csc) |
virtual void | eventTimeout () |
virtual void | eventError () |
virtual void | eventConnectionUp (const StreamContactHeader &header) |
virtual void | eventConnectionDown () |
virtual void | eventBundleRefused () |
virtual void | eventBundleForwarded () |
virtual void | eventBundleAck (size_t ack) |
dtn::core::Node::Protocol | getDiscoveryProtocol () const |
void | queue (const dtn::data::BundleID &bundle) |
bool | match (const dtn::core::Node &n) const |
bool | match (const dtn::data::EID &destination) const |
bool | match (const dtn::core::NodeEvent &evt) const |
Protected Member Functions | |
void | rejectTransmission () |
void | setup () |
void | connect () |
void | run () |
void | finally () |
void | __cancellation () |
void | clearQueue () |
void | keepalive () |
bool | good () const |
Friends | |
TCPConnection & | operator>> (TCPConnection &conn, dtn::data::Bundle &bundle) |
TCPConnection & | operator<< (TCPConnection &conn, const dtn::data::Bundle &bundle) |
Definition at line 45 of file TCPConvergenceLayer.h.
dtn::net::TCPConnection::TCPConnection | ( | TCPConvergenceLayer & | tcpsrv, |
ibrcommon::tcpstream * | stream, | ||
const dtn::data::EID & | name, | ||
const size_t | timeout = 10 |
||
) |
Constructor for a new TCPConnection object.
tcpsrv | |
stream | TCP stream to talk to the other peer. |
name | |
timeout |
Definition at line 49 of file TCPConnection.cpp.
References ibrcommon::tcpstream::enableNoDelay(), dtn::daemon::Configuration::getInstance(), dtn::streams::StreamContactHeader::REQUEST_ACKNOWLEDGMENTS, dtn::streams::StreamContactHeader::REQUEST_FRAGMENTATION, and dtn::streams::StreamContactHeader::REQUEST_NEGATIVE_ACKNOWLEDGMENTS.
dtn::net::TCPConnection::TCPConnection | ( | TCPConvergenceLayer & | tcpsrv, |
const dtn::core::Node & | node, | ||
const dtn::data::EID & | name, | ||
const size_t | timeout = 10 |
||
) |
Constructor for a new TCPConnection object.
tcpsrv | |
node | The node to talk to. |
name | |
timeout |
Definition at line 83 of file TCPConnection.cpp.
References dtn::daemon::Configuration::getInstance(), dtn::streams::StreamContactHeader::REQUEST_ACKNOWLEDGMENTS, dtn::streams::StreamContactHeader::REQUEST_FRAGMENTATION, and dtn::streams::StreamContactHeader::REQUEST_NEGATIVE_ACKNOWLEDGMENTS.
dtn::net::TCPConnection::~TCPConnection | ( | ) | [virtual] |
void dtn::net::TCPConnection::__cancellation | ( | ) | [protected, virtual] |
Implements ibrcommon::Thread.
Definition at line 295 of file TCPConnection.cpp.
void dtn::net::TCPConnection::clearQueue | ( | ) | [protected] |
Definition at line 637 of file TCPConnection.cpp.
References dtn::routing::RequeueBundleEvent::raise(), dtn::streams::StreamContactHeader::REQUEST_FRAGMENTATION, and dtn::core::FragmentManager::setOffset().
Referenced by finally().
void dtn::net::TCPConnection::connect | ( | ) | [protected] |
Definition at line 336 of file TCPConnection.cpp.
References dtn::core::Node::add(), dtn::core::Node::clear(), dtn::core::Node::CONN_TCPIP, dtn::core::Node::URI::decode(), dtn::core::Node::get(), dtn::daemon::Configuration::getInstance(), IBRCOMMON_LOGGER, IBRCOMMON_LOGGER_DEBUG, IBRCOMMON_LOGGER_ENDL, ibrcommon::tcpclient::open(), dtn::streams::StreamConnection::shutdown(), dtn::core::Node::toString(), and dtn::core::Node::URI::value.
Referenced by run().
void dtn::net::TCPConnection::eventBundleAck | ( | size_t | ack | ) | [virtual] |
This method is called if a ACK is received.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 267 of file TCPConnection.cpp.
void dtn::net::TCPConnection::eventBundleForwarded | ( | ) | [virtual] |
This method is called if a bundle is refused by the peer.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 248 of file TCPConnection.cpp.
References dtn::core::BUNDLE_FORWARDED, dtn::core::Node::getEID(), ibrcommon::Queue< T >::getnpop(), IBRCOMMON_LOGGER, IBRCOMMON_LOGGER_ENDL, dtn::net::TransferCompletedEvent::raise(), and dtn::core::BundleEvent::raise().
void dtn::net::TCPConnection::eventBundleRefused | ( | ) | [virtual] |
This method is called if a bundle is refused by the peer.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 231 of file TCPConnection.cpp.
References dtn::core::Node::getEID(), ibrcommon::Queue< T >::getnpop(), IBRCOMMON_LOGGER, IBRCOMMON_LOGGER_ENDL, dtn::net::TransferAbortedEvent::raise(), and dtn::net::TransferAbortedEvent::REASON_REFUSED.
void dtn::net::TCPConnection::eventConnectionDown | ( | ) | [virtual] |
This method is called if a connection went down.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 210 of file TCPConnection.cpp.
References dtn::streams::StreamContactHeader::_localeid, dtn::net::ConnectionEvent::CONNECTION_DOWN, IBRCOMMON_LOGGER_DEBUG, IBRCOMMON_LOGGER_ENDL, dtn::net::ConnectionEvent::raise(), and ibrcommon::Exception::what().
void dtn::net::TCPConnection::eventConnectionUp | ( | const StreamContactHeader & | header | ) | [virtual] |
This method is called if a handshake was successful.
header |
Implements dtn::streams::StreamConnection::Callback.
Definition at line 149 of file TCPConnection.cpp.
References dtn::streams::StreamContactHeader::_flags, dtn::streams::StreamContactHeader::_keepalive, dtn::streams::StreamContactHeader::_localeid, dtn::net::ConnectionEvent::CONNECTION_UP, dtn::streams::StreamConnection::enableIdleTimeout(), dtn::streams::StreamContactHeader::getEID(), dtn::daemon::Configuration::getInstance(), dtn::daemon::Configuration::getNetwork(), dtn::daemon::Configuration::Network::getTCPIdleTimeout(), IBRCOMMON_LOGGER, IBRCOMMON_LOGGER_ENDL, dtn::net::ConnectionEvent::raise(), dtn::streams::StreamContactHeader::REQUEST_TLS, and dtn::security::SecurityCertificateManager::validateSubject().
void dtn::net::TCPConnection::eventError | ( | ) | [virtual] |
This method is called if a error occured in the stream.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 145 of file TCPConnection.cpp.
void dtn::net::TCPConnection::eventShutdown | ( | StreamConnection::ConnectionShutdownCases | csc | ) | [virtual] |
callback methods for tcpstream
Implements dtn::streams::StreamConnection::Callback.
Definition at line 132 of file TCPConnection.cpp.
void dtn::net::TCPConnection::eventTimeout | ( | ) | [virtual] |
This method is called if the stream is closed by a TIMEOUT.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 136 of file TCPConnection.cpp.
References dtn::net::ConnectionEvent::CONNECTION_TIMEOUT, dtn::net::ConnectionEvent::raise(), and ibrcommon::DetachedThread::stop().
void dtn::net::TCPConnection::finally | ( | void | ) | [protected, virtual] |
This method is called when the run() method finishes.
Reimplemented from ibrcommon::Thread.
Definition at line 306 of file TCPConnection.cpp.
References clearQueue(), IBRCOMMON_LOGGER_DEBUG, and IBRCOMMON_LOGGER_ENDL.
const StreamContactHeader & dtn::net::TCPConnection::getHeader | ( | ) | const |
const dtn::core::Node & dtn::net::TCPConnection::getNode | ( | ) | const |
Get the associated Node object
Definition at line 122 of file TCPConnection.cpp.
Referenced by dtn::net::operator<<(), and dtn::net::TCPConvergenceLayer::queue().
bool dtn::net::TCPConnection::good | ( | ) | const [protected] |
Definition at line 693 of file TCPConnection.cpp.
void dtn::net::TCPConnection::initialize | ( | ) | [virtual] |
This method is called after accept()
Definition at line 272 of file TCPConnection.cpp.
References IBRCOMMON_LOGGER, IBRCOMMON_LOGGER_ENDL, ibrcommon::DetachedThread::start(), and ibrcommon::Exception::what().
Referenced by dtn::net::TCPConvergenceLayer::componentRun(), dtn::net::TCPConvergenceLayer::open(), and dtn::net::TCPConvergenceLayer::queue().
void dtn::net::TCPConnection::keepalive | ( | ) | [protected] |
Definition at line 688 of file TCPConnection.cpp.
bool dtn::net::TCPConnection::match | ( | const dtn::core::Node & | n | ) | const |
Definition at line 702 of file TCPConnection.cpp.
Referenced by dtn::net::TCPConvergenceLayer::open(), and dtn::net::TCPConvergenceLayer::queue().
bool dtn::net::TCPConnection::match | ( | const dtn::data::EID & | destination | ) | const |
Definition at line 707 of file TCPConnection.cpp.
References dtn::data::EID::getNode().
bool dtn::net::TCPConnection::match | ( | const dtn::core::NodeEvent & | evt | ) | const |
Definition at line 712 of file TCPConnection.cpp.
References dtn::core::NodeEvent::getNode().
void dtn::net::TCPConnection::queue | ( | const dtn::data::BundleID & | bundle | ) |
queue a bundle for this connection
bundle |
Definition at line 112 of file TCPConnection.cpp.
Referenced by dtn::net::TCPConvergenceLayer::queue().
void dtn::net::TCPConnection::rejectTransmission | ( | ) | [protected] |
Definition at line 127 of file TCPConnection.cpp.
References dtn::streams::StreamConnection::reject().
Referenced by run().
void dtn::net::TCPConnection::run | ( | ) | [protected, virtual] |
Abstract interface for thread context run method.
Implements ibrcommon::Thread.
Definition at line 386 of file TCPConnection.cpp.
References dtn::streams::StreamContactHeader::_localeid, connect(), dtn::streams::StreamConnection::handshake(), IBRCOMMON_LOGGER, IBRCOMMON_LOGGER_DEBUG, IBRCOMMON_LOGGER_ENDL, dtn::data::ScopeControlHopLimitBlock::increment(), dtn::net::BundleReceivedEvent::raise(), rejectTransmission(), dtn::streams::StreamConnection::shutdown(), ibrcommon::Exception::what(), and ibrcommon::Thread::yield().
void dtn::net::TCPConnection::setup | ( | void | ) | [protected, virtual] |
This method is called before the run.
Reimplemented from ibrcommon::Thread.
Definition at line 331 of file TCPConnection.cpp.
void dtn::net::TCPConnection::shutdown | ( | ) |
shutdown the whole tcp connection
Definition at line 282 of file TCPConnection.cpp.
References IBRCOMMON_LOGGER_DEBUG, IBRCOMMON_LOGGER_ENDL, dtn::streams::StreamConnection::shutdown(), ibrcommon::DetachedThread::stop(), and ibrcommon::Exception::what().
TCPConnection& operator<< | ( | TCPConnection & | conn, |
const dtn::data::Bundle & | bundle | ||
) | [friend] |
Definition at line 473 of file TCPConnection.cpp.
TCPConnection& operator>> | ( | TCPConnection & | conn, |
dtn::data::Bundle & | bundle | ||
) | [friend] |
Definition at line 454 of file TCPConnection.cpp.