IBR-DTNSuite
0.8
|
00001 #ifndef UDPCONVERGENCELAYER_H_ 00002 #define UDPCONVERGENCELAYER_H_ 00003 00004 #include "Component.h" 00005 #include "net/ConvergenceLayer.h" 00006 #include <ibrcommon/Exceptions.h> 00007 #include "net/DiscoveryServiceProvider.h" 00008 #include <ibrcommon/net/vinterface.h> 00009 #include <ibrcommon/net/udpsocket.h> 00010 00011 using namespace dtn::data; 00012 00013 00014 namespace dtn 00015 { 00016 namespace net 00017 { 00022 class UDPConvergenceLayer : public ConvergenceLayer, public dtn::daemon::IndependentComponent, public DiscoveryServiceProvider 00023 { 00024 public: 00032 UDPConvergenceLayer(ibrcommon::vinterface net, int port, unsigned int mtu = 1280); 00033 00037 virtual ~UDPConvergenceLayer(); 00038 00042 void update(const ibrcommon::vinterface &iface, std::string &name, std::string &data) throw(dtn::net::DiscoveryServiceProvider::NoServiceHereException); 00043 00044 dtn::core::Node::Protocol getDiscoveryProtocol() const; 00045 00046 void queue(const dtn::core::Node &n, const ConvergenceLayer::Job &job); 00047 00048 UDPConvergenceLayer& operator>>(dtn::data::Bundle&); 00049 00053 virtual const std::string getName() const; 00054 00055 protected: 00056 virtual void componentUp(); 00057 virtual void componentRun(); 00058 virtual void componentDown(); 00059 void __cancellation(); 00060 00061 private: 00062 ibrcommon::udpsocket *_socket; 00063 00064 ibrcommon::vinterface _net; 00065 int _port; 00066 int m_socket; 00067 00068 static const int DEFAULT_PORT; 00069 00070 unsigned int m_maxmsgsize; 00071 00072 ibrcommon::Mutex m_writelock; 00073 ibrcommon::Mutex m_readlock; 00074 00075 bool _running; 00076 00077 00078 }; 00079 } 00080 } 00081 00082 #endif /*UDPCONVERGENCELAYER_H_*/