h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
/* count handlers and apps, calculate size */
- for (h->n_applications = 0; stypes[h->n_applications]; h->n_applications++) ;
- for (h->n_handlers = 0; handlers[h->n_handlers].type; h->n_handlers++) ;
+ for (h->n_applications = 0;
+ stypes && stypes[h->n_applications];
+ h->n_applications++) ;
+ for (h->n_handlers = 0;
+ handlers && handlers[h->n_handlers].type;
+ h->n_handlers++) ;
send_connect (h);
LOG (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_MESH_connect() END\n");
return h;
unsigned int compression_characters)
{
struct GNUNET_MESH_RegexAnnounce *msg;
+ size_t payload;
size_t len;
size_t msgsize;
+ size_t offset;
+ char buffer[UINT16_MAX];
len = strlen (regex);
- msgsize = sizeof(struct GNUNET_MESH_RegexAnnounce) + len;
- GNUNET_assert (UINT16_MAX > msgsize);
-
+ payload = UINT16_MAX - sizeof(struct GNUNET_MESH_RegexAnnounce);
+ msg = (struct GNUNET_MESH_RegexAnnounce *) buffer;
+ msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_ANNOUNCE_REGEX);
+ msg->compression_characters = htons (compression_characters);
+ offset = 0;
+ do
{
- char buffer[msgsize];
+ msgsize = (len - offset > payload) ? payload : len - offset;
+ memcpy (&msg[1], ®ex[offset], msgsize);
+ offset += msgsize;
+ msgsize += sizeof(struct GNUNET_MESH_RegexAnnounce);
- msg = (struct GNUNET_MESH_RegexAnnounce *) buffer;
msg->header.size = htons (msgsize);
- msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_ANNOUNCE_REGEX);
- msg->compression_characters = htons (compression_characters);
- memcpy (&msg[1], regex, len);
+ msg->last = htons (offset >= len);
- send_packet(h, &msg->header, NULL);
- }
+ send_packet (h, &msg->header, NULL);
+ } while (len > offset);
}
/**
send_packet (h, &msg.header, NULL);
}
+
/**
* Request that a peer should be added to the tunnel. The existing
* connect handler will be called ONCE with either success or failure.
* This function should NOT be called again with the same peer before the
* connect handler is called.
+ * FIXME: I think the above documentation is false. I think it should
+ * read: "The connect handler will be called once the peer was actually
+ * successfully added to the multicast group. This function should
+ * not be called twice for the same peer (unless, of course,
+ * the peer was removed using GNUNET_MESH_peer_Request_connect_del in
+ * the meantime).
*
* @param tunnel handle to existing tunnel
* @param peer peer to add
msg.tunnel_id = htonl (tunnel->tid);
msg.peer = *peer;
send_packet (tunnel->mesh, &msg.header, tunnel);
-
- return;
}