diff options
Diffstat (limited to 'src/transport/transport_api.c')
-rw-r--r-- | src/transport/transport_api.c | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index db96d1800..fa06f7fdb 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c | |||
@@ -278,7 +278,7 @@ struct GNUNET_TRANSPORT_Handle | |||
278 | /** | 278 | /** |
279 | * Closure for the callbacks. | 279 | * Closure for the callbacks. |
280 | */ | 280 | */ |
281 | void *cls; | 281 | void *cls; |
282 | 282 | ||
283 | /** | 283 | /** |
284 | * Function to call for received data. | 284 | * Function to call for received data. |
@@ -361,7 +361,7 @@ struct GNUNET_TRANSPORT_Handle | |||
361 | * Delay until we try to reconnect. | 361 | * Delay until we try to reconnect. |
362 | */ | 362 | */ |
363 | struct GNUNET_TIME_Relative reconnect_delay; | 363 | struct GNUNET_TIME_Relative reconnect_delay; |
364 | 364 | ||
365 | /** | 365 | /** |
366 | * Set once we are in the process of disconnecting from the | 366 | * Set once we are in the process of disconnecting from the |
367 | * service. | 367 | * service. |
@@ -467,14 +467,14 @@ schedule_peer_transmission (struct GNUNET_TRANSPORT_Handle *h) | |||
467 | #if DEBUG_TRANSPORT | 467 | #if DEBUG_TRANSPORT |
468 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 468 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
469 | "Would need %llu ms before bandwidth is available for delivery to `%4s', that is too long. Signaling timeout.\n", | 469 | "Would need %llu ms before bandwidth is available for delivery to `%4s', that is too long. Signaling timeout.\n", |
470 | duration.value, | 470 | duration.value, |
471 | GNUNET_i2s (&n->id)); | 471 | GNUNET_i2s (&n->id)); |
472 | #endif | 472 | #endif |
473 | if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) | 473 | if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) |
474 | { | 474 | { |
475 | GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); | 475 | GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); |
476 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; | 476 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; |
477 | } | 477 | } |
478 | n->transmit_stage = TS_NEW; | 478 | n->transmit_stage = TS_NEW; |
479 | if (NULL != th->notify) | 479 | if (NULL != th->notify) |
480 | GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); | 480 | GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); |
@@ -487,7 +487,7 @@ schedule_peer_transmission (struct GNUNET_TRANSPORT_Handle *h) | |||
487 | "Need more bandwidth (%u b/s allowed, %u b needed), delaying delivery to `%4s' by %llu ms\n", | 487 | "Need more bandwidth (%u b/s allowed, %u b needed), delaying delivery to `%4s' by %llu ms\n", |
488 | (unsigned int) n->out_tracker.available_bytes_per_s__, | 488 | (unsigned int) n->out_tracker.available_bytes_per_s__, |
489 | (unsigned int) th->notify_size - sizeof (struct OutboundMessage), | 489 | (unsigned int) th->notify_size - sizeof (struct OutboundMessage), |
490 | GNUNET_i2s (&n->id), | 490 | GNUNET_i2s (&n->id), |
491 | duration.value); | 491 | duration.value); |
492 | #endif | 492 | #endif |
493 | retry_time = GNUNET_TIME_relative_min (retry_time, | 493 | retry_time = GNUNET_TIME_relative_min (retry_time, |
@@ -516,7 +516,7 @@ schedule_peer_transmission (struct GNUNET_TRANSPORT_Handle *h) | |||
516 | /** | 516 | /** |
517 | * Transmit message(s) to service. | 517 | * Transmit message(s) to service. |
518 | * | 518 | * |
519 | * @param cls handle to transport | 519 | * @param cls handle to transport |
520 | * @param size number of bytes available in buf | 520 | * @param size number of bytes available in buf |
521 | * @param buf where to copy the message | 521 | * @param buf where to copy the message |
522 | * @return number of bytes copied to buf | 522 | * @return number of bytes copied to buf |
@@ -556,7 +556,7 @@ transport_notify_ready (void *cls, size_t size, void *buf) | |||
556 | } | 556 | } |
557 | GNUNET_CONTAINER_DLL_remove (h->control_head, | 557 | GNUNET_CONTAINER_DLL_remove (h->control_head, |
558 | h->control_tail, | 558 | h->control_tail, |
559 | cm); | 559 | cm); |
560 | nret = cm->notify (cm->notify_cls, size, &cbuf[ret]); | 560 | nret = cm->notify (cm->notify_cls, size, &cbuf[ret]); |
561 | #if DEBUG_TRANSPORT | 561 | #if DEBUG_TRANSPORT |
562 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 562 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -595,14 +595,14 @@ transport_notify_ready (void *cls, size_t size, void *buf) | |||
595 | GNUNET_break (0); | 595 | GNUNET_break (0); |
596 | } | 596 | } |
597 | GNUNET_assert (size >= sizeof (struct OutboundMessage)); | 597 | GNUNET_assert (size >= sizeof (struct OutboundMessage)); |
598 | mret = th->notify (th->notify_cls, | 598 | mret = th->notify (th->notify_cls, |
599 | size - sizeof (struct OutboundMessage), | 599 | size - sizeof (struct OutboundMessage), |
600 | &cbuf[ret + sizeof (struct OutboundMessage)]); | 600 | &cbuf[ret + sizeof (struct OutboundMessage)]); |
601 | GNUNET_assert (mret <= size - sizeof (struct OutboundMessage)); | 601 | GNUNET_assert (mret <= size - sizeof (struct OutboundMessage)); |
602 | #if DEBUG_TRANSPORT | 602 | #if DEBUG_TRANSPORT |
603 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 603 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
604 | "Message of %u bytes with timeout %llums constructed for `%4s'\n", | 604 | "Message of %u bytes with timeout %llums constructed for `%4s'\n", |
605 | (unsigned int) mret, | 605 | (unsigned int) mret, |
606 | (unsigned long long) GNUNET_TIME_absolute_get_remaining (th->timeout).value, | 606 | (unsigned long long) GNUNET_TIME_absolute_get_remaining (th->timeout).value, |
607 | GNUNET_i2s (&n->id)); | 607 | GNUNET_i2s (&n->id)); |
608 | #endif | 608 | #endif |
@@ -655,7 +655,7 @@ transport_notify_ready (void *cls, size_t size, void *buf) | |||
655 | */ | 655 | */ |
656 | static void | 656 | static void |
657 | schedule_transmission (struct GNUNET_TRANSPORT_Handle *h) | 657 | schedule_transmission (struct GNUNET_TRANSPORT_Handle *h) |
658 | { | 658 | { |
659 | size_t size; | 659 | size_t size; |
660 | struct GNUNET_TIME_Relative timeout; | 660 | struct GNUNET_TIME_Relative timeout; |
661 | struct GNUNET_TRANSPORT_TransmitHandle *th; | 661 | struct GNUNET_TRANSPORT_TransmitHandle *th; |
@@ -668,7 +668,7 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h) | |||
668 | _("Could not yet schedule transmission: we are not yet connected to the transport service!\n")); | 668 | _("Could not yet schedule transmission: we are not yet connected to the transport service!\n")); |
669 | return; /* not yet connected */ | 669 | return; /* not yet connected */ |
670 | } | 670 | } |
671 | if (NULL != h->control_head) | 671 | if (NULL != h->control_head) |
672 | { | 672 | { |
673 | size = h->control_head->notify_size; | 673 | size = h->control_head->notify_size; |
674 | timeout = GNUNET_TIME_UNIT_FOREVER_REL; | 674 | timeout = GNUNET_TIME_UNIT_FOREVER_REL; |
@@ -688,7 +688,7 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h) | |||
688 | size = th->notify_size; | 688 | size = th->notify_size; |
689 | timeout = GNUNET_TIME_absolute_get_remaining (th->timeout); | 689 | timeout = GNUNET_TIME_absolute_get_remaining (th->timeout); |
690 | } | 690 | } |
691 | h->network_handle = | 691 | h->network_handle = |
692 | GNUNET_CLIENT_notify_transmit_ready (h->client, | 692 | GNUNET_CLIENT_notify_transmit_ready (h->client, |
693 | size, | 693 | size, |
694 | timeout, | 694 | timeout, |
@@ -756,7 +756,7 @@ schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h, | |||
756 | th->notify_delay_task | 756 | th->notify_delay_task |
757 | = GNUNET_SCHEDULER_add_delayed (h->sched, | 757 | = GNUNET_SCHEDULER_add_delayed (h->sched, |
758 | timeout, &control_transmit_timeout, th); | 758 | timeout, &control_transmit_timeout, th); |
759 | if (at_head) | 759 | if (at_head) |
760 | GNUNET_CONTAINER_DLL_insert (h->control_head, | 760 | GNUNET_CONTAINER_DLL_insert (h->control_head, |
761 | h->control_tail, | 761 | h->control_tail, |
762 | th); | 762 | th); |
@@ -811,7 +811,7 @@ send_set_quota (void *cls, size_t size, void *buf) | |||
811 | #if DEBUG_TRANSPORT | 811 | #if DEBUG_TRANSPORT |
812 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 812 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
813 | "Transmitting `%s' request with respect to `%4s'.\n", | 813 | "Transmitting `%s' request with respect to `%4s'.\n", |
814 | "SET_QUOTA", | 814 | "SET_QUOTA", |
815 | GNUNET_i2s (&sqc->target)); | 815 | GNUNET_i2s (&sqc->target)); |
816 | #endif | 816 | #endif |
817 | GNUNET_assert (size >= sizeof (struct QuotaSetMessage)); | 817 | GNUNET_assert (size >= sizeof (struct QuotaSetMessage)); |
@@ -920,7 +920,7 @@ GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle, | |||
920 | hwl->rec = rec; | 920 | hwl->rec = rec; |
921 | hwl->rec_cls = rec_cls; | 921 | hwl->rec_cls = rec_cls; |
922 | if (handle->my_hello == NULL) | 922 | if (handle->my_hello == NULL) |
923 | return; | 923 | return; |
924 | rec (rec_cls, (const struct GNUNET_MessageHeader *) handle->my_hello); | 924 | rec (rec_cls, (const struct GNUNET_MessageHeader *) handle->my_hello); |
925 | } | 925 | } |
926 | 926 | ||
@@ -1023,7 +1023,7 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle, | |||
1023 | GNUNET_break (0); | 1023 | GNUNET_break (0); |
1024 | return; | 1024 | return; |
1025 | } | 1025 | } |
1026 | #if DEBUG_TRANSPORT | 1026 | #if DEBUG_TRANSPORT |
1027 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1027 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1028 | "Offering `%s' message of `%4s' to transport for validation.\n", | 1028 | "Offering `%s' message of `%4s' to transport for validation.\n", |
1029 | "HELLO", | 1029 | "HELLO", |
@@ -1076,8 +1076,8 @@ send_start (void *cls, size_t size, void *buf) | |||
1076 | 1076 | ||
1077 | 1077 | ||
1078 | /** | 1078 | /** |
1079 | * Free neighbour. | 1079 | * Free neighbour. |
1080 | * | 1080 | * |
1081 | * @param n the entry to free | 1081 | * @param n the entry to free |
1082 | */ | 1082 | */ |
1083 | static void | 1083 | static void |
@@ -1112,8 +1112,8 @@ neighbour_free (struct NeighbourList *n) | |||
1112 | 1112 | ||
1113 | 1113 | ||
1114 | /** | 1114 | /** |
1115 | * Mark neighbour as disconnected. | 1115 | * Mark neighbour as disconnected. |
1116 | * | 1116 | * |
1117 | * @param n the entry to mark as disconnected | 1117 | * @param n the entry to mark as disconnected |
1118 | */ | 1118 | */ |
1119 | static void | 1119 | static void |
@@ -1151,7 +1151,7 @@ static void demultiplexer (void *cls, | |||
1151 | * @param tc scheduler context | 1151 | * @param tc scheduler context |
1152 | */ | 1152 | */ |
1153 | static void | 1153 | static void |
1154 | reconnect (void *cls, | 1154 | reconnect (void *cls, |
1155 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 1155 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
1156 | { | 1156 | { |
1157 | struct GNUNET_TRANSPORT_Handle *h = cls; | 1157 | struct GNUNET_TRANSPORT_Handle *h = cls; |
@@ -1179,7 +1179,7 @@ reconnect (void *cls, | |||
1179 | n = next; | 1179 | n = next; |
1180 | } | 1180 | } |
1181 | #if DEBUG_TRANSPORT | 1181 | #if DEBUG_TRANSPORT |
1182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1183 | "Connecting to transport service.\n"); | 1183 | "Connecting to transport service.\n"); |
1184 | #endif | 1184 | #endif |
1185 | GNUNET_assert (h->client == NULL); | 1185 | GNUNET_assert (h->client == NULL); |
@@ -1237,7 +1237,7 @@ schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h) | |||
1237 | { | 1237 | { |
1238 | h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS; | 1238 | h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS; |
1239 | } | 1239 | } |
1240 | else | 1240 | else |
1241 | { | 1241 | { |
1242 | h->reconnect_delay = GNUNET_TIME_relative_multiply (h->reconnect_delay, 2); | 1242 | h->reconnect_delay = GNUNET_TIME_relative_multiply (h->reconnect_delay, 2); |
1243 | h->reconnect_delay = GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, | 1243 | h->reconnect_delay = GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, |
@@ -1267,7 +1267,7 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h, | |||
1267 | } | 1267 | } |
1268 | #if DEBUG_TRANSPORT | 1268 | #if DEBUG_TRANSPORT |
1269 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1269 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1270 | "Creating entry for neighbour `%4s'.\n", | 1270 | "Creating entry for neighbour `%4s'.\n", |
1271 | GNUNET_i2s (pid)); | 1271 | GNUNET_i2s (pid)); |
1272 | #endif | 1272 | #endif |
1273 | n = GNUNET_malloc (sizeof (struct NeighbourList)); | 1273 | n = GNUNET_malloc (sizeof (struct NeighbourList)); |
@@ -1277,7 +1277,7 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h, | |||
1277 | MAX_BANDWIDTH_CARRY_S); | 1277 | MAX_BANDWIDTH_CARRY_S); |
1278 | n->next = h->neighbours; | 1278 | n->next = h->neighbours; |
1279 | n->h = h; | 1279 | n->h = h; |
1280 | h->neighbours = n; | 1280 | h->neighbours = n; |
1281 | return n; | 1281 | return n; |
1282 | } | 1282 | } |
1283 | 1283 | ||
@@ -1358,7 +1358,7 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) | |||
1358 | th->notify_delay_task); | 1358 | th->notify_delay_task); |
1359 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; | 1359 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; |
1360 | } | 1360 | } |
1361 | GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); | 1361 | GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); |
1362 | break; | 1362 | break; |
1363 | default: | 1363 | default: |
1364 | GNUNET_break (0); | 1364 | GNUNET_break (0); |
@@ -1456,7 +1456,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) | |||
1456 | GNUNET_free (h); | 1456 | GNUNET_free (h); |
1457 | return; | 1457 | return; |
1458 | } | 1458 | } |
1459 | if (msg == NULL) | 1459 | if (msg == NULL) |
1460 | { | 1460 | { |
1461 | #if DEBUG_TRANSPORT | 1461 | #if DEBUG_TRANSPORT |
1462 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1462 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -1530,7 +1530,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) | |||
1530 | n->is_connected = GNUNET_YES; | 1530 | n->is_connected = GNUNET_YES; |
1531 | if (h->nc_cb != NULL) | 1531 | if (h->nc_cb != NULL) |
1532 | h->nc_cb (h->cls, &n->id, | 1532 | h->nc_cb (h->cls, &n->id, |
1533 | GNUNET_TIME_relative_ntoh (cim->latency), | 1533 | GNUNET_TIME_relative_ntoh (cim->latency), |
1534 | ntohl (cim->distance)); | 1534 | ntohl (cim->distance)); |
1535 | break; | 1535 | break; |
1536 | case GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT: | 1536 | case GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT: |
@@ -1547,7 +1547,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) | |||
1547 | GNUNET_i2s (&dim->peer)); | 1547 | GNUNET_i2s (&dim->peer)); |
1548 | #endif | 1548 | #endif |
1549 | n = neighbour_find (h, &dim->peer); | 1549 | n = neighbour_find (h, &dim->peer); |
1550 | GNUNET_break (n != NULL); | 1550 | GNUNET_break (n != NULL); |
1551 | if (n != NULL) | 1551 | if (n != NULL) |
1552 | neighbour_disconnect (n); | 1552 | neighbour_disconnect (n); |
1553 | break; | 1553 | break; |
@@ -1607,7 +1607,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) | |||
1607 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1607 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1608 | "Received message of type %u from `%4s'.\n", | 1608 | "Received message of type %u from `%4s'.\n", |
1609 | ntohs (imm->type), GNUNET_i2s (&im->peer)); | 1609 | ntohs (imm->type), GNUNET_i2s (&im->peer)); |
1610 | #endif | 1610 | #endif |
1611 | n = neighbour_find (h, &im->peer); | 1611 | n = neighbour_find (h, &im->peer); |
1612 | if (n == NULL) | 1612 | if (n == NULL) |
1613 | { | 1613 | { |
@@ -1659,7 +1659,7 @@ peer_transmit_timeout (void *cls, | |||
1659 | "Triggering timeout for request to transmit to `%4s' (%d)\n", | 1659 | "Triggering timeout for request to transmit to `%4s' (%d)\n", |
1660 | GNUNET_i2s (&n->id), | 1660 | GNUNET_i2s (&n->id), |
1661 | n->transmit_stage); | 1661 | n->transmit_stage); |
1662 | #endif | 1662 | #endif |
1663 | notify = th->notify; | 1663 | notify = th->notify; |
1664 | notify_cls = th->notify_cls; | 1664 | notify_cls = th->notify_cls; |
1665 | switch (n->transmit_stage) | 1665 | switch (n->transmit_stage) |
@@ -1738,7 +1738,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle | |||
1738 | n = neighbour_find (handle, target); | 1738 | n = neighbour_find (handle, target); |
1739 | if (n == NULL) | 1739 | if (n == NULL) |
1740 | n = neighbour_add (handle, target); | 1740 | n = neighbour_add (handle, target); |
1741 | if (n == NULL) | 1741 | if (n == NULL) |
1742 | { | 1742 | { |
1743 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1743 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1744 | "Could not create neighbour entry for peer `%s'\n", | 1744 | "Could not create neighbour entry for peer `%s'\n", |