diff options
Diffstat (limited to 'src/transport/gnunet-transport.c')
-rw-r--r-- | src/transport/gnunet-transport.c | 381 |
1 files changed, 244 insertions, 137 deletions
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index edc253dae..8cd606f81 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -561,92 +561,119 @@ resolve_validation_address (const struct GNUNET_PeerIdentity *id, | |||
561 | enum GNUNET_TRANSPORT_ValidationState state); | 561 | enum GNUNET_TRANSPORT_ValidationState state); |
562 | 562 | ||
563 | 563 | ||
564 | |||
565 | /** | ||
566 | * Function to call with a textual representation of an address. This | ||
567 | * function will be called several times with different possible | ||
568 | * textual representations, and a last time with @address being NULL | ||
569 | * to signal the end of the iteration. Note that @address NULL | ||
570 | * always is the last call, regardless of the value in @a res. | ||
571 | * | ||
572 | * @param cls closure | ||
573 | * @param address NULL on end of iteration, | ||
574 | * otherwise 0-terminated printable UTF-8 string, | ||
575 | * in particular an empty string if @a res is #GNUNET_NO | ||
576 | * @param res result of the address to string conversion: | ||
577 | * if #GNUNET_OK: conversion successful | ||
578 | * if #GNUNET_NO: address was invalid (or not supported) | ||
579 | * if #GNUNET_SYSERR: communication error (IPC error) | ||
580 | */ | ||
564 | static void | 581 | static void |
565 | process_validation_string (void *cls, const char *address, int res) | 582 | process_validation_string (void *cls, |
583 | const char *address, | ||
584 | int res) | ||
566 | { | 585 | { |
567 | struct ValidationResolutionContext *vc = cls; | 586 | struct ValidationResolutionContext *vc = cls; |
568 | char *s_valid; | 587 | char *s_valid; |
569 | char *s_last; | 588 | char *s_last; |
570 | char *s_next; | 589 | char *s_next; |
571 | 590 | ||
572 | if (address != NULL ) | 591 | if (NULL != address) |
573 | { | 592 | { |
574 | if (GNUNET_SYSERR == res) | 593 | if (GNUNET_SYSERR == res) |
575 | { | 594 | { |
576 | FPRINTF (stderr, "Failed to convert address for peer `%s' plugin `%s' length %lu to string \n", | 595 | FPRINTF (stderr, |
577 | GNUNET_i2s (&vc->id), | 596 | "Failed to convert address for peer `%s' plugin `%s' length %lu to string \n", |
578 | vc->addrcp->transport_name, | 597 | GNUNET_i2s (&vc->id), |
579 | vc->addrcp->address_length); | 598 | vc->addrcp->transport_name, |
599 | vc->addrcp->address_length); | ||
580 | } | 600 | } |
581 | if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->valid_until.abs_value_us) | 601 | if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->valid_until.abs_value_us) |
582 | s_valid = GNUNET_strdup("never"); | 602 | s_valid = GNUNET_strdup ("never"); |
583 | else | 603 | else |
584 | s_valid = GNUNET_strdup(GNUNET_STRINGS_absolute_time_to_string (vc->valid_until)); | 604 | s_valid = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (vc->valid_until)); |
585 | 605 | ||
586 | if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->last_validation.abs_value_us) | 606 | if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->last_validation.abs_value_us) |
587 | s_last = GNUNET_strdup("never"); | 607 | s_last = GNUNET_strdup ("never"); |
588 | else | 608 | else |
589 | s_last = GNUNET_strdup(GNUNET_STRINGS_absolute_time_to_string (vc->last_validation)); | 609 | s_last = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (vc->last_validation)); |
590 | 610 | ||
591 | if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->next_validation.abs_value_us) | 611 | if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->next_validation.abs_value_us) |
592 | s_next = GNUNET_strdup("never"); | 612 | s_next = GNUNET_strdup ("never"); |
593 | else | 613 | else |
594 | s_next = GNUNET_strdup(GNUNET_STRINGS_absolute_time_to_string (vc->next_validation)); | 614 | s_next = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (vc->next_validation)); |
595 | 615 | ||
596 | FPRINTF (stdout, | 616 | FPRINTF (stdout, |
597 | _("Peer `%s' %s %s\n\t%s%s\n\t%s%s\n\t%s%s\n"), | 617 | _("Peer `%s' %s %s\n\t%s%s\n\t%s%s\n\t%s%s\n"), |
598 | GNUNET_i2s (&vc->id), | 618 | GNUNET_i2s (&vc->id), |
599 | (GNUNET_OK == res) ? address : "<invalid address>", | 619 | (GNUNET_OK == res) ? address : "<invalid address>", |
600 | (monitor_validation) ? GNUNET_TRANSPORT_vs2s (vc->state) : "", | 620 | (monitor_validation) ? GNUNET_TRANSPORT_vs2s (vc->state) : "", |
601 | "Valid until : ", s_valid, | 621 | "Valid until : ", s_valid, |
602 | "Last validation: ",s_last, | 622 | "Last validation: ",s_last, |
603 | "Next validation: ", s_next); | 623 | "Next validation: ", s_next); |
604 | GNUNET_free (s_valid); | 624 | GNUNET_free (s_valid); |
605 | GNUNET_free (s_last); | 625 | GNUNET_free (s_last); |
606 | GNUNET_free (s_next); | 626 | GNUNET_free (s_next); |
607 | vc->printed = GNUNET_YES; | 627 | vc->printed = GNUNET_YES; |
628 | return; | ||
608 | } | 629 | } |
609 | else | 630 | /* last call, we are done */ |
631 | GNUNET_assert (address_resolutions > 0); | ||
632 | address_resolutions--; | ||
633 | if ( (GNUNET_SYSERR == res) && | ||
634 | (GNUNET_NO == vc->printed) ) | ||
610 | { | 635 | { |
611 | /* done */ | 636 | if (numeric == GNUNET_NO) |
612 | |||
613 | GNUNET_assert(address_resolutions > 0); | ||
614 | address_resolutions--; | ||
615 | if ((GNUNET_SYSERR == res) && (GNUNET_NO == vc->printed)) | ||
616 | { | 637 | { |
617 | if (numeric == GNUNET_NO) | 638 | /* Failed to resolve address, try numeric lookup |
618 | { | 639 | (note: this should be unnecessary, as |
619 | /* Failed to resolve address, try numeric lookup */ | 640 | transport should fallback to numeric lookup |
620 | resolve_validation_address (&vc->id, vc->addrcp, GNUNET_NO, | 641 | internally if DNS takes too long anyway) */ |
621 | vc->last_validation, vc->valid_until, vc->next_validation, | 642 | resolve_validation_address (&vc->id, |
622 | vc->state); | 643 | vc->addrcp, |
623 | } | 644 | GNUNET_NO, |
624 | else | 645 | vc->last_validation, |
625 | { | 646 | vc->valid_until, |
626 | FPRINTF (stdout, _("Peer `%s' %s `%s' \n"), | 647 | vc->next_validation, |
627 | GNUNET_i2s (&vc->id), "<unable to resolve address>", | 648 | vc->state); |
628 | GNUNET_TRANSPORT_vs2s (vc->state)); | ||
629 | } | ||
630 | } | 649 | } |
631 | GNUNET_free (vc->transport); | 650 | else |
632 | GNUNET_free (vc->addrcp); | ||
633 | GNUNET_CONTAINER_DLL_remove(vc_head, vc_tail, vc); | ||
634 | GNUNET_free(vc); | ||
635 | if ((0 == address_resolutions) && (iterate_validation)) | ||
636 | { | 651 | { |
637 | if (GNUNET_SCHEDULER_NO_TASK != end) | 652 | FPRINTF (stdout, |
638 | { | 653 | _("Peer `%s' %s `%s' \n"), |
639 | GNUNET_SCHEDULER_cancel (end); | 654 | GNUNET_i2s (&vc->id), |
640 | end = GNUNET_SCHEDULER_NO_TASK; | 655 | "<unable to resolve address>", |
641 | } | 656 | GNUNET_TRANSPORT_vs2s (vc->state)); |
642 | if (GNUNET_SCHEDULER_NO_TASK != op_timeout) | 657 | } |
643 | { | 658 | } |
644 | GNUNET_SCHEDULER_cancel (op_timeout); | 659 | GNUNET_free (vc->transport); |
645 | op_timeout = GNUNET_SCHEDULER_NO_TASK; | 660 | GNUNET_free (vc->addrcp); |
646 | } | 661 | GNUNET_CONTAINER_DLL_remove (vc_head, vc_tail, vc); |
647 | ret = 0; | 662 | GNUNET_free (vc); |
648 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); | 663 | if ((0 == address_resolutions) && (iterate_validation)) |
664 | { | ||
665 | if (GNUNET_SCHEDULER_NO_TASK != end) | ||
666 | { | ||
667 | GNUNET_SCHEDULER_cancel (end); | ||
668 | end = GNUNET_SCHEDULER_NO_TASK; | ||
669 | } | ||
670 | if (GNUNET_SCHEDULER_NO_TASK != op_timeout) | ||
671 | { | ||
672 | GNUNET_SCHEDULER_cancel (op_timeout); | ||
673 | op_timeout = GNUNET_SCHEDULER_NO_TASK; | ||
649 | } | 674 | } |
675 | ret = 0; | ||
676 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
650 | } | 677 | } |
651 | } | 678 | } |
652 | 679 | ||
@@ -654,11 +681,12 @@ process_validation_string (void *cls, const char *address, int res) | |||
654 | 681 | ||
655 | static void | 682 | static void |
656 | resolve_validation_address (const struct GNUNET_PeerIdentity *id, | 683 | resolve_validation_address (const struct GNUNET_PeerIdentity *id, |
657 | const struct GNUNET_HELLO_Address *address, int numeric, | 684 | const struct GNUNET_HELLO_Address *address, |
658 | struct GNUNET_TIME_Absolute last_validation, | 685 | int numeric, |
659 | struct GNUNET_TIME_Absolute valid_until, | 686 | struct GNUNET_TIME_Absolute last_validation, |
660 | struct GNUNET_TIME_Absolute next_validation, | 687 | struct GNUNET_TIME_Absolute valid_until, |
661 | enum GNUNET_TRANSPORT_ValidationState state) | 688 | struct GNUNET_TIME_Absolute next_validation, |
689 | enum GNUNET_TRANSPORT_ValidationState state) | ||
662 | { | 690 | { |
663 | struct ValidationResolutionContext *vc; | 691 | struct ValidationResolutionContext *vc; |
664 | 692 | ||
@@ -677,8 +705,11 @@ resolve_validation_address (const struct GNUNET_PeerIdentity *id, | |||
677 | vc->next_validation = next_validation; | 705 | vc->next_validation = next_validation; |
678 | 706 | ||
679 | /* Resolve address to string */ | 707 | /* Resolve address to string */ |
680 | vc->asc = GNUNET_TRANSPORT_address_to_string (cfg, address, numeric, | 708 | vc->asc = GNUNET_TRANSPORT_address_to_string (cfg, |
681 | RESOLUTION_TIMEOUT, &process_validation_string, vc); | 709 | address, |
710 | numeric, | ||
711 | RESOLUTION_TIMEOUT, | ||
712 | &process_validation_string, vc); | ||
682 | } | 713 | } |
683 | 714 | ||
684 | 715 | ||
@@ -910,7 +941,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
910 | * @param peer the peer that disconnected | 941 | * @param peer the peer that disconnected |
911 | */ | 942 | */ |
912 | static void | 943 | static void |
913 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 944 | notify_disconnect (void *cls, |
945 | const struct GNUNET_PeerIdentity *peer) | ||
914 | { | 946 | { |
915 | if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity))) | 947 | if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity))) |
916 | return; | 948 | return; |
@@ -957,14 +989,19 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
957 | * @param peer the peer that connected | 989 | * @param peer the peer that connected |
958 | */ | 990 | */ |
959 | static void | 991 | static void |
960 | monitor_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | 992 | monitor_notify_connect (void *cls, |
993 | const struct GNUNET_PeerIdentity *peer) | ||
961 | { | 994 | { |
962 | monitor_connect_counter++; | 995 | monitor_connect_counter++; |
963 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | 996 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
964 | const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now); | 997 | const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now); |
965 | 998 | ||
966 | FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"), now_str, | 999 | FPRINTF (stdout, |
967 | _("Connected to"), GNUNET_i2s (peer), monitor_connect_counter); | 1000 | _("%24s: %-17s %4s (%u connections in total)\n"), |
1001 | now_str, | ||
1002 | _("Connected to"), | ||
1003 | GNUNET_i2s (peer), | ||
1004 | monitor_connect_counter); | ||
968 | } | 1005 | } |
969 | 1006 | ||
970 | 1007 | ||
@@ -976,7 +1013,8 @@ monitor_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
976 | * @param peer the peer that disconnected | 1013 | * @param peer the peer that disconnected |
977 | */ | 1014 | */ |
978 | static void | 1015 | static void |
979 | monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 1016 | monitor_notify_disconnect (void *cls, |
1017 | const struct GNUNET_PeerIdentity *peer) | ||
980 | { | 1018 | { |
981 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | 1019 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
982 | const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now); | 1020 | const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now); |
@@ -984,8 +1022,12 @@ monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
984 | GNUNET_assert(monitor_connect_counter > 0); | 1022 | GNUNET_assert(monitor_connect_counter > 0); |
985 | monitor_connect_counter--; | 1023 | monitor_connect_counter--; |
986 | 1024 | ||
987 | FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"), now_str, | 1025 | FPRINTF (stdout, |
988 | _("Disconnected from"), GNUNET_i2s (peer), monitor_connect_counter); | 1026 | _("%24s: %-17s %4s (%u connections in total)\n"), |
1027 | now_str, | ||
1028 | _("Disconnected from"), | ||
1029 | GNUNET_i2s (peer), | ||
1030 | monitor_connect_counter); | ||
989 | } | 1031 | } |
990 | 1032 | ||
991 | 1033 | ||
@@ -1006,8 +1048,10 @@ notify_receive (void *cls, | |||
1006 | if (GNUNET_MESSAGE_TYPE_DUMMY != ntohs (message->type)) | 1048 | if (GNUNET_MESSAGE_TYPE_DUMMY != ntohs (message->type)) |
1007 | return; | 1049 | return; |
1008 | if (verbosity > 0) | 1050 | if (verbosity > 0) |
1009 | FPRINTF (stdout, _("Received %u bytes from %s\n"), | 1051 | FPRINTF (stdout, |
1010 | (unsigned int) ntohs (message->size), GNUNET_i2s (peer)); | 1052 | _("Received %u bytes from %s\n"), |
1053 | (unsigned int) ntohs (message->size), | ||
1054 | GNUNET_i2s (peer)); | ||
1011 | 1055 | ||
1012 | if (traffic_received == 0) | 1056 | if (traffic_received == 0) |
1013 | start_time = GNUNET_TIME_absolute_get (); | 1057 | start_time = GNUNET_TIME_absolute_get (); |
@@ -1036,83 +1080,125 @@ print_info (const struct GNUNET_PeerIdentity *id, | |||
1036 | if ( ((GNUNET_YES == iterate_connections) && (GNUNET_YES == iterate_all)) || | 1080 | if ( ((GNUNET_YES == iterate_connections) && (GNUNET_YES == iterate_all)) || |
1037 | (GNUNET_YES == monitor_connections) ) | 1081 | (GNUNET_YES == monitor_connections) ) |
1038 | { | 1082 | { |
1039 | FPRINTF (stdout, _("Peer `%s': %s %s in state `%s' until %s\n"), | 1083 | FPRINTF (stdout, |
1040 | GNUNET_i2s (id), | 1084 | _("Peer `%s': %s %s in state `%s' until %s\n"), |
1041 | (NULL == transport) ? "<none>" : transport, | 1085 | GNUNET_i2s (id), |
1042 | (NULL == transport) ? "<none>" : addr, | 1086 | (NULL == transport) ? "<none>" : transport, |
1043 | GNUNET_TRANSPORT_ps2s (state), | 1087 | (NULL == transport) ? "<none>" : addr, |
1044 | GNUNET_STRINGS_absolute_time_to_string (state_timeout)); | 1088 | GNUNET_TRANSPORT_ps2s (state), |
1089 | GNUNET_STRINGS_absolute_time_to_string (state_timeout)); | ||
1045 | } | 1090 | } |
1046 | else if ( (GNUNET_YES == iterate_connections) && | 1091 | else if ( (GNUNET_YES == iterate_connections) && |
1047 | (GNUNET_TRANSPORT_is_connected(state)) ) | 1092 | (GNUNET_TRANSPORT_is_connected(state)) ) |
1048 | { | 1093 | { |
1049 | /* Only connected peers, skip state */ | 1094 | /* Only connected peers, skip state */ |
1050 | FPRINTF (stdout, _("Peer `%s': %s %s\n"), GNUNET_i2s (id), transport, addr); | 1095 | FPRINTF (stdout, |
1096 | _("Peer `%s': %s %s\n"), | ||
1097 | GNUNET_i2s (id), | ||
1098 | transport, | ||
1099 | addr); | ||
1051 | } | 1100 | } |
1052 | } | 1101 | } |
1053 | 1102 | ||
1054 | 1103 | ||
1104 | /** | ||
1105 | * Function called with a textual representation of an address. This | ||
1106 | * function will be called several times with different possible | ||
1107 | * textual representations, and a last time with @address being NULL | ||
1108 | * to signal the end of the iteration. Note that @address NULL | ||
1109 | * always is the last call, regardless of the value in @a res. | ||
1110 | * | ||
1111 | * @param cls closure | ||
1112 | * @param address NULL on end of iteration, | ||
1113 | * otherwise 0-terminated printable UTF-8 string, | ||
1114 | * in particular an empty string if @a res is #GNUNET_NO | ||
1115 | * @param res result of the address to string conversion: | ||
1116 | * if #GNUNET_OK: conversion successful | ||
1117 | * if #GNUNET_NO: address was invalid (or not supported) | ||
1118 | * if #GNUNET_SYSERR: communication error (IPC error) | ||
1119 | */ | ||
1055 | static void | 1120 | static void |
1056 | process_peer_string (void *cls, const char *address, int res) | 1121 | process_peer_string (void *cls, |
1122 | const char *address, | ||
1123 | int res) | ||
1057 | { | 1124 | { |
1058 | struct PeerResolutionContext *rc = cls; | 1125 | struct PeerResolutionContext *rc = cls; |
1059 | 1126 | ||
1060 | if (GNUNET_SYSERR == res) | 1127 | if (NULL != address) |
1061 | { | 1128 | { |
1062 | FPRINTF (stderr, "Failed to convert address for peer `%s' plugin `%s' length %lu to string \n", | 1129 | if (GNUNET_SYSERR == res) |
1063 | GNUNET_i2s (&rc->id), | 1130 | { |
1064 | rc->addrcp->transport_name, | 1131 | FPRINTF (stderr, |
1065 | rc->addrcp->address_length); | 1132 | "Failed to convert address for peer `%s' plugin `%s' length %lu to string \n", |
1066 | print_info (&rc->id, rc->transport, NULL, rc->state, rc->state_timeout); | 1133 | GNUNET_i2s (&rc->id), |
1067 | rc->printed = GNUNET_YES; | 1134 | rc->addrcp->transport_name, |
1135 | rc->addrcp->address_length); | ||
1136 | print_info (&rc->id, | ||
1137 | rc->transport, | ||
1138 | NULL, | ||
1139 | rc->state, | ||
1140 | rc->state_timeout); | ||
1141 | rc->printed = GNUNET_YES; | ||
1142 | return; | ||
1143 | } | ||
1144 | if (GNUNET_OK == res) | ||
1145 | { | ||
1146 | print_info (&rc->id, | ||
1147 | rc->transport, | ||
1148 | address, | ||
1149 | rc->state, | ||
1150 | rc->state_timeout); | ||
1151 | rc->printed = GNUNET_YES; | ||
1152 | return; /* Wait for done call */ | ||
1153 | } | ||
1154 | /* GNUNET_NO == res: ignore, was simply not supported */ | ||
1068 | return; | 1155 | return; |
1069 | } | 1156 | } |
1157 | /* NULL == address, last call, we are done */ | ||
1070 | 1158 | ||
1071 | if ((GNUNET_OK == res) && (address != NULL)) | 1159 | GNUNET_assert (address_resolutions > 0); |
1160 | address_resolutions--; | ||
1161 | if (GNUNET_NO == rc->printed) | ||
1072 | { | 1162 | { |
1073 | print_info (&rc->id, rc->transport, address, rc->state, rc->state_timeout); | 1163 | if (numeric == GNUNET_NO) |
1074 | rc->printed = GNUNET_YES; | 1164 | { |
1075 | return; /* Wait for done call */ | 1165 | /* Failed to resolve address, try numeric lookup |
1166 | (note: this should not be needed, as transport | ||
1167 | should fallback to numeric conversion if DNS takes | ||
1168 | too long) */ | ||
1169 | resolve_peer_address (&rc->id, | ||
1170 | rc->addrcp, | ||
1171 | GNUNET_YES, | ||
1172 | rc->state, | ||
1173 | rc->state_timeout); | ||
1174 | } | ||
1175 | else | ||
1176 | { | ||
1177 | print_info (&rc->id, | ||
1178 | rc->transport, | ||
1179 | NULL, | ||
1180 | rc->state, | ||
1181 | rc->state_timeout); | ||
1182 | } | ||
1076 | } | 1183 | } |
1077 | 1184 | GNUNET_free (rc->transport); | |
1078 | if (NULL == address) | 1185 | GNUNET_free (rc->addrcp); |
1186 | GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, rc); | ||
1187 | GNUNET_free (rc); | ||
1188 | if ((0 == address_resolutions) && (iterate_connections)) | ||
1079 | { | 1189 | { |
1080 | /* done */ | 1190 | if (GNUNET_SCHEDULER_NO_TASK != end) |
1081 | GNUNET_assert(address_resolutions > 0); | ||
1082 | address_resolutions--; | ||
1083 | if (GNUNET_NO == rc->printed) | ||
1084 | { | 1191 | { |
1085 | if (numeric == GNUNET_NO) | 1192 | GNUNET_SCHEDULER_cancel (end); |
1086 | { | 1193 | end = GNUNET_SCHEDULER_NO_TASK; |
1087 | /* Failed to resolve address, try numeric lookup */ | ||
1088 | resolve_peer_address (&rc->id, rc->addrcp, GNUNET_YES, | ||
1089 | rc->state, rc->state_timeout); | ||
1090 | } | ||
1091 | else | ||
1092 | { | ||
1093 | print_info (&rc->id, rc->transport, NULL, | ||
1094 | rc->state, rc->state_timeout); | ||
1095 | } | ||
1096 | } | 1194 | } |
1097 | GNUNET_free (rc->transport); | 1195 | if (GNUNET_SCHEDULER_NO_TASK != op_timeout) |
1098 | GNUNET_free (rc->addrcp); | ||
1099 | GNUNET_CONTAINER_DLL_remove(rc_head, rc_tail, rc); | ||
1100 | GNUNET_free(rc); | ||
1101 | if ((0 == address_resolutions) && (iterate_connections)) | ||
1102 | { | 1196 | { |
1103 | if (GNUNET_SCHEDULER_NO_TASK != end) | 1197 | GNUNET_SCHEDULER_cancel (op_timeout); |
1104 | { | 1198 | op_timeout = GNUNET_SCHEDULER_NO_TASK; |
1105 | GNUNET_SCHEDULER_cancel (end); | ||
1106 | end = GNUNET_SCHEDULER_NO_TASK; | ||
1107 | } | ||
1108 | if (GNUNET_SCHEDULER_NO_TASK != op_timeout) | ||
1109 | { | ||
1110 | GNUNET_SCHEDULER_cancel (op_timeout); | ||
1111 | op_timeout = GNUNET_SCHEDULER_NO_TASK; | ||
1112 | } | ||
1113 | ret = 0; | ||
1114 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); | ||
1115 | } | 1199 | } |
1200 | ret = 0; | ||
1201 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); | ||
1116 | } | 1202 | } |
1117 | } | 1203 | } |
1118 | 1204 | ||
@@ -1138,8 +1224,11 @@ resolve_peer_address (const struct GNUNET_PeerIdentity *id, | |||
1138 | rc->state = state; | 1224 | rc->state = state; |
1139 | rc->state_timeout = state_timeout; | 1225 | rc->state_timeout = state_timeout; |
1140 | /* Resolve address to string */ | 1226 | /* Resolve address to string */ |
1141 | rc->asc = GNUNET_TRANSPORT_address_to_string (cfg, address, numeric, | 1227 | rc->asc = GNUNET_TRANSPORT_address_to_string (cfg, |
1142 | RESOLUTION_TIMEOUT, &process_peer_string, rc); | 1228 | address, |
1229 | numeric, | ||
1230 | RESOLUTION_TIMEOUT, | ||
1231 | &process_peer_string, rc); | ||
1143 | } | 1232 | } |
1144 | 1233 | ||
1145 | 1234 | ||
@@ -1177,12 +1266,14 @@ process_peer_iteration_cb (void *cls, | |||
1177 | 1266 | ||
1178 | if (GNUNET_SCHEDULER_NO_TASK != op_timeout) | 1267 | if (GNUNET_SCHEDULER_NO_TASK != op_timeout) |
1179 | GNUNET_SCHEDULER_cancel (op_timeout); | 1268 | GNUNET_SCHEDULER_cancel (op_timeout); |
1180 | op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout, | 1269 | op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, |
1270 | &operation_timeout, | ||
1181 | NULL); | 1271 | NULL); |
1182 | 1272 | ||
1183 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1273 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1184 | "Received address for peer `%s': %s\n", | 1274 | "Received address for peer `%s': %s\n", |
1185 | GNUNET_i2s (peer), address->transport_name); | 1275 | GNUNET_i2s (peer), |
1276 | address->transport_name); | ||
1186 | 1277 | ||
1187 | if (NULL != address) | 1278 | if (NULL != address) |
1188 | resolve_peer_address (peer, address, numeric, state, state_timeout); | 1279 | resolve_peer_address (peer, address, numeric, state, state_timeout); |
@@ -1221,7 +1312,8 @@ process_peer_monitoring_cb (void *cls, | |||
1221 | 1312 | ||
1222 | if (GNUNET_SCHEDULER_NO_TASK != op_timeout) | 1313 | if (GNUNET_SCHEDULER_NO_TASK != op_timeout) |
1223 | GNUNET_SCHEDULER_cancel (op_timeout); | 1314 | GNUNET_SCHEDULER_cancel (op_timeout); |
1224 | op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout, | 1315 | op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, |
1316 | &operation_timeout, | ||
1225 | NULL); | 1317 | NULL); |
1226 | 1318 | ||
1227 | if (NULL == (m = GNUNET_CONTAINER_multipeermap_get (monitored_peers, peer))) | 1319 | if (NULL == (m = GNUNET_CONTAINER_multipeermap_get (monitored_peers, peer))) |
@@ -1254,15 +1346,26 @@ process_peer_monitoring_cb (void *cls, | |||
1254 | m->state_timeout = state_timeout; | 1346 | m->state_timeout = state_timeout; |
1255 | 1347 | ||
1256 | if (NULL != address) | 1348 | if (NULL != address) |
1257 | resolve_peer_address (peer, m->address, numeric, m->state, m->state_timeout); | 1349 | resolve_peer_address (peer, |
1350 | m->address, | ||
1351 | numeric, | ||
1352 | m->state, | ||
1353 | m->state_timeout); | ||
1258 | else | 1354 | else |
1259 | print_info (peer, NULL, NULL, m->state, m->state_timeout); | 1355 | print_info (peer, |
1356 | NULL, | ||
1357 | NULL, | ||
1358 | m->state, | ||
1359 | m->state_timeout); | ||
1260 | } | 1360 | } |
1261 | 1361 | ||
1362 | |||
1262 | static void | 1363 | static void |
1263 | try_connect_cb (void *cls, const int result) | 1364 | try_connect_cb (void *cls, |
1365 | const int result) | ||
1264 | { | 1366 | { |
1265 | static int retries = 0; | 1367 | static int retries = 0; |
1368 | |||
1266 | if (GNUNET_OK == result) | 1369 | if (GNUNET_OK == result) |
1267 | { | 1370 | { |
1268 | tc_handle = NULL; | 1371 | tc_handle = NULL; |
@@ -1274,8 +1377,9 @@ try_connect_cb (void *cls, const int result) | |||
1274 | NULL ); | 1377 | NULL ); |
1275 | else | 1378 | else |
1276 | { | 1379 | { |
1277 | FPRINTF (stderr, "%s", | 1380 | FPRINTF (stderr, |
1278 | _("Failed to send connect request to transport service\n") ); | 1381 | "%s", |
1382 | _("Failed to send connect request to transport service\n") ); | ||
1279 | if (GNUNET_SCHEDULER_NO_TASK != end) | 1383 | if (GNUNET_SCHEDULER_NO_TASK != end) |
1280 | GNUNET_SCHEDULER_cancel (end); | 1384 | GNUNET_SCHEDULER_cancel (end); |
1281 | ret = 1; | 1385 | ret = 1; |
@@ -1284,8 +1388,10 @@ try_connect_cb (void *cls, const int result) | |||
1284 | } | 1388 | } |
1285 | } | 1389 | } |
1286 | 1390 | ||
1391 | |||
1287 | static void | 1392 | static void |
1288 | try_disconnect_cb (void *cls, const int result) | 1393 | try_disconnect_cb (void *cls, |
1394 | const int result) | ||
1289 | { | 1395 | { |
1290 | static int retries = 0; | 1396 | static int retries = 0; |
1291 | if (GNUNET_OK == result) | 1397 | if (GNUNET_OK == result) |
@@ -1309,6 +1415,7 @@ try_disconnect_cb (void *cls, const int result) | |||
1309 | } | 1415 | } |
1310 | } | 1416 | } |
1311 | 1417 | ||
1418 | |||
1312 | /** | 1419 | /** |
1313 | * Function called with the result of the check if the 'transport' | 1420 | * Function called with the result of the check if the 'transport' |
1314 | * service is running. | 1421 | * service is running. |