|
IBR-DTNSuite 0.6
|
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/Exceptions.h" 00013 00014 /* Move to a better place */ 00015 #include "ibrcommon/net/ieee802154.h" 00016 00017 namespace ibrcommon 00018 { 00019 class lowpansocket 00020 { 00021 public: 00022 class SocketException : public ibrcommon::Exception 00023 { 00024 public: 00025 SocketException(string error) : ibrcommon::Exception(error) 00026 {}; 00027 }; 00028 00029 class peer 00030 { 00031 friend class lowpansocket; 00032 00033 protected: 00034 peer(lowpansocket &socket, const struct sockaddr_ieee802154 &dest, const unsigned int panid); 00035 00036 struct sockaddr_ieee802154 _destaddress; 00037 lowpansocket &_socket; 00038 00039 public: 00040 int send(const char *data, const size_t length); 00041 }; 00042 00043 virtual ~lowpansocket(); 00044 00045 virtual void shutdown(); 00046 00047 int receive(char* data, size_t maxbuffer); 00048 00049 lowpansocket::peer getPeer(const std::string address, const unsigned int panid); 00050 00051 protected: 00052 lowpansocket(u_char proto = 0) throw (SocketException); 00053 int _socket; 00054 struct sockaddr_ieee802154 _sockaddr; 00055 00056 static void getAddress(struct ieee802154_addr *ret, const vinterface &iface); 00057 }; 00058 } 00059 #endif /* LOWPANSOCKET_H_ */