IBR-DTNSuite
0.12
|
#include <TCPConnection.h>
Public Member Functions | |
TCPConnection (TCPConvergenceLayer &tcpsrv, const dtn::core::Node &node, ibrcommon::clientsocket *sock, const size_t timeout=10) | |
virtual | ~TCPConnection () |
virtual void | initialize () throw () |
void | shutdown () throw () |
const dtn::streams::StreamContactHeader & | getHeader () const |
const dtn::core::Node & | getNode () const |
virtual void | eventShutdown (dtn::streams::StreamConnection::ConnectionShutdownCases csc) throw () |
virtual void | eventTimeout () throw () |
virtual void | eventError () throw () |
virtual void | eventConnectionUp (const dtn::streams::StreamContactHeader &header) throw () |
virtual void | eventConnectionDown () throw () |
virtual void | eventBundleRefused () throw () |
virtual void | eventBundleForwarded () throw () |
virtual void | eventBundleAck (const dtn::data::Length &ack) throw () |
virtual void | addTrafficIn (size_t) throw () |
virtual void | addTrafficOut (size_t) throw () |
dtn::core::Node::Protocol | getDiscoveryProtocol () const |
void | queue (const dtn::net::BundleTransfer &job) |
bool | match (const dtn::core::Node &n) const |
bool | match (const dtn::data::EID &destination) const |
bool | match (const dtn::core::NodeEvent &evt) const |
Public Member Functions inherited from ibrcommon::DetachedThread | |
virtual | ~DetachedThread ()=0 |
void | start (int priority=0) throw (ThreadException) |
void | stop () throw (ThreadException) |
Protected Member Functions | |
void | rejectTransmission () |
void | setup () throw () |
void | connect () |
void | run () throw () |
void | finally () throw () |
void | __cancellation () throw () |
void | clearQueue () |
void | keepalive () |
bool | good () const |
void | initiateExtendedHandshake () throw (ibrcommon::Exception) |
Protected Member Functions inherited from ibrcommon::DetachedThread | |
DetachedThread (size_t size=DEFAULT_STACKSIZE) | |
Protected Member Functions inherited from ibrcommon::Thread | |
virtual | ~Thread ()=0 |
void | reset () throw (ThreadException) |
bool | isFinalized () throw () |
bool | operator== (const ibrcommon::Thread &other) |
Thread (size_t stack=DEFAULT_STACKSIZE) | |
int | kill (int sig) |
void | cancel () throw () |
Additional Inherited Members | |
Static Protected Member Functions inherited from ibrcommon::Thread | |
static size_t | getNumberOfProcessors () |
static void | yield (void) |
static void | sleep (time_t timeout) |
static void | concurrency (int level) |
static bool | equal (pthread_t thread1, pthread_t thread2) |
static void * | __execute__ (void *obj) throw () |
Definition at line 48 of file TCPConnection.h.
dtn::net::TCPConnection::TCPConnection | ( | TCPConvergenceLayer & | tcpsrv, |
const dtn::core::Node & | node, | ||
ibrcommon::clientsocket * | sock, | ||
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 64 of file TCPConnection.cpp.
|
virtual |
Destructor
Definition at line 71 of file TCPConnection.cpp.
References ibrcommon::RWMutex::LOCK_READWRITE.
|
protectedvirtual |
Implements ibrcommon::Thread.
Definition at line 358 of file TCPConnection.cpp.
References ibrcommon::socketstream::close().
|
virtual |
Reports inbound traffic amount
Reimplemented from dtn::streams::StreamConnection::Callback.
Definition at line 323 of file TCPConnection.cpp.
|
virtual |
Reports outbound traffic amount
Reimplemented from dtn::streams::StreamConnection::Callback.
Definition at line 328 of file TCPConnection.cpp.
|
protected |
Definition at line 733 of file TCPConnection.cpp.
References dtn::streams::StreamContactHeader::_flags, ibrcommon::Queue< T >::Locked::empty(), ibrcommon::Queue< T >::exclusive(), ibrcommon::Queue< T >::Locked::front(), dtn::data::Bitset< E >::getBit(), dtn::net::BundleTransfer::getBundle(), dtn::streams::StreamContactHeader::getEID(), ibrcommon::Queue< T >::Locked::pop(), dtn::streams::StreamContactHeader::REQUEST_FRAGMENTATION, and dtn::core::FragmentManager::setOffset().
Referenced by finally().
|
protected |
Definition at line 426 of file TCPConnection.cpp.
References dtn::core::Node::add(), dtn::core::Node::clear(), dtn::core::Node::CONN_TCPIP, dtn::streams::StreamConnection::CONNECTION_SHUTDOWN_ERROR, dtn::core::Node::URI::decode(), dtn::core::Node::get(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, shutdown(), dtn::core::Node::toString(), ibrcommon::tcpsocket::up(), dtn::core::Node::URI::value, and ibrcommon::LogLevel::warning.
Referenced by run().
|
virtual |
This method is called if a ACK is received.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 318 of file TCPConnection.cpp.
|
virtual |
This method is called if a bundle is refused by the peer.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 295 of file TCPConnection.cpp.
References dtn::net::BundleTransfer::complete(), ibrcommon::Queue< T >::Locked::empty(), ibrcommon::LogLevel::error, ibrcommon::Queue< T >::exclusive(), ibrcommon::Queue< T >::Locked::front(), IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, and ibrcommon::Queue< T >::Locked::pop().
|
virtual |
This method is called if a bundle is refused by the peer.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 272 of file TCPConnection.cpp.
References dtn::net::BundleTransfer::abort(), ibrcommon::Queue< T >::Locked::empty(), ibrcommon::LogLevel::error, ibrcommon::Queue< T >::exclusive(), ibrcommon::Queue< T >::Locked::front(), IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, ibrcommon::Queue< T >::Locked::pop(), and dtn::net::TransferAbortedEvent::REASON_REFUSED.
|
virtual |
This method is called if a connection went down.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 251 of file TCPConnection.cpp.
References dtn::streams::StreamContactHeader::_localeid, dtn::net::ConnectionEvent::CONNECTION_DOWN, ibrcommon::LogLevel::error, IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, dtn::net::ConnectionEvent::raise(), and ibrcommon::Exception::what().
|
virtual |
This method is called if a handshake was successful.
header |
Implements dtn::streams::StreamConnection::Callback.
Definition at line 196 of file TCPConnection.cpp.
References dtn::net::ConnectionEvent::CONNECTION_UP, dtn::core::BundleCore::getInstance(), dtn::daemon::Configuration::getInstance(), dtn::daemon::Configuration::getNetwork(), dtn::daemon::Configuration::Network::getTCPIdleTimeout(), IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, dtn::core::BundleCore::local, dtn::net::ConnectionEvent::raise(), ibrcommon::LogLevel::warning, and ibrcommon::Exception::what().
|
virtual |
This method is called if a error occured in the stream.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 134 of file TCPConnection.cpp.
|
virtual |
callback methods for tcpstream
Implements dtn::streams::StreamConnection::Callback.
Definition at line 117 of file TCPConnection.cpp.
|
virtual |
This method is called if the stream is closed by a TIMEOUT.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 121 of file TCPConnection.cpp.
References dtn::net::ConnectionEvent::CONNECTION_TIMEOUT, ibrcommon::LogLevel::error, IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, dtn::net::ConnectionEvent::raise(), ibrcommon::DetachedThread::stop(), and ibrcommon::Exception::what().
|
protectedvirtual |
This method is called when the run() method finishes.
Reimplemented from ibrcommon::Thread.
Definition at line 367 of file TCPConnection.cpp.
References clearQueue(), ibrcommon::socketstream::close(), IBRCOMMON_LOGGER_DEBUG_TAG, and IBRCOMMON_LOGGER_ENDL.
dtn::core::Node::Protocol dtn::net::TCPConnection::getDiscoveryProtocol | ( | ) | const |
const dtn::streams::StreamContactHeader & dtn::net::TCPConnection::getHeader | ( | ) | const |
const dtn::core::Node & dtn::net::TCPConnection::getNode | ( | ) | const |
Get the associated Node object
Definition at line 107 of file TCPConnection.cpp.
Referenced by dtn::net::TCPConvergenceLayer::queue().
|
protected |
Definition at line 770 of file TCPConnection.cpp.
|
virtual |
This method is called after accept()
Definition at line 333 of file TCPConnection.cpp.
References ibrcommon::LogLevel::error, IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, ibrcommon::DetachedThread::start(), and ibrcommon::Exception::what().
Referenced by dtn::net::TCPConvergenceLayer::componentRun(), dtn::net::TCPConvergenceLayer::open(), and dtn::net::TCPConvergenceLayer::queue().
|
protected |
Definition at line 138 of file TCPConnection.cpp.
References dtn::streams::StreamContactHeader::_flags, ibrcommon::TLSStream::activate(), dtn::data::Bitset< E >::getBit(), dtn::streams::StreamContactHeader::getEID(), dtn::data::EID::getHost(), dtn::daemon::Configuration::getInstance(), dtn::daemon::Configuration::getSecurity(), dtn::data::EID::getString(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, ibrcommon::LogLevel::notice, dtn::streams::StreamContactHeader::REQUEST_TLS, dtn::daemon::Configuration::Security::TLSRequired(), dtn::security::SecurityCertificateManager::validateSubject(), ibrcommon::LogLevel::warning, and ibrcommon::Exception::what().
|
protected |
Definition at line 765 of file TCPConnection.cpp.
bool dtn::net::TCPConnection::match | ( | const dtn::core::Node & | n) | const |
Definition at line 779 of file TCPConnection.cpp.
Referenced by match(), dtn::net::TCPConvergenceLayer::open(), and dtn::net::TCPConvergenceLayer::queue().
bool dtn::net::TCPConnection::match | ( | const dtn::data::EID & | destination) | const |
Definition at line 784 of file TCPConnection.cpp.
References dtn::core::Node::getEID(), and dtn::data::EID::sameHost().
bool dtn::net::TCPConnection::match | ( | const dtn::core::NodeEvent & | evt) | const |
Definition at line 789 of file TCPConnection.cpp.
References dtn::core::NodeEvent::getNode(), and match().
void dtn::net::TCPConnection::queue | ( | const dtn::net::BundleTransfer & | job) |
queue a bundle for this connection
bundle |
Definition at line 97 of file TCPConnection.cpp.
Referenced by dtn::net::TCPConvergenceLayer::queue().
|
protected |
Definition at line 112 of file TCPConnection.cpp.
Referenced by run().
|
protectedvirtual |
Abstract interface for thread context run method.
Implements ibrcommon::Thread.
Definition at line 497 of file TCPConnection.cpp.
References dtn::streams::StreamContactHeader::_flags, dtn::streams::StreamContactHeader::_localeid, connect(), dtn::streams::StreamConnection::CONNECTION_SHUTDOWN_ERROR, ibrcommon::LogLevel::error, dtn::data::Bitset< E >::getBit(), dtn::core::BundleCore::getInstance(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, dtn::core::BundleCore::local, dtn::net::BundleReceivedEvent::raise(), rejectTransmission(), dtn::streams::StreamContactHeader::REQUEST_FRAGMENTATION, dtn::data::DefaultDeserializer::setFragmentationSupport(), shutdown(), ibrcommon::LogLevel::warning, ibrcommon::Exception::what(), and ibrcommon::Thread::yield().
|
protectedvirtual |
This method is called before the run.
Reimplemented from ibrcommon::Thread.
Definition at line 390 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.
void dtn::net::TCPConnection::shutdown | ( | ) | ||
throw | ( | |||
) |
shutdown the whole tcp connection
Definition at line 343 of file TCPConnection.cpp.
References dtn::streams::StreamConnection::CONNECTION_SHUTDOWN_ERROR, ibrcommon::LogLevel::error, IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, ibrcommon::DetachedThread::stop(), and ibrcommon::Exception::what().
Referenced by connect(), and run().