diff options
-rw-r--r-- | src/transport/plugin_transport_udp_new.c | 214 |
1 files changed, 153 insertions, 61 deletions
diff --git a/src/transport/plugin_transport_udp_new.c b/src/transport/plugin_transport_udp_new.c index efb131dd4..d914e68eb 100644 --- a/src/transport/plugin_transport_udp_new.c +++ b/src/transport/plugin_transport_udp_new.c | |||
@@ -108,8 +108,10 @@ struct Session | |||
108 | 108 | ||
109 | struct GNUNET_ATS_Information ats; | 109 | struct GNUNET_ATS_Information ats; |
110 | 110 | ||
111 | struct FragmentationContext * head; | 111 | struct FragmentationContext * frag_ctx; |
112 | struct FragmentationContext * tail; | 112 | |
113 | // struct FragmentationContext * head; | ||
114 | // struct FragmentationContext * tail; | ||
113 | }; | 115 | }; |
114 | 116 | ||
115 | 117 | ||
@@ -201,9 +203,6 @@ struct DefragContext | |||
201 | * Length of 'src_addr' | 203 | * Length of 'src_addr' |
202 | */ | 204 | */ |
203 | size_t addr_len; | 205 | size_t addr_len; |
204 | |||
205 | struct GNUNET_PeerIdentity id; | ||
206 | |||
207 | }; | 206 | }; |
208 | 207 | ||
209 | 208 | ||
@@ -257,7 +256,7 @@ struct UDPMessageWrapper | |||
257 | */ | 256 | */ |
258 | void *cont_cls; | 257 | void *cont_cls; |
259 | 258 | ||
260 | struct FragmentationContext *frag; | 259 | struct FragmentationContext *frag_ctx; |
261 | 260 | ||
262 | }; | 261 | }; |
263 | 262 | ||
@@ -526,6 +525,7 @@ disconnect_and_free_it (void *cls, const GNUNET_HashCode * key, void *value) | |||
526 | { | 525 | { |
527 | struct Plugin *plugin = cls; | 526 | struct Plugin *plugin = cls; |
528 | struct Session *s = value; | 527 | struct Session *s = value; |
528 | struct UDPMessageWrapper *udpw; | ||
529 | 529 | ||
530 | #if DEBUG_UDP | 530 | #if DEBUG_UDP |
531 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 531 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -534,22 +534,35 @@ disconnect_and_free_it (void *cls, const GNUNET_HashCode * key, void *value) | |||
534 | GNUNET_i2s (&s->target), | 534 | GNUNET_i2s (&s->target), |
535 | GNUNET_a2s (s->sock_addr, s->addrlen)); | 535 | GNUNET_a2s (s->sock_addr, s->addrlen)); |
536 | #endif | 536 | #endif |
537 | struct FragmentationContext *fctx = s->head; | 537 | plugin->env->session_end (plugin->env->cls, &s->target, s); |
538 | while (fctx != NULL) | 538 | |
539 | while (s->frag_ctx != NULL) | ||
539 | { | 540 | { |
540 | GNUNET_FRAGMENT_context_destroy(fctx->frag); | 541 | GNUNET_FRAGMENT_context_destroy(s->frag_ctx->frag); |
541 | GNUNET_CONTAINER_DLL_remove(s->head, s->tail, fctx); | 542 | GNUNET_free (s->frag_ctx); |
542 | GNUNET_free (fctx); | 543 | s->frag_ctx = NULL; |
543 | fctx = s->head; | ||
544 | } | 544 | } |
545 | 545 | ||
546 | plugin->env->session_end (plugin->env->cls, &s->target, s); | 546 | udpw = plugin->msg_head; |
547 | while (udpw != NULL) | ||
548 | { | ||
549 | if (udpw->session == s) | ||
550 | { | ||
551 | GNUNET_CONTAINER_DLL_remove(plugin->msg_head, plugin->msg_tail, udpw); | ||
552 | |||
553 | if (udpw->cont != NULL) | ||
554 | udpw->cont (udpw->cont_cls, &s->target, GNUNET_SYSERR); | ||
555 | GNUNET_free (udpw); | ||
556 | } | ||
557 | udpw = plugin->msg_head; | ||
558 | } | ||
547 | 559 | ||
548 | GNUNET_assert (GNUNET_YES == | 560 | GNUNET_assert (GNUNET_YES == |
549 | GNUNET_CONTAINER_multihashmap_remove (plugin->sessions, | 561 | GNUNET_CONTAINER_multihashmap_remove (plugin->sessions, |
550 | &s->target.hashPubKey, | 562 | &s->target.hashPubKey, |
551 | s)); | 563 | s)); |
552 | 564 | ||
565 | |||
553 | GNUNET_free (s); | 566 | GNUNET_free (s); |
554 | return GNUNET_OK; | 567 | return GNUNET_OK; |
555 | } | 568 | } |
@@ -576,6 +589,8 @@ udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) | |||
576 | /* Clean up sessions */ | 589 | /* Clean up sessions */ |
577 | GNUNET_CONTAINER_multihashmap_get_multiple (plugin->sessions, &target->hashPubKey, &disconnect_and_free_it, plugin); | 590 | GNUNET_CONTAINER_multihashmap_get_multiple (plugin->sessions, &target->hashPubKey, &disconnect_and_free_it, plugin); |
578 | 591 | ||
592 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
593 | "FREEED SESSIONS from peer `%s'\n", GNUNET_i2s (target)); | ||
579 | } | 594 | } |
580 | 595 | ||
581 | static struct Session * | 596 | static struct Session * |
@@ -650,7 +665,7 @@ static int session_cmp_it (void *cls, | |||
650 | 665 | ||
651 | socklen_t s_addrlen = s->addrlen; | 666 | socklen_t s_addrlen = s->addrlen; |
652 | 667 | ||
653 | #if VERBOSE | 668 | #if VERBOSE_UDP |
654 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Comparing address %s <-> %s\n", | 669 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Comparing address %s <-> %s\n", |
655 | udp_address_to_string (NULL, (void *) address->address, address->address_length), | 670 | udp_address_to_string (NULL, (void *) address->address, address->address_length), |
656 | GNUNET_a2s (s->sock_addr, s->addrlen)); | 671 | GNUNET_a2s (s->sock_addr, s->addrlen)); |
@@ -719,13 +734,13 @@ udp_plugin_get_session (void *cls, | |||
719 | struct SessionCompareContext cctx; | 734 | struct SessionCompareContext cctx; |
720 | cctx.addr = address; | 735 | cctx.addr = address; |
721 | cctx.res = NULL; | 736 | cctx.res = NULL; |
722 | #if DEBUG_UDP | 737 | #if VERBOSE_UDP |
723 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for existing session for peer `%s' `%s' \n", GNUNET_i2s (&address->peer), udp_address_to_string(NULL, address->address, address->address_length)); | 738 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for existing session for peer `%s' `%s' \n", GNUNET_i2s (&address->peer), udp_address_to_string(NULL, address->address, address->address_length)); |
724 | #endif | 739 | #endif |
725 | GNUNET_CONTAINER_multihashmap_get_multiple(plugin->sessions, &address->peer.hashPubKey, session_cmp_it, &cctx); | 740 | GNUNET_CONTAINER_multihashmap_get_multiple(plugin->sessions, &address->peer.hashPubKey, session_cmp_it, &cctx); |
726 | if (cctx.res != NULL) | 741 | if (cctx.res != NULL) |
727 | { | 742 | { |
728 | #if DEBUG_UDP | 743 | #if VERBOSE_UDP |
729 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found existing session %p\n", cctx.res); | 744 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found existing session %p\n", cctx.res); |
730 | #endif | 745 | #endif |
731 | return cctx.res; | 746 | return cctx.res; |
@@ -737,7 +752,7 @@ udp_plugin_get_session (void *cls, | |||
737 | address->address, | 752 | address->address, |
738 | address->address_length, | 753 | address->address_length, |
739 | NULL, NULL); | 754 | NULL, NULL); |
740 | #if DEBUG_UDP | 755 | #if VERBOSE |
741 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 756 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
742 | "Creating new session %p for peer `%s' address `%s'\n", | 757 | "Creating new session %p for peer `%s' address `%s'\n", |
743 | s, | 758 | s, |
@@ -771,10 +786,9 @@ enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg) | |||
771 | 786 | ||
772 | size_t msg_len = ntohs (msg->size); | 787 | size_t msg_len = ntohs (msg->size); |
773 | 788 | ||
774 | #if DEBUG_UDP | 789 | #if VERBOSE_UDP |
790 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Enqueuing fragment with %u bytes %u\n", msg_len , sizeof (struct UDPMessageWrapper)); | ||
775 | #endif | 791 | #endif |
776 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Enqueueing fragment with %u bytes %u\n", msg_len , sizeof (struct UDPMessageWrapper)); | ||
777 | |||
778 | 792 | ||
779 | udpw = GNUNET_malloc (sizeof (struct UDPMessageWrapper) + msg_len); | 793 | udpw = GNUNET_malloc (sizeof (struct UDPMessageWrapper) + msg_len); |
780 | udpw->session = frag_ctx->session; | 794 | udpw->session = frag_ctx->session; |
@@ -784,7 +798,7 @@ enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg) | |||
784 | udpw->cont = frag_ctx->cont; | 798 | udpw->cont = frag_ctx->cont; |
785 | udpw->cont_cls = frag_ctx->cont_cls; | 799 | udpw->cont_cls = frag_ctx->cont_cls; |
786 | udpw->timeout = frag_ctx->timeout; | 800 | udpw->timeout = frag_ctx->timeout; |
787 | udpw->frag = frag_ctx; | 801 | udpw->frag_ctx = frag_ctx; |
788 | memcpy (udpw->udp, msg, msg_len); | 802 | memcpy (udpw->udp, msg, msg_len); |
789 | 803 | ||
790 | GNUNET_CONTAINER_DLL_insert(plugin->msg_head, plugin->msg_tail, udpw); | 804 | GNUNET_CONTAINER_DLL_insert(plugin->msg_head, plugin->msg_tail, udpw); |
@@ -848,7 +862,7 @@ udp_plugin_send (void *cls, | |||
848 | return GNUNET_SYSERR; | 862 | return GNUNET_SYSERR; |
849 | } | 863 | } |
850 | 864 | ||
851 | LOG (GNUNET_ERROR_TYPE_ERROR, | 865 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
852 | "UDP transmits %u-byte message to `%s' using address `%s'\n", | 866 | "UDP transmits %u-byte message to `%s' using address `%s'\n", |
853 | msgbuf_size, | 867 | msgbuf_size, |
854 | GNUNET_i2s (&s->target), | 868 | GNUNET_i2s (&s->target), |
@@ -870,7 +884,7 @@ udp_plugin_send (void *cls, | |||
870 | udpw->timeout = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), to); | 884 | udpw->timeout = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), to); |
871 | udpw->cont = cont; | 885 | udpw->cont = cont; |
872 | udpw->cont_cls = cont_cls; | 886 | udpw->cont_cls = cont_cls; |
873 | udpw->frag = NULL; | 887 | udpw->frag_ctx = NULL; |
874 | 888 | ||
875 | memcpy (udpw->udp, udp, sizeof (struct UDPMessage)); | 889 | memcpy (udpw->udp, udp, sizeof (struct UDPMessage)); |
876 | memcpy (&udpw->udp[sizeof (struct UDPMessage)], msgbuf, msgbuf_size); | 890 | memcpy (&udpw->udp[sizeof (struct UDPMessage)], msgbuf, msgbuf_size); |
@@ -879,8 +893,10 @@ udp_plugin_send (void *cls, | |||
879 | } | 893 | } |
880 | else | 894 | else |
881 | { | 895 | { |
882 | LOG (GNUNET_ERROR_TYPE_ERROR, | 896 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
883 | "UDP has to fragment message \n"); | 897 | "UDP has to fragment message \n"); |
898 | if (s->frag_ctx != NULL) | ||
899 | return GNUNET_SYSERR; | ||
884 | memcpy (&udp[1], msgbuf, msgbuf_size); | 900 | memcpy (&udp[1], msgbuf, msgbuf_size); |
885 | struct FragmentationContext * frag_ctx = GNUNET_malloc(sizeof (struct FragmentationContext)); | 901 | struct FragmentationContext * frag_ctx = GNUNET_malloc(sizeof (struct FragmentationContext)); |
886 | 902 | ||
@@ -898,7 +914,7 @@ udp_plugin_send (void *cls, | |||
898 | &enqueue_fragment, | 914 | &enqueue_fragment, |
899 | frag_ctx); | 915 | frag_ctx); |
900 | 916 | ||
901 | GNUNET_CONTAINER_DLL_insert(s->head, s->tail, frag_ctx); | 917 | s->frag_ctx = frag_ctx; |
902 | 918 | ||
903 | } | 919 | } |
904 | 920 | ||
@@ -1013,7 +1029,7 @@ process_inbound_tokenized_messages (void *cls, void *client, | |||
1013 | &si->sender, | 1029 | &si->sender, |
1014 | hdr, | 1030 | hdr, |
1015 | (const struct GNUNET_ATS_Information *) &ats, 2, | 1031 | (const struct GNUNET_ATS_Information *) &ats, 2, |
1016 | si->session, | 1032 | NULL, |
1017 | si->arg, | 1033 | si->arg, |
1018 | si->args); | 1034 | si->args); |
1019 | si->session->flow_delay_for_other_peer = delay; | 1035 | si->session->flow_delay_for_other_peer = delay; |
@@ -1147,13 +1163,16 @@ fragment_msg_proc (void *cls, const struct GNUNET_MessageHeader *msg) | |||
1147 | GNUNET_break (0); | 1163 | GNUNET_break (0); |
1148 | return; | 1164 | return; |
1149 | } | 1165 | } |
1166 | LOG (GNUNET_ERROR_TYPE_ERROR, "Sending fragment_msg_proc ms\n"); | ||
1150 | process_udp_message (rc->plugin, (const struct UDPMessage *) msg, | 1167 | process_udp_message (rc->plugin, (const struct UDPMessage *) msg, |
1151 | rc->src_addr, rc->addr_len); | 1168 | rc->src_addr, rc->addr_len); |
1152 | } | 1169 | } |
1153 | 1170 | ||
1154 | struct LookupContext | 1171 | struct LookupContext |
1155 | { | 1172 | { |
1156 | struct DefragContext *rc; | 1173 | const struct sockaddr * addr; |
1174 | size_t addrlen; | ||
1175 | |||
1157 | struct Session *res; | 1176 | struct Session *res; |
1158 | }; | 1177 | }; |
1159 | 1178 | ||
@@ -1163,11 +1182,9 @@ lookup_session_by_addr_it (void *cls, const GNUNET_HashCode * key, void *value) | |||
1163 | struct LookupContext *l_ctx = cls; | 1182 | struct LookupContext *l_ctx = cls; |
1164 | struct Session * s = value; | 1183 | struct Session * s = value; |
1165 | 1184 | ||
1166 | if ((s->addrlen == l_ctx->rc->addr_len) && | 1185 | if ((s->addrlen == l_ctx->addrlen) && |
1167 | (0 == memcmp (s->sock_addr, l_ctx->rc->src_addr, s->addrlen))) | 1186 | (0 == memcmp (s->sock_addr, l_ctx->addr, s->addrlen))) |
1168 | { | 1187 | { |
1169 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
1170 | "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY \n"); | ||
1171 | l_ctx->res = s; | 1188 | l_ctx->res = s; |
1172 | return GNUNET_NO; | 1189 | return GNUNET_NO; |
1173 | } | 1190 | } |
@@ -1185,6 +1202,7 @@ static void | |||
1185 | ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) | 1202 | ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) |
1186 | { | 1203 | { |
1187 | struct DefragContext *rc = cls; | 1204 | struct DefragContext *rc = cls; |
1205 | LOG (GNUNET_ERROR_TYPE_ERROR, "Sending ACK ms\n"); | ||
1188 | 1206 | ||
1189 | size_t msize = sizeof (struct UDP_ACK_Message) + ntohs (msg->size); | 1207 | size_t msize = sizeof (struct UDP_ACK_Message) + ntohs (msg->size); |
1190 | struct UDP_ACK_Message *udp_ack; | 1208 | struct UDP_ACK_Message *udp_ack; |
@@ -1193,21 +1211,18 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) | |||
1193 | struct Session *s; | 1211 | struct Session *s; |
1194 | 1212 | ||
1195 | struct LookupContext l_ctx; | 1213 | struct LookupContext l_ctx; |
1196 | l_ctx.rc = rc; | 1214 | l_ctx.addr = rc->src_addr; |
1215 | l_ctx.addrlen = rc->addr_len; | ||
1197 | l_ctx.res = NULL; | 1216 | l_ctx.res = NULL; |
1198 | GNUNET_CONTAINER_multihashmap_get_multiple(rc->plugin->sessions, | 1217 | GNUNET_CONTAINER_multihashmap_iterate (rc->plugin->sessions, |
1199 | &rc->id.hashPubKey, | ||
1200 | &lookup_session_by_addr_it, | 1218 | &lookup_session_by_addr_it, |
1201 | &l_ctx); | 1219 | &l_ctx); |
1202 | s = l_ctx.res; | 1220 | s = l_ctx.res; |
1203 | if (s != NULL) | ||
1204 | { | ||
1205 | if (s->flow_delay_for_other_peer.rel_value <= UINT32_MAX) | ||
1206 | delay = s->flow_delay_for_other_peer.rel_value; | ||
1207 | else | ||
1208 | delay = UINT32_MAX; | ||
1209 | } | ||
1210 | 1221 | ||
1222 | GNUNET_assert (s != NULL); | ||
1223 | |||
1224 | if (s->flow_delay_for_other_peer.rel_value <= UINT32_MAX) | ||
1225 | delay = s->flow_delay_for_other_peer.rel_value; | ||
1211 | 1226 | ||
1212 | #if DEBUG_UDP | 1227 | #if DEBUG_UDP |
1213 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1228 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1221,7 +1236,7 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) | |||
1221 | udpw = GNUNET_malloc (sizeof (struct UDPMessageWrapper) + msize); | 1236 | udpw = GNUNET_malloc (sizeof (struct UDPMessageWrapper) + msize); |
1222 | udpw->cont = NULL; | 1237 | udpw->cont = NULL; |
1223 | udpw->cont_cls = NULL; | 1238 | udpw->cont_cls = NULL; |
1224 | udpw->frag = NULL; | 1239 | udpw->frag_ctx = NULL; |
1225 | udpw->msg_size = msize; | 1240 | udpw->msg_size = msize; |
1226 | udpw->session = s; | 1241 | udpw->session = s; |
1227 | udpw->timeout = GNUNET_TIME_absolute_get_forever(); | 1242 | udpw->timeout = GNUNET_TIME_absolute_get_forever(); |
@@ -1253,15 +1268,79 @@ static void read_process_msg (struct Plugin *plugin, | |||
1253 | return; | 1268 | return; |
1254 | } | 1269 | } |
1255 | 1270 | ||
1256 | static void read_process_ack () | 1271 | static void read_process_ack (struct Plugin *plugin, |
1272 | const struct GNUNET_MessageHeader *msg, | ||
1273 | char *addr, | ||
1274 | socklen_t fromlen) | ||
1257 | { | 1275 | { |
1258 | //const struct GNUNET_MessageHeader *ack; | 1276 | const struct GNUNET_MessageHeader *ack; |
1259 | //struct Session *peer_session; | 1277 | const struct UDP_ACK_Message *udp_ack; |
1260 | //const struct UDP_ACK_Message *udp_ack; | 1278 | struct LookupContext l_ctx; |
1261 | //struct Session *s = NULL; | 1279 | struct Session *s = NULL; |
1262 | //struct GNUNET_TIME_Relative flow_delay; | 1280 | struct GNUNET_TIME_Relative flow_delay; |
1263 | //struct GNUNET_ATS_Information ats; | 1281 | |
1264 | GNUNET_break_op (0); | 1282 | if (ntohs (msg->size) < |
1283 | sizeof (struct UDP_ACK_Message) + sizeof (struct GNUNET_MessageHeader)) | ||
1284 | { | ||
1285 | GNUNET_break_op (0); | ||
1286 | return; | ||
1287 | } | ||
1288 | |||
1289 | udp_ack = (const struct UDP_ACK_Message *) msg; | ||
1290 | |||
1291 | l_ctx.addr = (const struct sockaddr *) addr; | ||
1292 | l_ctx.addrlen = fromlen; | ||
1293 | l_ctx.res = NULL; | ||
1294 | GNUNET_CONTAINER_multihashmap_iterate (plugin->sessions, | ||
1295 | &lookup_session_by_addr_it, | ||
1296 | &l_ctx); | ||
1297 | s = l_ctx.res; | ||
1298 | GNUNET_assert (s != NULL); | ||
1299 | |||
1300 | if (s != NULL) | ||
1301 | { | ||
1302 | flow_delay.rel_value = (uint64_t) ntohl (udp_ack->delay); | ||
1303 | |||
1304 | LOG (GNUNET_ERROR_TYPE_DEBUG, "We received a sending delay of %llu\n", | ||
1305 | flow_delay.rel_value); | ||
1306 | |||
1307 | s->flow_delay_from_other_peer = | ||
1308 | GNUNET_TIME_relative_to_absolute (flow_delay); | ||
1309 | } | ||
1310 | |||
1311 | ack = (const struct GNUNET_MessageHeader *) &udp_ack[1]; | ||
1312 | if (ntohs (ack->size) != | ||
1313 | ntohs (msg->size) - sizeof (struct UDP_ACK_Message)) | ||
1314 | { | ||
1315 | GNUNET_break_op (0); | ||
1316 | return; | ||
1317 | } | ||
1318 | |||
1319 | if (GNUNET_OK != GNUNET_FRAGMENT_process_ack (s->frag_ctx->frag, ack)) | ||
1320 | { | ||
1321 | #if DEBUG_UDP | ||
1322 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1323 | "UDP processes %u-byte acknowledgement from `%s' at `%s'\n", | ||
1324 | (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender), | ||
1325 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | ||
1326 | #endif | ||
1327 | return; | ||
1328 | } | ||
1329 | |||
1330 | #if DEBUG_UDP | ||
1331 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1332 | "FULL MESSAGE ACKed\n", | ||
1333 | (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender), | ||
1334 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | ||
1335 | #endif | ||
1336 | plugin->last_expected_delay = GNUNET_FRAGMENT_context_destroy (s->frag_ctx->frag); | ||
1337 | |||
1338 | if (s->frag_ctx->cont != NULL) | ||
1339 | s->frag_ctx->cont | ||
1340 | (s->frag_ctx->cont_cls, &udp_ack->sender, GNUNET_OK); | ||
1341 | GNUNET_free (s->frag_ctx); | ||
1342 | s->frag_ctx = NULL; | ||
1343 | return; | ||
1265 | } | 1344 | } |
1266 | 1345 | ||
1267 | static void read_process_fragment (struct Plugin *plugin, | 1346 | static void read_process_fragment (struct Plugin *plugin, |
@@ -1307,6 +1386,19 @@ static void read_process_fragment (struct Plugin *plugin, | |||
1307 | GNUNET_CONTAINER_heap_insert (plugin->defrag_ctxs, d_ctx, | 1386 | GNUNET_CONTAINER_heap_insert (plugin->defrag_ctxs, d_ctx, |
1308 | (GNUNET_CONTAINER_HeapCostType) | 1387 | (GNUNET_CONTAINER_HeapCostType) |
1309 | now.abs_value); | 1388 | now.abs_value); |
1389 | #if DEBUG_UDP | ||
1390 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Created new defragmentation context for %u-byte fragment from `%s'\n", | ||
1391 | (unsigned int) ntohs (msg->size), | ||
1392 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | ||
1393 | #endif | ||
1394 | } | ||
1395 | else | ||
1396 | { | ||
1397 | #if DEBUG_UDP | ||
1398 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Found existing defragmentation context for %u-byte fragment from `%s'\n", | ||
1399 | (unsigned int) ntohs (msg->size), | ||
1400 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | ||
1401 | #endif | ||
1310 | } | 1402 | } |
1311 | 1403 | ||
1312 | if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (d_ctx->defrag, msg)) | 1404 | if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (d_ctx->defrag, msg)) |
@@ -1375,7 +1467,7 @@ udp_select_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
1375 | return; | 1467 | return; |
1376 | 1468 | ||
1377 | case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK: | 1469 | case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK: |
1378 | read_process_ack (); | 1470 | read_process_ack (plugin, msg, addr, fromlen);; |
1379 | return; | 1471 | return; |
1380 | 1472 | ||
1381 | case GNUNET_MESSAGE_TYPE_FRAGMENT: | 1473 | case GNUNET_MESSAGE_TYPE_FRAGMENT: |
@@ -1409,13 +1501,13 @@ udp_select_send (struct Plugin *plugin) | |||
1409 | 1501 | ||
1410 | if (udpw->cont != NULL) | 1502 | if (udpw->cont != NULL) |
1411 | udpw->cont (udpw->cont_cls, &udpw->session->target, GNUNET_SYSERR); | 1503 | udpw->cont (udpw->cont_cls, &udpw->session->target, GNUNET_SYSERR); |
1412 | if (udpw->frag != NULL) | 1504 | if (udpw->frag_ctx != NULL) |
1413 | { | 1505 | { |
1414 | #if DEBUG_UDP | 1506 | #if DEBUG_UDP |
1415 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fragmendted message for peer `%s' with size %u timed out\n", | 1507 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fragmented message for peer `%s' with size %u timed out\n", |
1416 | GNUNET_i2s(&udpw->session->target), udpw->frag->bytes_to_send); | 1508 | GNUNET_i2s(&udpw->session->target), udpw->frag_ctx->bytes_to_send); |
1417 | #endif | 1509 | #endif |
1418 | GNUNET_FRAGMENT_context_destroy(udpw->frag->frag); | 1510 | GNUNET_FRAGMENT_context_destroy(udpw->frag_ctx->frag); |
1419 | } | 1511 | } |
1420 | else | 1512 | else |
1421 | { | 1513 | { |
@@ -1462,22 +1554,22 @@ udp_select_send (struct Plugin *plugin) | |||
1462 | if (GNUNET_SYSERR == sent) | 1554 | if (GNUNET_SYSERR == sent) |
1463 | { | 1555 | { |
1464 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto"); | 1556 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto"); |
1465 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1557 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1466 | "UDP transmitted %u-byte message to %s (%d: %s)\n", | 1558 | "UDP transmitted %u-byte message to %s (%d: %s)\n", |
1467 | (unsigned int) ntohs (udpw->msg_size), GNUNET_a2s (sa, slen), (int) sent, | 1559 | (unsigned int) (udpw->msg_size), GNUNET_a2s (sa, slen), (int) sent, |
1468 | (sent < 0) ? STRERROR (errno) : "ok"); | 1560 | (sent < 0) ? STRERROR (errno) : "ok"); |
1469 | if (udpw->cont != NULL) | 1561 | if (udpw->cont != NULL) |
1470 | udpw->cont (udpw->cont_cls, &udpw->session->target, GNUNET_SYSERR); | 1562 | udpw->cont (udpw->cont_cls, &udpw->session->target, GNUNET_SYSERR); |
1471 | } | 1563 | } |
1472 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1564 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1473 | "UDP transmitted %u-byte message to %s (%d: %s)\n", | 1565 | "UDP transmitted %u-byte message to %s (%d: %s)\n", |
1474 | (unsigned int) ntohs (udpw->msg_size), GNUNET_a2s (sa, slen), (int) sent, | 1566 | (unsigned int) (udpw->msg_size), GNUNET_a2s (sa, slen), (int) sent, |
1475 | (sent < 0) ? STRERROR (errno) : "ok"); | 1567 | (sent < 0) ? STRERROR (errno) : "ok"); |
1476 | 1568 | ||
1477 | /* This was just a message fragment */ | 1569 | /* This was just a message fragment */ |
1478 | if (udpw->frag != NULL) | 1570 | if (udpw->frag_ctx != NULL) |
1479 | { | 1571 | { |
1480 | GNUNET_FRAGMENT_context_transmission_done (udpw->frag->frag); | 1572 | GNUNET_FRAGMENT_context_transmission_done (udpw->frag_ctx->frag); |
1481 | } | 1573 | } |
1482 | /* This was a complete message*/ | 1574 | /* This was a complete message*/ |
1483 | else | 1575 | else |
@@ -1865,7 +1957,7 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
1865 | { | 1957 | { |
1866 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 1958 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; |
1867 | struct Plugin *plugin = api->cls; | 1959 | struct Plugin *plugin = api->cls; |
1868 | 1960 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "libgnunet_plugin_transport_udp_done\n "); | |
1869 | stop_broadcast (plugin); | 1961 | stop_broadcast (plugin); |
1870 | 1962 | ||
1871 | if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK) | 1963 | if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK) |