diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-04-30 13:23:18 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-04-30 13:23:18 +0000 |
commit | ee3eab264bbd26a7f1afd3f001628600dff84b11 (patch) | |
tree | 62d6a45a8c7fc2be519602ea7028224495130044 /src/dht | |
parent | 3673e64f188aec6506f4112b7a9bc3fa86999b78 (diff) | |
download | gnunet-ee3eab264bbd26a7f1afd3f001628600dff84b11.tar.gz gnunet-ee3eab264bbd26a7f1afd3f001628600dff84b11.zip |
-more stuff
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/gnunet-service-wdht_neighbours.c | 136 |
1 files changed, 69 insertions, 67 deletions
diff --git a/src/dht/gnunet-service-wdht_neighbours.c b/src/dht/gnunet-service-wdht_neighbours.c index b3a45c44d..a536f6df5 100644 --- a/src/dht/gnunet-service-wdht_neighbours.c +++ b/src/dht/gnunet-service-wdht_neighbours.c | |||
@@ -717,6 +717,70 @@ delete_trail (struct Trail *trail, | |||
717 | } | 717 | } |
718 | 718 | ||
719 | 719 | ||
720 | |||
721 | |||
722 | /** | ||
723 | * Blah. | ||
724 | */ | ||
725 | static void | ||
726 | forward_message_on_trail (struct FriendInfo *next_target, | ||
727 | const struct GNUNET_HashCode *trail_id, | ||
728 | int have_path, | ||
729 | const struct GNUNET_PeerIdentity *predecessor, | ||
730 | const struct GNUNET_PeerIdentity *path, | ||
731 | uint16_t path_length, | ||
732 | const struct GNUNET_MessageHeader *payload) | ||
733 | { | ||
734 | struct GNUNET_MQ_Envelope *env; | ||
735 | struct TrailRouteMessage *trm; | ||
736 | struct GNUNET_PeerIdentity *new_path; | ||
737 | unsigned int plen; | ||
738 | uint16_t payload_len; | ||
739 | |||
740 | payload_len = ntohs (payload->size); | ||
741 | if (have_path) | ||
742 | { | ||
743 | plen = path_length + 1; | ||
744 | if (plen >= (GNUNET_SERVER_MAX_MESSAGE_SIZE | ||
745 | - payload_len | ||
746 | - sizeof (struct TrailRouteMessage)) | ||
747 | / sizeof (struct GNUNET_PeerIdentity)) | ||
748 | { | ||
749 | /* Should really not have paths this long... */ | ||
750 | GNUNET_break_op (0); | ||
751 | plen = 0; | ||
752 | have_path = 0; | ||
753 | } | ||
754 | } | ||
755 | else | ||
756 | { | ||
757 | GNUNET_break_op (0 == path_length); | ||
758 | path_length = 0; | ||
759 | plen = 0; | ||
760 | } | ||
761 | env = GNUNET_MQ_msg_extra (trm, | ||
762 | payload_len + | ||
763 | plen * sizeof (struct GNUNET_PeerIdentity), | ||
764 | GNUNET_MESSAGE_TYPE_WDHT_TRAIL_ROUTE); | ||
765 | trm->record_path = htons (have_path); | ||
766 | trm->path_length = htons (plen); | ||
767 | trm->trail_id = *trail_id; | ||
768 | new_path = (struct GNUNET_PeerIdentity *) &trm[1]; | ||
769 | if (have_path) | ||
770 | { | ||
771 | memcpy (new_path, | ||
772 | path, | ||
773 | path_length * sizeof (struct GNUNET_PeerIdentity)); | ||
774 | new_path[path_length] = *predecessor; | ||
775 | } | ||
776 | memcpy (&new_path[plen], | ||
777 | payload, | ||
778 | payload_len); | ||
779 | GNUNET_MQ_send (next_target->mq, | ||
780 | env); | ||
781 | } | ||
782 | |||
783 | |||
720 | /** | 784 | /** |
721 | * Send the get result to requesting client. | 785 | * Send the get result to requesting client. |
722 | * | 786 | * |
@@ -741,8 +805,8 @@ GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *trail_id, | |||
741 | const void *data, | 805 | const void *data, |
742 | size_t data_size) | 806 | size_t data_size) |
743 | { | 807 | { |
744 | // TRICKY: need to introduce some context to remember trail from | 808 | /* basically: call 'forward_message_on_trail'; |
745 | // the lookup... | 809 | NOTE: ignore 'next_target/have_path' for now... */ |
746 | } | 810 | } |
747 | 811 | ||
748 | 812 | ||
@@ -802,8 +866,8 @@ handle_core_disconnect (void *cls, | |||
802 | static struct FriendInfo * | 866 | static struct FriendInfo * |
803 | pick_random_friend () | 867 | pick_random_friend () |
804 | { | 868 | { |
805 | // TODO: need to extend peermap API to return random entry... | 869 | /* FIXME: implement (easy..., use: |
806 | // (Note: same extension exists for hashmap API). | 870 | GNUNET_CONTAINER_multipeermap_get_random ()... */ |
807 | return NULL; // FIXME... | 871 | return NULL; // FIXME... |
808 | } | 872 | } |
809 | 873 | ||
@@ -904,7 +968,7 @@ do_random_walk (void *cls, | |||
904 | if (ft->finger_array_size < 42) | 968 | if (ft->finger_array_size < 42) |
905 | { | 969 | { |
906 | // FIXME: must have finger array of the right size here, | 970 | // FIXME: must have finger array of the right size here, |
907 | // FIXME: growing / shrinking are tricy -- with pointers | 971 | // FIXME: growing / shrinking are tricky -- with pointers |
908 | // from Trails!!! | 972 | // from Trails!!! |
909 | } | 973 | } |
910 | 974 | ||
@@ -1358,68 +1422,6 @@ struct TrailHandler | |||
1358 | 1422 | ||
1359 | 1423 | ||
1360 | /** | 1424 | /** |
1361 | * Blah. | ||
1362 | */ | ||
1363 | static void | ||
1364 | forward_message_on_trail (struct FriendInfo *next_target, | ||
1365 | const struct GNUNET_HashCode *trail_id, | ||
1366 | int have_path, | ||
1367 | const struct GNUNET_PeerIdentity *predecessor, | ||
1368 | const struct GNUNET_PeerIdentity *path, | ||
1369 | uint16_t path_length, | ||
1370 | const struct GNUNET_MessageHeader *payload) | ||
1371 | { | ||
1372 | struct GNUNET_MQ_Envelope *env; | ||
1373 | struct TrailRouteMessage *trm; | ||
1374 | struct GNUNET_PeerIdentity *new_path; | ||
1375 | unsigned int plen; | ||
1376 | uint16_t payload_len; | ||
1377 | |||
1378 | payload_len = ntohs (payload->size); | ||
1379 | if (have_path) | ||
1380 | { | ||
1381 | plen = path_length + 1; | ||
1382 | if (plen >= (GNUNET_SERVER_MAX_MESSAGE_SIZE | ||
1383 | - payload_len | ||
1384 | - sizeof (struct TrailRouteMessage)) | ||
1385 | / sizeof (struct GNUNET_PeerIdentity)) | ||
1386 | { | ||
1387 | /* Should really not have paths this long... */ | ||
1388 | GNUNET_break_op (0); | ||
1389 | plen = 0; | ||
1390 | have_path = 0; | ||
1391 | } | ||
1392 | } | ||
1393 | else | ||
1394 | { | ||
1395 | GNUNET_break_op (0 == path_length); | ||
1396 | path_length = 0; | ||
1397 | plen = 0; | ||
1398 | } | ||
1399 | env = GNUNET_MQ_msg_extra (trm, | ||
1400 | payload_len + | ||
1401 | plen * sizeof (struct GNUNET_PeerIdentity), | ||
1402 | GNUNET_MESSAGE_TYPE_WDHT_TRAIL_ROUTE); | ||
1403 | trm->record_path = htons (have_path); | ||
1404 | trm->path_length = htons (plen); | ||
1405 | trm->trail_id = *trail_id; | ||
1406 | new_path = (struct GNUNET_PeerIdentity *) &trm[1]; | ||
1407 | if (have_path) | ||
1408 | { | ||
1409 | memcpy (new_path, | ||
1410 | path, | ||
1411 | path_length * sizeof (struct GNUNET_PeerIdentity)); | ||
1412 | new_path[path_length] = *predecessor; | ||
1413 | } | ||
1414 | memcpy (&new_path[plen], | ||
1415 | payload, | ||
1416 | payload_len); | ||
1417 | GNUNET_MQ_send (next_target->mq, | ||
1418 | env); | ||
1419 | } | ||
1420 | |||
1421 | |||
1422 | /** | ||
1423 | * Handle a `struct TrailRouteMessage`. | 1425 | * Handle a `struct TrailRouteMessage`. |
1424 | * | 1426 | * |
1425 | * @param cls closure (NULL) | 1427 | * @param cls closure (NULL) |