IBR-DTNSuite
0.8
|
00001 /* 00002 * lowpansocket.h 00003 * 00004 * Created on: 01.06.2010 00005 * Author: stschmid 00006 */ 00007 00008 #ifndef LOWPANSOCKET_H_ 00009 #define LOWPANSOCKET_H_ 00010 00011 #include "ibrcommon/net/vinterface.h" 00012 #include "ibrcommon/net/vsocket.h" 00013 #include "ibrcommon/Exceptions.h" 00014 00015 /* Move to a better place */ 00016 #include "ibrcommon/net/ieee802154.h" 00017 00018 namespace ibrcommon 00019 { 00020 class lowpansocket 00021 { 00022 public: 00023 class SocketException : public ibrcommon::Exception 00024 { 00025 public: 00026 SocketException(string error) : ibrcommon::Exception(error) 00027 {}; 00028 }; 00029 00030 class peer 00031 { 00032 friend class lowpansocket; 00033 00034 protected: 00035 peer(lowpansocket &socket, const struct sockaddr_ieee802154 &dest, const unsigned int panid); 00036 00037 struct sockaddr_ieee802154 _destaddress; 00038 lowpansocket &_socket; 00039 00040 public: 00041 int send(const char *data, const size_t length); 00042 }; 00043 00044 virtual ~lowpansocket(); 00045 00046 virtual void shutdown(); 00047 00048 int receive(char* data, size_t maxbuffer); 00049 00050 lowpansocket::peer getPeer(unsigned int address, const unsigned int panid); 00051 static void getAddress(struct ieee802154_addr *ret, const vinterface &iface); 00052 00053 protected: 00054 lowpansocket(u_char proto = 0) throw (SocketException); 00055 ibrcommon::vsocket _vsocket; 00056 struct sockaddr_ieee802154 _sockaddr; 00057 00058 }; 00059 } 00060 #endif /* LOWPANSOCKET_H_ */