aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-05-06 01:12:57 +0000
committerChristian Grothoff <christian@grothoff.org>2012-05-06 01:12:57 +0000
commit9fac6b6eefdc9144053f736fd388cb2199a97046 (patch)
tree82740a981b7f6ae973d915aa77797acd9db668b2 /src/transport/transport_api.c
parent23d8d343d5c70481ecf78ec4fafc698907f3e8a9 (diff)
downloadgnunet-9fac6b6eefdc9144053f736fd388cb2199a97046.tar.gz
gnunet-9fac6b6eefdc9144053f736fd388cb2199a97046.zip
-removing legacy ifdefs, fixing log statements
Diffstat (limited to 'src/transport/transport_api.c')
-rw-r--r--src/transport/transport_api.c52
1 files changed, 1 insertions, 51 deletions
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index e7f2327d9..b97a24596 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -342,10 +342,8 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h,
342{ 342{
343 struct Neighbour *n; 343 struct Neighbour *n;
344 344
345#if DEBUG_TRANSPORT_API
346 LOG (GNUNET_ERROR_TYPE_DEBUG, "Creating entry for neighbour `%4s'.\n", 345 LOG (GNUNET_ERROR_TYPE_DEBUG, "Creating entry for neighbour `%4s'.\n",
347 GNUNET_i2s (pid)); 346 GNUNET_i2s (pid));
348#endif
349 n = GNUNET_malloc (sizeof (struct Neighbour)); 347 n = GNUNET_malloc (sizeof (struct Neighbour));
350 n->id = *pid; 348 n->id = *pid;
351 n->h = h; 349 n->h = h;
@@ -416,10 +414,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
416 GNUNET_assert (h->client != NULL); 414 GNUNET_assert (h->client != NULL);
417 if (msg == NULL) 415 if (msg == NULL)
418 { 416 {
419#if DEBUG_TRANSPORT_API 417 LOG (GNUNET_ERROR_TYPE_DEBUG,
420 LOG (GNUNET_ERROR_TYPE_INFO,
421 "Error receiving from transport service, disconnecting temporarily.\n"); 418 "Error receiving from transport service, disconnecting temporarily.\n");
422#endif
423 disconnect_and_schedule_reconnect (h); 419 disconnect_and_schedule_reconnect (h);
424 return; 420 return;
425 } 421 }
@@ -435,11 +431,9 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
435 GNUNET_break (0); 431 GNUNET_break (0);
436 break; 432 break;
437 } 433 }
438#if DEBUG_TRANSPORT_API
439 LOG (GNUNET_ERROR_TYPE_DEBUG, 434 LOG (GNUNET_ERROR_TYPE_DEBUG,
440 "Receiving (my own) `%s' message, I am `%4s'.\n", "HELLO", 435 "Receiving (my own) `%s' message, I am `%4s'.\n", "HELLO",
441 GNUNET_i2s (&me)); 436 GNUNET_i2s (&me));
442#endif
443 GNUNET_free_non_null (h->my_hello); 437 GNUNET_free_non_null (h->my_hello);
444 h->my_hello = NULL; 438 h->my_hello = NULL;
445 if (size < sizeof (struct GNUNET_MessageHeader)) 439 if (size < sizeof (struct GNUNET_MessageHeader))
@@ -474,10 +468,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
474 break; 468 break;
475 } 469 }
476 ats = (const struct GNUNET_ATS_Information *) &cim[1]; 470 ats = (const struct GNUNET_ATS_Information *) &cim[1];
477#if DEBUG_TRANSPORT_API
478 LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message for `%4s'.\n", 471 LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message for `%4s'.\n",
479 "CONNECT", GNUNET_i2s (&cim->id)); 472 "CONNECT", GNUNET_i2s (&cim->id));
480#endif
481 n = neighbour_find (h, &cim->id); 473 n = neighbour_find (h, &cim->id);
482 if (n != NULL) 474 if (n != NULL)
483 { 475 {
@@ -496,10 +488,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
496 } 488 }
497 dim = (const struct DisconnectInfoMessage *) msg; 489 dim = (const struct DisconnectInfoMessage *) msg;
498 GNUNET_break (ntohl (dim->reserved) == 0); 490 GNUNET_break (ntohl (dim->reserved) == 0);
499#if DEBUG_TRANSPORT_API_DISCONNECT
500 LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message for `%4s'.\n", 491 LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message for `%4s'.\n",
501 "DISCONNECT", GNUNET_i2s (&dim->peer)); 492 "DISCONNECT", GNUNET_i2s (&dim->peer));
502#endif
503 n = neighbour_find (h, &dim->peer); 493 n = neighbour_find (h, &dim->peer);
504 if (n == NULL) 494 if (n == NULL)
505 { 495 {
@@ -515,10 +505,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
515 break; 505 break;
516 } 506 }
517 okm = (const struct SendOkMessage *) msg; 507 okm = (const struct SendOkMessage *) msg;
518#if DEBUG_TRANSPORT_API
519 LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message, transmission %s.\n", 508 LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message, transmission %s.\n",
520 "SEND_OK", ntohl (okm->success) == GNUNET_OK ? "succeeded" : "failed"); 509 "SEND_OK", ntohl (okm->success) == GNUNET_OK ? "succeeded" : "failed");
521#endif
522 n = neighbour_find (h, &okm->peer); 510 n = neighbour_find (h, &okm->peer);
523 if (n == NULL) 511 if (n == NULL)
524 break; 512 break;
@@ -536,9 +524,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
536 } 524 }
537 break; 525 break;
538 case GNUNET_MESSAGE_TYPE_TRANSPORT_RECV: 526 case GNUNET_MESSAGE_TYPE_TRANSPORT_RECV:
539#if DEBUG_TRANSPORT_API
540 LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message.\n", "RECV"); 527 LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message.\n", "RECV");
541#endif
542 if (size < 528 if (size <
543 sizeof (struct InboundMessage) + sizeof (struct GNUNET_MessageHeader)) 529 sizeof (struct InboundMessage) + sizeof (struct GNUNET_MessageHeader))
544 { 530 {
@@ -555,10 +541,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
555 GNUNET_break (0); 541 GNUNET_break (0);
556 break; 542 break;
557 } 543 }
558#if DEBUG_TRANSPORT_API
559 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received message of type %u from `%4s'.\n", 544 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received message of type %u from `%4s'.\n",
560 ntohs (imm->type), GNUNET_i2s (&im->peer)); 545 ntohs (imm->type), GNUNET_i2s (&im->peer));
561#endif
562 n = neighbour_find (h, &im->peer); 546 n = neighbour_find (h, &im->peer);
563 if (n == NULL) 547 if (n == NULL)
564 { 548 {
@@ -569,9 +553,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
569 h->rec (h->cls, &im->peer, imm, ats, ats_count); 553 h->rec (h->cls, &im->peer, imm, ats, ats_count);
570 break; 554 break;
571 case GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA: 555 case GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA:
572#if DEBUG_TRANSPORT_API
573 LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message.\n", "SET_QUOTA"); 556 LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message.\n", "SET_QUOTA");
574#endif
575 if (size != sizeof (struct QuotaSetMessage)) 557 if (size != sizeof (struct QuotaSetMessage))
576 { 558 {
577 GNUNET_break (0); 559 GNUNET_break (0);
@@ -653,10 +635,8 @@ transport_notify_ready (void *cls, size_t size, void *buf)
653 { 635 {
654 GNUNET_CONTAINER_DLL_remove (h->control_head, h->control_tail, th); 636 GNUNET_CONTAINER_DLL_remove (h->control_head, h->control_tail, th);
655 nret = th->notify (th->notify_cls, size, &cbuf[ret]); 637 nret = th->notify (th->notify_cls, size, &cbuf[ret]);
656#if DEBUG_TRANSPORT_API
657 LOG (GNUNET_ERROR_TYPE_DEBUG, "Added %u bytes of control message at %u\n", 638 LOG (GNUNET_ERROR_TYPE_DEBUG, "Added %u bytes of control message at %u\n",
658 nret, ret); 639 nret, ret);
659#endif
660 GNUNET_free (th); 640 GNUNET_free (th);
661 ret += nret; 641 ret += nret;
662 size -= nret; 642 size -= nret;
@@ -714,10 +694,8 @@ transport_notify_ready (void *cls, size_t size, void *buf)
714 } 694 }
715 /* if there are more pending messages, try to schedule those */ 695 /* if there are more pending messages, try to schedule those */
716 schedule_transmission (h); 696 schedule_transmission (h);
717#if DEBUG_TRANSPORT_API
718 LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting %u bytes to transport service\n", 697 LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting %u bytes to transport service\n",
719 ret); 698 ret);
720#endif
721 return ret; 699 return ret;
722} 700}
723 701
@@ -750,11 +728,9 @@ schedule_transmission_task (void *cls,
750 n->th = NULL; 728 n->th = NULL;
751 GNUNET_assert (n == GNUNET_CONTAINER_heap_remove_root (h->ready_heap)); 729 GNUNET_assert (n == GNUNET_CONTAINER_heap_remove_root (h->ready_heap));
752 n->hn = NULL; 730 n->hn = NULL;
753#if DEBUG_TRANSPORT_API
754 LOG (GNUNET_ERROR_TYPE_DEBUG, 731 LOG (GNUNET_ERROR_TYPE_DEBUG,
755 "Signalling timeout for transmission to peer %s due to congestion\n", 732 "Signalling timeout for transmission to peer %s due to congestion\n",
756 GNUNET_i2s (&n->id)); 733 GNUNET_i2s (&n->id));
757#endif
758 GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); 734 GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL));
759 GNUNET_free (th); 735 GNUNET_free (th);
760 } 736 }
@@ -771,9 +747,7 @@ schedule_transmission_task (void *cls,
771 return; /* no pending messages */ 747 return; /* no pending messages */
772 size = n->th->notify_size + sizeof (struct OutboundMessage); 748 size = n->th->notify_size + sizeof (struct OutboundMessage);
773 } 749 }
774#if DEBUG_TRANSPORT_API
775 LOG (GNUNET_ERROR_TYPE_DEBUG, "Calling notify_transmit_ready\n"); 750 LOG (GNUNET_ERROR_TYPE_DEBUG, "Calling notify_transmit_ready\n");
776#endif
777 h->cth = 751 h->cth =
778 GNUNET_CLIENT_notify_transmit_ready (h->client, size, 752 GNUNET_CLIENT_notify_transmit_ready (h->client, size,
779 GNUNET_TIME_UNIT_FOREVER_REL, 753 GNUNET_TIME_UNIT_FOREVER_REL,
@@ -809,11 +783,9 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h)
809 n->th->notify_size); 783 n->th->notify_size);
810 else 784 else
811 return; /* no work to be done */ 785 return; /* no work to be done */
812#if DEBUG_TRANSPORT_API
813 LOG (GNUNET_ERROR_TYPE_DEBUG, 786 LOG (GNUNET_ERROR_TYPE_DEBUG,
814 "Scheduling next transmission to service in %llu ms\n", 787 "Scheduling next transmission to service in %llu ms\n",
815 (unsigned long long) delay.rel_value); 788 (unsigned long long) delay.rel_value);
816#endif
817 h->quota_task = 789 h->quota_task =
818 GNUNET_SCHEDULER_add_delayed (delay, &schedule_transmission_task, h); 790 GNUNET_SCHEDULER_add_delayed (delay, &schedule_transmission_task, h);
819} 791}
@@ -835,10 +807,8 @@ schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h, size_t size,
835{ 807{
836 struct GNUNET_TRANSPORT_TransmitHandle *th; 808 struct GNUNET_TRANSPORT_TransmitHandle *th;
837 809
838#if DEBUG_TRANSPORT_API
839 LOG (GNUNET_ERROR_TYPE_DEBUG, "Control transmit of %u bytes requested\n", 810 LOG (GNUNET_ERROR_TYPE_DEBUG, "Control transmit of %u bytes requested\n",
840 size); 811 size);
841#endif
842 th = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TransmitHandle)); 812 th = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TransmitHandle));
843 th->notify = notify; 813 th->notify = notify;
844 th->notify_cls = notify_cls; 814 th->notify_cls = notify_cls;
@@ -866,15 +836,11 @@ send_start (void *cls, size_t size, void *buf)
866 if (buf == NULL) 836 if (buf == NULL)
867 { 837 {
868 /* Can only be shutdown, just give up */ 838 /* Can only be shutdown, just give up */
869#if DEBUG_TRANSPORT_API
870 LOG (GNUNET_ERROR_TYPE_DEBUG, 839 LOG (GNUNET_ERROR_TYPE_DEBUG,
871 "Shutdown while trying to transmit `%s' request.\n", "START"); 840 "Shutdown while trying to transmit `%s' request.\n", "START");
872#endif
873 return 0; 841 return 0;
874 } 842 }
875#if DEBUG_TRANSPORT_API
876 LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' request.\n", "START"); 843 LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' request.\n", "START");
877#endif
878 GNUNET_assert (size >= sizeof (struct StartMessage)); 844 GNUNET_assert (size >= sizeof (struct StartMessage));
879 s.header.size = htons (sizeof (struct StartMessage)); 845 s.header.size = htons (sizeof (struct StartMessage));
880 s.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_START); 846 s.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_START);
@@ -909,9 +875,7 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
909 /* shutdown, just give up */ 875 /* shutdown, just give up */
910 return; 876 return;
911 } 877 }
912#if DEBUG_TRANSPORT_API
913 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service.\n"); 878 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service.\n");
914#endif
915 GNUNET_assert (h->client == NULL); 879 GNUNET_assert (h->client == NULL);
916 GNUNET_assert (h->control_head == NULL); 880 GNUNET_assert (h->control_head == NULL);
917 GNUNET_assert (h->control_tail == NULL); 881 GNUNET_assert (h->control_tail == NULL);
@@ -956,11 +920,9 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h)
956 th->notify (th->notify_cls, 0, NULL); 920 th->notify (th->notify_cls, 0, NULL);
957 GNUNET_free (th); 921 GNUNET_free (th);
958 } 922 }
959#if DEBUG_TRANSPORT_API
960 LOG (GNUNET_ERROR_TYPE_DEBUG, 923 LOG (GNUNET_ERROR_TYPE_DEBUG,
961 "Scheduling task to reconnect to transport service in %llu ms.\n", 924 "Scheduling task to reconnect to transport service in %llu ms.\n",
962 h->reconnect_delay.rel_value); 925 h->reconnect_delay.rel_value);
963#endif
964 h->reconnect_task = 926 h->reconnect_task =
965 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); 927 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
966 if (h->reconnect_delay.rel_value == 0) 928 if (h->reconnect_delay.rel_value == 0)
@@ -995,11 +957,9 @@ send_try_connect (void *cls, size_t size, void *buf)
995 GNUNET_free (pid); 957 GNUNET_free (pid);
996 return 0; 958 return 0;
997 } 959 }
998#if DEBUG_TRANSPORT_API
999 LOG (GNUNET_ERROR_TYPE_DEBUG, 960 LOG (GNUNET_ERROR_TYPE_DEBUG,
1000 "Transmitting `%s' request with respect to `%4s'.\n", "REQUEST_CONNECT", 961 "Transmitting `%s' request with respect to `%4s'.\n", "REQUEST_CONNECT",
1001 GNUNET_i2s (pid)); 962 GNUNET_i2s (pid));
1002#endif
1003 GNUNET_assert (size >= sizeof (struct TransportRequestConnectMessage)); 963 GNUNET_assert (size >= sizeof (struct TransportRequestConnectMessage));
1004 msg.header.size = htons (sizeof (struct TransportRequestConnectMessage)); 964 msg.header.size = htons (sizeof (struct TransportRequestConnectMessage));
1005 msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT); 965 msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT);
@@ -1050,16 +1010,12 @@ send_hello (void *cls, size_t size, void *buf)
1050 1010
1051 if (buf == NULL) 1011 if (buf == NULL)
1052 { 1012 {
1053#if DEBUG_TRANSPORT_TIMEOUT
1054 LOG (GNUNET_ERROR_TYPE_DEBUG, 1013 LOG (GNUNET_ERROR_TYPE_DEBUG,
1055 "Timeout while trying to transmit `%s' request.\n", "HELLO"); 1014 "Timeout while trying to transmit `%s' request.\n", "HELLO");
1056#endif
1057 GNUNET_free (msg); 1015 GNUNET_free (msg);
1058 return 0; 1016 return 0;
1059 } 1017 }
1060#if DEBUG_TRANSPORT_API
1061 LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' request.\n", "HELLO"); 1018 LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' request.\n", "HELLO");
1062#endif
1063 ssize = ntohs (msg->size); 1019 ssize = ntohs (msg->size);
1064 GNUNET_assert (size >= ssize); 1020 GNUNET_assert (size >= ssize);
1065 memcpy (buf, msg, ssize); 1021 memcpy (buf, msg, ssize);
@@ -1101,11 +1057,9 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
1101 } 1057 }
1102 msg = GNUNET_malloc (size); 1058 msg = GNUNET_malloc (size);
1103 memcpy (msg, hello, size); 1059 memcpy (msg, hello, size);
1104#if DEBUG_TRANSPORT_API
1105 LOG (GNUNET_ERROR_TYPE_DEBUG, 1060 LOG (GNUNET_ERROR_TYPE_DEBUG,
1106 "Offering `%s' message of `%4s' to transport for validation.\n", "HELLO", 1061 "Offering `%s' message of `%4s' to transport for validation.\n", "HELLO",
1107 GNUNET_i2s (&peer)); 1062 GNUNET_i2s (&peer));
1108#endif
1109 schedule_control_transmit (handle, size, &send_hello, msg); 1063 schedule_control_transmit (handle, size, &send_hello, msg);
1110} 1064}
1111 1065
@@ -1204,9 +1158,7 @@ GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
1204void 1158void
1205GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) 1159GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle)
1206{ 1160{
1207#if DEBUG_TRANSPORT_API
1208 LOG (GNUNET_ERROR_TYPE_DEBUG, "Transport disconnect called!\n"); 1161 LOG (GNUNET_ERROR_TYPE_DEBUG, "Transport disconnect called!\n");
1209#endif
1210 /* this disconnects all neighbours... */ 1162 /* this disconnects all neighbours... */
1211 if (handle->reconnect_task == GNUNET_SCHEDULER_NO_TASK) 1163 if (handle->reconnect_task == GNUNET_SCHEDULER_NO_TASK)
1212 disconnect_and_schedule_reconnect (handle); 1164 disconnect_and_schedule_reconnect (handle);
@@ -1291,11 +1243,9 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *handle,
1291 delay = GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker, size); 1243 delay = GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker, size);
1292 if (delay.rel_value > timeout.rel_value) 1244 if (delay.rel_value > timeout.rel_value)
1293 delay.rel_value = 0; /* notify immediately (with failure) */ 1245 delay.rel_value = 0; /* notify immediately (with failure) */
1294#if DEBUG_TRANSPORT_API
1295 LOG (GNUNET_ERROR_TYPE_DEBUG, 1246 LOG (GNUNET_ERROR_TYPE_DEBUG,
1296 "Bandwidth tracker allows next transmission to peer %s in %llu ms\n", 1247 "Bandwidth tracker allows next transmission to peer %s in %llu ms\n",
1297 GNUNET_i2s (target), (unsigned long long) delay.rel_value); 1248 GNUNET_i2s (target), (unsigned long long) delay.rel_value);
1298#endif
1299 n->hn = GNUNET_CONTAINER_heap_insert (handle->ready_heap, n, delay.rel_value); 1249 n->hn = GNUNET_CONTAINER_heap_insert (handle->ready_heap, n, delay.rel_value);
1300 schedule_transmission (handle); 1250 schedule_transmission (handle);
1301 return th; 1251 return th;