From: Bart Polot Date: Fri, 22 Jun 2012 14:13:52 +0000 (+0000) Subject: - add api for regex announce X-Git-Tag: initial-import-from-subversion-38251~12881 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=86bdc7e1e0c7e56f209c723678f99874fc01da5b;p=oweals%2Fgnunet.git - add api for regex announce --- diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index b52303c7f..02f53c7da 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h @@ -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 diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 5860e5d4d..8b4efce70 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c @@ -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); } /**