34 #include <sys/socket.h>
42 #define EXTENDED_MASK 0x08
43 #define SEQ_NUM_MASK 0x07
45 using namespace dtn::data;
51 LOWPANConvergenceLayer::LOWPANConvergenceLayer(
const ibrcommon::vinterface &net, uint16_t panid,
unsigned int mtu)
52 :
DiscoveryAgent(dtn::daemon::Configuration::getInstance().getDiscovery()),
53 _net(net), _panid(panid), _ipnd_buf(BUFF_SIZE), _ipnd_buf_len(0), m_maxmsgsize(mtu),
_running(false)
87 service <<
"ip=" << address.
addr.
short_addr <<
";port=" << _panid <<
";";
100 if (socks.size() == 0)
return;
106 if (_addr_broadcast == addr) {
111 sock.
sendto(buf, len, 0, _addr_broadcast);
117 sock.
sendto(buf, len, 0, addr);
124 if (uri_list.empty())
return;
133 std::stringstream ss_pan; ss_pan << pan;
147 for(std::list<LOWPANConnection*>::iterator i = ConnectionList.begin(); i != ConnectionList.end(); ++i)
160 ConnectionList.push_back(connection);
170 std::list<LOWPANConnection*>::iterator i;
171 for(i = ConnectionList.begin(); i != ConnectionList.end(); ++i)
175 ConnectionList.erase(i);
220 for (std::list<dtn::net::DiscoveryServiceProvider*>::iterator iter = providers.begin(); iter != providers.end(); ++iter)
226 provider.
update(_net, announcement);
234 _ipnd_buf[1] = (char)0x80;
245 memcpy(&_ipnd_buf[2], ss.str().c_str(), len);
248 send_cb(&_ipnd_buf[0], len + 2, _addr_broadcast);
257 _vsocket.
select(&readfds, NULL, NULL, NULL);
259 for (ibrcommon::socketset::iterator iter = readfds.begin(); iter != readfds.end(); ++iter) {
262 std::vector<char> data(m_maxmsgsize);
269 ssize_t len = sock.
recvfrom(&data[0], static_cast<size_t>(m_maxmsgsize), 0, peeraddr);
284 ss.write(&data[2], len-2);
313 }
catch (
const std::bad_cast&)
325 return "LOWPANConvergenceLayer";