diff options
author | Supriti Singh <supritisingh08@gmail.com> | 2014-06-23 13:30:07 +0000 |
---|---|---|
committer | Supriti Singh <supritisingh08@gmail.com> | 2014-06-23 13:30:07 +0000 |
commit | 310b25e5a713d547aea2f34c76e7b3e35ded1ea5 (patch) | |
tree | 5d0bcc92b665f97dec9bbc8f8cb0c1e31718c6dc /src | |
parent | 2ff52dabfadd9390d0751f9f9bdf463d76a80ec5 (diff) | |
download | gnunet-310b25e5a713d547aea2f34c76e7b3e35ded1ea5.tar.gz gnunet-310b25e5a713d547aea2f34c76e7b3e35ded1ea5.zip |
-- New message type, GNUNET_MESSAGE_TYPE_XDHT_P2P_PUT and GNUNET_MESSAGE_TYPE_XDHT_P2P_GET
-- Changing name of all the messages of X-Vine by appending X in front of DHT.
-- Not sending trail teardown in case next_hop or prev_hop is me (remove routing trail due to disconnected peer)
Diffstat (limited to 'src')
-rw-r--r-- | src/dht/gnunet-service-xdht_datacache.c | 1 | ||||
-rw-r--r-- | src/dht/gnunet-service-xdht_neighbours.c | 101 | ||||
-rw-r--r-- | src/dht/gnunet-service-xdht_routing.c | 32 | ||||
-rw-r--r-- | src/include/gnunet_protocols.h | 34 |
4 files changed, 100 insertions, 68 deletions
diff --git a/src/dht/gnunet-service-xdht_datacache.c b/src/dht/gnunet-service-xdht_datacache.c index fe27eec5e..ab1dedeab 100644 --- a/src/dht/gnunet-service-xdht_datacache.c +++ b/src/dht/gnunet-service-xdht_datacache.c | |||
@@ -311,7 +311,6 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode * key, | |||
311 | if (next_hop != NULL) | 311 | if (next_hop != NULL) |
312 | { | 312 | { |
313 | memcpy (&(ctx.next_hop), next_hop, sizeof (struct GNUNET_PeerIdentity)); | 313 | memcpy (&(ctx.next_hop), next_hop, sizeof (struct GNUNET_PeerIdentity)); |
314 | GNUNET_free (next_hop); | ||
315 | } | 314 | } |
316 | unsigned int i = 0; | 315 | unsigned int i = 0; |
317 | ctx.head = NULL; | 316 | ctx.head = NULL; |
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c index f4ecbab38..7ce0473cf 100644 --- a/src/dht/gnunet-service-xdht_neighbours.c +++ b/src/dht/gnunet-service-xdht_neighbours.c | |||
@@ -75,6 +75,13 @@ | |||
75 | * where a peer changes the value as we handle that case everywhere. s | 75 | * where a peer changes the value as we handle that case everywhere. s |
76 | */ | 76 | */ |
77 | /** | 77 | /** |
78 | 1. friend trails count in case it is finger, routing table trail | ||
79 | 2. select_closest_peer in compare and update predecessor and successor, | ||
80 | update_predecessor. | ||
81 | */ | ||
82 | |||
83 | |||
84 | /** | ||
78 | * Maximum possible fingers (including predecessor) of a peer | 85 | * Maximum possible fingers (including predecessor) of a peer |
79 | */ | 86 | */ |
80 | #define MAX_FINGERS 65 | 87 | #define MAX_FINGERS 65 |
@@ -139,7 +146,7 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
139 | struct PeerPutMessage | 146 | struct PeerPutMessage |
140 | { | 147 | { |
141 | /** | 148 | /** |
142 | * Type: #GNUNET_MESSAGE_TYPE_DHT_P2P_PUT | 149 | * Type: #GNUNET_MESSAGE_TYPE_XDHT_P2P_PUT |
143 | */ | 150 | */ |
144 | struct GNUNET_MessageHeader header; | 151 | struct GNUNET_MessageHeader header; |
145 | 152 | ||
@@ -203,7 +210,7 @@ struct PeerPutMessage | |||
203 | struct PeerGetMessage | 210 | struct PeerGetMessage |
204 | { | 211 | { |
205 | /** | 212 | /** |
206 | * Type: #GNUNET_MESSAGE_TYPE_DHT_P2P_GET | 213 | * Type: #GNUNET_MESSAGE_TYPE_XDHT_P2P_GET |
207 | */ | 214 | */ |
208 | struct GNUNET_MessageHeader header; | 215 | struct GNUNET_MessageHeader header; |
209 | 216 | ||
@@ -260,7 +267,7 @@ struct PeerGetMessage | |||
260 | struct PeerGetResultMessage | 267 | struct PeerGetResultMessage |
261 | { | 268 | { |
262 | /** | 269 | /** |
263 | * Type: #GNUNET_MESSAGE_TYPE_DHT_P2P_GET_RESULT | 270 | * Type: #GNUNET_MESSAGE_TYPE_XDHT_P2P_GET_RESULT |
264 | */ | 271 | */ |
265 | struct GNUNET_MessageHeader header; | 272 | struct GNUNET_MessageHeader header; |
266 | 273 | ||
@@ -309,7 +316,7 @@ struct PeerGetResultMessage | |||
309 | struct PeerTrailSetupMessage | 316 | struct PeerTrailSetupMessage |
310 | { | 317 | { |
311 | /** | 318 | /** |
312 | * Type: #GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP | 319 | * Type: #GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP |
313 | */ | 320 | */ |
314 | struct GNUNET_MessageHeader header; | 321 | struct GNUNET_MessageHeader header; |
315 | 322 | ||
@@ -359,7 +366,7 @@ struct PeerTrailSetupResultMessage | |||
359 | { | 366 | { |
360 | 367 | ||
361 | /** | 368 | /** |
362 | * Type: #GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP_RESULT | 369 | * Type: #GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP_RESULT |
363 | */ | 370 | */ |
364 | struct GNUNET_MessageHeader header; | 371 | struct GNUNET_MessageHeader header; |
365 | 372 | ||
@@ -401,7 +408,7 @@ struct PeerTrailSetupResultMessage | |||
401 | struct PeerVerifySuccessorMessage | 408 | struct PeerVerifySuccessorMessage |
402 | { | 409 | { |
403 | /** | 410 | /** |
404 | * Type: #GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR | 411 | * Type: #GNUNET_MESSAGE_TYPE_XDHT_P2P_VERIFY_SUCCESSOR |
405 | */ | 412 | */ |
406 | struct GNUNET_MessageHeader header; | 413 | struct GNUNET_MessageHeader header; |
407 | 414 | ||
@@ -432,7 +439,7 @@ struct PeerVerifySuccessorMessage | |||
432 | struct PeerVerifySuccessorResultMessage | 439 | struct PeerVerifySuccessorResultMessage |
433 | { | 440 | { |
434 | /** | 441 | /** |
435 | * Type: #GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR_RESULT | 442 | * Type: #GNUNET_MESSAGE_TYPE_XDHT_P2P_VERIFY_SUCCESSOR_RESULT |
436 | */ | 443 | */ |
437 | struct GNUNET_MessageHeader header; | 444 | struct GNUNET_MessageHeader header; |
438 | 445 | ||
@@ -475,7 +482,7 @@ struct PeerVerifySuccessorResultMessage | |||
475 | struct PeerNotifyNewSuccessorMessage | 482 | struct PeerNotifyNewSuccessorMessage |
476 | { | 483 | { |
477 | /** | 484 | /** |
478 | * Type: #GNUNET_MESSAGE_TYPE_DHT_P2P_NOTIFY_NEW_SUCCESSOR | 485 | * Type: #GNUNET_MESSAGE_TYPE_XDHT_P2P_NOTIFY_NEW_SUCCESSOR |
479 | */ | 486 | */ |
480 | struct GNUNET_MessageHeader header; | 487 | struct GNUNET_MessageHeader header; |
481 | 488 | ||
@@ -507,7 +514,7 @@ struct PeerNotifyNewSuccessorMessage | |||
507 | struct PeerTrailCompressionMessage | 514 | struct PeerTrailCompressionMessage |
508 | { | 515 | { |
509 | /** | 516 | /** |
510 | * Type: #GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_COMPRESSION | 517 | * Type: #GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_COMPRESSION |
511 | */ | 518 | */ |
512 | struct GNUNET_MessageHeader header; | 519 | struct GNUNET_MessageHeader header; |
513 | 520 | ||
@@ -536,7 +543,7 @@ struct PeerTrailCompressionMessage | |||
536 | struct PeerTrailTearDownMessage | 543 | struct PeerTrailTearDownMessage |
537 | { | 544 | { |
538 | /** | 545 | /** |
539 | * Type: #GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_TEARDOWN | 546 | * Type: #GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_TEARDOWN |
540 | */ | 547 | */ |
541 | struct GNUNET_MessageHeader header; | 548 | struct GNUNET_MessageHeader header; |
542 | 549 | ||
@@ -558,7 +565,7 @@ struct PeerTrailTearDownMessage | |||
558 | struct PeerTrailRejectionMessage | 565 | struct PeerTrailRejectionMessage |
559 | { | 566 | { |
560 | /** | 567 | /** |
561 | * Type: #GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP_REJECTION | 568 | * Type: #GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP_REJECTION |
562 | */ | 569 | */ |
563 | struct GNUNET_MessageHeader header; | 570 | struct GNUNET_MessageHeader header; |
564 | 571 | ||
@@ -604,7 +611,7 @@ struct PeerTrailRejectionMessage | |||
604 | struct PeerAddTrailMessage | 611 | struct PeerAddTrailMessage |
605 | { | 612 | { |
606 | /** | 613 | /** |
607 | * Type: #GNUNET_MESSAGE_TYPE_DHT_P2P_ADD_TRAIL | 614 | * Type: #GNUNET_MESSAGE_TYPE_XDHT_P2P_ADD_TRAIL |
608 | */ | 615 | */ |
609 | struct GNUNET_MessageHeader header; | 616 | struct GNUNET_MessageHeader header; |
610 | 617 | ||
@@ -1056,7 +1063,7 @@ GDS_NEIGHBOURS_send_trail_setup (struct GNUNET_PeerIdentity source_peer, | |||
1056 | tsm = (struct PeerTrailSetupMessage *) &pending[1]; | 1063 | tsm = (struct PeerTrailSetupMessage *) &pending[1]; |
1057 | pending->msg = &tsm->header; | 1064 | pending->msg = &tsm->header; |
1058 | tsm->header.size = htons (msize); | 1065 | tsm->header.size = htons (msize); |
1059 | tsm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP); | 1066 | tsm->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP); |
1060 | tsm->final_destination_finger_value = GNUNET_htonll (ultimate_destination_finger_value); | 1067 | tsm->final_destination_finger_value = GNUNET_htonll (ultimate_destination_finger_value); |
1061 | tsm->source_peer = source_peer; | 1068 | tsm->source_peer = source_peer; |
1062 | tsm->best_known_destination = best_known_destination; | 1069 | tsm->best_known_destination = best_known_destination; |
@@ -1130,7 +1137,7 @@ GDS_NEIGHBOURS_send_trail_setup_result (struct GNUNET_PeerIdentity querying_peer | |||
1130 | tsrm = (struct PeerTrailSetupResultMessage *) &pending[1]; | 1137 | tsrm = (struct PeerTrailSetupResultMessage *) &pending[1]; |
1131 | pending->msg = &tsrm->header; | 1138 | pending->msg = &tsrm->header; |
1132 | tsrm->header.size = htons (msize); | 1139 | tsrm->header.size = htons (msize); |
1133 | tsrm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP_RESULT); | 1140 | tsrm->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP_RESULT); |
1134 | tsrm->querying_peer = querying_peer; | 1141 | tsrm->querying_peer = querying_peer; |
1135 | tsrm->finger_identity = finger; | 1142 | tsrm->finger_identity = finger; |
1136 | tsrm->is_predecessor = htonl (is_predecessor); | 1143 | tsrm->is_predecessor = htonl (is_predecessor); |
@@ -1201,7 +1208,7 @@ GDS_NEIGHBOURS_send_trail_rejection (struct GNUNET_PeerIdentity source_peer, | |||
1201 | trm = (struct PeerTrailRejectionMessage *)&pending[1]; | 1208 | trm = (struct PeerTrailRejectionMessage *)&pending[1]; |
1202 | pending->msg = &trm->header; | 1209 | pending->msg = &trm->header; |
1203 | trm->header.size = htons (msize); | 1210 | trm->header.size = htons (msize); |
1204 | trm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP_REJECTION); | 1211 | trm->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP_REJECTION); |
1205 | trm->source_peer = source_peer; | 1212 | trm->source_peer = source_peer; |
1206 | trm->congested_peer = congested_peer; | 1213 | trm->congested_peer = congested_peer; |
1207 | trm->congestion_time = congestion_timeout; | 1214 | trm->congestion_time = congestion_timeout; |
@@ -1265,7 +1272,7 @@ GDS_NEIGHBOURS_send_verify_successor_message (struct GNUNET_PeerIdentity source_ | |||
1265 | vsm = (struct PeerVerifySuccessorMessage *) &pending[1]; | 1272 | vsm = (struct PeerVerifySuccessorMessage *) &pending[1]; |
1266 | pending->msg = &vsm->header; | 1273 | pending->msg = &vsm->header; |
1267 | vsm->header.size = htons (msize); | 1274 | vsm->header.size = htons (msize); |
1268 | vsm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR); | 1275 | vsm->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_VERIFY_SUCCESSOR); |
1269 | vsm->source_peer = source_peer; | 1276 | vsm->source_peer = source_peer; |
1270 | vsm->successor = successor; | 1277 | vsm->successor = successor; |
1271 | vsm->trail_id = trail_id; | 1278 | vsm->trail_id = trail_id; |
@@ -1326,7 +1333,7 @@ GDS_NEIGHBOURS_send_trail_teardown (struct GNUNET_HashCode trail_id, | |||
1326 | ttdm = (struct PeerTrailTearDownMessage *) &pending[1]; | 1333 | ttdm = (struct PeerTrailTearDownMessage *) &pending[1]; |
1327 | pending->msg = &ttdm->header; | 1334 | pending->msg = &ttdm->header; |
1328 | ttdm->header.size = htons (msize); | 1335 | ttdm->header.size = htons (msize); |
1329 | ttdm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_TEARDOWN); | 1336 | ttdm->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_TEARDOWN); |
1330 | ttdm->trail_id = trail_id; | 1337 | ttdm->trail_id = trail_id; |
1331 | ttdm->trail_direction = htonl (trail_direction); | 1338 | ttdm->trail_direction = htonl (trail_direction); |
1332 | 1339 | ||
@@ -1389,7 +1396,7 @@ GDS_NEIGHBOURS_send_verify_successor_result (struct GNUNET_PeerIdentity querying | |||
1389 | vsmr = (struct PeerVerifySuccessorResultMessage *) &pending[1]; | 1396 | vsmr = (struct PeerVerifySuccessorResultMessage *) &pending[1]; |
1390 | pending->msg = &vsmr->header; | 1397 | pending->msg = &vsmr->header; |
1391 | vsmr->header.size = htons (msize); | 1398 | vsmr->header.size = htons (msize); |
1392 | vsmr->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR_RESULT); | 1399 | vsmr->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_VERIFY_SUCCESSOR_RESULT); |
1393 | vsmr->querying_peer = querying_peer; | 1400 | vsmr->querying_peer = querying_peer; |
1394 | vsmr->current_successor = current_successor; | 1401 | vsmr->current_successor = current_successor; |
1395 | vsmr->probable_successor = probable_successor; | 1402 | vsmr->probable_successor = probable_successor; |
@@ -1455,7 +1462,7 @@ GDS_NEIGHBOURS_send_notify_new_successor (struct GNUNET_PeerIdentity source_peer | |||
1455 | nsm = (struct PeerNotifyNewSuccessorMessage *) &pending[1]; | 1462 | nsm = (struct PeerNotifyNewSuccessorMessage *) &pending[1]; |
1456 | pending->msg = &nsm->header; | 1463 | pending->msg = &nsm->header; |
1457 | nsm->header.size = htons (msize); | 1464 | nsm->header.size = htons (msize); |
1458 | nsm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_NOTIFY_NEW_SUCCESSOR); | 1465 | nsm->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_NOTIFY_NEW_SUCCESSOR); |
1459 | nsm->new_successor = successor; | 1466 | nsm->new_successor = successor; |
1460 | nsm->source_peer = source_peer; | 1467 | nsm->source_peer = source_peer; |
1461 | nsm->trail_id = succesor_trail_id; | 1468 | nsm->trail_id = succesor_trail_id; |
@@ -1519,7 +1526,7 @@ GDS_NEIGHBOURS_send_add_trail (struct GNUNET_PeerIdentity source_peer, | |||
1519 | adm = (struct PeerAddTrailMessage *) &pending[1]; | 1526 | adm = (struct PeerAddTrailMessage *) &pending[1]; |
1520 | pending->msg = &adm->header; | 1527 | pending->msg = &adm->header; |
1521 | adm->header.size = htons (msize); | 1528 | adm->header.size = htons (msize); |
1522 | adm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_ADD_TRAIL); | 1529 | adm->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_ADD_TRAIL); |
1523 | adm->source_peer = source_peer; | 1530 | adm->source_peer = source_peer; |
1524 | adm->destination_peer = destination_peer; | 1531 | adm->destination_peer = destination_peer; |
1525 | adm->trail_id = trail_id; | 1532 | adm->trail_id = trail_id; |
@@ -1573,7 +1580,7 @@ GDS_NEIGHBOURS_send_trail_compression (struct GNUNET_PeerIdentity source_peer, | |||
1573 | tcm = (struct PeerTrailCompressionMessage *) &pending[1]; | 1580 | tcm = (struct PeerTrailCompressionMessage *) &pending[1]; |
1574 | pending->msg = &tcm->header; | 1581 | pending->msg = &tcm->header; |
1575 | tcm->header.size = htons (msize); | 1582 | tcm->header.size = htons (msize); |
1576 | tcm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_COMPRESSION); | 1583 | tcm->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_COMPRESSION); |
1577 | tcm->source_peer = source_peer; | 1584 | tcm->source_peer = source_peer; |
1578 | tcm->new_first_friend = first_friend; | 1585 | tcm->new_first_friend = first_friend; |
1579 | tcm->trail_id = trail_id; | 1586 | tcm->trail_id = trail_id; |
@@ -2134,7 +2141,7 @@ GDS_NEIGHBOURS_send_put (const struct GNUNET_HashCode *key, | |||
2134 | ppm = (struct PeerPutMessage *) &pending[1]; | 2141 | ppm = (struct PeerPutMessage *) &pending[1]; |
2135 | pending->msg = &ppm->header; | 2142 | pending->msg = &ppm->header; |
2136 | ppm->header.size = htons (msize); | 2143 | ppm->header.size = htons (msize); |
2137 | ppm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_PUT); | 2144 | ppm->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_PUT); |
2138 | ppm->options = htonl (options); | 2145 | ppm->options = htonl (options); |
2139 | ppm->block_type = htonl (block_type); | 2146 | ppm->block_type = htonl (block_type); |
2140 | ppm->hop_count = htonl (hop_count + 1); | 2147 | ppm->hop_count = htonl (hop_count + 1); |
@@ -2252,7 +2259,7 @@ GDS_NEIGHBOURS_send_get (const struct GNUNET_HashCode *key, | |||
2252 | pgm = (struct PeerGetMessage *) &pending[1]; | 2259 | pgm = (struct PeerGetMessage *) &pending[1]; |
2253 | pending->msg = &pgm->header; | 2260 | pending->msg = &pgm->header; |
2254 | pgm->header.size = htons (msize); | 2261 | pgm->header.size = htons (msize); |
2255 | pgm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_GET); | 2262 | pgm->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_GET); |
2256 | pgm->get_path_length = htonl (get_path_length); | 2263 | pgm->get_path_length = htonl (get_path_length); |
2257 | pgm->best_known_destination = local_best_known_dest; | 2264 | pgm->best_known_destination = local_best_known_dest; |
2258 | 2265 | ||
@@ -2339,7 +2346,7 @@ GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key, | |||
2339 | get_result = (struct PeerGetResultMessage *)&pending[1]; | 2346 | get_result = (struct PeerGetResultMessage *)&pending[1]; |
2340 | pending->msg = &get_result->header; | 2347 | pending->msg = &get_result->header; |
2341 | get_result->header.size = htons (msize); | 2348 | get_result->header.size = htons (msize); |
2342 | get_result->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_GET_RESULT); | 2349 | get_result->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_GET_RESULT); |
2343 | get_result->key = *key; | 2350 | get_result->key = *key; |
2344 | /* FIXME: check if you are passing the correct querying_peer as described in | 2351 | /* FIXME: check if you are passing the correct querying_peer as described in |
2345 | the get_result documentation. */ | 2352 | the get_result documentation. */ |
@@ -2693,12 +2700,12 @@ send_trail_teardown (struct FingerInfo *finger, | |||
2693 | then remove finger. */ | 2700 | then remove finger. */ |
2694 | /* We should decerement the friend trail count here. */ | 2701 | /* We should decerement the friend trail count here. */ |
2695 | struct FriendInfo *friend; | 2702 | struct FriendInfo *friend; |
2696 | 2703 | ||
2697 | GNUNET_assert (NULL != (friend = | 2704 | GNUNET_assert (NULL != (friend = |
2698 | GNUNET_CONTAINER_multipeermap_get (friend_peermap, | 2705 | GNUNET_CONTAINER_multipeermap_get (friend_peermap, |
2699 | &trail->trail_head->peer))); | 2706 | &trail->trail_head->peer))); |
2700 | 2707 | ||
2701 | friend->trails_count--; | 2708 | //friend->trails_count--; |
2702 | GDS_NEIGHBOURS_send_trail_teardown (trail->trail_id, | 2709 | GDS_NEIGHBOURS_send_trail_teardown (trail->trail_id, |
2703 | GDS_ROUTING_SRC_TO_DEST, | 2710 | GDS_ROUTING_SRC_TO_DEST, |
2704 | &trail->trail_head->peer); | 2711 | &trail->trail_head->peer); |
@@ -3304,7 +3311,7 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity, | |||
3304 | add_new_finger (finger_identity, updated_trail, updated_finger_trail_length, | 3311 | add_new_finger (finger_identity, updated_trail, updated_finger_trail_length, |
3305 | finger_trail_id, finger_table_index); | 3312 | finger_trail_id, finger_table_index); |
3306 | update_current_search_finger_index (finger_identity, finger_table_index); | 3313 | update_current_search_finger_index (finger_identity, finger_table_index); |
3307 | GNUNET_free (updated_trail); | 3314 | GNUNET_free_non_null (updated_trail); |
3308 | return; | 3315 | return; |
3309 | } | 3316 | } |
3310 | 3317 | ||
@@ -3330,7 +3337,7 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity, | |||
3330 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&(existing_finger->finger_identity), | 3337 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&(existing_finger->finger_identity), |
3331 | &my_identity)) | 3338 | &my_identity)) |
3332 | { | 3339 | { |
3333 | GNUNET_free (updated_trail); | 3340 | GNUNET_free_non_null (updated_trail); |
3334 | return; | 3341 | return; |
3335 | } | 3342 | } |
3336 | /* If the existing finger is not a friend. */ | 3343 | /* If the existing finger is not a friend. */ |
@@ -3348,7 +3355,7 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity, | |||
3348 | } | 3355 | } |
3349 | } | 3356 | } |
3350 | update_current_search_finger_index (finger_identity, finger_table_index); | 3357 | update_current_search_finger_index (finger_identity, finger_table_index); |
3351 | GNUNET_free (updated_trail); | 3358 | GNUNET_free_non_null (updated_trail); |
3352 | return; | 3359 | return; |
3353 | } | 3360 | } |
3354 | 3361 | ||
@@ -3502,6 +3509,7 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3502 | GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (put->expiration_time), | 3509 | GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (put->expiration_time), |
3503 | &(put->key),putlen, pp, ntohl (put->block_type), | 3510 | &(put->key),putlen, pp, ntohl (put->block_type), |
3504 | payload_size, payload); | 3511 | payload_size, payload); |
3512 | GNUNET_free_non_null (next_hop); | ||
3505 | return GNUNET_YES; | 3513 | return GNUNET_YES; |
3506 | } | 3514 | } |
3507 | else | 3515 | else |
@@ -3855,8 +3863,7 @@ handle_dht_p2p_trail_setup (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3855 | &my_identity))) | 3863 | &my_identity))) |
3856 | { | 3864 | { |
3857 | /* If I was not the source of this message for which now I am destination */ | 3865 | /* If I was not the source of this message for which now I am destination */ |
3858 | if ((0 != GNUNET_CRYPTO_cmp_peer_identity (&source, &my_identity)) || | 3866 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&source, &my_identity)) |
3859 | (trail_length > 0)) | ||
3860 | { | 3867 | { |
3861 | GDS_ROUTING_add (trail_id, *peer, my_identity); | 3868 | GDS_ROUTING_add (trail_id, *peer, my_identity); |
3862 | } | 3869 | } |
@@ -4991,6 +4998,7 @@ handle_dht_p2p_trail_teardown (void *cls, const struct GNUNET_PeerIdentity *peer | |||
4991 | struct GNUNET_PeerIdentity *next_hop; | 4998 | struct GNUNET_PeerIdentity *next_hop; |
4992 | size_t msize; | 4999 | size_t msize; |
4993 | msize = ntohs (message->size); | 5000 | msize = ntohs (message->size); |
5001 | |||
4994 | /* Here we pass only the trail id. */ | 5002 | /* Here we pass only the trail id. */ |
4995 | if (msize != sizeof (struct PeerTrailTearDownMessage)) | 5003 | if (msize != sizeof (struct PeerTrailTearDownMessage)) |
4996 | { | 5004 | { |
@@ -5136,7 +5144,7 @@ remove_matching_trails (const struct GNUNET_PeerIdentity *disconnected_friend, | |||
5136 | /* Number of trails with disconnected_friend as the first hop in the trail | 5144 | /* Number of trails with disconnected_friend as the first hop in the trail |
5137 | * to reach from me to remove_finger, NOT including endpoints. */ | 5145 | * to reach from me to remove_finger, NOT including endpoints. */ |
5138 | matching_trails_count = 0; | 5146 | matching_trails_count = 0; |
5139 | 5147 | ||
5140 | /* Iterate over all the trails of finger. */ | 5148 | /* Iterate over all the trails of finger. */ |
5141 | for (i = 0; i < remove_finger->trails_count; i++) | 5149 | for (i = 0; i < remove_finger->trails_count; i++) |
5142 | { | 5150 | { |
@@ -5329,6 +5337,7 @@ core_init (void *cls, | |||
5329 | FPRINTF (stderr,_("\nSUPU %s, %s, %d, my_identity = %s"), | 5337 | FPRINTF (stderr,_("\nSUPU %s, %s, %d, my_identity = %s"), |
5330 | __FILE__, __func__,__LINE__, GNUNET_i2s (&my_identity)); | 5338 | __FILE__, __func__,__LINE__, GNUNET_i2s (&my_identity)); |
5331 | #endif | 5339 | #endif |
5340 | |||
5332 | } | 5341 | } |
5333 | 5342 | ||
5334 | 5343 | ||
@@ -5360,20 +5369,20 @@ int | |||
5360 | GDS_NEIGHBOURS_init (void) | 5369 | GDS_NEIGHBOURS_init (void) |
5361 | { | 5370 | { |
5362 | static struct GNUNET_CORE_MessageHandler core_handlers[] = { | 5371 | static struct GNUNET_CORE_MessageHandler core_handlers[] = { |
5363 | {&handle_dht_p2p_put, GNUNET_MESSAGE_TYPE_DHT_P2P_PUT, 0}, | 5372 | {&handle_dht_p2p_put, GNUNET_MESSAGE_TYPE_XDHT_P2P_PUT, 0}, |
5364 | {&handle_dht_p2p_get, GNUNET_MESSAGE_TYPE_DHT_P2P_GET, 0}, | 5373 | {&handle_dht_p2p_get, GNUNET_MESSAGE_TYPE_XDHT_P2P_GET, 0}, |
5365 | {&handle_dht_p2p_get_result, GNUNET_MESSAGE_TYPE_DHT_P2P_GET_RESULT, 0}, | 5374 | {&handle_dht_p2p_get_result, GNUNET_MESSAGE_TYPE_XDHT_P2P_GET_RESULT, 0}, |
5366 | {&handle_dht_p2p_trail_setup, GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP, 0}, | 5375 | {&handle_dht_p2p_trail_setup, GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP, 0}, |
5367 | {&handle_dht_p2p_trail_setup_result, GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP_RESULT, 0}, | 5376 | {&handle_dht_p2p_trail_setup_result, GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP_RESULT, 0}, |
5368 | {&handle_dht_p2p_verify_successor, GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR, 0}, | 5377 | {&handle_dht_p2p_verify_successor, GNUNET_MESSAGE_TYPE_XDHT_P2P_VERIFY_SUCCESSOR, 0}, |
5369 | {&handle_dht_p2p_verify_successor_result, GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR_RESULT, 0}, | 5378 | {&handle_dht_p2p_verify_successor_result, GNUNET_MESSAGE_TYPE_XDHT_P2P_VERIFY_SUCCESSOR_RESULT, 0}, |
5370 | {&handle_dht_p2p_notify_new_successor, GNUNET_MESSAGE_TYPE_DHT_P2P_NOTIFY_NEW_SUCCESSOR, 0}, | 5379 | {&handle_dht_p2p_notify_new_successor, GNUNET_MESSAGE_TYPE_XDHT_P2P_NOTIFY_NEW_SUCCESSOR, 0}, |
5371 | {&handle_dht_p2p_trail_setup_rejection, GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP_REJECTION, 0}, | 5380 | {&handle_dht_p2p_trail_setup_rejection, GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP_REJECTION, 0}, |
5372 | {&handle_dht_p2p_trail_compression, GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_COMPRESSION, | 5381 | {&handle_dht_p2p_trail_compression, GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_COMPRESSION, |
5373 | sizeof (struct PeerTrailCompressionMessage)}, | 5382 | sizeof (struct PeerTrailCompressionMessage)}, |
5374 | {&handle_dht_p2p_trail_teardown, GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_TEARDOWN, | 5383 | {&handle_dht_p2p_trail_teardown, GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_TEARDOWN, |
5375 | sizeof (struct PeerTrailTearDownMessage)}, | 5384 | sizeof (struct PeerTrailTearDownMessage)}, |
5376 | {&handle_dht_p2p_add_trail, GNUNET_MESSAGE_TYPE_DHT_P2P_ADD_TRAIL, 0}, | 5385 | {&handle_dht_p2p_add_trail, GNUNET_MESSAGE_TYPE_XDHT_P2P_ADD_TRAIL, 0}, |
5377 | {NULL, 0, 0} | 5386 | {NULL, 0, 0} |
5378 | }; | 5387 | }; |
5379 | 5388 | ||
diff --git a/src/dht/gnunet-service-xdht_routing.c b/src/dht/gnunet-service-xdht_routing.c index e320c2df9..102ea404b 100644 --- a/src/dht/gnunet-service-xdht_routing.c +++ b/src/dht/gnunet-service-xdht_routing.c | |||
@@ -166,17 +166,24 @@ static int remove_matching_trails (void *cls, | |||
166 | const struct GNUNET_HashCode *key, | 166 | const struct GNUNET_HashCode *key, |
167 | void *value) | 167 | void *value) |
168 | { | 168 | { |
169 | struct RoutingTrail *remove_trail = cls; | 169 | struct RoutingTrail *remove_trail = value; |
170 | struct GNUNET_PeerIdentity *disconnected_peer = value; | 170 | struct GNUNET_PeerIdentity *disconnected_peer = cls; |
171 | struct GNUNET_HashCode trail_id = *key; | ||
172 | struct GNUNET_PeerIdentity my_identity; | ||
171 | 173 | ||
172 | /* If disconnected_peer is next_hop, then send a trail teardown message through | 174 | /* If disconnected_peer is next_hop, then send a trail teardown message through |
173 | * prev_hop in direction from destination to source. */ | 175 | * prev_hop in direction from destination to source. */ |
174 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&remove_trail->next_hop, | 176 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&remove_trail->next_hop, |
175 | disconnected_peer)) | 177 | disconnected_peer)) |
176 | { | 178 | { |
177 | GDS_NEIGHBOURS_send_trail_teardown (remove_trail->trail_id, | 179 | my_identity = GDS_NEIGHBOURS_get_my_id (); |
178 | GDS_ROUTING_DEST_TO_SRC, | 180 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, |
179 | &remove_trail->prev_hop); | 181 | &remove_trail->prev_hop)) |
182 | { | ||
183 | GDS_NEIGHBOURS_send_trail_teardown (trail_id, | ||
184 | GDS_ROUTING_DEST_TO_SRC, | ||
185 | &remove_trail->prev_hop); | ||
186 | } | ||
180 | } | 187 | } |
181 | 188 | ||
182 | /* If disconnected_peer is prev_hop, then send a trail teardown through | 189 | /* If disconnected_peer is prev_hop, then send a trail teardown through |
@@ -184,14 +191,19 @@ static int remove_matching_trails (void *cls, | |||
184 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&remove_trail->prev_hop, | 191 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&remove_trail->prev_hop, |
185 | disconnected_peer)) | 192 | disconnected_peer)) |
186 | { | 193 | { |
187 | GDS_NEIGHBOURS_send_trail_teardown (remove_trail->trail_id, | 194 | my_identity = GDS_NEIGHBOURS_get_my_id (); |
188 | GDS_ROUTING_SRC_TO_DEST, | 195 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, |
189 | &remove_trail->next_hop); | 196 | &remove_trail->next_hop)) |
197 | { | ||
198 | GDS_NEIGHBOURS_send_trail_teardown (trail_id, | ||
199 | GDS_ROUTING_SRC_TO_DEST, | ||
200 | &remove_trail->next_hop); | ||
201 | } | ||
190 | } | 202 | } |
191 | 203 | ||
192 | GNUNET_assert (GNUNET_YES == | 204 | GNUNET_assert (GNUNET_YES == |
193 | GNUNET_CONTAINER_multihashmap_remove (routing_table, | 205 | GNUNET_CONTAINER_multihashmap_remove (routing_table, |
194 | &remove_trail->trail_id, | 206 | &trail_id, |
195 | remove_trail)); | 207 | remove_trail)); |
196 | GNUNET_free (remove_trail); | 208 | GNUNET_free (remove_trail); |
197 | return GNUNET_YES; | 209 | return GNUNET_YES; |
@@ -239,6 +251,7 @@ GDS_ROUTING_test_print (void) | |||
239 | void | 251 | void |
240 | GDS_ROUTING_remove_trail_by_peer (const struct GNUNET_PeerIdentity *peer) | 252 | GDS_ROUTING_remove_trail_by_peer (const struct GNUNET_PeerIdentity *peer) |
241 | { | 253 | { |
254 | GNUNET_assert (GNUNET_CONTAINER_multihashmap_size(routing_table) > 0); | ||
242 | GNUNET_CONTAINER_multihashmap_iterate (routing_table, &remove_matching_trails, | 255 | GNUNET_CONTAINER_multihashmap_iterate (routing_table, &remove_matching_trails, |
243 | (void *)peer); | 256 | (void *)peer); |
244 | } | 257 | } |
@@ -264,6 +277,7 @@ GDS_ROUTING_add (struct GNUNET_HashCode new_trail_id, | |||
264 | new_entry->trail_id = new_trail_id; | 277 | new_entry->trail_id = new_trail_id; |
265 | new_entry->next_hop = next_hop; | 278 | new_entry->next_hop = next_hop; |
266 | new_entry->prev_hop = prev_hop; | 279 | new_entry->prev_hop = prev_hop; |
280 | |||
267 | return GNUNET_CONTAINER_multihashmap_put (routing_table, | 281 | return GNUNET_CONTAINER_multihashmap_put (routing_table, |
268 | &new_trail_id, new_entry, | 282 | &new_trail_id, new_entry, |
269 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 283 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 77c6a6337..b24810110 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -2499,64 +2499,74 @@ extern "C" | |||
2499 | /** | 2499 | /** |
2500 | * Trail setup request is received by a peer. | 2500 | * Trail setup request is received by a peer. |
2501 | */ | 2501 | */ |
2502 | #define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP 880 | 2502 | #define GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP 880 |
2503 | 2503 | ||
2504 | /** | 2504 | /** |
2505 | * Trail to a particular peer is returned to this peer. | 2505 | * Trail to a particular peer is returned to this peer. |
2506 | */ | 2506 | */ |
2507 | #define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP_RESULT 881 | 2507 | #define GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP_RESULT 881 |
2508 | 2508 | ||
2509 | /** | 2509 | /** |
2510 | * Verify if your immediate successor is still your immediate successor. | 2510 | * Verify if your immediate successor is still your immediate successor. |
2511 | */ | 2511 | */ |
2512 | #define GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR 882 | 2512 | #define GNUNET_MESSAGE_TYPE_XDHT_P2P_VERIFY_SUCCESSOR 882 |
2513 | 2513 | ||
2514 | /** | 2514 | /** |
2515 | * Notify your new immediate successor that you are its new predecessor. | 2515 | * Notify your new immediate successor that you are its new predecessor. |
2516 | */ | 2516 | */ |
2517 | #define GNUNET_MESSAGE_TYPE_DHT_P2P_NOTIFY_NEW_SUCCESSOR 883 | 2517 | #define GNUNET_MESSAGE_TYPE_XDHT_P2P_NOTIFY_NEW_SUCCESSOR 883 |
2518 | 2518 | ||
2519 | /** | 2519 | /** |
2520 | * Message which contains the immediate predecessor of requested successor | 2520 | * Message which contains the immediate predecessor of requested successor |
2521 | */ | 2521 | */ |
2522 | #define GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR_RESULT 884 | 2522 | #define GNUNET_MESSAGE_TYPE_XDHT_P2P_VERIFY_SUCCESSOR_RESULT 884 |
2523 | 2523 | ||
2524 | /** | 2524 | /** |
2525 | * Message which contains the get result. | 2525 | * Message which contains the get result. |
2526 | */ | 2526 | */ |
2527 | #define GNUNET_MESSAGE_TYPE_DHT_P2P_GET_RESULT 885 | 2527 | #define GNUNET_MESSAGE_TYPE_XDHT_P2P_GET_RESULT 885 |
2528 | 2528 | ||
2529 | /** | 2529 | /** |
2530 | * Trail Rejection Message. | 2530 | * Trail Rejection Message. |
2531 | */ | 2531 | */ |
2532 | #define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP_REJECTION 886 | 2532 | #define GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP_REJECTION 886 |
2533 | 2533 | ||
2534 | /** | 2534 | /** |
2535 | * Trail Tear down Message. | 2535 | * Trail Tear down Message. |
2536 | */ | 2536 | */ |
2537 | #define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_TEARDOWN 887 | 2537 | #define GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_TEARDOWN 887 |
2538 | 2538 | ||
2539 | /** | 2539 | /** |
2540 | * Routing table add message. | 2540 | * Routing table add message. |
2541 | */ | 2541 | */ |
2542 | #define GNUNET_MESSAGE_TYPE_DHT_P2P_ADD_TRAIL 888 | 2542 | #define GNUNET_MESSAGE_TYPE_XDHT_P2P_ADD_TRAIL 888 |
2543 | 2543 | ||
2544 | /** | 2544 | /** |
2545 | * Trail compression message. | 2545 | * Trail compression message. |
2546 | */ | 2546 | */ |
2547 | #define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_COMPRESSION 889 | 2547 | #define GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_COMPRESSION 889 |
2548 | |||
2549 | /** | ||
2550 | * Client wants to store item in DHT. | ||
2551 | */ | ||
2552 | #define GNUNET_MESSAGE_TYPE_XDHT_P2P_PUT 890 | ||
2553 | |||
2554 | /** | ||
2555 | * Peer tries to find data in DHT. | ||
2556 | */ | ||
2557 | #define GNUNET_MESSAGE_TYPE_XDHT_P2P_GET 891 | ||
2548 | 2558 | ||
2549 | #if ENABLE_MALICIOUS | 2559 | #if ENABLE_MALICIOUS |
2550 | /** | 2560 | /** |
2551 | * Turn X-VINE DHT service malicious | 2561 | * Turn X-VINE DHT service malicious |
2552 | */ | 2562 | */ |
2553 | #define GNUNET_MESSAGE_TYPE_DHT_ACT_MALICIOUS 890 | 2563 | #define GNUNET_MESSAGE_TYPE_DHT_ACT_MALICIOUS 892 |
2554 | #endif | 2564 | #endif |
2555 | 2565 | ||
2556 | /*******************************************************************************/ | 2566 | /*******************************************************************************/ |
2557 | 2567 | ||
2558 | /** | 2568 | /** |
2559 | * Next available: 900 | 2569 | * Next available: 902 |
2560 | */ | 2570 | */ |
2561 | 2571 | ||
2562 | /** | 2572 | /** |