40 : _panid(panid), _iface(iface)
73 }
catch (
const std::bad_cast&) {
74 throw DatagramException(
"bind failed");
76 throw DatagramException(
"bind failed");
98 if (length > _params.max_msg_length)
105 if (socks.size() == 0)
return;
110 LOWPANDatagramService::decode(identifier, destaddr);
113 std::vector<char> tmp(length + 1);
127 tmp[0] |=
static_cast<char>((0x03 & seqno) << 2);
135 ::memcpy(&tmp[1], buf, length);
141 sock.
sendto(&tmp[0], length + 1, 0, destaddr);
155 if (length > _params.max_msg_length)
162 if (socks.size() == 0)
return;
166 std::vector<char> tmp(length + 1);
180 tmp[0] |=
static_cast<char>((0x03 & seqno) << 2);
188 ::memcpy(&tmp[1], buf, length);
197 sock.
sendto(&tmp[0], length + 1, 0, _addr_broadcast);
218 _vsocket.select(&readfds, NULL, NULL, NULL);
220 for (ibrcommon::socketset::iterator iter = readfds.begin(); iter != readfds.end(); ++iter) {
223 std::vector<char> tmp(length + 1);
229 size_t ret = sock.
recvfrom(&tmp[0], length + 1, 0, fromaddr);
235 switch (tmp[0] & (0x03 << 4)) {
251 seqno = (tmp[0] & (0x03 << 2)) >> 2;
260 ::memcpy(buf, &tmp[1], ret);
264 address = LOWPANDatagramService::encode(fromaddr);
283 return "dgram:lowpan";
293 std::stringstream ss_pan; ss_pan << _panid;
299 return LOWPANDatagramService::encode(addr);
327 std::stringstream ss;
328 ss <<
"addr=" << addr.
address() <<
";pan=" << addr.
service() <<
";";
332 void LOWPANDatagramService::decode(
const std::string &identifier,
ibrcommon::vaddress &addr)
339 std::vector<string>::const_iterator param_iter = parameters.begin();
341 while (param_iter != parameters.end())
345 if (p[0].compare(
"addr") == 0)
350 if (p[0].compare(
"pan") == 0)