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/NetInterface.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::NetInterface net, int port, bool broadcast = false, unsigned int mtu = 1280); 00033 00037 virtual ~UDPConvergenceLayer(); 00038 00039 virtual void update(std::string &name, std::string &data); 00040 virtual bool onInterface(const ibrcommon::NetInterface &net) const; 00041 00042 dtn::core::Node::Protocol getDiscoveryProtocol() const; 00043 00044 void queue(const dtn::core::Node &n, const ConvergenceLayer::Job &job); 00045 00046 UDPConvergenceLayer& operator>>(dtn::data::Bundle&); 00047 00051 virtual const std::string getName() const; 00052 00053 protected: 00054 virtual void componentUp(); 00055 virtual void componentRun(); 00056 virtual void componentDown(); 00057 bool __cancellation(); 00058 00059 private: 00060 ibrcommon::udpsocket *_socket; 00061 00062 ibrcommon::NetInterface _net; 00063 int _port; 00064 int m_socket; 00065 00066 static const int DEFAULT_PORT; 00067 00068 unsigned int m_maxmsgsize; 00069 00070 ibrcommon::Mutex m_writelock; 00071 ibrcommon::Mutex m_readlock; 00072 00073 bool _running; 00074 00075 00076 }; 00077 } 00078 } 00079 00080 #endif /*UDPCONVERGENCELAYER_H_*/
1.7.1