IBR-DTNSuite
0.8
|
00001 #ifndef LOWPANCONVERGENCELAYER_H_ 00002 #define LOWPANCONVERGENCELAYER_H_ 00003 00004 #include "Component.h" 00005 #include "net/ConvergenceLayer.h" 00006 #include "net/LOWPANConnection.h" 00007 #include "net/DiscoveryAgent.h" 00008 #include "net/DiscoveryServiceProvider.h" 00009 #include <ibrcommon/net/vinterface.h> 00010 #include <ibrcommon/net/lowpansocket.h> 00011 #include <ibrcommon/net/lowpanstream.h> 00012 00013 #include <list> 00014 00015 using namespace dtn::data; 00016 00017 namespace dtn 00018 { 00019 namespace net 00020 { 00021 class LOWPANConnection; 00025 class LOWPANConvergenceLayer : public DiscoveryAgent, public ConvergenceLayer, public dtn::daemon::IndependentComponent, public ibrcommon::lowpanstream_callback, public EventReceiver, public DiscoveryServiceProvider 00026 { 00027 public: 00028 LOWPANConvergenceLayer(ibrcommon::vinterface net, int panid, unsigned int mtu = 115); //MTU is actually 127... 00029 00030 virtual ~LOWPANConvergenceLayer(); 00031 00035 void update(const ibrcommon::vinterface &iface, std::string &name, std::string &data) throw(dtn::net::DiscoveryServiceProvider::NoServiceHereException); 00036 00037 dtn::core::Node::Protocol getDiscoveryProtocol() const; 00038 00044 void queue(const dtn::core::Node &n, const ConvergenceLayer::Job &job); 00045 00049 virtual const std::string getName() const; 00050 00051 virtual void raiseEvent(const Event *evt); 00052 00059 virtual void send_cb(char *buf, int len, unsigned int address); 00060 00061 static const size_t BUFF_SIZE = 113; 00062 00063 void remove(const LOWPANConnection *conn); 00064 00065 protected: 00066 virtual void componentUp(); 00067 virtual void componentRun(); 00068 virtual void componentDown(); 00069 void __cancellation(); 00070 00071 virtual void sendAnnoucement(const u_int16_t &sn, std::list<dtn::net::DiscoveryService> &services); 00072 00073 private: 00074 ibrcommon::lowpansocket *_socket; 00075 00076 ibrcommon::vinterface _net; 00077 int _panid; 00078 char *_ipnd_buf; 00079 int _ipnd_buf_len; 00080 00081 ibrcommon::Mutex _connection_lock; 00082 std::list<LOWPANConnection*> ConnectionList; 00083 LOWPANConnection* getConnection(unsigned short address); 00084 00085 unsigned int m_maxmsgsize; 00086 00087 ibrcommon::Mutex m_writelock; 00088 ibrcommon::Mutex m_readlock; 00089 00090 bool _running; 00091 }; 00092 } 00093 } 00094 #endif /*LOWPANCONVERGENCELAYER_H_*/