IBR-DTNSuite
0.8
|
00001 /* 00002 * LOWPANDatagramService.h 00003 * 00004 * Created on: 24.11.2011 00005 * Author: morgenro 00006 */ 00007 00008 #ifndef LOWPANDATAGRAMSERVICE_H_ 00009 #define LOWPANDATAGRAMSERVICE_H_ 00010 00011 #include "net/DatagramConvergenceLayer.h" 00012 #include "net/DatagramConnectionParameter.h" 00013 #include <ibrcommon/net/lowpansocket.h> 00014 00015 namespace dtn 00016 { 00017 namespace net 00018 { 00019 class LOWPANDatagramService : public dtn::net::DatagramService 00020 { 00021 public: 00022 LOWPANDatagramService(const ibrcommon::vinterface &iface, int panid); 00023 virtual ~LOWPANDatagramService(); 00024 00029 virtual void bind() throw (DatagramException); 00030 00034 virtual void shutdown(); 00035 00042 virtual void send(const char &type, const char &flags, const unsigned int &seqno, const std::string &address, const char *buf, size_t length) throw (DatagramException); 00043 00049 virtual void send(const char &type, const char &flags, const unsigned int &seqno, const char *buf, size_t length) throw (DatagramException); 00050 00059 virtual size_t recvfrom(char *buf, size_t length, char &type, char &flags, unsigned int &seqno, std::string &address) throw (DatagramException); 00060 00065 virtual const std::string getServiceTag() const; 00066 00072 virtual const std::string getServiceDescription() const; 00073 00078 virtual const ibrcommon::vinterface& getInterface() const; 00079 00084 virtual dtn::core::Node::Protocol getProtocol() const; 00085 00090 virtual const DatagramConnectionParameter& getParameter() const; 00091 00092 private: 00093 static const std::string encode(const uint16_t &addr, const int &panid); 00094 static void decode(const std::string &identifier, uint16_t &addr, int &panid); 00095 00096 const static uint16_t BROADCAST_ADDR = 0; 00097 int _panid; 00098 const ibrcommon::vinterface _iface; 00099 DatagramConnectionParameter _params; 00100 00101 ibrcommon::lowpansocket *_socket; 00102 }; 00103 } /* namespace net */ 00104 } /* namespace dtn */ 00105 #endif /* LOWPANDATAGRAMSERVICE_H_ */