diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-03-06 01:36:20 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-03-06 01:36:20 +0000 |
commit | 469c5e6c8791286db6d9c5801621efc060cec722 (patch) | |
tree | c4650324e3ed91ffb28f89e68a7c9bd027ebff1f /src/mesh/gnunet-service-mesh_tunnel.c | |
parent | 71b8784460c4df4338844b0936a96a0d52cdb111 (diff) | |
download | gnunet-469c5e6c8791286db6d9c5801621efc060cec722.tar.gz gnunet-469c5e6c8791286db6d9c5801621efc060cec722.zip |
Move mesh connection keepalive messages inside tunnel encryption to reduce information leakage.
Diffstat (limited to 'src/mesh/gnunet-service-mesh_tunnel.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh_tunnel.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index 902e64a28..f00544b2e 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c | |||
@@ -724,6 +724,7 @@ queue_data (struct MeshTunnel3 *t, const struct GNUNET_MessageHeader *msg) | |||
724 | * | 724 | * |
725 | * @param message Message to send. Function modifies it. | 725 | * @param message Message to send. Function modifies it. |
726 | * @param t Tunnel on which this message is transmitted. | 726 | * @param t Tunnel on which this message is transmitted. |
727 | * @param c Connection to use (autoselect if NULL). | ||
727 | * @param force Force the tunnel to take the message (buffer overfill). | 728 | * @param force Force the tunnel to take the message (buffer overfill). |
728 | * @param cont Continuation to call once message is really sent. | 729 | * @param cont Continuation to call once message is really sent. |
729 | * @param cont_cls Closure for @c cont. | 730 | * @param cont_cls Closure for @c cont. |
@@ -735,12 +736,11 @@ queue_data (struct MeshTunnel3 *t, const struct GNUNET_MessageHeader *msg) | |||
735 | */ | 736 | */ |
736 | static struct MeshTunnel3Queue * | 737 | static struct MeshTunnel3Queue * |
737 | send_prebuilt_message (const struct GNUNET_MessageHeader *message, | 738 | send_prebuilt_message (const struct GNUNET_MessageHeader *message, |
738 | struct MeshTunnel3 *t, int force, | 739 | struct MeshTunnel3 *t, struct MeshConnection *c, |
739 | GMT_sent cont, void *cont_cls, | 740 | int force, GMT_sent cont, void *cont_cls, |
740 | struct MeshTunnel3Queue *existing_q) | 741 | struct MeshTunnel3Queue *existing_q) |
741 | { | 742 | { |
742 | struct MeshTunnel3Queue *tq; | 743 | struct MeshTunnel3Queue *tq; |
743 | struct MeshConnection *c; | ||
744 | struct GNUNET_MESH_Encrypted *msg; | 744 | struct GNUNET_MESH_Encrypted *msg; |
745 | size_t size = ntohs (message->size); | 745 | size_t size = ntohs (message->size); |
746 | char cbuf[sizeof (struct GNUNET_MESH_Encrypted) + size]; | 746 | char cbuf[sizeof (struct GNUNET_MESH_Encrypted) + size]; |
@@ -776,7 +776,8 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
776 | msg->iv = iv; | 776 | msg->iv = iv; |
777 | GNUNET_assert (t_encrypt (t, &msg[1], message, size, iv) == size); | 777 | GNUNET_assert (t_encrypt (t, &msg[1], message, size, iv) == size); |
778 | msg->header.size = htons (sizeof (struct GNUNET_MESH_Encrypted) + size); | 778 | msg->header.size = htons (sizeof (struct GNUNET_MESH_Encrypted) + size); |
779 | c = tunnel_get_connection (t); | 779 | if (NULL == c) |
780 | c = tunnel_get_connection (t); | ||
780 | if (NULL == c) | 781 | if (NULL == c) |
781 | { | 782 | { |
782 | if (GNUNET_SCHEDULER_NO_TASK != t->destroy_task | 783 | if (GNUNET_SCHEDULER_NO_TASK != t->destroy_task |
@@ -868,7 +869,7 @@ send_queued_data (struct MeshTunnel3 *t) | |||
868 | next = tqd->next; | 869 | next = tqd->next; |
869 | room--; | 870 | room--; |
870 | send_prebuilt_message ((struct GNUNET_MessageHeader *) &tqd[1], | 871 | send_prebuilt_message ((struct GNUNET_MessageHeader *) &tqd[1], |
871 | tqd->t, GNUNET_YES, | 872 | tqd->t, NULL, GNUNET_YES, |
872 | NULL != tqd->tq ? tqd->tq->cont : NULL, | 873 | NULL != tqd->tq ? tqd->tq->cont : NULL, |
873 | NULL != tqd->tq ? tqd->tq->cont_cls : NULL, | 874 | NULL != tqd->tq ? tqd->tq->cont_cls : NULL, |
874 | tqd->tq); | 875 | tqd->tq); |
@@ -1179,7 +1180,7 @@ send_channel_destroy (struct MeshTunnel3 *t, unsigned int gid) | |||
1179 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1180 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1180 | "WARNING destroying unknown channel %u on tunnel %s\n", | 1181 | "WARNING destroying unknown channel %u on tunnel %s\n", |
1181 | gid, GMT_2s (t)); | 1182 | gid, GMT_2s (t)); |
1182 | send_prebuilt_message (&msg.header, t, GNUNET_YES, NULL, NULL, NULL); | 1183 | send_prebuilt_message (&msg.header, t, NULL, GNUNET_YES, NULL, NULL, NULL); |
1183 | } | 1184 | } |
1184 | 1185 | ||
1185 | 1186 | ||
@@ -1552,6 +1553,10 @@ handle_decrypted (struct MeshTunnel3 *t, | |||
1552 | 1553 | ||
1553 | switch (type) | 1554 | switch (type) |
1554 | { | 1555 | { |
1556 | case GNUNET_MESSAGE_TYPE_MESH_KEEPALIVE: | ||
1557 | /* Do nothing, connection aleady got updated. */ | ||
1558 | break; | ||
1559 | |||
1555 | case GNUNET_MESSAGE_TYPE_MESH_DATA: | 1560 | case GNUNET_MESSAGE_TYPE_MESH_DATA: |
1556 | /* Don't send hop ACK, wait for client to ACK */ | 1561 | /* Don't send hop ACK, wait for client to ACK */ |
1557 | handle_data (t, (struct GNUNET_MESH_Data *) msgh, fwd); | 1562 | handle_data (t, (struct GNUNET_MESH_Data *) msgh, fwd); |
@@ -1585,7 +1590,7 @@ handle_decrypted (struct MeshTunnel3 *t, | |||
1585 | 1590 | ||
1586 | default: | 1591 | default: |
1587 | GNUNET_break_op (0); | 1592 | GNUNET_break_op (0); |
1588 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1593 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1589 | "end-to-end message not known (%u)\n", | 1594 | "end-to-end message not known (%u)\n", |
1590 | ntohs (msgh->type)); | 1595 | ntohs (msgh->type)); |
1591 | GMT_debug (t); | 1596 | GMT_debug (t); |
@@ -2506,10 +2511,11 @@ GMT_cancel (struct MeshTunnel3Queue *q) | |||
2506 | 2511 | ||
2507 | /** | 2512 | /** |
2508 | * Sends an already built message on a tunnel, encrypting it and | 2513 | * Sends an already built message on a tunnel, encrypting it and |
2509 | * choosing the best connection. | 2514 | * choosing the best connection if not provided. |
2510 | * | 2515 | * |
2511 | * @param message Message to send. Function modifies it. | 2516 | * @param message Message to send. Function modifies it. |
2512 | * @param t Tunnel on which this message is transmitted. | 2517 | * @param t Tunnel on which this message is transmitted. |
2518 | * @param c Connection to use (autoselect if NULL). | ||
2513 | * @param force Force the tunnel to take the message (buffer overfill). | 2519 | * @param force Force the tunnel to take the message (buffer overfill). |
2514 | * @param cont Continuation to call once message is really sent. | 2520 | * @param cont Continuation to call once message is really sent. |
2515 | * @param cont_cls Closure for @c cont. | 2521 | * @param cont_cls Closure for @c cont. |
@@ -2518,10 +2524,10 @@ GMT_cancel (struct MeshTunnel3Queue *q) | |||
2518 | */ | 2524 | */ |
2519 | struct MeshTunnel3Queue * | 2525 | struct MeshTunnel3Queue * |
2520 | GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | 2526 | GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message, |
2521 | struct MeshTunnel3 *t, int force, | 2527 | struct MeshTunnel3 *t, struct MeshConnection *c, |
2522 | GMT_sent cont, void *cont_cls) | 2528 | int force, GMT_sent cont, void *cont_cls) |
2523 | { | 2529 | { |
2524 | return send_prebuilt_message (message, t, force, cont, cont_cls, NULL); | 2530 | return send_prebuilt_message (message, t, c, force, cont, cont_cls, NULL); |
2525 | } | 2531 | } |
2526 | 2532 | ||
2527 | 2533 | ||