IBR-DTNSuite  0.10
lowpansocket.h
Go to the documentation of this file.
1 /*
2  * lowpansocket.h
3  *
4  * Copyright (C) 2011 IBR, TU Braunschweig
5  *
6  * Written-by: Stefan Schmidt <stefan@datenfreihafen.org>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 
22 #ifndef LOWPANSOCKET_H_
23 #define LOWPANSOCKET_H_
24 
26 #include "ibrcommon/net/vsocket.h"
27 #include "ibrcommon/net/vaddress.h"
28 #include "ibrcommon/Exceptions.h"
29 
30 /* Move to a better place */
32 
33 namespace ibrcommon
34 {
36  {
37  public:
38  lowpansocket(const uint16_t &panid, const vinterface &iface);
39  ~lowpansocket();
40  void up() throw (socket_exception);
41  void down() throw (socket_exception);
42 
46  void setAutoAck(bool enable) throw (socket_exception);
47 
48  virtual ssize_t recvfrom(char *buf, size_t buflen, int flags, ibrcommon::vaddress &addr) throw (socket_exception);
49  virtual void sendto(const char *buf, size_t buflen, int flags, const ibrcommon::vaddress &addr) throw (socket_exception);
50 
51  static void getAddress(const vinterface &iface, const std::string &panid, ibrcommon::vaddress &addr);
52  static void getAddress(struct ieee802154_addr *ret, const vinterface &iface);
53 
54  private:
55  const uint16_t _panid;
56  const vinterface _iface;
57  };
58 }
59 #endif /* LOWPANSOCKET_H_ */