diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-04-11 17:01:26 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-04-11 17:01:26 +0000 |
commit | f3e8dd9be26aa204b77472bc5049fc63ccf98564 (patch) | |
tree | 569301bbb8594e9764f9253929fd4faf2113e38b /src | |
parent | f3ccc5a2dabd83bcb8b7c727ee1d72b3dc22861e (diff) | |
download | gnunet-f3e8dd9be26aa204b77472bc5049fc63ccf98564.tar.gz gnunet-f3e8dd9be26aa204b77472bc5049fc63ccf98564.zip |
- more info in log about payload
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/gnunet-service-mesh_channel.c | 10 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_connection.c | 70 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_connection.h | 2 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_peer.c | 34 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_peer.h | 5 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_tunnel.c | 21 |
6 files changed, 97 insertions, 45 deletions
diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c index bdad559b7..d3bbcdbc0 100644 --- a/src/mesh/gnunet-service-mesh_channel.c +++ b/src/mesh/gnunet-service-mesh_channel.c | |||
@@ -1524,7 +1524,7 @@ GMCH_send_data_ack (struct MeshChannel *ch, int fwd) | |||
1524 | } | 1524 | } |
1525 | rel = fwd ? ch->dest_rel : ch->root_rel; | 1525 | rel = fwd ? ch->dest_rel : ch->root_rel; |
1526 | ack = rel->mid_recv - 1; | 1526 | ack = rel->mid_recv - 1; |
1527 | LOG (GNUNET_ERROR_TYPE_INFO, "=> DATA_ACK for %u\n", ack); | 1527 | LOG (GNUNET_ERROR_TYPE_INFO, "===> DATA_ACK for %u\n", ack); |
1528 | 1528 | ||
1529 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_DATA_ACK); | 1529 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_DATA_ACK); |
1530 | msg.header.size = htons (sizeof (msg)); | 1530 | msg.header.size = htons (sizeof (msg)); |
@@ -1941,7 +1941,7 @@ GMCH_handle_data (struct MeshChannel *ch, | |||
1941 | GNUNET_STATISTICS_update (stats, "# data received", 1, GNUNET_NO); | 1941 | GNUNET_STATISTICS_update (stats, "# data received", 1, GNUNET_NO); |
1942 | 1942 | ||
1943 | mid = ntohl (msg->mid); | 1943 | mid = ntohl (msg->mid); |
1944 | LOG (GNUNET_ERROR_TYPE_INFO, "<= DATA %u %s on channel %s\n", | 1944 | LOG (GNUNET_ERROR_TYPE_INFO, "<=== DATA %u %s on channel %s\n", |
1945 | mid, GM_f2s (fwd), GMCH_2s (ch)); | 1945 | mid, GM_f2s (fwd), GMCH_2s (ch)); |
1946 | 1946 | ||
1947 | if (GNUNET_NO == ch->reliable || | 1947 | if (GNUNET_NO == ch->reliable || |
@@ -2020,7 +2020,7 @@ GMCH_handle_data_ack (struct MeshChannel *ch, | |||
2020 | } | 2020 | } |
2021 | 2021 | ||
2022 | ack = ntohl (msg->mid); | 2022 | ack = ntohl (msg->mid); |
2023 | LOG (GNUNET_ERROR_TYPE_INFO, "<= %s ACK %u\n", GM_f2s (fwd), ack); | 2023 | LOG (GNUNET_ERROR_TYPE_INFO, "<=== %s ACK %u\n", GM_f2s (fwd), ack); |
2024 | 2024 | ||
2025 | if (GNUNET_YES == fwd) | 2025 | if (GNUNET_YES == fwd) |
2026 | { | 2026 | { |
@@ -2295,7 +2295,7 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2295 | uint16_t type; | 2295 | uint16_t type; |
2296 | 2296 | ||
2297 | type = ntohs (message->type); | 2297 | type = ntohs (message->type); |
2298 | LOG (GNUNET_ERROR_TYPE_INFO, "=> %s %s on channel %s\n", | 2298 | LOG (GNUNET_ERROR_TYPE_INFO, "===> %s %s on channel %s\n", |
2299 | GM_m2s (type), GM_f2s (fwd), GMCH_2s (ch)); | 2299 | GM_m2s (type), GM_f2s (fwd), GMCH_2s (ch)); |
2300 | 2300 | ||
2301 | if (GMT_is_loopback (ch->t)) | 2301 | if (GMT_is_loopback (ch->t)) |
@@ -2310,7 +2310,7 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2310 | case GNUNET_MESSAGE_TYPE_MESH_DATA: | 2310 | case GNUNET_MESSAGE_TYPE_MESH_DATA: |
2311 | 2311 | ||
2312 | payload = (struct GNUNET_MESH_Data *) message; | 2312 | payload = (struct GNUNET_MESH_Data *) message; |
2313 | LOG (GNUNET_ERROR_TYPE_INFO, "=> %s %u\n", | 2313 | LOG (GNUNET_ERROR_TYPE_INFO, "===> %s %u\n", |
2314 | GM_m2s (type), ntohl (payload->mid)); | 2314 | GM_m2s (type), ntohl (payload->mid)); |
2315 | if (GNUNET_YES == ch->reliable) | 2315 | if (GNUNET_YES == ch->reliable) |
2316 | { | 2316 | { |
diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index d90d92fe8..022b54d3a 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c | |||
@@ -549,8 +549,9 @@ send_ack (struct MeshConnection *c, unsigned int buffer, int fwd, int force) | |||
549 | msg.ack = htonl (ack); | 549 | msg.ack = htonl (ack); |
550 | msg.cid = c->id; | 550 | msg.cid = c->id; |
551 | 551 | ||
552 | prev_fc->ack_msg = GMC_send_prebuilt_message (&msg.header, c, | 552 | prev_fc->ack_msg = GMC_send_prebuilt_message (&msg.header, |
553 | !fwd, GNUNET_YES, | 553 | GNUNET_MESSAGE_TYPE_MESH_ACK, |
554 | ack, c, !fwd, GNUNET_YES, | ||
554 | &ack_sent, prev_fc); | 555 | &ack_sent, prev_fc); |
555 | } | 556 | } |
556 | 557 | ||
@@ -818,6 +819,7 @@ send_connection_ack (struct MeshConnection *connection, int fwd) | |||
818 | GM_f2s (!fwd), GMC_2s (connection)); | 819 | GM_f2s (!fwd), GMC_2s (connection)); |
819 | GMP_queue_add (get_hop (connection, fwd), NULL, | 820 | GMP_queue_add (get_hop (connection, fwd), NULL, |
820 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK, | 821 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK, |
822 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK, 0, | ||
821 | sizeof (struct GNUNET_MESH_ConnectionACK), | 823 | sizeof (struct GNUNET_MESH_ConnectionACK), |
822 | connection, fwd, &message_sent, NULL); | 824 | connection, fwd, &message_sent, NULL); |
823 | connection->pending_messages++; | 825 | connection->pending_messages++; |
@@ -849,7 +851,9 @@ send_broken (struct MeshConnection *c, | |||
849 | msg.cid = c->id; | 851 | msg.cid = c->id; |
850 | msg.peer1 = *id1; | 852 | msg.peer1 = *id1; |
851 | msg.peer2 = *id2; | 853 | msg.peer2 = *id2; |
852 | GMC_send_prebuilt_message (&msg.header, c, fwd, GNUNET_YES, NULL, NULL); | 854 | GMC_send_prebuilt_message (&msg.header, |
855 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN, 0, | ||
856 | c, fwd, GNUNET_YES, NULL, NULL); | ||
853 | } | 857 | } |
854 | 858 | ||
855 | 859 | ||
@@ -883,6 +887,7 @@ send_broken2 (struct GNUNET_MESH_Hash *connection_id, | |||
883 | neighbor = GMP_get_short (peer_id); | 887 | neighbor = GMP_get_short (peer_id); |
884 | GMP_queue_add (neighbor, msg, | 888 | GMP_queue_add (neighbor, msg, |
885 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN, | 889 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN, |
890 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN, 2, | ||
886 | sizeof (struct GNUNET_MESH_ConnectionBroken), | 891 | sizeof (struct GNUNET_MESH_ConnectionBroken), |
887 | NULL, GNUNET_SYSERR, /* connection, fwd */ | 892 | NULL, GNUNET_SYSERR, /* connection, fwd */ |
888 | NULL, NULL); /* continuation */ | 893 | NULL, NULL); /* continuation */ |
@@ -1236,9 +1241,12 @@ connection_poll (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1236 | msg.header.size = htons (sizeof (msg)); | 1241 | msg.header.size = htons (sizeof (msg)); |
1237 | msg.pid = htonl (fc->last_pid_sent); | 1242 | msg.pid = htonl (fc->last_pid_sent); |
1238 | LOG (GNUNET_ERROR_TYPE_DEBUG, " *** last pid sent: %u!\n", fc->last_pid_sent); | 1243 | LOG (GNUNET_ERROR_TYPE_DEBUG, " *** last pid sent: %u!\n", fc->last_pid_sent); |
1239 | fc->poll_msg = GMC_send_prebuilt_message (&msg.header, c, | 1244 | fc->poll_msg = |
1240 | fc == &c->fwd_fc, GNUNET_YES, | 1245 | GMC_send_prebuilt_message (&msg.header, |
1241 | &poll_sent, fc); | 1246 | GNUNET_MESSAGE_TYPE_MESH_POLL, |
1247 | fc->last_pid_sent, | ||
1248 | c, fc == &c->fwd_fc, GNUNET_YES, | ||
1249 | &poll_sent, fc); | ||
1242 | } | 1250 | } |
1243 | 1251 | ||
1244 | 1252 | ||
@@ -1512,7 +1520,7 @@ log_message (const struct GNUNET_MessageHeader *message, | |||
1512 | const struct GNUNET_PeerIdentity *peer, | 1520 | const struct GNUNET_PeerIdentity *peer, |
1513 | const struct GNUNET_MESH_Hash *hash) | 1521 | const struct GNUNET_MESH_Hash *hash) |
1514 | { | 1522 | { |
1515 | LOG (GNUNET_ERROR_TYPE_INFO, "<- %s on connection %s from %s\n", | 1523 | LOG (GNUNET_ERROR_TYPE_INFO, "<-- %s on connection %s from %s\n", |
1516 | GM_m2s (ntohs (message->type)), GNUNET_h2s (GM_h2hc (hash)), | 1524 | GM_m2s (ntohs (message->type)), GNUNET_h2s (GM_h2hc (hash)), |
1517 | GNUNET_i2s (peer)); | 1525 | GNUNET_i2s (peer)); |
1518 | } | 1526 | } |
@@ -1640,7 +1648,9 @@ GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1640 | LOG (GNUNET_ERROR_TYPE_DEBUG, " Retransmitting.\n"); | 1648 | LOG (GNUNET_ERROR_TYPE_DEBUG, " Retransmitting.\n"); |
1641 | GMP_add_path (dest_peer, path_duplicate (path), GNUNET_NO); | 1649 | GMP_add_path (dest_peer, path_duplicate (path), GNUNET_NO); |
1642 | GMP_add_path_to_origin (orig_peer, path_duplicate (path), GNUNET_NO); | 1650 | GMP_add_path_to_origin (orig_peer, path_duplicate (path), GNUNET_NO); |
1643 | GMC_send_prebuilt_message (message, c, GNUNET_YES, GNUNET_YES, | 1651 | GMC_send_prebuilt_message (message, |
1652 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE, 0, | ||
1653 | c, GNUNET_YES, GNUNET_YES, | ||
1644 | NULL, NULL); | 1654 | NULL, NULL); |
1645 | } | 1655 | } |
1646 | path_destroy (path); | 1656 | path_destroy (path); |
@@ -1768,7 +1778,9 @@ GMC_handle_confirm (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1768 | } | 1778 | } |
1769 | 1779 | ||
1770 | LOG (GNUNET_ERROR_TYPE_DEBUG, " not for us, retransmitting...\n"); | 1780 | LOG (GNUNET_ERROR_TYPE_DEBUG, " not for us, retransmitting...\n"); |
1771 | GMC_send_prebuilt_message (message, c, fwd, GNUNET_YES, NULL, NULL); | 1781 | GMC_send_prebuilt_message (message, |
1782 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK, 0, | ||
1783 | c, fwd, GNUNET_YES, NULL, NULL); | ||
1772 | return GNUNET_OK; | 1784 | return GNUNET_OK; |
1773 | } | 1785 | } |
1774 | 1786 | ||
@@ -1828,7 +1840,9 @@ GMC_handle_broken (void* cls, | |||
1828 | } | 1840 | } |
1829 | else | 1841 | else |
1830 | { | 1842 | { |
1831 | GMC_send_prebuilt_message (message, c, fwd, GNUNET_YES, NULL, NULL); | 1843 | GMC_send_prebuilt_message (message, |
1844 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN, 0, | ||
1845 | c, fwd, GNUNET_YES, NULL, NULL); | ||
1832 | c->destroy = GNUNET_YES; | 1846 | c->destroy = GNUNET_YES; |
1833 | connection_cancel_queues (c, !fwd); | 1847 | connection_cancel_queues (c, !fwd); |
1834 | } | 1848 | } |
@@ -1877,10 +1891,12 @@ GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1877 | return GNUNET_OK; | 1891 | return GNUNET_OK; |
1878 | } | 1892 | } |
1879 | if (GNUNET_NO == GMC_is_terminal (c, fwd)) | 1893 | if (GNUNET_NO == GMC_is_terminal (c, fwd)) |
1880 | GMC_send_prebuilt_message (message, c, fwd, GNUNET_YES, NULL, NULL); | 1894 | GMC_send_prebuilt_message (message, |
1895 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY, 0, | ||
1896 | c, fwd, GNUNET_YES, NULL, NULL); | ||
1881 | else if (0 == c->pending_messages) | 1897 | else if (0 == c->pending_messages) |
1882 | { | 1898 | { |
1883 | LOG (GNUNET_ERROR_TYPE_DEBUG, "! directly destroying connection!\n"); | 1899 | LOG (GNUNET_ERROR_TYPE_DEBUG, " directly destroying connection!\n"); |
1884 | GMC_destroy (c); | 1900 | GMC_destroy (c); |
1885 | return GNUNET_OK; | 1901 | return GNUNET_OK; |
1886 | } | 1902 | } |
@@ -2020,7 +2036,9 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer, | |||
2020 | } | 2036 | } |
2021 | 2037 | ||
2022 | GNUNET_STATISTICS_update (stats, "# messages forwarded", 1, GNUNET_NO); | 2038 | GNUNET_STATISTICS_update (stats, "# messages forwarded", 1, GNUNET_NO); |
2023 | GMC_send_prebuilt_message (&msg->header, c, fwd, GNUNET_NO, NULL, NULL); | 2039 | GMC_send_prebuilt_message (&msg->header, |
2040 | GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED, 0, | ||
2041 | c, fwd, GNUNET_NO, NULL, NULL); | ||
2024 | 2042 | ||
2025 | return GNUNET_OK; | 2043 | return GNUNET_OK; |
2026 | } | 2044 | } |
@@ -2118,7 +2136,8 @@ handle_mesh_kx (const struct GNUNET_PeerIdentity *peer, | |||
2118 | /* Message not for us: forward to next hop */ | 2136 | /* Message not for us: forward to next hop */ |
2119 | LOG (GNUNET_ERROR_TYPE_DEBUG, " not for us, retransmitting...\n"); | 2137 | LOG (GNUNET_ERROR_TYPE_DEBUG, " not for us, retransmitting...\n"); |
2120 | GNUNET_STATISTICS_update (stats, "# messages forwarded", 1, GNUNET_NO); | 2138 | GNUNET_STATISTICS_update (stats, "# messages forwarded", 1, GNUNET_NO); |
2121 | GMC_send_prebuilt_message (&msg->header, c, fwd, GNUNET_NO, NULL, NULL); | 2139 | GMC_send_prebuilt_message (&msg->header, GNUNET_MESSAGE_TYPE_MESH_KX, 0, |
2140 | c, fwd, GNUNET_NO, NULL, NULL); | ||
2122 | 2141 | ||
2123 | return GNUNET_OK; | 2142 | return GNUNET_OK; |
2124 | } | 2143 | } |
@@ -2827,6 +2846,7 @@ GMC_is_direct (struct MeshConnection *c) | |||
2827 | * | 2846 | * |
2828 | * @param message Message to send. Function makes a copy of it. | 2847 | * @param message Message to send. Function makes a copy of it. |
2829 | * If message is not hop-by-hop, decrements TTL of copy. | 2848 | * If message is not hop-by-hop, decrements TTL of copy. |
2849 | * @param payload_type Type of payload, in case the message is encrypted. | ||
2830 | * @param c Connection on which this message is transmitted. | 2850 | * @param c Connection on which this message is transmitted. |
2831 | * @param fwd Is this a fwd message? | 2851 | * @param fwd Is this a fwd message? |
2832 | * @param force Force the connection to accept the message (buffer overfill). | 2852 | * @param force Force the connection to accept the message (buffer overfill). |
@@ -2839,6 +2859,7 @@ GMC_is_direct (struct MeshConnection *c) | |||
2839 | */ | 2859 | */ |
2840 | struct MeshConnectionQueue * | 2860 | struct MeshConnectionQueue * |
2841 | GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | 2861 | GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, |
2862 | uint16_t payload_type, uint32_t payload_id, | ||
2842 | struct MeshConnection *c, int fwd, int force, | 2863 | struct MeshConnection *c, int fwd, int force, |
2843 | GMC_sent cont, void *cont_cls) | 2864 | GMC_sent cont, void *cont_cls) |
2844 | { | 2865 | { |
@@ -2854,8 +2875,8 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2854 | data = GNUNET_malloc (size); | 2875 | data = GNUNET_malloc (size); |
2855 | memcpy (data, message, size); | 2876 | memcpy (data, message, size); |
2856 | type = ntohs (message->type); | 2877 | type = ntohs (message->type); |
2857 | LOG (GNUNET_ERROR_TYPE_INFO, "-> %s on connection %s (%u bytes)\n", | 2878 | LOG (GNUNET_ERROR_TYPE_INFO, "--> %s (%s %u) on connection %s (%u bytes)\n", |
2858 | GM_m2s (type), GMC_2s (c), size); | 2879 | GM_m2s (type), GM_m2s (payload_type), payload_id, GMC_2s (c), size); |
2859 | 2880 | ||
2860 | fc = fwd ? &c->fwd_fc : &c->bck_fc; | 2881 | fc = fwd ? &c->fwd_fc : &c->bck_fc; |
2861 | droppable = GNUNET_NO == force; | 2882 | droppable = GNUNET_NO == force; |
@@ -2961,13 +2982,13 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2961 | } | 2982 | } |
2962 | 2983 | ||
2963 | LOG (GNUNET_ERROR_TYPE_DEBUG, " C_P+ %p %u\n", c, c->pending_messages); | 2984 | LOG (GNUNET_ERROR_TYPE_DEBUG, " C_P+ %p %u\n", c, c->pending_messages); |
2964 | c->pending_messages++; | 2985 | // c->pending_messages++; |
2965 | 2986 | ||
2966 | q = GNUNET_new (struct MeshConnectionQueue); | 2987 | q = GNUNET_new (struct MeshConnectionQueue); |
2967 | q->forced = !droppable; | 2988 | q->forced = !droppable; |
2968 | q->pid = pid; | 2989 | q->pid = pid; |
2969 | q->q = GMP_queue_add (get_hop (c, fwd), data, type, size, c, fwd, | 2990 | q->q = GMP_queue_add (get_hop (c, fwd), data, type, payload_type, payload_id, |
2970 | &message_sent, q); | 2991 | size, c, fwd, &message_sent, q); |
2971 | if (NULL == q->q) | 2992 | if (NULL == q->q) |
2972 | { | 2993 | { |
2973 | LOG (GNUNET_ERROR_TYPE_DEBUG, "WARNING dropping msg on %s\n", GMC_2s (c)); | 2994 | LOG (GNUNET_ERROR_TYPE_DEBUG, "WARNING dropping msg on %s\n", GMC_2s (c)); |
@@ -3025,6 +3046,7 @@ GMC_send_create (struct MeshConnection *connection) | |||
3025 | connection->maintenance_q = | 3046 | connection->maintenance_q = |
3026 | GMP_queue_add (get_next_hop (connection), NULL, | 3047 | GMP_queue_add (get_next_hop (connection), NULL, |
3027 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE, | 3048 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE, |
3049 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE, 0, | ||
3028 | size, connection, GNUNET_YES, &message_sent, NULL); | 3050 | size, connection, GNUNET_YES, &message_sent, NULL); |
3029 | 3051 | ||
3030 | state = GMT_get_cstate (connection->t); | 3052 | state = GMT_get_cstate (connection->t); |
@@ -3060,11 +3082,13 @@ GMC_send_destroy (struct MeshConnection *c) | |||
3060 | GMC_2s (c)); | 3082 | GMC_2s (c)); |
3061 | 3083 | ||
3062 | if (GNUNET_NO == GMC_is_terminal (c, GNUNET_YES)) | 3084 | if (GNUNET_NO == GMC_is_terminal (c, GNUNET_YES)) |
3063 | GMC_send_prebuilt_message (&msg.header, c, | 3085 | GMC_send_prebuilt_message (&msg.header, |
3064 | GNUNET_YES, GNUNET_YES, NULL, NULL); | 3086 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY, 0, |
3087 | c, GNUNET_YES, GNUNET_YES, NULL, NULL); | ||
3065 | if (GNUNET_NO == GMC_is_terminal (c, GNUNET_NO)) | 3088 | if (GNUNET_NO == GMC_is_terminal (c, GNUNET_NO)) |
3066 | GMC_send_prebuilt_message (&msg.header, c, | 3089 | GMC_send_prebuilt_message (&msg.header, |
3067 | GNUNET_NO, GNUNET_YES, NULL, NULL); | 3090 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY, 0, |
3091 | c, GNUNET_NO, GNUNET_YES, NULL, NULL); | ||
3068 | c->destroy = GNUNET_YES; | 3092 | c->destroy = GNUNET_YES; |
3069 | c->state = MESH_CONNECTION_DESTROYED; | 3093 | c->state = MESH_CONNECTION_DESTROYED; |
3070 | } | 3094 | } |
diff --git a/src/mesh/gnunet-service-mesh_connection.h b/src/mesh/gnunet-service-mesh_connection.h index 6864c8733..b97f61194 100644 --- a/src/mesh/gnunet-service-mesh_connection.h +++ b/src/mesh/gnunet-service-mesh_connection.h | |||
@@ -472,6 +472,7 @@ GMC_cancel (struct MeshConnectionQueue *q); | |||
472 | * | 472 | * |
473 | * @param message Message to send. Function makes a copy of it. | 473 | * @param message Message to send. Function makes a copy of it. |
474 | * If message is not hop-by-hop, decrements TTL of copy. | 474 | * If message is not hop-by-hop, decrements TTL of copy. |
475 | * @param payload_type Type of payload, in case the message is encrypted. | ||
475 | * @param c Connection on which this message is transmitted. | 476 | * @param c Connection on which this message is transmitted. |
476 | * @param fwd Is this a fwd message? | 477 | * @param fwd Is this a fwd message? |
477 | * @param force Force the connection to accept the message (buffer overfill). | 478 | * @param force Force the connection to accept the message (buffer overfill). |
@@ -484,6 +485,7 @@ GMC_cancel (struct MeshConnectionQueue *q); | |||
484 | */ | 485 | */ |
485 | struct MeshConnectionQueue * | 486 | struct MeshConnectionQueue * |
486 | GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | 487 | GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, |
488 | uint16_t payload_type, uint32_t payload_id, | ||
487 | struct MeshConnection *c, int fwd, int force, | 489 | struct MeshConnection *c, int fwd, int force, |
488 | GMC_sent cont, void *cont_cls); | 490 | GMC_sent cont, void *cont_cls); |
489 | 491 | ||
diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c index e010f7647..8bd4b6567 100644 --- a/src/mesh/gnunet-service-mesh_peer.c +++ b/src/mesh/gnunet-service-mesh_peer.c | |||
@@ -75,12 +75,22 @@ struct MeshPeerQueue | |||
75 | */ | 75 | */ |
76 | void *cls; | 76 | void *cls; |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Type of message | 79 | * Type of message |
80 | */ | 80 | */ |
81 | uint16_t type; | 81 | uint16_t type; |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Type of message | ||
85 | */ | ||
86 | uint16_t payload_type; | ||
87 | |||
88 | /** | ||
89 | * Type of message | ||
90 | */ | ||
91 | uint32_t payload_id; | ||
92 | |||
93 | /** | ||
84 | * Size of the message | 94 | * Size of the message |
85 | */ | 95 | */ |
86 | size_t size; | 96 | size_t size; |
@@ -984,8 +994,9 @@ queue_send (void *cls, size_t size, void *buf) | |||
984 | else | 994 | else |
985 | { | 995 | { |
986 | LOG (GNUNET_ERROR_TYPE_INFO, | 996 | LOG (GNUNET_ERROR_TYPE_INFO, |
987 | "ss %s on connection %s (%p) %s (size %u)\n", | 997 | "snd %s (%s %u) on connection %s (%p) %s (size %u)\n", |
988 | GM_m2s (queue->type), GMC_2s (c), c, GM_f2s (queue->fwd), data_size); | 998 | GM_m2s (queue->type), GM_m2s (queue->payload_type), |
999 | queue->payload_type, GMC_2s (c), c, GM_f2s (queue->fwd), data_size); | ||
989 | } | 1000 | } |
990 | 1001 | ||
991 | /* Free queue, but cls was freed by send_core_* */ | 1002 | /* Free queue, but cls was freed by send_core_* */ |
@@ -1116,7 +1127,8 @@ GMP_queue_destroy (struct MeshPeerQueue *queue, int clear_cls, int sent) | |||
1116 | * message has been sent and therefore the handle is no longer valid. | 1127 | * message has been sent and therefore the handle is no longer valid. |
1117 | */ | 1128 | */ |
1118 | struct MeshPeerQueue * | 1129 | struct MeshPeerQueue * |
1119 | GMP_queue_add (struct MeshPeer *peer, void *cls, uint16_t type, size_t size, | 1130 | GMP_queue_add (struct MeshPeer *peer, void *cls, uint16_t type, |
1131 | uint16_t payload_type, uint32_t payload_id, size_t size, | ||
1120 | struct MeshConnection *c, int fwd, | 1132 | struct MeshConnection *c, int fwd, |
1121 | GMP_sent cont, void *cont_cls) | 1133 | GMP_sent cont, void *cont_cls) |
1122 | { | 1134 | { |
@@ -1124,8 +1136,10 @@ GMP_queue_add (struct MeshPeer *peer, void *cls, uint16_t type, size_t size, | |||
1124 | int priority; | 1136 | int priority; |
1125 | int call_core; | 1137 | int call_core; |
1126 | 1138 | ||
1127 | LOG (GNUNET_ERROR_TYPE_INFO, "qq %s on connection %s (%p) %s towards %s (size %u)\n", | 1139 | LOG (GNUNET_ERROR_TYPE_INFO, |
1128 | GM_m2s (type), GMC_2s (c), c, GM_f2s (fwd), GMP_2s(peer), size); | 1140 | "que %s (%s %u) on connection %s (%p) %s towards %s (size %u)\n", |
1141 | GM_m2s (type), GM_m2s (payload_type), payload_id, | ||
1142 | GMC_2s (c), c, GM_f2s (fwd), GMP_2s (peer), size); | ||
1129 | 1143 | ||
1130 | if (NULL == peer->connections) | 1144 | if (NULL == peer->connections) |
1131 | { | 1145 | { |
@@ -1150,6 +1164,8 @@ GMP_queue_add (struct MeshPeer *peer, void *cls, uint16_t type, size_t size, | |||
1150 | queue = GNUNET_new (struct MeshPeerQueue); | 1164 | queue = GNUNET_new (struct MeshPeerQueue); |
1151 | queue->cls = cls; | 1165 | queue->cls = cls; |
1152 | queue->type = type; | 1166 | queue->type = type; |
1167 | queue->payload_type = payload_type; | ||
1168 | queue->payload_id = payload_id; | ||
1153 | queue->size = size; | 1169 | queue->size = size; |
1154 | queue->peer = peer; | 1170 | queue->peer = peer; |
1155 | queue->c = c; | 1171 | queue->c = c; |
diff --git a/src/mesh/gnunet-service-mesh_peer.h b/src/mesh/gnunet-service-mesh_peer.h index dca31a94a..153e8a15d 100644 --- a/src/mesh/gnunet-service-mesh_peer.h +++ b/src/mesh/gnunet-service-mesh_peer.h | |||
@@ -148,8 +148,9 @@ GMP_queue_destroy (struct MeshPeerQueue *queue, int clear_cls, int sent); | |||
148 | * message has been sent and therefore the handle is no longer valid. | 148 | * message has been sent and therefore the handle is no longer valid. |
149 | */ | 149 | */ |
150 | struct MeshPeerQueue * | 150 | struct MeshPeerQueue * |
151 | GMP_queue_add (struct MeshPeer *peer, void *cls, uint16_t type, size_t size, | 151 | GMP_queue_add (struct MeshPeer *peer, void *cls, uint16_t type, |
152 | struct MeshConnection *c, int fwd, | 152 | uint16_t payload_type, uint32_t payload_id, |
153 | size_t size, struct MeshConnection *c, int fwd, | ||
153 | GMP_sent cont, void *cont_cls); | 154 | GMP_sent cont, void *cont_cls); |
154 | 155 | ||
155 | /** | 156 | /** |
diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index 6564f3c2a..ed478a7ab 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c | |||
@@ -804,6 +804,7 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
804 | struct GNUNET_MESH_Encrypted *msg; | 804 | struct GNUNET_MESH_Encrypted *msg; |
805 | size_t size = ntohs (message->size); | 805 | size_t size = ntohs (message->size); |
806 | char cbuf[sizeof (struct GNUNET_MESH_Encrypted) + size]; | 806 | char cbuf[sizeof (struct GNUNET_MESH_Encrypted) + size]; |
807 | uint32_t mid; | ||
807 | uint32_t iv; | 808 | uint32_t iv; |
808 | uint16_t type; | 809 | uint16_t type; |
809 | int fwd; | 810 | int fwd; |
@@ -851,12 +852,18 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
851 | return NULL; | 852 | return NULL; |
852 | } | 853 | } |
853 | 854 | ||
855 | mid = 0; | ||
854 | type = ntohs (message->type); | 856 | type = ntohs (message->type); |
855 | switch (type) | 857 | switch (type) |
856 | { | 858 | { |
857 | case GNUNET_MESSAGE_TYPE_MESH_KEEPALIVE: | ||
858 | case GNUNET_MESSAGE_TYPE_MESH_DATA: | 859 | case GNUNET_MESSAGE_TYPE_MESH_DATA: |
859 | case GNUNET_MESSAGE_TYPE_MESH_DATA_ACK: | 860 | case GNUNET_MESSAGE_TYPE_MESH_DATA_ACK: |
861 | if (GNUNET_MESSAGE_TYPE_MESH_DATA == type) | ||
862 | mid = ntohl (((struct GNUNET_MESH_Data *) message)->mid); | ||
863 | else | ||
864 | mid = ntohl (((struct GNUNET_MESH_DataACK *) message)->mid); | ||
865 | /* Fall thru */ | ||
866 | case GNUNET_MESSAGE_TYPE_MESH_KEEPALIVE: | ||
860 | case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE: | 867 | case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE: |
861 | case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY: | 868 | case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY: |
862 | case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK: | 869 | case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK: |
@@ -865,8 +872,7 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
865 | msg->ttl = htonl (default_ttl); | 872 | msg->ttl = htonl (default_ttl); |
866 | break; | 873 | break; |
867 | default: | 874 | default: |
868 | LOG (GNUNET_ERROR_TYPE_DEBUG, "unkown type %s\n", | 875 | LOG (GNUNET_ERROR_TYPE_DEBUG, "unkown type %s\n", GM_m2s (type)); |
869 | GM_m2s (type)); | ||
870 | GNUNET_break (0); | 876 | GNUNET_break (0); |
871 | } | 877 | } |
872 | 878 | ||
@@ -874,7 +880,9 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
874 | 880 | ||
875 | if (NULL == cont) | 881 | if (NULL == cont) |
876 | { | 882 | { |
877 | (void) GMC_send_prebuilt_message (&msg->header, c, fwd, force, NULL, NULL); | 883 | GNUNET_break (NULL == |
884 | GMC_send_prebuilt_message (&msg->header, type, mid, | ||
885 | c, fwd, force, NULL, NULL)); | ||
878 | return NULL; | 886 | return NULL; |
879 | } | 887 | } |
880 | if (NULL == existing_q) | 888 | if (NULL == existing_q) |
@@ -886,7 +894,7 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
886 | tq = existing_q; | 894 | tq = existing_q; |
887 | tq->tqd = NULL; | 895 | tq->tqd = NULL; |
888 | } | 896 | } |
889 | tq->cq = GMC_send_prebuilt_message (&msg->header, c, fwd, force, | 897 | tq->cq = GMC_send_prebuilt_message (&msg->header, type, mid, c, fwd, force, |
890 | &tun_message_sent, tq); | 898 | &tun_message_sent, tq); |
891 | tq->cont = cont; | 899 | tq->cont = cont; |
892 | tq->cont_cls = cont_cls; | 900 | tq->cont_cls = cont_cls; |
@@ -1012,7 +1020,8 @@ send_kx (struct MeshTunnel3 *t, | |||
1012 | 1020 | ||
1013 | fwd = GMC_is_origin (t->connection_head->c, GNUNET_YES); | 1021 | fwd = GMC_is_origin (t->connection_head->c, GNUNET_YES); |
1014 | /* TODO save handle and cancel in case of a unneeded retransmission */ | 1022 | /* TODO save handle and cancel in case of a unneeded retransmission */ |
1015 | GMC_send_prebuilt_message (&msg->header, c, fwd, GNUNET_YES, NULL, NULL); | 1023 | GMC_send_prebuilt_message (&msg->header, GNUNET_MESSAGE_TYPE_MESH_KX, |
1024 | message->type, c, fwd, GNUNET_YES, NULL, NULL); | ||
1016 | } | 1025 | } |
1017 | 1026 | ||
1018 | 1027 | ||