diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-06-08 08:35:14 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-06-08 08:35:14 +0000 |
commit | 6db5516751484bc331e57c869f16f859a6f87ffd (patch) | |
tree | c0c0709ac284e5e637841308ac17747506ae577d /src | |
parent | f820a4b7918625b07d37e63f3ce8791840a9d4ec (diff) | |
download | gnunet-6db5516751484bc331e57c869f16f859a6f87ffd.tar.gz gnunet-6db5516751484bc331e57c869f16f859a6f87ffd.zip |
-indentation, doxygen, be a bit pickier about return values to eliminate possible causes of #3794
Diffstat (limited to 'src')
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.c | 122 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_peer.c | 226 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_peer.h | 46 |
3 files changed, 221 insertions, 173 deletions
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index d613f627c..2c9ec0704 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2001-2013 Christian Grothoff (and other contributing authors) | 3 | Copyright (C) 2001-2015 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -17,7 +17,6 @@ | |||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | |||
21 | /** | 20 | /** |
22 | * @file cadet/gnunet-service-cadet_connection.c | 21 | * @file cadet/gnunet-service-cadet_connection.c |
23 | * @brief GNUnet CADET service connection handling | 22 | * @brief GNUnet CADET service connection handling |
@@ -623,9 +622,11 @@ conn_message_sent (void *cls, | |||
623 | } | 622 | } |
624 | LOG (GNUNET_ERROR_TYPE_DEBUG, " C_P- %p %u\n", c, c->pending_messages); | 623 | LOG (GNUNET_ERROR_TYPE_DEBUG, " C_P- %p %u\n", c, c->pending_messages); |
625 | c->pending_messages--; | 624 | c->pending_messages--; |
626 | if (GNUNET_YES == c->destroy && 0 == c->pending_messages) | 625 | if ( (GNUNET_YES == c->destroy) && |
626 | (0 == c->pending_messages) ) | ||
627 | { | 627 | { |
628 | LOG (GNUNET_ERROR_TYPE_DEBUG, "! destroying connection!\n"); | 628 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
629 | "! destroying connection!\n"); | ||
629 | GCC_destroy (c); | 630 | GCC_destroy (c); |
630 | return GNUNET_YES; | 631 | return GNUNET_YES; |
631 | } | 632 | } |
@@ -729,8 +730,8 @@ get_prev_hop (const struct CadetConnection *c) | |||
729 | 730 | ||
730 | if (NULL == c->path) | 731 | if (NULL == c->path) |
731 | return NULL; | 732 | return NULL; |
732 | 733 | LOG (GNUNET_ERROR_TYPE_DEBUG, | |
733 | LOG (GNUNET_ERROR_TYPE_DEBUG, " get prev hop %s [%u/%u]\n", | 734 | " get prev hop %s [%u/%u]\n", |
734 | GCC_2s (c), c->own_pos, c->path->length); | 735 | GCC_2s (c), c->own_pos, c->path->length); |
735 | if (0 == c->own_pos || c->path->length < 2) | 736 | if (0 == c->own_pos || c->path->length < 2) |
736 | id = c->path->peers[0]; | 737 | id = c->path->peers[0]; |
@@ -1376,7 +1377,8 @@ connection_fwd_timeout (void *cls, | |||
1376 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 1377 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
1377 | return; | 1378 | return; |
1378 | 1379 | ||
1379 | LOG (GNUNET_ERROR_TYPE_INFO, "Connection %s FWD timed out. Destroying.\n", | 1380 | LOG (GNUNET_ERROR_TYPE_INFO, |
1381 | "Connection %s FWD timed out. Destroying.\n", | ||
1380 | GCC_2s (c)); | 1382 | GCC_2s (c)); |
1381 | GCC_debug (c, GNUNET_ERROR_TYPE_DEBUG); | 1383 | GCC_debug (c, GNUNET_ERROR_TYPE_DEBUG); |
1382 | 1384 | ||
@@ -1510,21 +1512,25 @@ register_neighbors (struct CadetConnection *c) | |||
1510 | GCC_2s (c), prev_peer); | 1512 | GCC_2s (c), prev_peer); |
1511 | LOG (GNUNET_ERROR_TYPE_DEBUG, "prev peer %p %s\n", prev_peer, GCP_2s (prev_peer)); | 1513 | LOG (GNUNET_ERROR_TYPE_DEBUG, "prev peer %p %s\n", prev_peer, GCP_2s (prev_peer)); |
1512 | 1514 | ||
1513 | if (GNUNET_NO == GCP_is_neighbor (next_peer) | 1515 | if ( (GNUNET_NO == GCP_is_neighbor (next_peer)) || |
1514 | || GNUNET_NO == GCP_is_neighbor (prev_peer)) | 1516 | (GNUNET_NO == GCP_is_neighbor (prev_peer)) ) |
1515 | { | 1517 | { |
1516 | if (GCC_is_origin (c, GNUNET_YES)) | 1518 | if (GCC_is_origin (c, GNUNET_YES)) |
1517 | GNUNET_STATISTICS_update (stats, "# local bad paths", 1, GNUNET_NO); | 1519 | GNUNET_STATISTICS_update (stats, "# local bad paths", 1, GNUNET_NO); |
1518 | GNUNET_STATISTICS_update (stats, "# bad paths", 1, GNUNET_NO); | 1520 | GNUNET_STATISTICS_update (stats, "# bad paths", 1, GNUNET_NO); |
1519 | 1521 | ||
1520 | LOG (GNUNET_ERROR_TYPE_DEBUG, " register neighbors failed\n"); | 1522 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1521 | LOG (GNUNET_ERROR_TYPE_DEBUG, " prev: %s, neighbor?: %d\n", | 1523 | " register neighbors failed\n"); |
1522 | GCP_2s (prev_peer), GCP_is_neighbor (prev_peer)); | 1524 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1523 | LOG (GNUNET_ERROR_TYPE_DEBUG, " next: %s, neighbor?: %d\n", | 1525 | " prev: %s, neighbor?: %d\n", |
1524 | GCP_2s (next_peer), GCP_is_neighbor (next_peer)); | 1526 | GCP_2s (prev_peer), |
1527 | GCP_is_neighbor (prev_peer)); | ||
1528 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1529 | " next: %s, neighbor?: %d\n", | ||
1530 | GCP_2s (next_peer), | ||
1531 | GCP_is_neighbor (next_peer)); | ||
1525 | return GNUNET_SYSERR; | 1532 | return GNUNET_SYSERR; |
1526 | } | 1533 | } |
1527 | |||
1528 | GCP_add_connection (next_peer, c); | 1534 | GCP_add_connection (next_peer, c); |
1529 | GCP_add_connection (prev_peer, c); | 1535 | GCP_add_connection (prev_peer, c); |
1530 | 1536 | ||
@@ -1543,18 +1549,9 @@ unregister_neighbors (struct CadetConnection *c) | |||
1543 | struct CadetPeer *peer; | 1549 | struct CadetPeer *peer; |
1544 | 1550 | ||
1545 | peer = get_next_hop (c); | 1551 | peer = get_next_hop (c); |
1546 | if (GNUNET_OK != GCP_remove_connection (peer, c)) | 1552 | GCP_remove_connection (peer, c); |
1547 | { | ||
1548 | LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate: %u\n", c->state); | ||
1549 | if (NULL != c->t) GCT_debug (c->t, GNUNET_ERROR_TYPE_DEBUG); | ||
1550 | } | ||
1551 | |||
1552 | peer = get_prev_hop (c); | 1553 | peer = get_prev_hop (c); |
1553 | if (GNUNET_OK != GCP_remove_connection (peer, c)) | 1554 | GCP_remove_connection (peer, c); |
1554 | { | ||
1555 | LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate: %u\n", c->state); | ||
1556 | if (NULL != c->t) GCT_debug (c->t, GNUNET_ERROR_TYPE_DEBUG); | ||
1557 | } | ||
1558 | } | 1555 | } |
1559 | 1556 | ||
1560 | 1557 | ||
@@ -1634,7 +1631,8 @@ does_connection_exist (struct CadetConnection *conn) | |||
1634 | if (NULL == t) | 1631 | if (NULL == t) |
1635 | return GNUNET_NO; | 1632 | return GNUNET_NO; |
1636 | 1633 | ||
1637 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Checking for duplicates\n"); | 1634 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1635 | "Checking for duplicates\n"); | ||
1638 | 1636 | ||
1639 | GCT_iterate_connections (t, &check_path, conn); | 1637 | GCT_iterate_connections (t, &check_path, conn); |
1640 | 1638 | ||
@@ -1985,8 +1983,8 @@ GCC_handle_confirm (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1985 | * @param id Peer identity of sending neighbor. | 1983 | * @param id Peer identity of sending neighbor. |
1986 | * @param message Message. | 1984 | * @param message Message. |
1987 | * | 1985 | * |
1988 | * @return GNUNET_OK to keep the connection open, | 1986 | * @return #GNUNET_OK to keep the connection open, |
1989 | * GNUNET_SYSERR to close it (signal serious error) | 1987 | * #GNUNET_SYSERR to close it (signal serious error) |
1990 | */ | 1988 | */ |
1991 | int | 1989 | int |
1992 | GCC_handle_broken (void* cls, | 1990 | GCC_handle_broken (void* cls, |
@@ -2058,19 +2056,19 @@ GCC_handle_broken (void* cls, | |||
2058 | * @param cls Closure (unused). | 2056 | * @param cls Closure (unused). |
2059 | * @param peer Peer identity of sending neighbor. | 2057 | * @param peer Peer identity of sending neighbor. |
2060 | * @param message Message. | 2058 | * @param message Message. |
2061 | * | 2059 | * @return #GNUNET_OK to keep the connection open, |
2062 | * @return GNUNET_OK to keep the connection open, | 2060 | * #GNUNET_SYSERR to close it (signal serious error) |
2063 | * GNUNET_SYSERR to close it (signal serious error) | ||
2064 | */ | 2061 | */ |
2065 | int | 2062 | int |
2066 | GCC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer, | 2063 | GCC_handle_destroy (void *cls, |
2064 | const struct GNUNET_PeerIdentity *peer, | ||
2067 | const struct GNUNET_MessageHeader *message) | 2065 | const struct GNUNET_MessageHeader *message) |
2068 | { | 2066 | { |
2069 | struct GNUNET_CADET_ConnectionDestroy *msg; | 2067 | const struct GNUNET_CADET_ConnectionDestroy *msg; |
2070 | struct CadetConnection *c; | 2068 | struct CadetConnection *c; |
2071 | int fwd; | 2069 | int fwd; |
2072 | 2070 | ||
2073 | msg = (struct GNUNET_CADET_ConnectionDestroy *) message; | 2071 | msg = (const struct GNUNET_CADET_ConnectionDestroy *) message; |
2074 | log_message (message, peer, &msg->cid); | 2072 | log_message (message, peer, &msg->cid); |
2075 | c = connection_get (&msg->cid); | 2073 | c = connection_get (&msg->cid); |
2076 | if (NULL == c) | 2074 | if (NULL == c) |
@@ -2081,7 +2079,8 @@ GCC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2081 | */ | 2079 | */ |
2082 | GNUNET_STATISTICS_update (stats, "# control on unknown connection", | 2080 | GNUNET_STATISTICS_update (stats, "# control on unknown connection", |
2083 | 1, GNUNET_NO); | 2081 | 1, GNUNET_NO); |
2084 | LOG (GNUNET_ERROR_TYPE_DEBUG, " connection unknown: already destroyed?\n"); | 2082 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2083 | " connection unknown: already destroyed?\n"); | ||
2085 | return GNUNET_OK; | 2084 | return GNUNET_OK; |
2086 | } | 2085 | } |
2087 | fwd = is_fwd (c, peer); | 2086 | fwd = is_fwd (c, peer); |
@@ -2651,9 +2650,9 @@ GCC_init (const struct GNUNET_CONFIGURATION_Handle *c) | |||
2651 | * | 2650 | * |
2652 | * @param cls Closure (unused). | 2651 | * @param cls Closure (unused). |
2653 | * @param key Current key code (CID, unused). | 2652 | * @param key Current key code (CID, unused). |
2654 | * @param value Value in the hash map (connection) | 2653 | * @param value Value in the hash map (`struct CadetConnection`) |
2655 | * | 2654 | * |
2656 | * @return #GNUNET_YES, because we should continue to iterate, | 2655 | * @return #GNUNET_YES, because we should continue to iterate |
2657 | */ | 2656 | */ |
2658 | static int | 2657 | static int |
2659 | shutdown_iterator (void *cls, | 2658 | shutdown_iterator (void *cls, |
@@ -2662,6 +2661,7 @@ shutdown_iterator (void *cls, | |||
2662 | { | 2661 | { |
2663 | struct CadetConnection *c = value; | 2662 | struct CadetConnection *c = value; |
2664 | 2663 | ||
2664 | c->state = CADET_CONNECTION_DESTROYED; | ||
2665 | GCC_destroy (c); | 2665 | GCC_destroy (c); |
2666 | return GNUNET_YES; | 2666 | return GNUNET_YES; |
2667 | } | 2667 | } |
@@ -2673,7 +2673,9 @@ shutdown_iterator (void *cls, | |||
2673 | void | 2673 | void |
2674 | GCC_shutdown (void) | 2674 | GCC_shutdown (void) |
2675 | { | 2675 | { |
2676 | GNUNET_CONTAINER_multihashmap_iterate (connections, &shutdown_iterator, NULL); | 2676 | GNUNET_CONTAINER_multihashmap_iterate (connections, |
2677 | &shutdown_iterator, | ||
2678 | NULL); | ||
2677 | GNUNET_CONTAINER_multihashmap_destroy (connections); | 2679 | GNUNET_CONTAINER_multihashmap_destroy (connections); |
2678 | connections = NULL; | 2680 | connections = NULL; |
2679 | } | 2681 | } |
@@ -2745,11 +2747,16 @@ GCC_destroy (struct CadetConnection *c) | |||
2745 | return; /* -> message_sent -> GCC_destroy. Don't loop. */ | 2747 | return; /* -> message_sent -> GCC_destroy. Don't loop. */ |
2746 | c->destroy = 2; | 2748 | c->destroy = 2; |
2747 | 2749 | ||
2748 | LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying connection %s\n", GCC_2s (c)); | 2750 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2749 | LOG (GNUNET_ERROR_TYPE_DEBUG, " fc's f: %p, b: %p\n", | 2751 | "destroying connection %s\n", |
2752 | GCC_2s (c)); | ||
2753 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2754 | " fc's f: %p, b: %p\n", | ||
2750 | &c->fwd_fc, &c->bck_fc); | 2755 | &c->fwd_fc, &c->bck_fc); |
2751 | LOG (GNUNET_ERROR_TYPE_DEBUG, " fc tasks f: %u, b: %u\n", | 2756 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2752 | c->fwd_fc.poll_task, c->bck_fc.poll_task); | 2757 | " fc tasks f: %u, b: %u\n", |
2758 | c->fwd_fc.poll_task, | ||
2759 | c->bck_fc.poll_task); | ||
2753 | 2760 | ||
2754 | /* Cancel all traffic */ | 2761 | /* Cancel all traffic */ |
2755 | if (NULL != c->path) | 2762 | if (NULL != c->path) |
@@ -2763,19 +2770,22 @@ GCC_destroy (struct CadetConnection *c) | |||
2763 | if (NULL != c->fwd_fc.poll_msg) | 2770 | if (NULL != c->fwd_fc.poll_msg) |
2764 | { | 2771 | { |
2765 | GCC_cancel (c->fwd_fc.poll_msg); | 2772 | GCC_cancel (c->fwd_fc.poll_msg); |
2766 | LOG (GNUNET_ERROR_TYPE_DEBUG, " *** POLL msg FWD canceled\n"); | 2773 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2774 | " *** POLL msg FWD canceled\n"); | ||
2767 | } | 2775 | } |
2768 | if (NULL != c->bck_fc.poll_msg) | 2776 | if (NULL != c->bck_fc.poll_msg) |
2769 | { | 2777 | { |
2770 | GCC_cancel (c->bck_fc.poll_msg); | 2778 | GCC_cancel (c->bck_fc.poll_msg); |
2771 | LOG (GNUNET_ERROR_TYPE_DEBUG, " *** POLL msg BCK canceled\n"); | 2779 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2780 | " *** POLL msg BCK canceled\n"); | ||
2772 | } | 2781 | } |
2773 | 2782 | ||
2774 | /* Delete from tunnel */ | 2783 | /* Delete from tunnel */ |
2775 | if (NULL != c->t) | 2784 | if (NULL != c->t) |
2776 | GCT_remove_connection (c->t, c); | 2785 | GCT_remove_connection (c->t, c); |
2777 | 2786 | ||
2778 | if (GNUNET_NO == GCC_is_origin (c, GNUNET_YES) && NULL != c->path) | 2787 | if ( (GNUNET_NO == GCC_is_origin (c, GNUNET_YES)) && |
2788 | (NULL != c->path) ) | ||
2779 | path_destroy (c->path); | 2789 | path_destroy (c->path); |
2780 | if (NULL != c->fwd_maintenance_task) | 2790 | if (NULL != c->fwd_maintenance_task) |
2781 | GNUNET_SCHEDULER_cancel (c->fwd_maintenance_task); | 2791 | GNUNET_SCHEDULER_cancel (c->fwd_maintenance_task); |
@@ -2794,12 +2804,16 @@ GCC_destroy (struct CadetConnection *c) | |||
2794 | 2804 | ||
2795 | GNUNET_break (GNUNET_YES == | 2805 | GNUNET_break (GNUNET_YES == |
2796 | GNUNET_CONTAINER_multihashmap_remove (connections, | 2806 | GNUNET_CONTAINER_multihashmap_remove (connections, |
2797 | GCC_get_h (c), c)); | 2807 | GCC_get_h (c), |
2798 | 2808 | c)); | |
2799 | GNUNET_STATISTICS_update (stats, "# connections", -1, GNUNET_NO); | 2809 | GNUNET_STATISTICS_update (stats, |
2810 | "# connections", | ||
2811 | -1, | ||
2812 | GNUNET_NO); | ||
2800 | GNUNET_free (c); | 2813 | GNUNET_free (c); |
2801 | } | 2814 | } |
2802 | 2815 | ||
2816 | |||
2803 | /** | 2817 | /** |
2804 | * Get the connection ID. | 2818 | * Get the connection ID. |
2805 | * | 2819 | * |
@@ -2983,9 +2997,9 @@ GCC_notify_broken (struct CadetConnection *c, | |||
2983 | int fwd; | 2997 | int fwd; |
2984 | 2998 | ||
2985 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2999 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2986 | " notify broken on %s due to %s disconnect\n", | 3000 | "Notify broken on %s due to %s disconnect\n", |
2987 | GCC_2s (c), GCP_2s (peer)); | 3001 | GCC_2s (c), |
2988 | 3002 | GCP_2s (peer)); | |
2989 | hop = get_prev_hop (c); | 3003 | hop = get_prev_hop (c); |
2990 | if (NULL == hop) | 3004 | if (NULL == hop) |
2991 | { | 3005 | { |
@@ -2993,7 +3007,6 @@ GCC_notify_broken (struct CadetConnection *c, | |||
2993 | GNUNET_break (0); | 3007 | GNUNET_break (0); |
2994 | return; | 3008 | return; |
2995 | } | 3009 | } |
2996 | |||
2997 | fwd = (peer == hop); | 3010 | fwd = (peer == hop); |
2998 | if (GNUNET_YES == GCC_is_terminal (c, fwd)) | 3011 | if (GNUNET_YES == GCC_is_terminal (c, fwd)) |
2999 | { | 3012 | { |
@@ -3014,8 +3027,6 @@ GCC_notify_broken (struct CadetConnection *c, | |||
3014 | * Cancel all queues, if no message is left, connection will be destroyed. | 3027 | * Cancel all queues, if no message is left, connection will be destroyed. |
3015 | */ | 3028 | */ |
3016 | connection_cancel_queues (c, !fwd); | 3029 | connection_cancel_queues (c, !fwd); |
3017 | |||
3018 | return; | ||
3019 | } | 3030 | } |
3020 | 3031 | ||
3021 | 3032 | ||
@@ -3486,4 +3497,3 @@ GCC_debug (const struct CadetConnection *c, enum GNUNET_ErrorType level) | |||
3486 | 3497 | ||
3487 | LOG2 (level, "CCC DEBUG CONNECTION END\n"); | 3498 | LOG2 (level, "CCC DEBUG CONNECTION END\n"); |
3488 | } | 3499 | } |
3489 | |||
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c index fef95dfcc..af160d88c 100644 --- a/src/cadet/gnunet-service-cadet_peer.c +++ b/src/cadet/gnunet-service-cadet_peer.c | |||
@@ -49,34 +49,34 @@ | |||
49 | */ | 49 | */ |
50 | struct CadetPeerQueue | 50 | struct CadetPeerQueue |
51 | { | 51 | { |
52 | /** | 52 | /** |
53 | * DLL next | 53 | * DLL next |
54 | */ | 54 | */ |
55 | struct CadetPeerQueue *next; | 55 | struct CadetPeerQueue *next; |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * DLL previous | 58 | * DLL previous |
59 | */ | 59 | */ |
60 | struct CadetPeerQueue *prev; | 60 | struct CadetPeerQueue *prev; |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * Peer this transmission is directed to. | 63 | * Peer this transmission is directed to. |
64 | */ | 64 | */ |
65 | struct CadetPeer *peer; | 65 | struct CadetPeer *peer; |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * Connection this message belongs to. | 68 | * Connection this message belongs to. |
69 | */ | 69 | */ |
70 | struct CadetConnection *c; | 70 | struct CadetConnection *c; |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * Is FWD in c? | 73 | * Is FWD in c? |
74 | */ | 74 | */ |
75 | int fwd; | 75 | int fwd; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Pointer to info stucture used as cls. | 78 | * Pointer to info stucture used as cls. |
79 | */ | 79 | */ |
80 | void *cls; | 80 | void *cls; |
81 | 81 | ||
82 | /** | 82 | /** |
@@ -95,26 +95,27 @@ struct CadetPeerQueue | |||
95 | uint32_t payload_id; | 95 | uint32_t payload_id; |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * Size of the message | 98 | * Size of the message |
99 | */ | 99 | */ |
100 | size_t size; | 100 | size_t size; |
101 | 101 | ||
102 | /** | 102 | /** |
103 | * Set when this message starts waiting for CORE. | 103 | * Set when this message starts waiting for CORE. |
104 | */ | 104 | */ |
105 | struct GNUNET_TIME_Absolute start_waiting; | 105 | struct GNUNET_TIME_Absolute start_waiting; |
106 | 106 | ||
107 | /** | 107 | /** |
108 | * Function to call on sending. | 108 | * Function to call on sending. |
109 | */ | 109 | */ |
110 | GCP_sent cont; | 110 | GCP_sent cont; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | * Closure for callback. | 113 | * Closure for callback. |
114 | */ | 114 | */ |
115 | void *cont_cls; | 115 | void *cont_cls; |
116 | }; | 116 | }; |
117 | 117 | ||
118 | |||
118 | /** | 119 | /** |
119 | * Struct containing all information regarding a given peer | 120 | * Struct containing all information regarding a given peer |
120 | */ | 121 | */ |
@@ -150,19 +151,19 @@ struct CadetPeer | |||
150 | */ | 151 | */ |
151 | struct GNUNET_SCHEDULER_Task *search_delayed; | 152 | struct GNUNET_SCHEDULER_Task *search_delayed; |
152 | 153 | ||
153 | /** | 154 | /** |
154 | * Tunnel to this peer, if any. | 155 | * Tunnel to this peer, if any. |
155 | */ | 156 | */ |
156 | struct CadetTunnel *tunnel; | 157 | struct CadetTunnel *tunnel; |
157 | 158 | ||
158 | /** | 159 | /** |
159 | * Connections that go through this peer, indexed by tid; | 160 | * Connections that go through this peer, indexed by tid; |
160 | */ | 161 | */ |
161 | struct GNUNET_CONTAINER_MultiHashMap *connections; | 162 | struct GNUNET_CONTAINER_MultiHashMap *connections; |
162 | 163 | ||
163 | /** | 164 | /** |
164 | * Handle for queued transmissions | 165 | * Handle for queued transmissions |
165 | */ | 166 | */ |
166 | struct GNUNET_CORE_TransmitHandle *core_transmit; | 167 | struct GNUNET_CORE_TransmitHandle *core_transmit; |
167 | 168 | ||
168 | /** | 169 | /** |
@@ -212,7 +213,7 @@ extern struct GNUNET_PeerIdentity my_full_id; | |||
212 | extern GNUNET_PEER_Id myid; | 213 | extern GNUNET_PEER_Id myid; |
213 | 214 | ||
214 | /** | 215 | /** |
215 | * Peers known, indexed by PeerIdentity (CadetPeer). | 216 | * Peers known, indexed by PeerIdentity, values of type `struct CadetPeer`. |
216 | */ | 217 | */ |
217 | static struct GNUNET_CONTAINER_MultiPeerMap *peers; | 218 | static struct GNUNET_CONTAINER_MultiPeerMap *peers; |
218 | 219 | ||
@@ -347,10 +348,12 @@ notify_broken (void *cls, | |||
347 | struct CadetPeer *peer = cls; | 348 | struct CadetPeer *peer = cls; |
348 | struct CadetConnection *c = value; | 349 | struct CadetConnection *c = value; |
349 | 350 | ||
350 | LOG (GNUNET_ERROR_TYPE_DEBUG, " notifying %s due to %s\n", | 351 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
351 | GCC_2s (c), GCP_2s (peer)); | 352 | "Notifying %s due to %s\n", |
352 | GCC_notify_broken (c, peer); | 353 | GCC_2s (c), |
353 | 354 | GCP_2s (peer)); | |
355 | GCC_notify_broken (c, | ||
356 | peer); | ||
354 | return GNUNET_YES; | 357 | return GNUNET_YES; |
355 | } | 358 | } |
356 | 359 | ||
@@ -434,26 +437,33 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
434 | * @param peer peer identity this notification is about | 437 | * @param peer peer identity this notification is about |
435 | */ | 438 | */ |
436 | static void | 439 | static void |
437 | core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 440 | core_disconnect (void *cls, |
441 | const struct GNUNET_PeerIdentity *peer) | ||
438 | { | 442 | { |
439 | struct CadetPeer *p; | 443 | struct CadetPeer *p; |
440 | struct CadetPeerPath *direct_path; | 444 | struct CadetPeerPath *direct_path; |
441 | char own_id[16]; | 445 | char own_id[16]; |
442 | 446 | ||
443 | strncpy (own_id, GNUNET_i2s (&my_full_id), 15); | 447 | strncpy (own_id, GNUNET_i2s (&my_full_id), 15); |
444 | p = GNUNET_CONTAINER_multipeermap_get (peers, peer); | 448 | p = GNUNET_CONTAINER_multipeermap_get (peers, |
449 | peer); | ||
445 | if (NULL == p) | 450 | if (NULL == p) |
446 | { | 451 | { |
447 | GNUNET_break (0); | 452 | GNUNET_break (0); |
448 | return; | 453 | return; |
449 | } | 454 | } |
450 | if (myid == p->id) | 455 | if (myid == p->id) |
451 | LOG (GNUNET_ERROR_TYPE_INFO, "DISCONNECTED %s (self)\n", own_id); | 456 | LOG (GNUNET_ERROR_TYPE_INFO, |
457 | "DISCONNECTED %s (self)\n", | ||
458 | own_id); | ||
452 | else | 459 | else |
453 | LOG (GNUNET_ERROR_TYPE_INFO, "DISCONNECTED %s <= %s\n", | 460 | LOG (GNUNET_ERROR_TYPE_INFO, |
461 | "DISCONNECTED %s <= %s\n", | ||
454 | own_id, GNUNET_i2s (peer)); | 462 | own_id, GNUNET_i2s (peer)); |
455 | direct_path = pop_direct_path (p); | 463 | direct_path = pop_direct_path (p); |
456 | GNUNET_CONTAINER_multihashmap_iterate (p->connections, ¬ify_broken, p); | 464 | GNUNET_CONTAINER_multihashmap_iterate (p->connections, |
465 | ¬ify_broken, | ||
466 | p); | ||
457 | GNUNET_CONTAINER_multihashmap_destroy (p->connections); | 467 | GNUNET_CONTAINER_multihashmap_destroy (p->connections); |
458 | p->connections = NULL; | 468 | p->connections = NULL; |
459 | if (NULL != p->core_transmit) | 469 | if (NULL != p->core_transmit) |
@@ -756,10 +766,14 @@ peer_destroy (struct CadetPeer *peer) | |||
756 | GNUNET_PEER_resolve (peer->id, &id); | 766 | GNUNET_PEER_resolve (peer->id, &id); |
757 | GNUNET_PEER_change_rc (peer->id, -1); | 767 | GNUNET_PEER_change_rc (peer->id, -1); |
758 | 768 | ||
759 | LOG (GNUNET_ERROR_TYPE_WARNING, "destroying peer %s\n", GNUNET_i2s (&id)); | 769 | LOG (GNUNET_ERROR_TYPE_WARNING, |
770 | "destroying peer %s\n", | ||
771 | GNUNET_i2s (&id)); | ||
760 | 772 | ||
761 | if (GNUNET_YES != | 773 | if (GNUNET_YES != |
762 | GNUNET_CONTAINER_multipeermap_remove (peers, &id, peer)) | 774 | GNUNET_CONTAINER_multipeermap_remove (peers, |
775 | &id, | ||
776 | peer)) | ||
763 | { | 777 | { |
764 | GNUNET_break (0); | 778 | GNUNET_break (0); |
765 | LOG (GNUNET_ERROR_TYPE_WARNING, " not in peermap!!\n"); | 779 | LOG (GNUNET_ERROR_TYPE_WARNING, " not in peermap!!\n"); |
@@ -1634,7 +1648,8 @@ GCP_queue_unlock (struct CadetPeer *peer, struct CadetConnection *c) | |||
1634 | void | 1648 | void |
1635 | GCP_init (const struct GNUNET_CONFIGURATION_Handle *c) | 1649 | GCP_init (const struct GNUNET_CONFIGURATION_Handle *c) |
1636 | { | 1650 | { |
1637 | LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n"); | 1651 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1652 | "GCP_init\n"); | ||
1638 | peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); | 1653 | peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); |
1639 | if (GNUNET_OK != | 1654 | if (GNUNET_OK != |
1640 | GNUNET_CONFIGURATION_get_value_number (c, "CADET", "MAX_PEERS", | 1655 | GNUNET_CONFIGURATION_get_value_number (c, "CADET", "MAX_PEERS", |
@@ -1704,19 +1719,22 @@ GCP_init (const struct GNUNET_CONFIGURATION_Handle *c) | |||
1704 | void | 1719 | void |
1705 | GCP_shutdown (void) | 1720 | GCP_shutdown (void) |
1706 | { | 1721 | { |
1707 | GNUNET_CONTAINER_multipeermap_iterate (peers, &shutdown_tunnel, NULL); | 1722 | GNUNET_CONTAINER_multipeermap_iterate (peers, |
1708 | 1723 | &shutdown_tunnel, | |
1709 | if (core_handle != NULL) | 1724 | NULL); |
1725 | if (NULL != core_handle) | ||
1710 | { | 1726 | { |
1711 | GNUNET_CORE_disconnect (core_handle); | 1727 | GNUNET_CORE_disconnect (core_handle); |
1712 | core_handle = NULL; | 1728 | core_handle = NULL; |
1713 | } | 1729 | } |
1714 | if (transport_handle != NULL) | 1730 | if (NULL != transport_handle) |
1715 | { | 1731 | { |
1716 | GNUNET_TRANSPORT_disconnect (transport_handle); | 1732 | GNUNET_TRANSPORT_disconnect (transport_handle); |
1717 | transport_handle = NULL; | 1733 | transport_handle = NULL; |
1718 | } | 1734 | } |
1719 | GNUNET_PEER_change_rc (myid, -1); | 1735 | GNUNET_PEER_change_rc (myid, -1); |
1736 | GNUNET_CONTAINER_multipeermap_destroy (peers); | ||
1737 | peers = NULL; | ||
1720 | } | 1738 | } |
1721 | 1739 | ||
1722 | 1740 | ||
@@ -1741,9 +1759,11 @@ GCP_get (const struct GNUNET_PeerIdentity *peer_id) | |||
1741 | { | 1759 | { |
1742 | peer_delete_oldest (); | 1760 | peer_delete_oldest (); |
1743 | } | 1761 | } |
1744 | GNUNET_CONTAINER_multipeermap_put (peers, peer_id, peer, | 1762 | GNUNET_CONTAINER_multipeermap_put (peers, |
1745 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 1763 | peer_id, |
1746 | peer->id = GNUNET_PEER_intern (peer_id); | 1764 | peer, |
1765 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | ||
1766 | peer->id = GNUNET_PEER_intern (peer_id); | ||
1747 | } | 1767 | } |
1748 | peer->last_contact = GNUNET_TIME_absolute_get (); | 1768 | peer->last_contact = GNUNET_TIME_absolute_get (); |
1749 | 1769 | ||
@@ -1921,38 +1941,30 @@ GCP_add_tunnel (struct CadetPeer *peer) | |||
1921 | * | 1941 | * |
1922 | * @param peer Peer to add connection to. | 1942 | * @param peer Peer to add connection to. |
1923 | * @param c Connection to add. | 1943 | * @param c Connection to add. |
1924 | * | ||
1925 | * @return GNUNET_OK on success. | ||
1926 | */ | 1944 | */ |
1927 | int | 1945 | void |
1928 | GCP_add_connection (struct CadetPeer *peer, | 1946 | GCP_add_connection (struct CadetPeer *peer, |
1929 | struct CadetConnection *c) | 1947 | struct CadetConnection *c) |
1930 | { | 1948 | { |
1931 | int result; | ||
1932 | LOG (GNUNET_ERROR_TYPE_DEBUG, "adding connection %s\n", GCC_2s (c)); | ||
1933 | LOG (GNUNET_ERROR_TYPE_DEBUG, "to peer %s\n", GCP_2s (peer)); | ||
1934 | |||
1935 | if (NULL == peer->connections) | ||
1936 | { | ||
1937 | GNUNET_break (0); | ||
1938 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1939 | "Peer %s is not a neighbor!\n", | ||
1940 | GCP_2s (peer)); | ||
1941 | return GNUNET_SYSERR; | ||
1942 | } | ||
1943 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1949 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1944 | "peer %s ok, has %u connections.\n", | 1950 | "adding connection %s\n", |
1945 | GCP_2s (peer), GNUNET_CONTAINER_multihashmap_size (peer->connections)); | 1951 | GCC_2s (c)); |
1946 | result = GNUNET_CONTAINER_multihashmap_put (peer->connections, | 1952 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1947 | GCC_get_h (c), | 1953 | "to peer %s\n", |
1948 | c, | 1954 | GCP_2s (peer)); |
1949 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 1955 | GNUNET_assert (NULL != peer->connections); |
1956 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1957 | "peer %s has %u connections.\n", | ||
1958 | GCP_2s (peer), | ||
1959 | GNUNET_CONTAINER_multihashmap_size (peer->connections)); | ||
1960 | GNUNET_assert (GNUNET_OK == | ||
1961 | GNUNET_CONTAINER_multihashmap_put (peer->connections, | ||
1962 | GCC_get_h (c), | ||
1963 | c, | ||
1964 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); | ||
1950 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1965 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1951 | " now has %u connections.\n", | 1966 | " now has %u connections.\n", |
1952 | GNUNET_CONTAINER_multihashmap_size (peer->connections)); | 1967 | GNUNET_CONTAINER_multihashmap_size (peer->connections)); |
1953 | LOG (GNUNET_ERROR_TYPE_DEBUG, "result %u\n", result); | ||
1954 | |||
1955 | return result; | ||
1956 | } | 1968 | } |
1957 | 1969 | ||
1958 | 1970 | ||
@@ -2121,8 +2133,11 @@ GCP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path) | |||
2121 | GNUNET_assert (myid == path->peers[0]); | 2133 | GNUNET_assert (myid == path->peers[0]); |
2122 | GNUNET_assert (peer->id == path->peers[path->length - 1]); | 2134 | GNUNET_assert (peer->id == path->peers[path->length - 1]); |
2123 | 2135 | ||
2124 | LOG (GNUNET_ERROR_TYPE_INFO, "Removing path %p (%u) from %s\n", | 2136 | LOG (GNUNET_ERROR_TYPE_INFO, |
2125 | path, path->length, GCP_2s (peer)); | 2137 | "Removing path %p (%u) from %s\n", |
2138 | path, | ||
2139 | path->length, | ||
2140 | GCP_2s (peer)); | ||
2126 | 2141 | ||
2127 | for (iter = peer->path_head; NULL != iter; iter = next) | 2142 | for (iter = peer->path_head; NULL != iter; iter = next) |
2128 | { | 2143 | { |
@@ -2143,30 +2158,28 @@ GCP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path) | |||
2143 | * | 2158 | * |
2144 | * @param peer Peer to remove connection from. | 2159 | * @param peer Peer to remove connection from. |
2145 | * @param c Connection to remove. | 2160 | * @param c Connection to remove. |
2146 | * | ||
2147 | * @return GNUNET_OK on success. | ||
2148 | */ | 2161 | */ |
2149 | int | 2162 | void |
2150 | GCP_remove_connection (struct CadetPeer *peer, | 2163 | GCP_remove_connection (struct CadetPeer *peer, |
2151 | const struct CadetConnection *c) | 2164 | const struct CadetConnection *c) |
2152 | { | 2165 | { |
2153 | LOG (GNUNET_ERROR_TYPE_DEBUG, "removing connection %s\n", GCC_2s (c)); | ||
2154 | LOG (GNUNET_ERROR_TYPE_DEBUG, "from peer %s\n", GCP_2s (peer)); | ||
2155 | |||
2156 | if (NULL == peer || NULL == peer->connections) | ||
2157 | { | ||
2158 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2159 | "Peer %s is not a neighbor!\n", | ||
2160 | GCP_2s (peer)); | ||
2161 | return GNUNET_SYSERR; | ||
2162 | } | ||
2163 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2166 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2164 | "peer %s ok, has %u connections.\n", | 2167 | "removing connection %s\n", |
2165 | GCP_2s (peer), GNUNET_CONTAINER_multihashmap_size (peer->connections)); | 2168 | GCC_2s (c)); |
2166 | 2169 | LOG (GNUNET_ERROR_TYPE_DEBUG, | |
2167 | return GNUNET_CONTAINER_multihashmap_remove (peer->connections, | 2170 | "from peer %s\n", |
2168 | GCC_get_h (c), | 2171 | GCP_2s (peer)); |
2169 | c); | 2172 | |
2173 | GNUNET_assert ( (NULL != peer) && | ||
2174 | (NULL != peer->connections) ); | ||
2175 | GNUNET_assert (GNUNET_OK == | ||
2176 | GNUNET_CONTAINER_multihashmap_remove (peer->connections, | ||
2177 | GCC_get_h (c), | ||
2178 | c)); | ||
2179 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2180 | "peer %s ok, has %u connections left.\n", | ||
2181 | GCP_2s (peer), | ||
2182 | GNUNET_CONTAINER_multihashmap_size (peer->connections)); | ||
2170 | } | 2183 | } |
2171 | 2184 | ||
2172 | /** | 2185 | /** |
@@ -2454,9 +2467,12 @@ GCP_count_paths (const struct CadetPeer *peer) | |||
2454 | * @param cls Closure for @c iter. | 2467 | * @param cls Closure for @c iter. |
2455 | */ | 2468 | */ |
2456 | void | 2469 | void |
2457 | GCP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls) | 2470 | GCP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, |
2471 | void *cls) | ||
2458 | { | 2472 | { |
2459 | GNUNET_CONTAINER_multipeermap_iterate (peers, iter, cls); | 2473 | GNUNET_CONTAINER_multipeermap_iterate (peers, |
2474 | iter, | ||
2475 | cls); | ||
2460 | } | 2476 | } |
2461 | 2477 | ||
2462 | 2478 | ||
diff --git a/src/cadet/gnunet-service-cadet_peer.h b/src/cadet/gnunet-service-cadet_peer.h index a0211328b..af937007a 100644 --- a/src/cadet/gnunet-service-cadet_peer.h +++ b/src/cadet/gnunet-service-cadet_peer.h | |||
@@ -215,6 +215,7 @@ GCP_queue_unlock (struct CadetPeer *peer, struct CadetConnection *c); | |||
215 | void | 215 | void |
216 | GCP_set_tunnel (struct CadetPeer *peer, struct CadetTunnel *t); | 216 | GCP_set_tunnel (struct CadetPeer *peer, struct CadetTunnel *t); |
217 | 217 | ||
218 | |||
218 | /** | 219 | /** |
219 | * Check whether there is a direct (core level) connection to peer. | 220 | * Check whether there is a direct (core level) connection to peer. |
220 | * | 221 | * |
@@ -225,6 +226,7 @@ GCP_set_tunnel (struct CadetPeer *peer, struct CadetTunnel *t); | |||
225 | int | 226 | int |
226 | GCP_is_neighbor (const struct CadetPeer *peer); | 227 | GCP_is_neighbor (const struct CadetPeer *peer); |
227 | 228 | ||
229 | |||
228 | /** | 230 | /** |
229 | * Create and initialize a new tunnel towards a peer, in case it has none. | 231 | * Create and initialize a new tunnel towards a peer, in case it has none. |
230 | * | 232 | * |
@@ -235,6 +237,7 @@ GCP_is_neighbor (const struct CadetPeer *peer); | |||
235 | void | 237 | void |
236 | GCP_add_tunnel (struct CadetPeer *peer); | 238 | GCP_add_tunnel (struct CadetPeer *peer); |
237 | 239 | ||
240 | |||
238 | /** | 241 | /** |
239 | * Add a connection to a neighboring peer. | 242 | * Add a connection to a neighboring peer. |
240 | * | 243 | * |
@@ -244,11 +247,11 @@ GCP_add_tunnel (struct CadetPeer *peer); | |||
244 | * | 247 | * |
245 | * @param peer Peer to add connection to. | 248 | * @param peer Peer to add connection to. |
246 | * @param c Connection to add. | 249 | * @param c Connection to add. |
247 | * | ||
248 | * @return GNUNET_OK on success. | ||
249 | */ | 250 | */ |
250 | int | 251 | void |
251 | GCP_add_connection (struct CadetPeer *peer, struct CadetConnection *c); | 252 | GCP_add_connection (struct CadetPeer *peer, |
253 | struct CadetConnection *c); | ||
254 | |||
252 | 255 | ||
253 | /** | 256 | /** |
254 | * Add the path to the peer and update the path used to reach it in case this | 257 | * Add the path to the peer and update the path used to reach it in case this |
@@ -263,7 +266,10 @@ GCP_add_connection (struct CadetPeer *peer, struct CadetConnection *c); | |||
263 | * NULL on error. | 266 | * NULL on error. |
264 | */ | 267 | */ |
265 | struct CadetPeerPath * | 268 | struct CadetPeerPath * |
266 | GCP_add_path (struct CadetPeer *peer, struct CadetPeerPath *p, int trusted); | 269 | GCP_add_path (struct CadetPeer *peer, |
270 | struct CadetPeerPath *p, | ||
271 | int trusted); | ||
272 | |||
267 | 273 | ||
268 | /** | 274 | /** |
269 | * Add the path to the origin peer and update the path used to reach it in case | 275 | * Add the path to the origin peer and update the path used to reach it in case |
@@ -293,6 +299,7 @@ GCP_add_path_to_origin (struct CadetPeer *peer, | |||
293 | void | 299 | void |
294 | GCP_add_path_to_all (const struct CadetPeerPath *p, int confirmed); | 300 | GCP_add_path_to_all (const struct CadetPeerPath *p, int confirmed); |
295 | 301 | ||
302 | |||
296 | /** | 303 | /** |
297 | * Remove any path to the peer that has the extact same peers as the one given. | 304 | * Remove any path to the peer that has the extact same peers as the one given. |
298 | * | 305 | * |
@@ -300,18 +307,20 @@ GCP_add_path_to_all (const struct CadetPeerPath *p, int confirmed); | |||
300 | * @param path Path to remove. Is always destroyed . | 307 | * @param path Path to remove. Is always destroyed . |
301 | */ | 308 | */ |
302 | void | 309 | void |
303 | GCP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path); | 310 | GCP_remove_path (struct CadetPeer *peer, |
311 | struct CadetPeerPath *path); | ||
312 | |||
304 | 313 | ||
305 | /** | 314 | /** |
306 | * Remove a connection from a neighboring peer. | 315 | * Remove a connection from a neighboring peer. |
307 | * | 316 | * |
308 | * @param peer Peer to remove connection from. | 317 | * @param peer Peer to remove connection from. |
309 | * @param c Connection to remove. | 318 | * @param c Connection to remove. |
310 | * | ||
311 | * @return GNUNET_OK on success. | ||
312 | */ | 319 | */ |
313 | int | 320 | void |
314 | GCP_remove_connection (struct CadetPeer *peer, const struct CadetConnection *c); | 321 | GCP_remove_connection (struct CadetPeer *peer, |
322 | const struct CadetConnection *c); | ||
323 | |||
315 | 324 | ||
316 | /** | 325 | /** |
317 | * Start the DHT search for new paths towards the peer: we don't have | 326 | * Start the DHT search for new paths towards the peer: we don't have |
@@ -322,6 +331,7 @@ GCP_remove_connection (struct CadetPeer *peer, const struct CadetConnection *c); | |||
322 | void | 331 | void |
323 | GCP_start_search (struct CadetPeer *peer); | 332 | GCP_start_search (struct CadetPeer *peer); |
324 | 333 | ||
334 | |||
325 | /** | 335 | /** |
326 | * Stop the DHT search for new paths towards the peer: we already have | 336 | * Stop the DHT search for new paths towards the peer: we already have |
327 | * enough good connections. | 337 | * enough good connections. |
@@ -331,6 +341,7 @@ GCP_start_search (struct CadetPeer *peer); | |||
331 | void | 341 | void |
332 | GCP_stop_search (struct CadetPeer *peer); | 342 | GCP_stop_search (struct CadetPeer *peer); |
333 | 343 | ||
344 | |||
334 | /** | 345 | /** |
335 | * Get the Full ID of a peer. | 346 | * Get the Full ID of a peer. |
336 | * | 347 | * |
@@ -341,6 +352,7 @@ GCP_stop_search (struct CadetPeer *peer); | |||
341 | const struct GNUNET_PeerIdentity * | 352 | const struct GNUNET_PeerIdentity * |
342 | GCP_get_id (const struct CadetPeer *peer); | 353 | GCP_get_id (const struct CadetPeer *peer); |
343 | 354 | ||
355 | |||
344 | /** | 356 | /** |
345 | * Get the Short ID of a peer. | 357 | * Get the Short ID of a peer. |
346 | * | 358 | * |
@@ -351,6 +363,7 @@ GCP_get_id (const struct CadetPeer *peer); | |||
351 | GNUNET_PEER_Id | 363 | GNUNET_PEER_Id |
352 | GCP_get_short_id (const struct CadetPeer *peer); | 364 | GCP_get_short_id (const struct CadetPeer *peer); |
353 | 365 | ||
366 | |||
354 | /** | 367 | /** |
355 | * Get the tunnel towards a peer. | 368 | * Get the tunnel towards a peer. |
356 | * | 369 | * |
@@ -361,6 +374,7 @@ GCP_get_short_id (const struct CadetPeer *peer); | |||
361 | struct CadetTunnel * | 374 | struct CadetTunnel * |
362 | GCP_get_tunnel (const struct CadetPeer *peer); | 375 | GCP_get_tunnel (const struct CadetPeer *peer); |
363 | 376 | ||
377 | |||
364 | /** | 378 | /** |
365 | * Set the hello message. | 379 | * Set the hello message. |
366 | * | 380 | * |
@@ -368,7 +382,9 @@ GCP_get_tunnel (const struct CadetPeer *peer); | |||
368 | * @param hello Hello message. | 382 | * @param hello Hello message. |
369 | */ | 383 | */ |
370 | void | 384 | void |
371 | GCP_set_hello (struct CadetPeer *peer, const struct GNUNET_HELLO_Message *hello); | 385 | GCP_set_hello (struct CadetPeer *peer, |
386 | const struct GNUNET_HELLO_Message *hello); | ||
387 | |||
372 | 388 | ||
373 | /** | 389 | /** |
374 | * Get the hello message. | 390 | * Get the hello message. |
@@ -389,6 +405,7 @@ GCP_get_hello (struct CadetPeer *peer); | |||
389 | void | 405 | void |
390 | GCP_try_connect (struct CadetPeer *peer); | 406 | GCP_try_connect (struct CadetPeer *peer); |
391 | 407 | ||
408 | |||
392 | /** | 409 | /** |
393 | * Notify a peer that a link between two other peers is broken. If any path | 410 | * Notify a peer that a link between two other peers is broken. If any path |
394 | * used that link, eliminate it. | 411 | * used that link, eliminate it. |
@@ -402,6 +419,7 @@ GCP_notify_broken_link (struct CadetPeer *peer, | |||
402 | struct GNUNET_PeerIdentity *peer1, | 419 | struct GNUNET_PeerIdentity *peer1, |
403 | struct GNUNET_PeerIdentity *peer2); | 420 | struct GNUNET_PeerIdentity *peer2); |
404 | 421 | ||
422 | |||
405 | /** | 423 | /** |
406 | * Count the number of known paths toward the peer. | 424 | * Count the number of known paths toward the peer. |
407 | * | 425 | * |
@@ -412,6 +430,7 @@ GCP_notify_broken_link (struct CadetPeer *peer, | |||
412 | unsigned int | 430 | unsigned int |
413 | GCP_count_paths (const struct CadetPeer *peer); | 431 | GCP_count_paths (const struct CadetPeer *peer); |
414 | 432 | ||
433 | |||
415 | /** | 434 | /** |
416 | * Iterate all known peers. | 435 | * Iterate all known peers. |
417 | * | 436 | * |
@@ -421,6 +440,7 @@ GCP_count_paths (const struct CadetPeer *peer); | |||
421 | void | 440 | void |
422 | GCP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls); | 441 | GCP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls); |
423 | 442 | ||
443 | |||
424 | /** | 444 | /** |
425 | * Get the static string for a peer ID. | 445 | * Get the static string for a peer ID. |
426 | * | 446 | * |
@@ -431,13 +451,15 @@ GCP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls); | |||
431 | const char * | 451 | const char * |
432 | GCP_2s (const struct CadetPeer *peer); | 452 | GCP_2s (const struct CadetPeer *peer); |
433 | 453 | ||
454 | |||
434 | /** | 455 | /** |
435 | * Log all kinds of info about a peer. | 456 | * Log all kinds of info about a peer. |
436 | * | 457 | * |
437 | * @param peer Peer. | 458 | * @param peer Peer. |
438 | */ | 459 | */ |
439 | void | 460 | void |
440 | GCP_debug (const struct CadetPeer *p, enum GNUNET_ErrorType level); | 461 | GCP_debug (const struct CadetPeer *p, |
462 | enum GNUNET_ErrorType level); | ||
441 | 463 | ||
442 | 464 | ||
443 | #if 0 /* keep Emacsens' auto-indent happy */ | 465 | #if 0 /* keep Emacsens' auto-indent happy */ |