- add api for regex announce
authorBart Polot <bart@net.in.tum.de>
Fri, 22 Jun 2012 14:13:52 +0000 (14:13 +0000)
committerBart Polot <bart@net.in.tum.de>
Fri, 22 Jun 2012 14:13:52 +0000 (14:13 +0000)
src/include/gnunet_protocols.h
src/mesh/mesh_api.c

index b52303c7f8fab19f0be9de65da2786d9a54874c7..02f53c7dac658cfd1083117c410d91499c876bcd 100644 (file)
@@ -828,17 +828,22 @@ extern "C"
 /**
  * Ask the mesh service to add a peer described by a service string
  */
-#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD_BY_STRING 278
+#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_ANNOUNCE_REGEX   278
+
+/**
+ * Ask the mesh service to add a peer described by a service string
+ */
+#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD_BY_STRING 279
 
 /**
  * Ask the mesh service to add a peer to the blacklist of an existing tunnel
  */
-#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_BLACKLIST   279
+#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_BLACKLIST   280
 
 /**
  * Ask the mesh service to remove a peer from the blacklist of a tunnel
  */
-#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_UNBLACKLIST 280
+#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_UNBLACKLIST 281
 
 /**
  * 640kb should be enough for everybody
index 5860e5d4d7e535621f91aea830d5e8a18a194d65..8b4efce7039679b9f49d47e6a1e190642d635f0f 100644 (file)
@@ -1393,8 +1393,19 @@ GNUNET_MESH_announce_regex (struct GNUNET_MESH_Handle *h,
                             const char *regex)
 {
   struct GNUNET_MessageHeader *msg;
-  
-  msg = GNUNET_malloc
+  size_t len;
+  size_t msgsize;
+
+  len = strlen (regex);
+  msgsize = sizeof(struct GNUNET_MessageHeader) + len;
+  GNUNET_assert (UINT16_MAX > msgsize);
+
+  msg = GNUNET_malloc (msgsize);
+  msg->size = htons (msgsize);
+  msg->type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_ANNOUNCE_REGEX);
+  memcpy (&msg[1], regex, len);
+
+  send_packet(h, msg, NULL);
 }
 
 /**