diff options
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 1630c48b1..c7bfe6237 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -273,6 +273,11 @@ struct UDP_FragmentationContext | |||
273 | * Payload size of original unfragmented message | 273 | * Payload size of original unfragmented message |
274 | */ | 274 | */ |
275 | size_t payload_size; | 275 | size_t payload_size; |
276 | |||
277 | /** | ||
278 | * Bytes used to send all fragments on wire including UDP overhead | ||
279 | */ | ||
280 | size_t on_wire_size; | ||
276 | }; | 281 | }; |
277 | 282 | ||
278 | 283 | ||
@@ -688,7 +693,12 @@ call_continuation (struct UDP_MessageWrapper *udpw, int result) | |||
688 | if (NULL != udpw->cont) | 693 | if (NULL != udpw->cont) |
689 | { | 694 | { |
690 | /* FIXME: add bytes used on wire here */ | 695 | /* FIXME: add bytes used on wire here */ |
691 | udpw->cont (udpw->cont_cls, &udpw->session->target, result); | 696 | /* Calls transport continuation if message was not fragmented, |
697 | * GNUNET_FRAGMENT if just an fragment was sent | ||
698 | */ | ||
699 | |||
700 | /* Call continuation for fragmented message */ | ||
701 | udpw->cont (udpw->cont_cls, &udpw->session->target, result, udpw->payload_size, udpw->msg_size); | ||
692 | } | 702 | } |
693 | 703 | ||
694 | } | 704 | } |
@@ -837,7 +847,8 @@ disconnect_session (struct Session *s) | |||
837 | { | 847 | { |
838 | if (NULL != s->frag_ctx->cont) | 848 | if (NULL != s->frag_ctx->cont) |
839 | { | 849 | { |
840 | s->frag_ctx->cont (s->frag_ctx->cont_cls, &s->target, GNUNET_SYSERR); | 850 | s->frag_ctx->cont (s->frag_ctx->cont_cls, &s->target, GNUNET_SYSERR, |
851 | s->frag_ctx->payload_size, s->frag_ctx->on_wire_size); | ||
841 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 852 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
842 | "Calling continuation for fragemented message to `%s' with result SYSERR\n", | 853 | "Calling continuation for fragemented message to `%s' with result SYSERR\n", |
843 | GNUNET_i2s (&s->target)); | 854 | GNUNET_i2s (&s->target)); |
@@ -1186,10 +1197,9 @@ enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) | |||
1186 | static void | 1197 | static void |
1187 | send_next_fragment (void *cls, | 1198 | send_next_fragment (void *cls, |
1188 | const struct GNUNET_PeerIdentity *target, | 1199 | const struct GNUNET_PeerIdentity *target, |
1189 | int result) | 1200 | int result, size_t payload, size_t physical) |
1190 | { | 1201 | { |
1191 | struct UDP_MessageWrapper *udpw = cls; | 1202 | struct UDP_MessageWrapper *udpw = cls; |
1192 | |||
1193 | GNUNET_FRAGMENT_context_transmission_done (udpw->frag_ctx->frag); | 1203 | GNUNET_FRAGMENT_context_transmission_done (udpw->frag_ctx->frag); |
1194 | } | 1204 | } |
1195 | 1205 | ||
@@ -1223,6 +1233,7 @@ enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg) | |||
1223 | udpw->timeout = frag_ctx->timeout; | 1233 | udpw->timeout = frag_ctx->timeout; |
1224 | udpw->frag_ctx = frag_ctx; | 1234 | udpw->frag_ctx = frag_ctx; |
1225 | memcpy (udpw->msg_buf, msg, msg_len); | 1235 | memcpy (udpw->msg_buf, msg, msg_len); |
1236 | frag_ctx->on_wire_size += msg_len; | ||
1226 | enqueue (plugin, udpw); | 1237 | enqueue (plugin, udpw); |
1227 | schedule_select (plugin); | 1238 | schedule_select (plugin); |
1228 | } | 1239 | } |
@@ -1337,6 +1348,7 @@ udp_plugin_send (void *cls, | |||
1337 | frag_ctx->cont_cls = cont_cls; | 1348 | frag_ctx->cont_cls = cont_cls; |
1338 | frag_ctx->timeout = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), to); | 1349 | frag_ctx->timeout = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), to); |
1339 | frag_ctx->payload_size = msgbuf_size; /* unfragmented message size without UDP overhead */ | 1350 | frag_ctx->payload_size = msgbuf_size; /* unfragmented message size without UDP overhead */ |
1351 | frag_ctx->on_wire_size = 0; | ||
1340 | frag_ctx->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, | 1352 | frag_ctx->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, |
1341 | UDP_MTU, | 1353 | UDP_MTU, |
1342 | &plugin->tracker, | 1354 | &plugin->tracker, |
@@ -1344,7 +1356,6 @@ udp_plugin_send (void *cls, | |||
1344 | &udp->header, | 1356 | &udp->header, |
1345 | &enqueue_fragment, | 1357 | &enqueue_fragment, |
1346 | frag_ctx); | 1358 | frag_ctx); |
1347 | |||
1348 | s->frag_ctx = frag_ctx; | 1359 | s->frag_ctx = frag_ctx; |
1349 | } | 1360 | } |
1350 | schedule_select (plugin); | 1361 | schedule_select (plugin); |
@@ -1714,11 +1725,12 @@ read_process_ack (struct Plugin *plugin, | |||
1714 | "UDP processes %u-byte acknowledgement from `%s' at `%s'\n", | 1725 | "UDP processes %u-byte acknowledgement from `%s' at `%s'\n", |
1715 | (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender), | 1726 | (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender), |
1716 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | 1727 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); |
1728 | /* Expect more ACKs to arrive */ | ||
1717 | return; | 1729 | return; |
1718 | } | 1730 | } |
1719 | 1731 | ||
1720 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1732 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1721 | "FULL MESSAGE ACKed\n", | 1733 | "Message full ACK'ed\n", |
1722 | (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender), | 1734 | (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender), |
1723 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | 1735 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); |
1724 | s->last_expected_delay = GNUNET_FRAGMENT_context_destroy (s->frag_ctx->frag); | 1736 | s->last_expected_delay = GNUNET_FRAGMENT_context_destroy (s->frag_ctx->frag); |
@@ -1759,7 +1771,9 @@ read_process_ack (struct Plugin *plugin, | |||
1759 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1771 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1760 | "Calling continuation for fragmented message to `%s' with result %s\n", | 1772 | "Calling continuation for fragmented message to `%s' with result %s\n", |
1761 | GNUNET_i2s (&s->target), "OK"); | 1773 | GNUNET_i2s (&s->target), "OK"); |
1762 | s->frag_ctx->cont (s->frag_ctx->cont_cls, &udp_ack->sender, GNUNET_OK); | 1774 | /* FIXME add overhead bytes here */ |
1775 | s->frag_ctx->cont (s->frag_ctx->cont_cls, &udp_ack->sender, GNUNET_OK, | ||
1776 | s->frag_ctx->payload_size, s->frag_ctx->on_wire_size); | ||
1763 | } | 1777 | } |
1764 | 1778 | ||
1765 | GNUNET_free (s->frag_ctx); | 1779 | GNUNET_free (s->frag_ctx); |