-fix fix
[oweals/gnunet.git] / src / mesh / mesh_api.c
index 4fb46a26ea661b76d3b8445f3c9c47ab0ac197a9..bef8ecae3e574b4237969e90f2a0af53d532c013 100644 (file)
@@ -1152,15 +1152,17 @@ process_incoming_data (struct GNUNET_MESH_Handle *h,
   LOG (GNUNET_ERROR_TYPE_DEBUG, "  pid %u\n", pid);
   if (NULL == t)
   {
-    /* Tunnel was ignored, probably service didn't get it yet */
+    /* Tunnel was ignored/destroyed, probably service didn't get it yet */
     LOG (GNUNET_ERROR_TYPE_DEBUG, "  ignored!\n");
     return GNUNET_YES;
   }
-    if (GNUNET_YES ==
-        GMC_is_pid_bigger(pid, t->max_recv_pid))
+  if (GNUNET_YES ==
+      GMC_is_pid_bigger(pid, t->max_recv_pid))
   {
     GNUNET_break (0);
-    LOG (GNUNET_ERROR_TYPE_WARNING, "  unauthorized message!\n");
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+         "  unauthorized message! (%u, max %u)\n",
+         pid, t->max_recv_pid);
     // FIXME fc what now? accept? reject?
     return GNUNET_YES;
   }
@@ -1664,30 +1666,38 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle)
  * (for instance 'gnunet://'). If you put a variable part in there (*, +. ()),
  * all matching strings will be stored in the DHT.
  *
- * @param h handle to mesh.
- * @param regex string with the regular expression describing local services.
+ * @param h Handle to mesh.
+ * @param regex String with the regular expression describing local services.
+ * @param compression_characters How many characters can be assigned to one
+ *                               edge of the graph. The bigger the variability
+ *                               of the data, the smaller this parameter should
+ *                               be (down to 1).
+ *                               For maximum compression, use strlen (regex)
+ *                               or 0 (special value). Use with care!
  */
 void
 GNUNET_MESH_announce_regex (struct GNUNET_MESH_Handle *h,
-                            const char *regex)
+                            const char *regex,
+                            unsigned int compression_characters)
 {
-  struct GNUNET_MessageHeader *msg;
+  struct GNUNET_MESH_RegexAnnounce *msg;
   size_t len;
   size_t msgsize;
 
   len = strlen (regex);
-  msgsize = sizeof(struct GNUNET_MessageHeader) + len;
+  msgsize = sizeof(struct GNUNET_MESH_RegexAnnounce) + len;
   GNUNET_assert (UINT16_MAX > msgsize);
 
   {
     char buffer[msgsize];
 
-    msg = (struct GNUNET_MessageHeader *) buffer;
-    msg->size = htons (msgsize);
-    msg->type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_ANNOUNCE_REGEX);
+    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);
 
-    send_packet(h, msg, NULL);
+    send_packet(h, &msg->header, NULL);
   }
 }