diff options
author | Bart Polot <bart@net.in.tum.de> | 2012-01-17 17:29:00 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2012-01-17 17:29:00 +0000 |
commit | 6a665489add525880f1f609271dace270c868786 (patch) | |
tree | e805d7831358ec188579ae31b0cfd6df96dfaefb /src/mesh | |
parent | 53c1a5bf753575d9ca1c2134e0e99fa38b29a552 (diff) | |
download | gnunet-6a665489add525880f1f609271dace270c868786.tar.gz gnunet-6a665489add525880f1f609271dace270c868786.zip |
Fixed #2070 and simplified data transmission unicast/multicast handling
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 171 |
1 files changed, 85 insertions, 86 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index fb6d09e5a..56ae515f9 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -82,39 +82,50 @@ | |||
82 | /** FWD declaration */ | 82 | /** FWD declaration */ |
83 | struct MeshPeerInfo; | 83 | struct MeshPeerInfo; |
84 | 84 | ||
85 | |||
86 | /** | ||
87 | * Struct representing a piece of data being sent to other peers | ||
88 | */ | ||
89 | struct MeshData | ||
90 | { | ||
91 | /** Tunnel it belongs to. */ | ||
92 | struct MeshTunnel *t; | ||
93 | |||
94 | /** In case of a multicast, task to allow a client to send more data if | ||
95 | * some neighbor is too slow. */ | ||
96 | GNUNET_SCHEDULER_TaskIdentifier *task; | ||
97 | |||
98 | /** How many remaining neighbors we need to send this to. */ | ||
99 | unsigned int *reference_counter; | ||
100 | |||
101 | /** Size of the data. */ | ||
102 | size_t data_len; | ||
103 | |||
104 | /** Data itself */ | ||
105 | void *data; | ||
106 | }; | ||
107 | |||
108 | |||
85 | /** | 109 | /** |
86 | * Struct containing all info possibly needed to build a package when called | 110 | * Struct containing all info possibly needed to build a package when called |
87 | * back by core. | 111 | * back by core. |
88 | */ | 112 | */ |
89 | struct MeshDataDescriptor | 113 | struct MeshTransmissionDescriptor |
90 | { | 114 | { |
91 | /** ID of the tunnel this packet travels in */ | 115 | /** ID of the tunnel this packet travels in */ |
92 | struct MESH_TunnelID *origin; | 116 | struct MESH_TunnelID *origin; |
93 | 117 | ||
94 | /** Data itself */ | ||
95 | void *data; | ||
96 | |||
97 | /** Client that asked for the transmission, if any */ | ||
98 | struct GNUNET_SERVER_Client *client; | ||
99 | |||
100 | /** Who was this message being sent to */ | 118 | /** Who was this message being sent to */ |
101 | struct MeshPeerInfo *peer; | 119 | struct MeshPeerInfo *peer; |
102 | 120 | ||
103 | /** Ultimate destination of the packet */ | 121 | /** Ultimate destination of the packet */ |
104 | GNUNET_PEER_Id destination; | 122 | GNUNET_PEER_Id destination; |
105 | 123 | ||
106 | /** Number of identical messages sent to different hops (multicast) */ | ||
107 | unsigned int *copies; | ||
108 | |||
109 | /** Which handler was used to request the transmission */ | 124 | /** Which handler was used to request the transmission */ |
110 | unsigned int handler_n; | 125 | unsigned int handler_n; |
111 | 126 | ||
112 | /** Size of the data */ | 127 | /** Data descriptor */ |
113 | size_t size; | 128 | struct MeshData* mesh_data; |
114 | |||
115 | /** Used to allow a client send more traffic to the service after a | ||
116 | * previous packet was tried to be sent to a neighbor and couldn't */ | ||
117 | GNUNET_SCHEDULER_TaskIdentifier *timeout_task; | ||
118 | }; | 129 | }; |
119 | 130 | ||
120 | 131 | ||
@@ -723,17 +734,18 @@ client_is_subscribed (uint16_t message_type, struct MeshClient *c) | |||
723 | static void | 734 | static void |
724 | client_allow_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 735 | client_allow_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
725 | { | 736 | { |
726 | struct MeshClient *c = cls; | 737 | struct MeshData *mdata = cls; |
727 | 738 | ||
728 | if (GNUNET_SCHEDULER_REASON_SHUTDOWN == tc->reason) | 739 | if (GNUNET_SCHEDULER_REASON_SHUTDOWN == tc->reason) |
729 | return; | 740 | return; |
730 | #if 0 | 741 | #if MESH_DEBUG |
742 | GNUNET_assert (NULL != mdata->reference_counter); | ||
731 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 743 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
732 | "MESH: CLIENT ALLOW SEND DESPITE %u COPIES PENDING\n", | 744 | "MESH: CLIENT ALLOW SEND DESPITE %u COPIES PENDING\n", |
733 | (info->copies != NULL) ? *(info->copies) : 0); | 745 | mdata->reference_counter); |
734 | #endif | 746 | #endif |
735 | // *(info->timeout_task) = GNUNET_SCHEDULER_NO_TASK; | 747 | *(mdata->task) = GNUNET_SCHEDULER_NO_TASK; |
736 | GNUNET_SERVER_receive_done (c->handle, GNUNET_OK); | 748 | GNUNET_SERVER_receive_done (mdata->t->client->handle, GNUNET_OK); |
737 | } | 749 | } |
738 | 750 | ||
739 | 751 | ||
@@ -912,29 +924,30 @@ send_core_data_multicast (void *cls, size_t size, void *buf); | |||
912 | /** | 924 | /** |
913 | * Decrements the reference counter and frees all resources if needed | 925 | * Decrements the reference counter and frees all resources if needed |
914 | * | 926 | * |
915 | * @param dd Data Descriptor used in a multicast message | 927 | * @param dd Data Descriptor used in a multicast message. Freed if needed. |
916 | */ | 928 | */ |
917 | static void | 929 | static void |
918 | data_descriptor_decrement_multicast (struct MeshDataDescriptor *dd) | 930 | data_descriptor_decrement_multicast (struct MeshData *mesh_data) |
919 | { | 931 | { |
920 | if (0 == --(*(dd->copies))) | 932 | /* Make sure it's a multicast packet */ |
933 | GNUNET_assert (NULL != mesh_data->reference_counter); | ||
934 | |||
935 | if (0 == --(*(mesh_data->reference_counter))) | ||
921 | { | 936 | { |
922 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Last copy!\n"); | 937 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Last copy!\n"); |
923 | if (NULL != dd->client) | 938 | if (NULL != mesh_data->task) |
924 | { | 939 | { |
925 | if (GNUNET_SCHEDULER_NO_TASK != *(dd->timeout_task)) | 940 | if (GNUNET_SCHEDULER_NO_TASK != *(mesh_data->task)) |
926 | { | 941 | { |
927 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 942 | GNUNET_SCHEDULER_cancel (*(mesh_data->task)); |
928 | "MESH: cancelling client timeout (%u)...\n", | ||
929 | *(dd->timeout_task)); | ||
930 | GNUNET_SCHEDULER_cancel (*(dd->timeout_task)); | ||
931 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: notifying client...\n"); | 943 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: notifying client...\n"); |
932 | GNUNET_SERVER_receive_done (dd->client, GNUNET_OK); | 944 | GNUNET_SERVER_receive_done (mesh_data->t->client->handle, GNUNET_OK); |
933 | } | 945 | } |
934 | GNUNET_free (dd->timeout_task); | 946 | GNUNET_free (mesh_data->task); |
935 | } | 947 | } |
936 | GNUNET_free (dd->copies); | 948 | GNUNET_free (mesh_data->reference_counter); |
937 | GNUNET_free (dd->data); | 949 | GNUNET_free (mesh_data->data); |
950 | GNUNET_free (mesh_data); | ||
938 | } | 951 | } |
939 | } | 952 | } |
940 | 953 | ||
@@ -951,7 +964,7 @@ peer_info_cancel_transmission (struct MeshPeerInfo *peer, unsigned int i) | |||
951 | { | 964 | { |
952 | if (NULL != peer->core_transmit[i]) | 965 | if (NULL != peer->core_transmit[i]) |
953 | { | 966 | { |
954 | struct MeshDataDescriptor *dd; | 967 | struct MeshTransmissionDescriptor *dd; |
955 | struct MeshPathInfo *path_info; | 968 | struct MeshPathInfo *path_info; |
956 | 969 | ||
957 | #if MESH_DEBUG | 970 | #if MESH_DEBUG |
@@ -974,7 +987,7 @@ peer_info_cancel_transmission (struct MeshPeerInfo *peer, unsigned int i) | |||
974 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: | 987 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: |
975 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: type payload\n"); | 988 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: type payload\n"); |
976 | dd = peer->infos[i]; | 989 | dd = peer->infos[i]; |
977 | data_descriptor_decrement_multicast (dd); | 990 | data_descriptor_decrement_multicast (dd->mesh_data); |
978 | break; | 991 | break; |
979 | case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE: | 992 | case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE: |
980 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: type create path\n"); | 993 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: type create path\n"); |
@@ -1099,7 +1112,7 @@ peer_info_delete_tunnel (void *cls, const GNUNET_HashCode * key, void *value) | |||
1099 | /** | 1112 | /** |
1100 | * Core callback to write a | 1113 | * Core callback to write a |
1101 | * | 1114 | * |
1102 | * @param cls Closure (MeshDataDescriptor with data in "data" member). | 1115 | * @param cls Closure (MeshTransmissionDescriptor with data in "data" member). |
1103 | * @param size Number of bytes available in buf. | 1116 | * @param size Number of bytes available in buf. |
1104 | * @param buf Where the to write the message. | 1117 | * @param buf Where the to write the message. |
1105 | * | 1118 | * |
@@ -1108,13 +1121,13 @@ peer_info_delete_tunnel (void *cls, const GNUNET_HashCode * key, void *value) | |||
1108 | static size_t | 1121 | static size_t |
1109 | send_core_data_raw (void *cls, size_t size, void *buf) | 1122 | send_core_data_raw (void *cls, size_t size, void *buf) |
1110 | { | 1123 | { |
1111 | struct MeshDataDescriptor *info = cls; | 1124 | struct MeshTransmissionDescriptor *info = cls; |
1112 | struct GNUNET_MessageHeader *msg; | 1125 | struct GNUNET_MessageHeader *msg; |
1113 | size_t total_size; | 1126 | size_t total_size; |
1114 | 1127 | ||
1115 | GNUNET_assert (NULL != info); | 1128 | GNUNET_assert (NULL != info); |
1116 | GNUNET_assert (NULL != info->data); | 1129 | GNUNET_assert (NULL != info->mesh_data); |
1117 | msg = (struct GNUNET_MessageHeader *) info->data; | 1130 | msg = (struct GNUNET_MessageHeader *) info->mesh_data->data; |
1118 | total_size = ntohs (msg->size); | 1131 | total_size = ntohs (msg->size); |
1119 | 1132 | ||
1120 | if (total_size > size) | 1133 | if (total_size > size) |
@@ -1130,7 +1143,7 @@ send_core_data_raw (void *cls, size_t size, void *buf) | |||
1130 | } | 1143 | } |
1131 | info->peer->core_transmit[info->handler_n] = NULL; | 1144 | info->peer->core_transmit[info->handler_n] = NULL; |
1132 | memcpy (buf, msg, total_size); | 1145 | memcpy (buf, msg, total_size); |
1133 | GNUNET_free (info->data); | 1146 | GNUNET_free (info->mesh_data); |
1134 | GNUNET_free (info); | 1147 | GNUNET_free (info); |
1135 | return total_size; | 1148 | return total_size; |
1136 | } | 1149 | } |
@@ -1142,12 +1155,14 @@ send_core_data_raw (void *cls, size_t size, void *buf) | |||
1142 | * | 1155 | * |
1143 | * @param message Message to send. Fucntion makes a copy of it. | 1156 | * @param message Message to send. Fucntion makes a copy of it. |
1144 | * @param peer Short ID of the neighbor whom to send the message. | 1157 | * @param peer Short ID of the neighbor whom to send the message. |
1158 | * | ||
1159 | * FIXME tunnel? | ||
1145 | */ | 1160 | */ |
1146 | static void | 1161 | static void |
1147 | send_message (const struct GNUNET_MessageHeader *message, | 1162 | send_message (const struct GNUNET_MessageHeader *message, |
1148 | const struct GNUNET_PeerIdentity *peer) | 1163 | const struct GNUNET_PeerIdentity *peer) |
1149 | { | 1164 | { |
1150 | struct MeshDataDescriptor *info; | 1165 | struct MeshTransmissionDescriptor *info; |
1151 | struct MeshPeerInfo *neighbor; | 1166 | struct MeshPeerInfo *neighbor; |
1152 | struct MeshPeerPath *p; | 1167 | struct MeshPeerPath *p; |
1153 | unsigned int i; | 1168 | unsigned int i; |
@@ -1156,9 +1171,11 @@ send_message (const struct GNUNET_MessageHeader *message, | |||
1156 | // GNUNET_TRANSPORT_try_connect(); | 1171 | // GNUNET_TRANSPORT_try_connect(); |
1157 | 1172 | ||
1158 | size = ntohs (message->size); | 1173 | size = ntohs (message->size); |
1159 | info = GNUNET_malloc (sizeof (struct MeshDataDescriptor)); | 1174 | info = GNUNET_malloc (sizeof (struct MeshTransmissionDescriptor)); |
1160 | info->data = GNUNET_malloc (size); | 1175 | info->mesh_data = GNUNET_malloc (sizeof (struct MeshData)); |
1161 | memcpy (info->data, message, size); | 1176 | info->mesh_data->data = GNUNET_malloc (size); |
1177 | memcpy (info->mesh_data->data, message, size); | ||
1178 | info->mesh_data->data_len = size; | ||
1162 | neighbor = peer_info_get (peer); | 1179 | neighbor = peer_info_get (peer); |
1163 | for (p = neighbor->path_head; NULL != p; p = p->next) | 1180 | for (p = neighbor->path_head; NULL != p; p = p->next) |
1164 | { | 1181 | { |
@@ -1170,6 +1187,8 @@ send_message (const struct GNUNET_MessageHeader *message, | |||
1170 | if (NULL == p) | 1187 | if (NULL == p) |
1171 | { | 1188 | { |
1172 | GNUNET_break (0); | 1189 | GNUNET_break (0); |
1190 | GNUNET_free (info->mesh_data->data); | ||
1191 | GNUNET_free (info->mesh_data); | ||
1173 | GNUNET_free (info); | 1192 | GNUNET_free (info); |
1174 | return; | 1193 | return; |
1175 | } | 1194 | } |
@@ -1978,20 +1997,6 @@ tunnel_notify_connection_broken (struct MeshTunnel *t, GNUNET_PEER_Id p1, | |||
1978 | } | 1997 | } |
1979 | 1998 | ||
1980 | 1999 | ||
1981 | struct MeshMulticastData | ||
1982 | { | ||
1983 | struct MeshTunnel *t; | ||
1984 | |||
1985 | GNUNET_SCHEDULER_TaskIdentifier *task; | ||
1986 | |||
1987 | unsigned int *reference_counter; | ||
1988 | |||
1989 | size_t data_len; | ||
1990 | |||
1991 | void *data; | ||
1992 | }; | ||
1993 | |||
1994 | |||
1995 | /** | 2000 | /** |
1996 | * Send a multicast packet to a neighbor. | 2001 | * Send a multicast packet to a neighbor. |
1997 | * | 2002 | * |
@@ -2001,23 +2006,15 @@ struct MeshMulticastData | |||
2001 | static void | 2006 | static void |
2002 | tunnel_send_multicast_iterator (void *cls, GNUNET_PEER_Id neighbor_id) | 2007 | tunnel_send_multicast_iterator (void *cls, GNUNET_PEER_Id neighbor_id) |
2003 | { | 2008 | { |
2004 | struct MeshMulticastData *mdata = cls; | 2009 | struct MeshData *mdata = cls; |
2005 | struct MeshDataDescriptor *info; | 2010 | struct MeshTransmissionDescriptor *info; |
2006 | struct GNUNET_PeerIdentity neighbor; | 2011 | struct GNUNET_PeerIdentity neighbor; |
2007 | unsigned int i; | 2012 | unsigned int i; |
2008 | 2013 | ||
2009 | info = GNUNET_malloc (sizeof (struct MeshDataDescriptor)); | 2014 | info = GNUNET_malloc (sizeof (struct MeshTransmissionDescriptor)); |
2010 | |||
2011 | info->data = mdata->data; | ||
2012 | info->size = mdata->data_len; | ||
2013 | info->copies = mdata->reference_counter; | ||
2014 | (*(mdata->reference_counter))++; | ||
2015 | 2015 | ||
2016 | if (NULL != mdata->t->client) | 2016 | info->mesh_data = mdata; |
2017 | { | 2017 | (*(mdata->reference_counter)) ++; |
2018 | info->client = mdata->t->client->handle; | ||
2019 | info->timeout_task = mdata->task; | ||
2020 | } | ||
2021 | info->destination = neighbor_id; | 2018 | info->destination = neighbor_id; |
2022 | GNUNET_PEER_resolve (neighbor_id, &neighbor); | 2019 | GNUNET_PEER_resolve (neighbor_id, &neighbor); |
2023 | #if MESH_DEBUG | 2020 | #if MESH_DEBUG |
@@ -2033,7 +2030,7 @@ tunnel_send_multicast_iterator (void *cls, GNUNET_PEER_Id neighbor_id) | |||
2033 | info->peer->core_transmit[i] = | 2030 | info->peer->core_transmit[i] = |
2034 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, | 2031 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, |
2035 | GNUNET_TIME_UNIT_FOREVER_REL, | 2032 | GNUNET_TIME_UNIT_FOREVER_REL, |
2036 | &neighbor, info->size, | 2033 | &neighbor, info->mesh_data->data_len, |
2037 | &send_core_data_multicast, info); | 2034 | &send_core_data_multicast, info); |
2038 | } | 2035 | } |
2039 | 2036 | ||
@@ -2048,13 +2045,13 @@ static void | |||
2048 | tunnel_send_multicast (struct MeshTunnel *t, | 2045 | tunnel_send_multicast (struct MeshTunnel *t, |
2049 | const struct GNUNET_MessageHeader *msg) | 2046 | const struct GNUNET_MessageHeader *msg) |
2050 | { | 2047 | { |
2051 | struct MeshMulticastData *mdata; | 2048 | struct MeshData *mdata; |
2052 | 2049 | ||
2053 | #if MESH_DEBUG | 2050 | #if MESH_DEBUG |
2054 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2051 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2055 | "MESH: sending a multicast packet...\n"); | 2052 | "MESH: sending a multicast packet...\n"); |
2056 | #endif | 2053 | #endif |
2057 | mdata = GNUNET_malloc (sizeof (struct MeshMulticastData)); | 2054 | mdata = GNUNET_malloc (sizeof (struct MeshData)); |
2058 | mdata->data_len = ntohs (msg->size); | 2055 | mdata->data_len = ntohs (msg->size); |
2059 | mdata->reference_counter = GNUNET_malloc (sizeof (unsigned int)); | 2056 | mdata->reference_counter = GNUNET_malloc (sizeof (unsigned int)); |
2060 | mdata->t = t; | 2057 | mdata->t = t; |
@@ -2078,9 +2075,11 @@ tunnel_send_multicast (struct MeshTunnel *t, | |||
2078 | if (NULL != t->client) | 2075 | if (NULL != t->client) |
2079 | { | 2076 | { |
2080 | mdata->task = GNUNET_malloc (sizeof (GNUNET_SCHEDULER_TaskIdentifier)); | 2077 | mdata->task = GNUNET_malloc (sizeof (GNUNET_SCHEDULER_TaskIdentifier)); |
2081 | *(mdata->task) = | 2078 | (*(mdata->task)) = |
2082 | GNUNET_SCHEDULER_add_delayed (UNACKNOWLEDGED_WAIT, &client_allow_send, | 2079 | GNUNET_SCHEDULER_add_delayed (UNACKNOWLEDGED_WAIT, &client_allow_send, |
2083 | t->client->handle); | 2080 | mdata); |
2081 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: timeout task %u\n", | ||
2082 | *(mdata->task)); | ||
2084 | } | 2083 | } |
2085 | 2084 | ||
2086 | tree_iterate_children (t->tree, &tunnel_send_multicast_iterator, mdata); | 2085 | tree_iterate_children (t->tree, &tunnel_send_multicast_iterator, mdata); |
@@ -2089,8 +2088,8 @@ tunnel_send_multicast (struct MeshTunnel *t, | |||
2089 | GNUNET_free (mdata->data); | 2088 | GNUNET_free (mdata->data); |
2090 | GNUNET_free (mdata->reference_counter); | 2089 | GNUNET_free (mdata->reference_counter); |
2091 | GNUNET_free_non_null (mdata->task); | 2090 | GNUNET_free_non_null (mdata->task); |
2091 | GNUNET_free (mdata); | ||
2092 | } | 2092 | } |
2093 | GNUNET_free (mdata); | ||
2094 | #if MESH_DEBUG | 2093 | #if MESH_DEBUG |
2095 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2094 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2096 | "MESH: sending a multicast packet done\n"); | 2095 | "MESH: sending a multicast packet done\n"); |
@@ -2361,13 +2360,13 @@ send_core_create_path (void *cls, size_t size, void *buf) | |||
2361 | static size_t | 2360 | static size_t |
2362 | send_core_data_multicast (void *cls, size_t size, void *buf) | 2361 | send_core_data_multicast (void *cls, size_t size, void *buf) |
2363 | { | 2362 | { |
2364 | struct MeshDataDescriptor *info = cls; | 2363 | struct MeshTransmissionDescriptor *info = cls; |
2365 | size_t total_size; | 2364 | size_t total_size; |
2366 | 2365 | ||
2367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Multicast callback.\n"); | 2366 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Multicast callback.\n"); |
2368 | GNUNET_assert (NULL != info); | 2367 | GNUNET_assert (NULL != info); |
2369 | GNUNET_assert (NULL != info->peer); | 2368 | GNUNET_assert (NULL != info->peer); |
2370 | total_size = info->size; | 2369 | total_size = info->mesh_data->data_len; |
2371 | GNUNET_assert (total_size < GNUNET_SERVER_MAX_MESSAGE_SIZE); | 2370 | GNUNET_assert (total_size < GNUNET_SERVER_MAX_MESSAGE_SIZE); |
2372 | 2371 | ||
2373 | if (total_size > size) | 2372 | if (total_size > size) |
@@ -2389,7 +2388,7 @@ send_core_data_multicast (void *cls, size_t size, void *buf) | |||
2389 | info->peer->core_transmit[info->handler_n] = NULL; | 2388 | info->peer->core_transmit[info->handler_n] = NULL; |
2390 | info->peer->infos[info->handler_n] = NULL; | 2389 | info->peer->infos[info->handler_n] = NULL; |
2391 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: copying data...\n"); | 2390 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: copying data...\n"); |
2392 | memcpy (buf, info->data, total_size); | 2391 | memcpy (buf, info->mesh_data->data, total_size); |
2393 | #if MESH_DEBUG | 2392 | #if MESH_DEBUG |
2394 | { | 2393 | { |
2395 | struct GNUNET_MESH_Multicast *mc; | 2394 | struct GNUNET_MESH_Multicast *mc; |
@@ -2412,7 +2411,7 @@ send_core_data_multicast (void *cls, size_t size, void *buf) | |||
2412 | } | 2411 | } |
2413 | } | 2412 | } |
2414 | #endif | 2413 | #endif |
2415 | data_descriptor_decrement_multicast (info); | 2414 | data_descriptor_decrement_multicast (info->mesh_data); |
2416 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: freeing info...\n"); | 2415 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: freeing info...\n"); |
2417 | GNUNET_free (info); | 2416 | GNUNET_free (info); |
2418 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: return %u\n", total_size); | 2417 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: return %u\n", total_size); |
@@ -2426,7 +2425,7 @@ send_core_data_multicast (void *cls, size_t size, void *buf) | |||
2426 | * NULL and "size" zero if the socket was closed for | 2425 | * NULL and "size" zero if the socket was closed for |
2427 | * writing in the meantime. | 2426 | * writing in the meantime. |
2428 | * | 2427 | * |
2429 | * @param cls closure (MeshDataDescriptor) | 2428 | * @param cls closure (MeshTransmissionDescriptor) |
2430 | * @param size number of bytes available in buf | 2429 | * @param size number of bytes available in buf |
2431 | * @param buf where the callee should write the message | 2430 | * @param buf where the callee should write the message |
2432 | * @return number of bytes written to buf | 2431 | * @return number of bytes written to buf |
@@ -2434,7 +2433,7 @@ send_core_data_multicast (void *cls, size_t size, void *buf) | |||
2434 | static size_t | 2433 | static size_t |
2435 | send_core_path_ack (void *cls, size_t size, void *buf) | 2434 | send_core_path_ack (void *cls, size_t size, void *buf) |
2436 | { | 2435 | { |
2437 | struct MeshDataDescriptor *info = cls; | 2436 | struct MeshTransmissionDescriptor *info = cls; |
2438 | struct GNUNET_MESH_PathACK *msg = buf; | 2437 | struct GNUNET_MESH_PathACK *msg = buf; |
2439 | 2438 | ||
2440 | GNUNET_assert (NULL != info); | 2439 | GNUNET_assert (NULL != info); |
@@ -2605,7 +2604,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2605 | if (own_pos == size - 1) | 2604 | if (own_pos == size - 1) |
2606 | { | 2605 | { |
2607 | /* It is for us! Send ack. */ | 2606 | /* It is for us! Send ack. */ |
2608 | struct MeshDataDescriptor *info; | 2607 | struct MeshTransmissionDescriptor *info; |
2609 | unsigned int j; | 2608 | unsigned int j; |
2610 | 2609 | ||
2611 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: It's for us!\n"); | 2610 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: It's for us!\n"); |
@@ -2631,7 +2630,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2631 | (&my_full_id), | 2630 | (&my_full_id), |
2632 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE)); | 2631 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE)); |
2633 | /* FIXME use send_message */ | 2632 | /* FIXME use send_message */ |
2634 | info = GNUNET_malloc (sizeof (struct MeshDataDescriptor)); | 2633 | info = GNUNET_malloc (sizeof (struct MeshTransmissionDescriptor)); |
2635 | info->origin = &t->id; | 2634 | info->origin = &t->id; |
2636 | info->peer = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); | 2635 | info->peer = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); |
2637 | GNUNET_assert (NULL != info->peer); | 2636 | GNUNET_assert (NULL != info->peer); |