diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-10-05 11:34:32 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-10-05 11:34:32 +0000 |
commit | de7c4d4ac3646953f99807dc21ad17cad1b6ee44 (patch) | |
tree | 488b58a73fe20ef5124056c2f04b2aaca2627575 /src/dht | |
parent | c26fb31c8747566e558715e17e95c3ae45831a22 (diff) | |
download | gnunet-de7c4d4ac3646953f99807dc21ad17cad1b6ee44.tar.gz gnunet-de7c4d4ac3646953f99807dc21ad17cad1b6ee44.zip |
-remove superflous semicolon causing branch to be always taken and significant logic to be omitted; pass pointers to HashCode and PeerIdentities instead of making copies
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/gnunet-service-xdht_neighbours.c | 39 | ||||
-rw-r--r-- | src/dht/gnunet-service-xdht_neighbours.h | 18 | ||||
-rw-r--r-- | src/dht/gnunet-service-xdht_routing.c | 64 |
3 files changed, 62 insertions, 59 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c index d7d2f6c38..812df9a1e 100644 --- a/src/dht/gnunet-service-xdht_neighbours.c +++ b/src/dht/gnunet-service-xdht_neighbours.c | |||
@@ -1398,14 +1398,15 @@ GDS_NEIGHBOURS_send_verify_successor_message (struct GNUNET_PeerIdentity source_ | |||
1398 | * the pointer to friend in routing table rather than gnunet_peeridentity. | 1398 | * the pointer to friend in routing table rather than gnunet_peeridentity. |
1399 | * if yes then we should keep friend info in.h andmake lot of changes. | 1399 | * if yes then we should keep friend info in.h andmake lot of changes. |
1400 | * Construct a trail teardown message and forward it to target friend. | 1400 | * Construct a trail teardown message and forward it to target friend. |
1401 | * | ||
1401 | * @param trail_id Unique identifier of the trail. | 1402 | * @param trail_id Unique identifier of the trail. |
1402 | * @param trail_direction Direction of trail. | 1403 | * @param trail_direction Direction of trail. |
1403 | * @param target_friend Friend to get this message. | 1404 | * @param target_friend Friend to get this message. |
1404 | */ | 1405 | */ |
1405 | void | 1406 | void |
1406 | GDS_NEIGHBOURS_send_trail_teardown (struct GNUNET_HashCode trail_id, | 1407 | GDS_NEIGHBOURS_send_trail_teardown (const struct GNUNET_HashCode *trail_id, |
1407 | unsigned int trail_direction, | 1408 | unsigned int trail_direction, |
1408 | struct GNUNET_PeerIdentity peer) | 1409 | const struct GNUNET_PeerIdentity *peer) |
1409 | { | 1410 | { |
1410 | struct PeerTrailTearDownMessage *ttdm; | 1411 | struct PeerTrailTearDownMessage *ttdm; |
1411 | struct P2PPendingMessage *pending; | 1412 | struct P2PPendingMessage *pending; |
@@ -1413,17 +1414,19 @@ GDS_NEIGHBOURS_send_trail_teardown (struct GNUNET_HashCode trail_id, | |||
1413 | size_t msize; | 1414 | size_t msize; |
1414 | 1415 | ||
1415 | msize = sizeof (struct PeerTrailTearDownMessage); | 1416 | msize = sizeof (struct PeerTrailTearDownMessage); |
1416 | |||
1417 | if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE) | 1417 | if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE) |
1418 | { | 1418 | { |
1419 | GNUNET_break (0); | 1419 | GNUNET_break (0); |
1420 | return; | 1420 | return; |
1421 | } | 1421 | } |
1422 | 1422 | ||
1423 | /*FIXME:In what case friend can be null. ?*/ | ||
1424 | if (NULL == (target_friend = | 1423 | if (NULL == (target_friend = |
1425 | GNUNET_CONTAINER_multipeermap_get (friend_peermap, &peer))); | 1424 | GNUNET_CONTAINER_multipeermap_get (friend_peermap, peer))) |
1426 | return; | 1425 | { |
1426 | /* FIXME: In what case friend can be null. ?*/ | ||
1427 | GNUNET_break (0); | ||
1428 | return; | ||
1429 | } | ||
1427 | 1430 | ||
1428 | if (target_friend->pending_count >= MAXIMUM_PENDING_PER_FRIEND) | 1431 | if (target_friend->pending_count >= MAXIMUM_PENDING_PER_FRIEND) |
1429 | { | 1432 | { |
@@ -1438,7 +1441,7 @@ GDS_NEIGHBOURS_send_trail_teardown (struct GNUNET_HashCode trail_id, | |||
1438 | pending->msg = &ttdm->header; | 1441 | pending->msg = &ttdm->header; |
1439 | ttdm->header.size = htons (msize); | 1442 | ttdm->header.size = htons (msize); |
1440 | ttdm->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_TEARDOWN); | 1443 | ttdm->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_TEARDOWN); |
1441 | ttdm->trail_id = trail_id; | 1444 | ttdm->trail_id = *trail_id; |
1442 | ttdm->trail_direction = htonl (trail_direction); | 1445 | ttdm->trail_direction = htonl (trail_direction); |
1443 | 1446 | ||
1444 | /* Send the message to chosen friend. */ | 1447 | /* Send the message to chosen friend. */ |
@@ -2765,9 +2768,9 @@ select_and_replace_trail (struct FingerInfo *finger, | |||
2765 | { | 2768 | { |
2766 | next_hop = GDS_ROUTING_get_next_hop (new_trail_id, GDS_ROUTING_SRC_TO_DEST); | 2769 | next_hop = GDS_ROUTING_get_next_hop (new_trail_id, GDS_ROUTING_SRC_TO_DEST); |
2767 | GDS_ROUTING_remove_trail (new_trail_id); | 2770 | GDS_ROUTING_remove_trail (new_trail_id); |
2768 | GDS_NEIGHBOURS_send_trail_teardown (new_trail_id, | 2771 | GDS_NEIGHBOURS_send_trail_teardown (&new_trail_id, |
2769 | GDS_ROUTING_SRC_TO_DEST, | 2772 | GDS_ROUTING_SRC_TO_DEST, |
2770 | *next_hop); | 2773 | next_hop); |
2771 | return; | 2774 | return; |
2772 | } | 2775 | } |
2773 | 2776 | ||
@@ -2775,9 +2778,9 @@ select_and_replace_trail (struct FingerInfo *finger, | |||
2775 | struct Trail *replace_trail = &finger->trail_list[largest_trail_index]; | 2778 | struct Trail *replace_trail = &finger->trail_list[largest_trail_index]; |
2776 | next_hop = GDS_ROUTING_get_next_hop (replace_trail->trail_id, GDS_ROUTING_SRC_TO_DEST); | 2779 | next_hop = GDS_ROUTING_get_next_hop (replace_trail->trail_id, GDS_ROUTING_SRC_TO_DEST); |
2777 | GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (replace_trail->trail_id)); | 2780 | GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (replace_trail->trail_id)); |
2778 | GDS_NEIGHBOURS_send_trail_teardown (replace_trail->trail_id, | 2781 | GDS_NEIGHBOURS_send_trail_teardown (&replace_trail->trail_id, |
2779 | GDS_ROUTING_SRC_TO_DEST, | 2782 | GDS_ROUTING_SRC_TO_DEST, |
2780 | *next_hop); | 2783 | next_hop); |
2781 | 2784 | ||
2782 | /* Free the trail. */ | 2785 | /* Free the trail. */ |
2783 | while (NULL != (trail_element = replace_trail->trail_head)) | 2786 | while (NULL != (trail_element = replace_trail->trail_head)) |
@@ -3042,9 +3045,9 @@ send_trail_teardown (struct FingerInfo *finger, | |||
3042 | } | 3045 | } |
3043 | GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail->trail_id)); | 3046 | GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail->trail_id)); |
3044 | friend->trails_count--; | 3047 | friend->trails_count--; |
3045 | GDS_NEIGHBOURS_send_trail_teardown (trail->trail_id, | 3048 | GDS_NEIGHBOURS_send_trail_teardown (&trail->trail_id, |
3046 | GDS_ROUTING_SRC_TO_DEST, | 3049 | GDS_ROUTING_SRC_TO_DEST, |
3047 | friend->id); | 3050 | &friend->id); |
3048 | } | 3051 | } |
3049 | 3052 | ||
3050 | 3053 | ||
@@ -3597,13 +3600,13 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity, | |||
3597 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&finger_identity, &my_identity)) | 3600 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&finger_identity, &my_identity)) |
3598 | { | 3601 | { |
3599 | if (finger_trail_length > 0) | 3602 | if (finger_trail_length > 0) |
3600 | GDS_NEIGHBOURS_send_trail_teardown (finger_trail_id, | 3603 | GDS_NEIGHBOURS_send_trail_teardown (&finger_trail_id, |
3601 | GDS_ROUTING_SRC_TO_DEST, | 3604 | GDS_ROUTING_SRC_TO_DEST, |
3602 | finger_trail[0]); | 3605 | &finger_trail[0]); |
3603 | else | 3606 | else |
3604 | GDS_NEIGHBOURS_send_trail_teardown (finger_trail_id, | 3607 | GDS_NEIGHBOURS_send_trail_teardown (&finger_trail_id, |
3605 | GDS_ROUTING_SRC_TO_DEST, | 3608 | GDS_ROUTING_SRC_TO_DEST, |
3606 | finger_identity); | 3609 | &finger_identity); |
3607 | } | 3610 | } |
3608 | } | 3611 | } |
3609 | } | 3612 | } |
@@ -5786,7 +5789,7 @@ handle_dht_p2p_trail_teardown (void *cls, const struct GNUNET_PeerIdentity *peer | |||
5786 | /* If not final destination, then send a trail teardown message to next hop.*/ | 5789 | /* If not final destination, then send a trail teardown message to next hop.*/ |
5787 | GNUNET_assert (NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop)); | 5790 | GNUNET_assert (NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop)); |
5788 | GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail_id)); | 5791 | GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail_id)); |
5789 | GDS_NEIGHBOURS_send_trail_teardown (trail_id, trail_direction, *next_hop); | 5792 | GDS_NEIGHBOURS_send_trail_teardown (&trail_id, trail_direction, next_hop); |
5790 | } | 5793 | } |
5791 | 5794 | ||
5792 | return GNUNET_OK; | 5795 | return GNUNET_OK; |
diff --git a/src/dht/gnunet-service-xdht_neighbours.h b/src/dht/gnunet-service-xdht_neighbours.h index 66295702d..801712d52 100644 --- a/src/dht/gnunet-service-xdht_neighbours.h +++ b/src/dht/gnunet-service-xdht_neighbours.h | |||
@@ -42,7 +42,7 @@ GDS_NEIGHBOURS_act_malicious (unsigned int malicious); | |||
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Handle the put request from the client. | 45 | * Handle the put request from the client. |
46 | * @param key Key for the content | 46 | * @param key Key for the content |
47 | * @param block_type Type of the block | 47 | * @param block_type Type of the block |
48 | * @param options Routing options | 48 | * @param options Routing options |
@@ -60,15 +60,15 @@ GDS_NEIGHBOURS_handle_put (const struct GNUNET_HashCode *key, | |||
60 | const void *data, size_t data_size); | 60 | const void *data, size_t data_size); |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * Handle the get request from the client file. If I am destination do | 63 | * Handle the get request from the client file. If I am destination do |
64 | * datacache put and return. Else find the target friend and forward message | 64 | * datacache put and return. Else find the target friend and forward message |
65 | * to it. | 65 | * to it. |
66 | * @param key Key for the content | 66 | * @param key Key for the content |
67 | * @param block_type Type of the block | 67 | * @param block_type Type of the block |
68 | * @param options Routing options | 68 | * @param options Routing options |
69 | * @param desired_replication_level Desired replication count | 69 | * @param desired_replication_level Desired replication count |
70 | */ | 70 | */ |
71 | void | 71 | void |
72 | GDS_NEIGHBOURS_handle_get(const struct GNUNET_HashCode *key, | 72 | GDS_NEIGHBOURS_handle_get(const struct GNUNET_HashCode *key, |
73 | enum GNUNET_BLOCK_Type block_type, | 73 | enum GNUNET_BLOCK_Type block_type, |
74 | enum GNUNET_DHT_RouteOption options, | 74 | enum GNUNET_DHT_RouteOption options, |
@@ -101,15 +101,15 @@ GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key, | |||
101 | const void *data, size_t data_size); | 101 | const void *data, size_t data_size); |
102 | 102 | ||
103 | /** | 103 | /** |
104 | * Construct a trail teardown message and forward it to target friend. | 104 | * Construct a trail teardown message and forward it to target friend. |
105 | * @param trail_id Unique identifier of the trail. | 105 | * @param trail_id Unique identifier of the trail. |
106 | * @param trail_direction Direction of trail. | 106 | * @param trail_direction Direction of trail. |
107 | * @param target_friend Friend to get this message. | 107 | * @param target_friend Friend to get this message. |
108 | */ | 108 | */ |
109 | void | 109 | void |
110 | GDS_NEIGHBOURS_send_trail_teardown (struct GNUNET_HashCode trail_id, | 110 | GDS_NEIGHBOURS_send_trail_teardown (const struct GNUNET_HashCode *trail_id, |
111 | unsigned int trail_direction, | 111 | unsigned int trail_direction, |
112 | struct GNUNET_PeerIdentity peer); | 112 | const struct GNUNET_PeerIdentity *peer); |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Return friend corresponding to peer. | 115 | * Return friend corresponding to peer. |
@@ -121,7 +121,7 @@ GDS_NEIGHBOURS_get_friend (struct GNUNET_PeerIdentity peer); | |||
121 | /** | 121 | /** |
122 | * Initialize neighbours subsystem. | 122 | * Initialize neighbours subsystem. |
123 | * | 123 | * |
124 | * @return #GNUNET_OK on success, | 124 | * @return #GNUNET_OK on success, |
125 | * #GNUNET_SYSERR on error | 125 | * #GNUNET_SYSERR on error |
126 | */ | 126 | */ |
127 | int | 127 | int |
@@ -140,7 +140,7 @@ GDS_NEIGHBOURS_done (void); | |||
140 | * | 140 | * |
141 | * @return my identity | 141 | * @return my identity |
142 | */ | 142 | */ |
143 | struct GNUNET_PeerIdentity | 143 | struct GNUNET_PeerIdentity |
144 | GDS_NEIGHBOURS_get_my_id (void); | 144 | GDS_NEIGHBOURS_get_my_id (void); |
145 | 145 | ||
146 | #endif | 146 | #endif |
diff --git a/src/dht/gnunet-service-xdht_routing.c b/src/dht/gnunet-service-xdht_routing.c index e03dfa13b..183349242 100644 --- a/src/dht/gnunet-service-xdht_routing.c +++ b/src/dht/gnunet-service-xdht_routing.c | |||
@@ -31,7 +31,7 @@ | |||
31 | 31 | ||
32 | /** | 32 | /** |
33 | * FIXME: Check if its better to store pointer to friend rather than storing | 33 | * FIXME: Check if its better to store pointer to friend rather than storing |
34 | * peer identity next_hop or prev_hop. | 34 | * peer identity next_hop or prev_hop. |
35 | * keep entries in destnation and source peer also. so when we send the trail | 35 | * keep entries in destnation and source peer also. so when we send the trail |
36 | * teardown message then we don't know the source but if source gets the message | 36 | * teardown message then we don't know the source but if source gets the message |
37 | * then it shold remove that trail id from its finger table. But how does | 37 | * then it shold remove that trail id from its finger table. But how does |
@@ -39,8 +39,8 @@ | |||
39 | * will do a lookup in routing table and if no trail id present the remove | 39 | * will do a lookup in routing table and if no trail id present the remove |
40 | * that trail of the finger and if only one trail then remove the finger. | 40 | * that trail of the finger and if only one trail then remove the finger. |
41 | * because of this use case of trail teardown I think trail compression | 41 | * because of this use case of trail teardown I think trail compression |
42 | * and trail teardown should not be merged. | 42 | * and trail teardown should not be merged. |
43 | * 2. store a pointer to friendInfo in place o peer identity. | 43 | * 2. store a pointer to friendInfo in place o peer identity. |
44 | */ | 44 | */ |
45 | /** | 45 | /** |
46 | * Maximum number of entries in routing table. | 46 | * Maximum number of entries in routing table. |
@@ -48,7 +48,7 @@ | |||
48 | #define ROUTING_TABLE_THRESHOLD 80000 | 48 | #define ROUTING_TABLE_THRESHOLD 80000 |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * FIXME: Store friend pointer instead of peer identifier. | 51 | * FIXME: Store friend pointer instead of peer identifier. |
52 | * Routing table entry . | 52 | * Routing table entry . |
53 | */ | 53 | */ |
54 | struct RoutingTrail | 54 | struct RoutingTrail |
@@ -61,12 +61,12 @@ struct RoutingTrail | |||
61 | /** | 61 | /** |
62 | * The peer to which this request should be passed to. | 62 | * The peer to which this request should be passed to. |
63 | */ | 63 | */ |
64 | struct GNUNET_PeerIdentity next_hop; | 64 | struct GNUNET_PeerIdentity next_hop; |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * Peer just before next hop in the trail. | 67 | * Peer just before next hop in the trail. |
68 | */ | 68 | */ |
69 | struct GNUNET_PeerIdentity prev_hop; | 69 | struct GNUNET_PeerIdentity prev_hop; |
70 | }; | 70 | }; |
71 | 71 | ||
72 | /** | 72 | /** |
@@ -100,7 +100,7 @@ GDS_ROUTING_update_trail_prev_hop (const struct GNUNET_HashCode trail_id, | |||
100 | /** | 100 | /** |
101 | * Update the next hop of the trail. Call made by trail compression where | 101 | * Update the next hop of the trail. Call made by trail compression where |
102 | * if you are source of the trail and now you have a new first friend, then | 102 | * if you are source of the trail and now you have a new first friend, then |
103 | * you should update the trail. | 103 | * you should update the trail. |
104 | * @param trail_id | 104 | * @param trail_id |
105 | * @return #GNUNET_OK success | 105 | * @return #GNUNET_OK success |
106 | * #GNUNET_SYSERR in case no matching entry found in routing table. | 106 | * #GNUNET_SYSERR in case no matching entry found in routing table. |
@@ -114,7 +114,7 @@ GDS_ROUTING_update_trail_next_hop (const struct GNUNET_HashCode trail_id, | |||
114 | trail = GNUNET_CONTAINER_multihashmap_get (routing_table, &trail_id); | 114 | trail = GNUNET_CONTAINER_multihashmap_get (routing_table, &trail_id); |
115 | 115 | ||
116 | if (NULL == trail) | 116 | if (NULL == trail) |
117 | 117 | ||
118 | return GNUNET_SYSERR; | 118 | return GNUNET_SYSERR; |
119 | 119 | ||
120 | trail->next_hop = next_hop; | 120 | trail->next_hop = next_hop; |
@@ -167,7 +167,7 @@ GDS_ROUTING_remove_trail (const struct GNUNET_HashCode remove_trail_id) | |||
167 | remove_entry = GNUNET_CONTAINER_multihashmap_get (routing_table, &remove_trail_id); | 167 | remove_entry = GNUNET_CONTAINER_multihashmap_get (routing_table, &remove_trail_id); |
168 | if (NULL == remove_entry) | 168 | if (NULL == remove_entry) |
169 | return GNUNET_NO; | 169 | return GNUNET_NO; |
170 | 170 | ||
171 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (routing_table, | 171 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (routing_table, |
172 | &remove_trail_id, | 172 | &remove_trail_id, |
173 | remove_entry)) | 173 | remove_entry)) |
@@ -175,14 +175,14 @@ GDS_ROUTING_remove_trail (const struct GNUNET_HashCode remove_trail_id) | |||
175 | GNUNET_free (remove_entry); | 175 | GNUNET_free (remove_entry); |
176 | return GNUNET_YES; | 176 | return GNUNET_YES; |
177 | } | 177 | } |
178 | 178 | ||
179 | return GNUNET_NO; | 179 | return GNUNET_NO; |
180 | } | 180 | } |
181 | 181 | ||
182 | 182 | ||
183 | /** | 183 | /** |
184 | * Iterate over routing table and remove entries with value as part of any trail. | 184 | * Iterate over routing table and remove entries with value as part of any trail. |
185 | * | 185 | * |
186 | * @param cls closure | 186 | * @param cls closure |
187 | * @param key current public key | 187 | * @param key current public key |
188 | * @param value value in the hash map | 188 | * @param value value in the hash map |
@@ -197,35 +197,35 @@ static int remove_matching_trails (void *cls, | |||
197 | struct GNUNET_PeerIdentity *disconnected_peer = cls; | 197 | struct GNUNET_PeerIdentity *disconnected_peer = cls; |
198 | struct GNUNET_HashCode trail_id = *key; | 198 | struct GNUNET_HashCode trail_id = *key; |
199 | struct GNUNET_PeerIdentity my_identity; | 199 | struct GNUNET_PeerIdentity my_identity; |
200 | 200 | ||
201 | /* If disconnected_peer is next_hop, then send a trail teardown message through | 201 | /* If disconnected_peer is next_hop, then send a trail teardown message through |
202 | * prev_hop in direction from destination to source. */ | 202 | * prev_hop in direction from destination to source. */ |
203 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&remove_trail->next_hop, | 203 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&remove_trail->next_hop, |
204 | disconnected_peer)) | 204 | disconnected_peer)) |
205 | { | 205 | { |
206 | my_identity = GDS_NEIGHBOURS_get_my_id (); | 206 | my_identity = GDS_NEIGHBOURS_get_my_id (); |
207 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, | 207 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, |
208 | &remove_trail->prev_hop)) | 208 | &remove_trail->prev_hop)) |
209 | { | 209 | { |
210 | GDS_NEIGHBOURS_send_trail_teardown (trail_id, | 210 | GDS_NEIGHBOURS_send_trail_teardown (&trail_id, |
211 | GDS_ROUTING_DEST_TO_SRC, | 211 | GDS_ROUTING_DEST_TO_SRC, |
212 | remove_trail->prev_hop); | 212 | &remove_trail->prev_hop); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | /* If disconnected_peer is prev_hop, then send a trail teardown through | 216 | /* If disconnected_peer is prev_hop, then send a trail teardown through |
217 | * next_hop in direction from Source to Destination. */ | 217 | * next_hop in direction from Source to Destination. */ |
218 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&remove_trail->prev_hop, | 218 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&remove_trail->prev_hop, |
219 | disconnected_peer)) | 219 | disconnected_peer)) |
220 | { | 220 | { |
221 | my_identity = GDS_NEIGHBOURS_get_my_id (); | 221 | my_identity = GDS_NEIGHBOURS_get_my_id (); |
222 | 222 | ||
223 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, | 223 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, |
224 | &remove_trail->next_hop)) | 224 | &remove_trail->next_hop)) |
225 | { | 225 | { |
226 | GDS_NEIGHBOURS_send_trail_teardown (trail_id, | 226 | GDS_NEIGHBOURS_send_trail_teardown (&trail_id, |
227 | GDS_ROUTING_SRC_TO_DEST, | 227 | GDS_ROUTING_SRC_TO_DEST, |
228 | remove_trail->next_hop); | 228 | &remove_trail->next_hop); |
229 | } | 229 | } |
230 | } | 230 | } |
231 | 231 | ||
@@ -240,9 +240,9 @@ static int remove_matching_trails (void *cls, | |||
240 | #if 0 | 240 | #if 0 |
241 | /** | 241 | /** |
242 | * TEST FUNCTION | 242 | * TEST FUNCTION |
243 | * Remove after using. | 243 | * Remove after using. |
244 | */ | 244 | */ |
245 | void | 245 | void |
246 | GDS_ROUTING_test_print (void) | 246 | GDS_ROUTING_test_print (void) |
247 | { | 247 | { |
248 | struct GNUNET_CONTAINER_MultiHashMapIterator *iter; | 248 | struct GNUNET_CONTAINER_MultiHashMapIterator *iter; |
@@ -250,7 +250,7 @@ GDS_ROUTING_test_print (void) | |||
250 | struct GNUNET_PeerIdentity print_peer; | 250 | struct GNUNET_PeerIdentity print_peer; |
251 | struct GNUNET_HashCode key_ret; | 251 | struct GNUNET_HashCode key_ret; |
252 | int i; | 252 | int i; |
253 | 253 | ||
254 | struct GNUNET_PeerIdentity my_identity = GDS_NEIGHBOURS_get_my_id(); | 254 | struct GNUNET_PeerIdentity my_identity = GDS_NEIGHBOURS_get_my_id(); |
255 | print_peer = my_identity; | 255 | print_peer = my_identity; |
256 | FPRINTF (stderr,_("\nSUPU ***PRINTING ROUTING TABLE ***** of =%s"),GNUNET_i2s(&print_peer)); | 256 | FPRINTF (stderr,_("\nSUPU ***PRINTING ROUTING TABLE ***** of =%s"),GNUNET_i2s(&print_peer)); |
@@ -275,7 +275,7 @@ GDS_ROUTING_test_print (void) | |||
275 | #endif | 275 | #endif |
276 | 276 | ||
277 | /** | 277 | /** |
278 | * Remove every trail where peer is either next_hop or prev_hop. Also send a | 278 | * Remove every trail where peer is either next_hop or prev_hop. Also send a |
279 | * trail teardown message in direction of hop which is not disconnected. | 279 | * trail teardown message in direction of hop which is not disconnected. |
280 | * @param peer Peer identity. Trail containing this peer should be removed. | 280 | * @param peer Peer identity. Trail containing this peer should be removed. |
281 | */ | 281 | */ |
@@ -283,12 +283,12 @@ int | |||
283 | GDS_ROUTING_remove_trail_by_peer (const struct GNUNET_PeerIdentity *peer) | 283 | GDS_ROUTING_remove_trail_by_peer (const struct GNUNET_PeerIdentity *peer) |
284 | { | 284 | { |
285 | int ret; | 285 | int ret; |
286 | 286 | ||
287 | 287 | ||
288 | /* No entries in my routing table. */ | 288 | /* No entries in my routing table. */ |
289 | if (0 == GNUNET_CONTAINER_multihashmap_size(routing_table)) | 289 | if (0 == GNUNET_CONTAINER_multihashmap_size(routing_table)) |
290 | return GNUNET_YES; | 290 | return GNUNET_YES; |
291 | 291 | ||
292 | ret = GNUNET_CONTAINER_multihashmap_iterate (routing_table, | 292 | ret = GNUNET_CONTAINER_multihashmap_iterate (routing_table, |
293 | &remove_matching_trails, | 293 | &remove_matching_trails, |
294 | (void *)peer); | 294 | (void *)peer); |
@@ -311,13 +311,13 @@ GDS_ROUTING_add (struct GNUNET_HashCode new_trail_id, | |||
311 | struct GNUNET_PeerIdentity next_hop) | 311 | struct GNUNET_PeerIdentity next_hop) |
312 | { | 312 | { |
313 | struct RoutingTrail *new_entry; | 313 | struct RoutingTrail *new_entry; |
314 | 314 | ||
315 | new_entry = GNUNET_new (struct RoutingTrail); | 315 | new_entry = GNUNET_new (struct RoutingTrail); |
316 | new_entry->trail_id = new_trail_id; | 316 | new_entry->trail_id = new_trail_id; |
317 | new_entry->next_hop = next_hop; | 317 | new_entry->next_hop = next_hop; |
318 | new_entry->prev_hop = prev_hop; | 318 | new_entry->prev_hop = prev_hop; |
319 | 319 | ||
320 | 320 | ||
321 | return GNUNET_CONTAINER_multihashmap_put (routing_table, | 321 | return GNUNET_CONTAINER_multihashmap_put (routing_table, |
322 | &new_trail_id, new_entry, | 322 | &new_trail_id, new_entry, |
323 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 323 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |