35 #include <sys/socket.h>
43 #define EXTENDED_MASK 0x08
44 #define SEQ_NUM_MASK 0x07
46 using namespace dtn::data;
54 LOWPANConvergenceLayer::LOWPANConvergenceLayer(
const ibrcommon::vinterface &net, uint16_t panid,
unsigned int mtu)
55 : _net(net), _panid(panid), m_maxmsgsize(mtu),
_running(false)
89 service <<
"ip=" << address.
addr.
short_addr <<
";port=" << _panid <<
";";
91 announcement.addService(
DiscoveryService(getDiscoveryProtocol(), service.str()));
102 if (socks.size() == 0)
return;
108 if (_addr_broadcast == addr) {
113 sock.
sendto(buf, len, 0, _addr_broadcast);
119 sock.
sendto(buf, len, 0, addr);
126 if (uri_list.empty())
return;
135 std::stringstream ss_pan; ss_pan << pan;
149 for(std::list<LOWPANConnection*>::iterator i = ConnectionList.begin(); i != ConnectionList.end(); ++i)
162 ConnectionList.push_back(connection);
172 std::list<LOWPANConnection*>::iterator i;
173 for(i = ConnectionList.begin(); i != ConnectionList.end(); ++i)
177 ConnectionList.erase(i);
211 if (_net != iface)
return;
220 ipnd_buf[1] = (char)0x80;
231 memcpy(&ipnd_buf[2], ss.str().c_str(), len);
234 send_cb(&ipnd_buf[0], len + 2, _addr_broadcast);
245 _vsocket.
select(&readfds, NULL, NULL, NULL);
247 for (ibrcommon::socketset::iterator iter = readfds.begin(); iter != readfds.end(); ++iter) {
250 std::vector<char> data(m_maxmsgsize);
257 ssize_t len = sock.
recvfrom(&data[0], static_cast<size_t>(m_maxmsgsize), 0, peeraddr);
272 ss.write(&data[2], len-2);
279 if (!beacon.isShort())
311 return "LOWPANConvergenceLayer";