From e7b82d24d48e3a8f3f582595e1ea14f265296312 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Sun, 1 Dec 2013 00:44:45 +0000 Subject: [PATCH] - cleanup tunnel api - doxygen --- src/mesh/gnunet-service-mesh_channel.c | 34 +++++++++++++++----------- src/mesh/gnunet-service-mesh_tunnel.c | 14 +++-------- src/mesh/gnunet-service-mesh_tunnel.h | 3 +-- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c index ec73d67e7..0775c8fa3 100644 --- a/src/mesh/gnunet-service-mesh_channel.c +++ b/src/mesh/gnunet-service-mesh_channel.c @@ -803,6 +803,24 @@ send_ack (struct MeshChannel *ch, int fwd) } +/** + * Sent a message and don't keep any info about it: we won't need to cancel it + * or resend it. + * + * @param msg Header of the message to fire away. + * @param ch Channel on which the message should go. + * @param force Is this a forced (undroppable) message? + */ +static void +fire_and_forget (const struct GNUNET_MessageHeader *msg, + struct MeshChannel *ch, + int force) +{ + GNUNET_break (NULL == GMT_send_prebuilt_message (msg, ch->t, ch, force, + NULL, NULL)); +} + + /** * Notify that a channel create didn't succeed. * @@ -2090,17 +2108,6 @@ GMCH_handle_destroy (struct MeshChannel *ch, } -void -fire_and_forget (struct GNUNET_MessageHeader *msg, - struct MeshChannel *ch, - int force) -{ - GNUNET_break (NULL == GMT_send_prebuilt_message (msg, ch->t, ch, - GNUNET_YES, force, - NULL, NULL)); -} - - /** * Sends an already built message on a channel. * @@ -2173,7 +2180,7 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, LOG (GNUNET_ERROR_TYPE_DEBUG, " new q: %p\n", q); q->copy->q = q; q->q = GMT_send_prebuilt_message (message, ch->t, ch, - fwd, NULL != existing_copy, + NULL != existing_copy, &ch_message_sent, q); /* q itself is stored in copy */ } @@ -2209,8 +2216,7 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, GNUNET_free (q->rel->uniq); } } - q->q = GMT_send_prebuilt_message (message, ch->t, ch, - fwd, GNUNET_YES, + q->q = GMT_send_prebuilt_message (message, ch->t, ch, GNUNET_YES, &ch_message_sent, q); q->rel->uniq = q; break; diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index eb18ae75b..d0177b463 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c @@ -2150,7 +2150,6 @@ GMT_cancel (struct MeshTunnel3Queue *q) * @param message Message to send. Function modifies it. * @param t Tunnel on which this message is transmitted. * @param ch Channel on which this message is transmitted. - * @param fwd Is this a fwd message on @c ch? * @param force Force the tunnel to take the message (buffer overfill). * @param cont Continuation to call once message is really sent. * @param cont_cls Closure for @c cont. @@ -2159,8 +2158,8 @@ GMT_cancel (struct MeshTunnel3Queue *q) */ struct MeshTunnel3Queue * GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message, - struct MeshTunnel3 *t, - struct MeshChannel *ch, int fwd, int force, + struct MeshTunnel3 *t, struct MeshChannel *ch, + int force, GMT_sent cont, void *cont_cls) { struct MeshTunnel3Queue *q; @@ -2171,6 +2170,7 @@ GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message, char cbuf[sizeof (struct GNUNET_MESH_Encrypted) + size]; uint32_t iv; uint16_t type; + int fwd; LOG (GNUNET_ERROR_TYPE_DEBUG, "GMT Send on Tunnel %s\n", GMT_2s (t)); @@ -2181,13 +2181,7 @@ GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message, return NULL; } - if (GMT_is_loopback (t)) - { - LOG (GNUNET_ERROR_TYPE_DEBUG, " loopback!\n"); - handle_decrypted (t, message, fwd); - GNUNET_break (0); /* FIXME replace with assert */ - return NULL; /* Already delivered, cannot cancel */ - } + GNUNET_assert (GNUNET_NO == GMT_is_loopback (t)); iv = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); msg = (struct GNUNET_MESH_Encrypted *) cbuf; diff --git a/src/mesh/gnunet-service-mesh_tunnel.h b/src/mesh/gnunet-service-mesh_tunnel.h index 1a48bf280..e76ad5eb1 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.h +++ b/src/mesh/gnunet-service-mesh_tunnel.h @@ -393,7 +393,6 @@ GMT_cancel (struct MeshTunnel3Queue *q); * @param message Message to send. Function modifies it. * @param t Tunnel on which this message is transmitted. * @param ch Channel on which this message is transmitted. - * @param fwd Is this a fwd message on @c ch? * @param force Force the tunnel to take the message (buffer overfill). * @param cont Continuation to call once message is really sent. * @param cont_cls Closure for @c cont. @@ -403,7 +402,7 @@ GMT_cancel (struct MeshTunnel3Queue *q); struct MeshTunnel3Queue * GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message, struct MeshTunnel3 *t, - struct MeshChannel *ch, int fwd, int force, + struct MeshChannel *ch, int force, GMT_sent cont, void *cont_cls); /** -- 2.25.1