IBR-DTNSuite  0.8
ibrcommon/ibrcommon/net/UnicastSocketLowpan.cpp
Go to the documentation of this file.
00001 /*
00002  * UnicastSocket.cpp
00003  *
00004  *  Created on: 28.06.2010
00005  *      Author: morgenro
00006  */
00007 
00008 #include "ibrcommon/net/UnicastSocketLowpan.h"
00009 
00010 namespace ibrcommon
00011 {
00012         UnicastSocketLowpan::UnicastSocketLowpan()
00013          : lowpansocket(IPPROTO_UDP) //FIXME
00014         {
00015         }
00016 
00017         UnicastSocketLowpan::~UnicastSocketLowpan()
00018         {
00019         }
00020 
00021         void UnicastSocketLowpan::bind(int panid, const vinterface &iface)
00022         {
00023 
00024                 _sockaddr.addr.addr_type = IEEE802154_ADDR_SHORT;
00025                 _sockaddr.addr.pan_id = panid;
00026 
00027                 // Get address via netlink
00028                 getAddress(&_sockaddr.addr, iface);
00029 
00030                 if ( ::bind(_vsocket.fd(), (struct sockaddr *) &_sockaddr, sizeof(_sockaddr)) < 0 )
00031                 {
00032                         throw SocketException("UnicastSocketLowpan: cannot bind socket");
00033                 }
00034         }
00035 }