diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-09-27 12:46:48 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-09-27 12:46:48 +0000 |
commit | 1f3e06a9d063aefd82ff5081f340a3ce5783ca9b (patch) | |
tree | 21c32a583fc253eb4609fdabaf1ab00305824a4d /src | |
parent | fb8d41530a536dda3dba02ea3674475db6570f04 (diff) | |
download | gnunet-1f3e06a9d063aefd82ff5081f340a3ce5783ca9b.tar.gz gnunet-1f3e06a9d063aefd82ff5081f340a3ce5783ca9b.zip |
process find peer requests and replies
Diffstat (limited to 'src')
-rw-r--r-- | src/dht/Makefile.am | 1 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht-new.c | 23 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht.h | 4 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.c | 200 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_routing.c | 21 | ||||
-rw-r--r-- | src/include/gnunet_constants.h | 8 | ||||
-rw-r--r-- | src/include/gnunet_peerinfo_service.h | 4 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport.c | 2 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_hello.c | 3 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_hello.h | 7 |
10 files changed, 219 insertions, 54 deletions
diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am index 3d30f98d7..274a89b18 100644 --- a/src/dht/Makefile.am +++ b/src/dht/Makefile.am | |||
@@ -128,6 +128,7 @@ gnunet_service_dht_new_LDADD = \ | |||
128 | $(top_builddir)/src/core/libgnunetcore.la \ | 128 | $(top_builddir)/src/core/libgnunetcore.la \ |
129 | $(top_builddir)/src/nse/libgnunetnse.la \ | 129 | $(top_builddir)/src/nse/libgnunetnse.la \ |
130 | $(top_builddir)/src/transport/libgnunettransport.la \ | 130 | $(top_builddir)/src/transport/libgnunettransport.la \ |
131 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | ||
131 | $(top_builddir)/src/hello/libgnunethello.la \ | 132 | $(top_builddir)/src/hello/libgnunethello.la \ |
132 | $(top_builddir)/src/block/libgnunetblock.la \ | 133 | $(top_builddir)/src/block/libgnunetblock.la \ |
133 | $(top_builddir)/src/datacache/libgnunetdatacache.la \ | 134 | $(top_builddir)/src/datacache/libgnunetdatacache.la \ |
diff --git a/src/dht/gnunet-service-dht-new.c b/src/dht/gnunet-service-dht-new.c index e4ea3891b..766c6c0a9 100644 --- a/src/dht/gnunet-service-dht-new.c +++ b/src/dht/gnunet-service-dht-new.c | |||
@@ -60,16 +60,17 @@ const struct GNUNET_CONFIGURATION_Handle *GDS_cfg; | |||
60 | */ | 60 | */ |
61 | struct GNUNET_MessageHeader *GDS_my_hello; | 61 | struct GNUNET_MessageHeader *GDS_my_hello; |
62 | 62 | ||
63 | |||
64 | /** | 63 | /** |
65 | * Handle to get our current HELLO. | 64 | * Handle to the transport service, for getting our hello |
66 | */ | 65 | */ |
67 | static struct GNUNET_TRANSPORT_GetHelloHandle *ghh; | 66 | struct GNUNET_TRANSPORT_Handle *GDS_transport_handle; |
67 | |||
68 | |||
68 | 69 | ||
69 | /** | 70 | /** |
70 | * Handle to the transport service, for getting our hello | 71 | * Handle to get our current HELLO. |
71 | */ | 72 | */ |
72 | static struct GNUNET_TRANSPORT_Handle *transport_handle; | 73 | static struct GNUNET_TRANSPORT_GetHelloHandle *ghh; |
73 | 74 | ||
74 | 75 | ||
75 | /** | 76 | /** |
@@ -104,10 +105,10 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
104 | GNUNET_TRANSPORT_get_hello_cancel (ghh); | 105 | GNUNET_TRANSPORT_get_hello_cancel (ghh); |
105 | ghh = NULL; | 106 | ghh = NULL; |
106 | } | 107 | } |
107 | if (transport_handle != NULL) | 108 | if (GDS_transport_handle != NULL) |
108 | { | 109 | { |
109 | GNUNET_TRANSPORT_disconnect (transport_handle); | 110 | GNUNET_TRANSPORT_disconnect (GDS_transport_handle); |
110 | transport_handle = NULL; | 111 | GDS_transport_handle = NULL; |
111 | } | 112 | } |
112 | GDS_NEIGHBOURS_done (); | 113 | GDS_NEIGHBOURS_done (); |
113 | GDS_DATACACHE_done (); | 114 | GDS_DATACACHE_done (); |
@@ -155,15 +156,15 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
155 | } | 156 | } |
156 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 157 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
157 | &shutdown_task, NULL); | 158 | &shutdown_task, NULL); |
158 | transport_handle = | 159 | GDS_transport_handle = |
159 | GNUNET_TRANSPORT_connect (GDS_cfg, NULL, NULL, NULL, NULL, NULL); | 160 | GNUNET_TRANSPORT_connect (GDS_cfg, NULL, NULL, NULL, NULL, NULL); |
160 | if (transport_handle == NULL) | 161 | if (GDS_transport_handle == NULL) |
161 | { | 162 | { |
162 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 163 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
163 | _("Failed to connect to transport service!\n")); | 164 | _("Failed to connect to transport service!\n")); |
164 | return; | 165 | return; |
165 | } | 166 | } |
166 | ghh = GNUNET_TRANSPORT_get_hello (transport_handle, | 167 | ghh = GNUNET_TRANSPORT_get_hello (GDS_transport_handle, |
167 | &process_hello, NULL); | 168 | &process_hello, NULL); |
168 | } | 169 | } |
169 | 170 | ||
diff --git a/src/dht/gnunet-service-dht.h b/src/dht/gnunet-service-dht.h index cacc00971..3a716acde 100644 --- a/src/dht/gnunet-service-dht.h +++ b/src/dht/gnunet-service-dht.h | |||
@@ -50,5 +50,9 @@ extern struct GNUNET_STATISTICS_Handle *GDS_stats; | |||
50 | */ | 50 | */ |
51 | extern struct GNUNET_MessageHeader *GDS_my_hello; | 51 | extern struct GNUNET_MessageHeader *GDS_my_hello; |
52 | 52 | ||
53 | /** | ||
54 | * Handle to the transport service, for getting our hello | ||
55 | */ | ||
56 | extern struct GNUNET_TRANSPORT_Handle *GDS_transport_handle; | ||
53 | 57 | ||
54 | #endif | 58 | #endif |
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index f9e31310e..705168b17 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "platform.h" | 28 | #include "platform.h" |
29 | #include "gnunet_block_lib.h" | 29 | #include "gnunet_block_lib.h" |
30 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
31 | #include "gnunet_hello_lib.h" | ||
31 | #include "gnunet_constants.h" | 32 | #include "gnunet_constants.h" |
32 | #include "gnunet_protocols.h" | 33 | #include "gnunet_protocols.h" |
33 | #include "gnunet_nse_service.h" | 34 | #include "gnunet_nse_service.h" |
@@ -37,6 +38,7 @@ | |||
37 | #include "gnunet_hello_lib.h" | 38 | #include "gnunet_hello_lib.h" |
38 | #include "gnunet_dht_service.h" | 39 | #include "gnunet_dht_service.h" |
39 | #include "gnunet_statistics_service.h" | 40 | #include "gnunet_statistics_service.h" |
41 | #include "gnunet_peerinfo_service.h" | ||
40 | #include "dht.h" | 42 | #include "dht.h" |
41 | #include "gnunet-service-dht.h" | 43 | #include "gnunet-service-dht.h" |
42 | #include "gnunet-service-dht_clients.h" | 44 | #include "gnunet-service-dht_clients.h" |
@@ -326,9 +328,10 @@ struct PeerInfo | |||
326 | struct GNUNET_CORE_InformationRequestContext *info_ctx; | 328 | struct GNUNET_CORE_InformationRequestContext *info_ctx; |
327 | 329 | ||
328 | /** | 330 | /** |
329 | * Task for scheduling message sends. | 331 | * HELLO message for the peer, NULL if not known. FIXME: track |
332 | * separately? FIXME: free!? | ||
330 | */ | 333 | */ |
331 | GNUNET_SCHEDULER_TaskIdentifier send_task; | 334 | struct GNUNET_HELLO_Message *hello; |
332 | 335 | ||
333 | /** | 336 | /** |
334 | * Task for scheduling preference updates | 337 | * Task for scheduling preference updates |
@@ -418,6 +421,11 @@ static struct GNUNET_PeerIdentity my_identity; | |||
418 | */ | 421 | */ |
419 | static struct GNUNET_CORE_Handle *coreAPI; | 422 | static struct GNUNET_CORE_Handle *coreAPI; |
420 | 423 | ||
424 | /** | ||
425 | * Handle for peerinfo notifications. | ||
426 | */ | ||
427 | static struct GNUNET_PEERINFO_NotifyContext *pnc; | ||
428 | |||
421 | 429 | ||
422 | /** | 430 | /** |
423 | * Find the optimal bucket for this key. | 431 | * Find the optimal bucket for this key. |
@@ -1511,6 +1519,81 @@ handle_dht_p2p_put (void *cls, | |||
1511 | 1519 | ||
1512 | 1520 | ||
1513 | /** | 1521 | /** |
1522 | * We have received a FIND PEER request. Send matching | ||
1523 | * HELLOs back. | ||
1524 | * | ||
1525 | * @param sender sender of the FIND PEER request | ||
1526 | * @param key peers close to this key are desired | ||
1527 | * @param bf peers matching this bf are excluded | ||
1528 | * @param bf_mutator mutator for bf | ||
1529 | */ | ||
1530 | static void | ||
1531 | handle_find_peer (const struct GNUNET_PeerIdentity *sender, | ||
1532 | const GNUNET_HashCode *key, | ||
1533 | struct GNUNET_CONTAINER_BloomFilter *bf, | ||
1534 | uint32_t bf_mutator) | ||
1535 | { | ||
1536 | int bucket_idx; | ||
1537 | struct PeerBucket *bucket; | ||
1538 | struct PeerInfo *peer; | ||
1539 | unsigned int choice; | ||
1540 | GNUNET_HashCode mhash; | ||
1541 | |||
1542 | /* first, check about our own HELLO */ | ||
1543 | if (NULL != GDS_my_hello) | ||
1544 | { | ||
1545 | GNUNET_BLOCK_mingle_hash (&my_identity.hashPubKey, bf_mutator, &mhash); | ||
1546 | if (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (bf, &mhash)) | ||
1547 | |||
1548 | GDS_NEIGHBOURS_handle_reply (sender, | ||
1549 | GNUNET_BLOCK_TYPE_DHT_HELLO, | ||
1550 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION), | ||
1551 | key, | ||
1552 | 0, NULL, | ||
1553 | 0, NULL, | ||
1554 | GDS_my_hello, | ||
1555 | GNUNET_HELLO_size ((const struct GNUNET_HELLO_Message*) GDS_my_hello)); | ||
1556 | } | ||
1557 | |||
1558 | /* then, also consider sending a random HELLO from the closest bucket */ | ||
1559 | bucket_idx = find_bucket (key); | ||
1560 | if (bucket_idx == GNUNET_SYSERR) | ||
1561 | return; | ||
1562 | bucket = &k_buckets[bucket_idx]; | ||
1563 | if (bucket->peers_size == 0) | ||
1564 | return; | ||
1565 | choice = GNUNET_CRYPTO_random_u32 (bucket->peers_size, | ||
1566 | GNUNET_CRYPTO_QUALITY_WEAK); | ||
1567 | peer = bucket->head; | ||
1568 | while (choice > 0) | ||
1569 | { | ||
1570 | GNUNET_assert (peer != NULL); | ||
1571 | peer = peer->next; | ||
1572 | } | ||
1573 | choice = bucket->peers_size; | ||
1574 | do | ||
1575 | { | ||
1576 | peer = peer->next; | ||
1577 | if (choice-- == 0) | ||
1578 | return; /* no non-masked peer available */ | ||
1579 | if (peer == NULL) | ||
1580 | peer = bucket->head; | ||
1581 | GNUNET_BLOCK_mingle_hash (&peer->id.hashPubKey, bf_mutator, &mhash); | ||
1582 | } | ||
1583 | while ( (peer->hello == NULL) || | ||
1584 | (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (bf, &mhash)) ); | ||
1585 | GDS_NEIGHBOURS_handle_reply (sender, | ||
1586 | GNUNET_BLOCK_TYPE_DHT_HELLO, | ||
1587 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION), | ||
1588 | key, | ||
1589 | 0, NULL, | ||
1590 | 0, NULL, | ||
1591 | peer->hello, | ||
1592 | GNUNET_HELLO_size (peer->hello)); | ||
1593 | } | ||
1594 | |||
1595 | |||
1596 | /** | ||
1514 | * Core handler for p2p get requests. | 1597 | * Core handler for p2p get requests. |
1515 | * | 1598 | * |
1516 | * @param cls closure | 1599 | * @param cls closure |
@@ -1588,19 +1671,30 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1588 | &get->key, | 1671 | &get->key, |
1589 | xquery, xquery_size, | 1672 | xquery, xquery_size, |
1590 | reply_bf, get->bf_mutator); | 1673 | reply_bf, get->bf_mutator); |
1591 | /* FIXME: check options (find peer, local-processing-only-if-nearest, etc.!) */ | ||
1592 | 1674 | ||
1593 | /* local lookup (this may update the reply_bf) */ | 1675 | /* local lookup (this may update the reply_bf) */ |
1594 | if ( (0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) || | 1676 | if ( (0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) || |
1595 | (am_closest_peer (&get->key, | 1677 | (am_closest_peer (&get->key, |
1596 | peer_bf) ) ) | 1678 | peer_bf) ) ) |
1597 | GDS_DATACACHE_handle_get (&get->key, | 1679 | { |
1598 | type, | 1680 | if ( (0 != (options & GNUNET_DHT_RO_FIND_PEER))) |
1599 | xquery, xquery_size, | 1681 | { |
1600 | &reply_bf, | 1682 | handle_find_peer (peer, |
1601 | get->bf_mutator); | 1683 | &get->key, |
1602 | /* FIXME: should track if the local lookup resulted in a | 1684 | reply_bf, |
1603 | definitive result and then NOT do P2P forwarding */ | 1685 | get->bf_mutator); |
1686 | } | ||
1687 | else | ||
1688 | { | ||
1689 | GDS_DATACACHE_handle_get (&get->key, | ||
1690 | type, | ||
1691 | xquery, xquery_size, | ||
1692 | &reply_bf, | ||
1693 | get->bf_mutator); | ||
1694 | /* FIXME: should track if the local lookup resulted in a | ||
1695 | definitive result and then NOT do P2P forwarding */ | ||
1696 | } | ||
1697 | } | ||
1604 | 1698 | ||
1605 | /* P2P forwarding */ | 1699 | /* P2P forwarding */ |
1606 | GDS_NEIGHBOURS_handle_get (type, | 1700 | GDS_NEIGHBOURS_handle_get (type, |
@@ -1669,6 +1763,44 @@ handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1669 | data = (const void*) &get_path[get_path_length]; | 1763 | data = (const void*) &get_path[get_path_length]; |
1670 | data_size = msize - (sizeof (struct PeerResultMessage) + | 1764 | data_size = msize - (sizeof (struct PeerResultMessage) + |
1671 | (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity)); | 1765 | (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity)); |
1766 | if (type == GNUNET_BLOCK_TYPE_DHT_HELLO) | ||
1767 | { | ||
1768 | const struct GNUNET_MessageHeader *h; | ||
1769 | struct GNUNET_PeerIdentity pid; | ||
1770 | int bucket; | ||
1771 | |||
1772 | /* Should be a HELLO, validate and consider using it! */ | ||
1773 | if (data_size < sizeof (struct GNUNET_MessageHeader)) | ||
1774 | { | ||
1775 | GNUNET_break_op (0); | ||
1776 | return GNUNET_YES; | ||
1777 | } | ||
1778 | h = data; | ||
1779 | if (data_size != ntohs (h->size)) | ||
1780 | { | ||
1781 | GNUNET_break_op (0); | ||
1782 | return GNUNET_YES; | ||
1783 | } | ||
1784 | if (GNUNET_OK != | ||
1785 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message*) h, | ||
1786 | &pid)) | ||
1787 | { | ||
1788 | GNUNET_break_op (0); | ||
1789 | return GNUNET_YES; | ||
1790 | } | ||
1791 | bucket = find_bucket (&pid.hashPubKey); | ||
1792 | if ( (bucket >= 0) && | ||
1793 | (k_buckets[bucket].peers_size < bucket_size) ) | ||
1794 | { | ||
1795 | if (NULL != GDS_transport_handle) | ||
1796 | GNUNET_TRANSPORT_offer_hello (GDS_transport_handle, | ||
1797 | h, NULL, NULL); | ||
1798 | (void) GNUNET_CORE_peer_request_connect (coreAPI, | ||
1799 | &pid, | ||
1800 | NULL, NULL); | ||
1801 | } | ||
1802 | } | ||
1803 | |||
1672 | /* append 'peer' to 'get_path' */ | 1804 | /* append 'peer' to 'get_path' */ |
1673 | { | 1805 | { |
1674 | struct GNUNET_PeerIdentity xget_path[get_path_length+1]; | 1806 | struct GNUNET_PeerIdentity xget_path[get_path_length+1]; |
@@ -1704,6 +1836,25 @@ handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1704 | 1836 | ||
1705 | 1837 | ||
1706 | /** | 1838 | /** |
1839 | * Function called for each HELLO known to PEERINFO. | ||
1840 | * | ||
1841 | * @param cls closure | ||
1842 | * @param peer id of the peer, NULL for last call | ||
1843 | * @param hello hello message for the peer (can be NULL) | ||
1844 | * @param error message | ||
1845 | */ | ||
1846 | static void | ||
1847 | process_hello (void *cls, | ||
1848 | const struct GNUNET_PeerIdentity * | ||
1849 | peer, | ||
1850 | const struct GNUNET_HELLO_Message * | ||
1851 | hello, const char *err_msg) | ||
1852 | { | ||
1853 | // FIXME: track HELLOs, possibly ask core to establish connections | ||
1854 | } | ||
1855 | |||
1856 | |||
1857 | /** | ||
1707 | * Initialize neighbours subsystem. | 1858 | * Initialize neighbours subsystem. |
1708 | * | 1859 | * |
1709 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 1860 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
@@ -1736,20 +1887,9 @@ GDS_NEIGHBOURS_init () | |||
1736 | if (coreAPI == NULL) | 1887 | if (coreAPI == NULL) |
1737 | return GNUNET_SYSERR; | 1888 | return GNUNET_SYSERR; |
1738 | all_known_peers = GNUNET_CONTAINER_multihashmap_create (256); | 1889 | all_known_peers = GNUNET_CONTAINER_multihashmap_create (256); |
1739 | #if 0 | 1890 | pnc = GNUNET_PEERINFO_notify (GDS_cfg, |
1740 | struct GNUNET_TIME_Relative next_send_time; | 1891 | &process_hello, |
1741 | 1892 | NULL); | |
1742 | // FIXME! | ||
1743 | next_send_time.rel_value = | ||
1744 | DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value + | ||
1745 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, | ||
1746 | (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / | ||
1747 | 2) - | ||
1748 | DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value); | ||
1749 | find_peer_task = GNUNET_SCHEDULER_add_delayed (next_send_time, | ||
1750 | &send_find_peer_message, | ||
1751 | &find_peer_context); | ||
1752 | #endif | ||
1753 | return GNUNET_OK; | 1893 | return GNUNET_OK; |
1754 | } | 1894 | } |
1755 | 1895 | ||
@@ -1762,6 +1902,11 @@ GDS_NEIGHBOURS_done () | |||
1762 | { | 1902 | { |
1763 | if (coreAPI == NULL) | 1903 | if (coreAPI == NULL) |
1764 | return; | 1904 | return; |
1905 | if (NULL != pnc) | ||
1906 | { | ||
1907 | GNUNET_PEERINFO_notify_cancel (pnc); | ||
1908 | pnc = NULL; | ||
1909 | } | ||
1765 | GNUNET_CORE_disconnect (coreAPI); | 1910 | GNUNET_CORE_disconnect (coreAPI); |
1766 | coreAPI = NULL; | 1911 | coreAPI = NULL; |
1767 | GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (all_known_peers)); | 1912 | GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (all_known_peers)); |
@@ -1776,10 +1921,3 @@ GDS_NEIGHBOURS_done () | |||
1776 | 1921 | ||
1777 | 1922 | ||
1778 | /* end of gnunet-service-dht_neighbours.c */ | 1923 | /* end of gnunet-service-dht_neighbours.c */ |
1779 | |||
1780 | |||
1781 | #if 0 | ||
1782 | |||
1783 | |||
1784 | |||
1785 | #endif | ||
diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c index 41996d654..5a87f8b32 100644 --- a/src/dht/gnunet-service-dht_routing.c +++ b/src/dht/gnunet-service-dht_routing.c | |||
@@ -169,6 +169,8 @@ process (void *cls, | |||
169 | enum GNUNET_BLOCK_EvaluationResult eval; | 169 | enum GNUNET_BLOCK_EvaluationResult eval; |
170 | unsigned int gpl; | 170 | unsigned int gpl; |
171 | unsigned int ppl; | 171 | unsigned int ppl; |
172 | GNUNET_HashCode hc; | ||
173 | const GNUNET_HashCode *eval_key; | ||
172 | 174 | ||
173 | if ( (rr->type != GNUNET_BLOCK_TYPE_ANY) && | 175 | if ( (rr->type != GNUNET_BLOCK_TYPE_ANY) && |
174 | (rr->type != pc->type) ) | 176 | (rr->type != pc->type) ) |
@@ -184,9 +186,26 @@ process (void *cls, | |||
184 | gpl = 0; | 186 | gpl = 0; |
185 | ppl = 0; | 187 | ppl = 0; |
186 | } | 188 | } |
189 | if ( (0 != (rr->options & GNUNET_DHT_RO_FIND_PEER)) && | ||
190 | (pc->type == GNUNET_BLOCK_TYPE_DHT_HELLO) ) | ||
191 | { | ||
192 | /* key may not match HELLO, which is OK since | ||
193 | the search is approximate. Still, the evaluation | ||
194 | would fail since the match is not exact. So | ||
195 | we fake it by changing the key to the actual PID ... */ | ||
196 | GNUNET_BLOCK_get_key (GDS_block_context, | ||
197 | GNUNET_BLOCK_TYPE_DHT_HELLO, | ||
198 | pc->data, pc->data_size, | ||
199 | &hc); | ||
200 | eval_key = &hc; | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | eval_key = key; | ||
205 | } | ||
187 | eval = GNUNET_BLOCK_evaluate (GDS_block_context, | 206 | eval = GNUNET_BLOCK_evaluate (GDS_block_context, |
188 | pc->type, | 207 | pc->type, |
189 | key, | 208 | eval_key, |
190 | &rr->reply_bf, | 209 | &rr->reply_bf, |
191 | rr->reply_bf_mutator, | 210 | rr->reply_bf_mutator, |
192 | rr->xquery, | 211 | rr->xquery, |
diff --git a/src/include/gnunet_constants.h b/src/include/gnunet_constants.h index 7315c9c73..0fc63a526 100644 --- a/src/include/gnunet_constants.h +++ b/src/include/gnunet_constants.h | |||
@@ -98,6 +98,14 @@ extern "C" | |||
98 | #define GNUNET_CONSTANTS_IDLE_LOAD_THRESHOLD 70 | 98 | #define GNUNET_CONSTANTS_IDLE_LOAD_THRESHOLD 70 |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * After how long do we expire an address in a HELLO that we just | ||
102 | * validated? This value is also used for our own addresses when we | ||
103 | * create a HELLO. | ||
104 | */ | ||
105 | #define GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 12) | ||
106 | |||
107 | |||
108 | /** | ||
101 | * Size of the 'struct EncryptedMessage' of the core (which | 109 | * Size of the 'struct EncryptedMessage' of the core (which |
102 | * is the per-message overhead of the core). | 110 | * is the per-message overhead of the core). |
103 | */ | 111 | */ |
diff --git a/src/include/gnunet_peerinfo_service.h b/src/include/gnunet_peerinfo_service.h index 158eae602..12264fb1f 100644 --- a/src/include/gnunet_peerinfo_service.h +++ b/src/include/gnunet_peerinfo_service.h | |||
@@ -111,8 +111,8 @@ struct GNUNET_PEERINFO_IteratorContext; | |||
111 | 111 | ||
112 | 112 | ||
113 | /** | 113 | /** |
114 | * Call a method for each known matching host and change its trust | 114 | * Call a method for each known matching host to get its HELLO. |
115 | * value. The callback method will be invoked once for each matching | 115 | * The callback method will be invoked once for each matching |
116 | * host and then finally once with a NULL pointer. After that final | 116 | * host and then finally once with a NULL pointer. After that final |
117 | * invocation, the iterator context must no longer be used. | 117 | * invocation, the iterator context must no longer be used. |
118 | * | 118 | * |
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index d8733fbb3..537f99dcf 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -92,7 +92,7 @@ transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target, | |||
92 | const struct GNUNET_MessageHeader *hello = cls; | 92 | const struct GNUNET_MessageHeader *hello = cls; |
93 | 93 | ||
94 | GST_neighbours_send (target, (const char *) hello, ntohs (hello->size), | 94 | GST_neighbours_send (target, (const char *) hello, ntohs (hello->size), |
95 | GST_HELLO_ADDRESS_EXPIRATION, NULL, NULL); | 95 | GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION, NULL, NULL); |
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c index 2793ce5eb..a1c721857 100644 --- a/src/transport/gnunet-service-transport_hello.c +++ b/src/transport/gnunet-service-transport_hello.c | |||
@@ -24,6 +24,7 @@ | |||
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_constants.h" | ||
27 | #include "gnunet_hello_lib.h" | 28 | #include "gnunet_hello_lib.h" |
28 | #include "gnunet_peerinfo_service.h" | 29 | #include "gnunet_peerinfo_service.h" |
29 | #include "gnunet_statistics_service.h" | 30 | #include "gnunet_statistics_service.h" |
@@ -165,7 +166,7 @@ refresh_hello_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
165 | hello_task = GNUNET_SCHEDULER_NO_TASK; | 166 | hello_task = GNUNET_SCHEDULER_NO_TASK; |
166 | gc.addr_pos = oal_head; | 167 | gc.addr_pos = oal_head; |
167 | gc.expiration = | 168 | gc.expiration = |
168 | GNUNET_TIME_relative_to_absolute (GST_HELLO_ADDRESS_EXPIRATION); | 169 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION); |
169 | GNUNET_free (our_hello); | 170 | GNUNET_free (our_hello); |
170 | our_hello = GNUNET_HELLO_create (&GST_my_public_key, &address_generator, &gc); | 171 | our_hello = GNUNET_HELLO_create (&GST_my_public_key, &address_generator, &gc); |
171 | #if DEBUG_TRANSPORT | 172 | #if DEBUG_TRANSPORT |
diff --git a/src/transport/gnunet-service-transport_hello.h b/src/transport/gnunet-service-transport_hello.h index 153b7447e..8d15ec6b5 100644 --- a/src/transport/gnunet-service-transport_hello.h +++ b/src/transport/gnunet-service-transport_hello.h | |||
@@ -31,13 +31,6 @@ | |||
31 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
32 | 32 | ||
33 | 33 | ||
34 | /** | ||
35 | * After how long do we expire an address in a HELLO that we just | ||
36 | * validated? This value is also used for our own addresses when we | ||
37 | * create a HELLO. | ||
38 | */ | ||
39 | #define GST_HELLO_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 12) | ||
40 | |||
41 | 34 | ||
42 | /** | 35 | /** |
43 | * Signature of a function to call whenever our hello changes. | 36 | * Signature of a function to call whenever our hello changes. |