aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht_neighbours.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-01-09 12:22:04 +0100
committerChristian Grothoff <christian@grothoff.org>2022-01-09 12:22:04 +0100
commitec19c1e316efdd29a7af0524fc2ff33cc4b19d09 (patch)
tree184a59ff1c8408c462254e53f7e2004be829e237 /src/dht/gnunet-service-dht_neighbours.c
parentc3ecadd45b11f82e22ba81b42864c7826d0f97c6 (diff)
downloadgnunet-ec19c1e316efdd29a7af0524fc2ff33cc4b19d09.tar.gz
gnunet-ec19c1e316efdd29a7af0524fc2ff33cc4b19d09.zip
DHT: modify API and protocol messages to add path signatures, except for now the actual signatures are just placeholders (signing and signature verification are missing)
Diffstat (limited to 'src/dht/gnunet-service-dht_neighbours.c')
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c200
1 files changed, 57 insertions, 143 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index 35502e0f5..e100ae2ee 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -346,11 +346,6 @@ struct ConnectInfo
346static int cache_results; 346static int cache_results;
347 347
348/** 348/**
349 * Should routing details be logged to stderr (for debugging)?
350 */
351static int log_route_details_stderr;
352
353/**
354 * The lowest currently used bucket, initially 0 (for 0-bits matching bucket). 349 * The lowest currently used bucket, initially 0 (for 0-bits matching bucket).
355 */ 350 */
356static unsigned int closest_bucket; 351static unsigned int closest_bucket;
@@ -1437,7 +1432,7 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
1437 struct GNUNET_MQ_Envelope *env; 1432 struct GNUNET_MQ_Envelope *env;
1438 struct PeerGetMessage *pgm; 1433 struct PeerGetMessage *pgm;
1439 char *xq; 1434 char *xq;
1440 1435
1441 if (GNUNET_MQ_get_length (target->mq) >= MAXIMUM_PENDING_PER_PEER) 1436 if (GNUNET_MQ_get_length (target->mq) >= MAXIMUM_PENDING_PER_PEER)
1442 { 1437 {
1443 /* skip */ 1438 /* skip */
@@ -1503,20 +1498,20 @@ GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi,
1503 const struct GDS_DATACACHE_BlockData *bd, 1498 const struct GDS_DATACACHE_BlockData *bd,
1504 const struct GNUNET_HashCode *query_hash, 1499 const struct GNUNET_HashCode *query_hash,
1505 unsigned int get_path_length, 1500 unsigned int get_path_length,
1506 const struct GNUNET_PeerIdentity *get_path) 1501 const struct GNUNET_DHT_PathElement *get_path)
1507{ 1502{
1508 struct GNUNET_MQ_Envelope *env; 1503 struct GNUNET_MQ_Envelope *env;
1509 struct PeerResultMessage *prm; 1504 struct PeerResultMessage *prm;
1510 struct GNUNET_PeerIdentity *paths; 1505 struct GNUNET_DHT_PathElement *paths;
1511 size_t msize; 1506 size_t msize;
1512 1507
1513 msize = bd->data_size + (get_path_length + bd->put_path_length) 1508 msize = bd->data_size + (get_path_length + bd->put_path_length)
1514 * sizeof(struct GNUNET_PeerIdentity); 1509 * sizeof(struct GNUNET_DHT_PathElement);
1515 if ( (msize + sizeof(struct PeerResultMessage) >= GNUNET_MAX_MESSAGE_SIZE) || 1510 if ( (msize + sizeof(struct PeerResultMessage) >= GNUNET_MAX_MESSAGE_SIZE) ||
1516 (get_path_length > 1511 (get_path_length >
1517 GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_PeerIdentity)) || 1512 GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) ||
1518 (bd->put_path_length > 1513 (bd->put_path_length >
1519 GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_PeerIdentity)) || 1514 GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) ||
1520 (bd->data_size > GNUNET_MAX_MESSAGE_SIZE)) 1515 (bd->data_size > GNUNET_MAX_MESSAGE_SIZE))
1521 { 1516 {
1522 GNUNET_break (0); 1517 GNUNET_break (0);
@@ -1551,13 +1546,13 @@ GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi,
1551 prm->get_path_length = htonl (get_path_length); 1546 prm->get_path_length = htonl (get_path_length);
1552 prm->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time); 1547 prm->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time);
1553 prm->key = *query_hash; 1548 prm->key = *query_hash;
1554 paths = (struct GNUNET_PeerIdentity *) &prm[1]; 1549 paths = (struct GNUNET_DHT_PathElement *) &prm[1];
1555 GNUNET_memcpy (paths, 1550 GNUNET_memcpy (paths,
1556 bd->put_path, 1551 bd->put_path,
1557 bd->put_path_length * sizeof(struct GNUNET_PeerIdentity)); 1552 bd->put_path_length * sizeof(struct GNUNET_DHT_PathElement));
1558 GNUNET_memcpy (&paths[bd->put_path_length], 1553 GNUNET_memcpy (&paths[bd->put_path_length],
1559 get_path, 1554 get_path,
1560 get_path_length * sizeof(struct GNUNET_PeerIdentity)); 1555 get_path_length * sizeof(struct GNUNET_DHT_PathElement));
1561 GNUNET_memcpy (&paths[bd->put_path_length + get_path_length], 1556 GNUNET_memcpy (&paths[bd->put_path_length + get_path_length],
1562 bd->data, 1557 bd->data,
1563 bd->data_size); 1558 bd->data_size);
@@ -1582,7 +1577,7 @@ core_init (void *cls,
1582 GNUNET_i2s (identity)); 1577 GNUNET_i2s (identity));
1583 my_identity = *identity; 1578 my_identity = *identity;
1584 GNUNET_CRYPTO_hash (identity, 1579 GNUNET_CRYPTO_hash (identity,
1585 sizeof(struct GNUNET_PeerIdentity), 1580 sizeof(struct GNUNET_PeerIdentity),
1586 &my_identity_hash); 1581 &my_identity_hash);
1587 GNUNET_SERVICE_resume (GDS_service); 1582 GNUNET_SERVICE_resume (GDS_service);
1588} 1583}
@@ -1605,9 +1600,9 @@ check_dht_p2p_put (void *cls,
1605 (void) cls; 1600 (void) cls;
1606 if ( (msize < 1601 if ( (msize <
1607 sizeof(struct PeerPutMessage) 1602 sizeof(struct PeerPutMessage)
1608 + putlen * sizeof(struct GNUNET_PeerIdentity)) || 1603 + putlen * sizeof(struct GNUNET_DHT_PathElement)) ||
1609 (putlen > 1604 (putlen >
1610 GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_PeerIdentity)) ) 1605 GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) )
1611 { 1606 {
1612 GNUNET_break_op (0); 1607 GNUNET_break_op (0);
1613 return GNUNET_SYSERR; 1608 return GNUNET_SYSERR;
@@ -1635,13 +1630,13 @@ handle_dht_p2p_put (void *cls,
1635 .expiration_time = GNUNET_TIME_absolute_ntoh (put->expiration_time), 1630 .expiration_time = GNUNET_TIME_absolute_ntoh (put->expiration_time),
1636 .type = ntohl (put->type) 1631 .type = ntohl (put->type)
1637 }; 1632 };
1638 const struct GNUNET_PeerIdentity *put_path 1633 const struct GNUNET_DHT_PathElement *put_path
1639 = (const struct GNUNET_PeerIdentity *) &put[1]; 1634 = (const struct GNUNET_DHT_PathElement *) &put[1];
1640 uint32_t putlen 1635 uint32_t putlen
1641 = ntohl (put->put_path_length); 1636 = ntohl (put->put_path_length);
1642 1637
1643 bd.data_size = msize - (sizeof(*put) 1638 bd.data_size = msize - (sizeof(*put)
1644 + putlen * sizeof(struct GNUNET_PeerIdentity)); 1639 + putlen * sizeof(struct GNUNET_DHT_PathElement));
1645 bd.data = &put_path[putlen]; 1640 bd.data = &put_path[putlen];
1646 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1641 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1647 "PUT for `%s' from %s\n", 1642 "PUT for `%s' from %s\n",
@@ -1663,35 +1658,6 @@ handle_dht_p2p_put (void *cls,
1663 "# P2P PUT bytes received", 1658 "# P2P PUT bytes received",
1664 msize, 1659 msize,
1665 GNUNET_NO); 1660 GNUNET_NO);
1666 if (GNUNET_YES == log_route_details_stderr)
1667 {
1668 char *tmp;
1669 char *pp;
1670 struct GNUNET_HashCode mxor;
1671 struct GNUNET_HashCode pxor;
1672
1673 GNUNET_CRYPTO_hash_xor (&my_identity_hash,
1674 &put->key,
1675 &mxor);
1676 GNUNET_CRYPTO_hash_xor (&peer->phash,
1677 &put->key,
1678 &pxor);
1679 pp = GNUNET_STRINGS_pp2s (put_path,
1680 putlen);
1681 tmp = GNUNET_strdup (GNUNET_i2s (&my_identity));
1682 LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG,
1683 "R5N PUT %s: %s->%s (%u, %u=>%u, PP: %s)\n",
1684 GNUNET_h2s (&put->key),
1685 GNUNET_i2s (peer->id),
1686 tmp,
1687 ntohl (put->hop_count),
1688 GNUNET_CRYPTO_hash_count_leading_zeros (&pxor),
1689 GNUNET_CRYPTO_hash_count_leading_zeros (&mxor),
1690 pp);
1691 GNUNET_free (pp);
1692 GNUNET_free (tmp);
1693 }
1694
1695 { 1661 {
1696 struct GNUNET_HashCode test_key; 1662 struct GNUNET_HashCode test_key;
1697 enum GNUNET_GenericReturnValue ret; 1663 enum GNUNET_GenericReturnValue ret;
@@ -1733,7 +1699,7 @@ handle_dht_p2p_put (void *cls,
1733 1699
1734 { 1700 {
1735 struct GNUNET_CONTAINER_BloomFilter *bf; 1701 struct GNUNET_CONTAINER_BloomFilter *bf;
1736 struct GNUNET_PeerIdentity pp[putlen + 1]; 1702 struct GNUNET_DHT_PathElement pp[putlen + 1];
1737 1703
1738 bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter, 1704 bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter,
1739 DHT_BLOOM_SIZE, 1705 DHT_BLOOM_SIZE,
@@ -1742,7 +1708,7 @@ handle_dht_p2p_put (void *cls,
1742 GNUNET_CONTAINER_bloomfilter_test (bf, 1708 GNUNET_CONTAINER_bloomfilter_test (bf,
1743 &peer->phash)); 1709 &peer->phash));
1744 /* extend 'put path' by sender */ 1710 /* extend 'put path' by sender */
1745 bd.put_path = (const struct GNUNET_PeerIdentity *) pp; 1711 bd.put_path = (const struct GNUNET_DHT_PathElement *) pp;
1746 bd.put_path_length = putlen + 1; 1712 bd.put_path_length = putlen + 1;
1747 if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE)) 1713 if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE))
1748 { 1714 {
@@ -1752,18 +1718,22 @@ handle_dht_p2p_put (void *cls,
1752 for (unsigned int j = 0; j < i; j++) 1718 for (unsigned int j = 0; j < i; j++)
1753 { 1719 {
1754 GNUNET_break (0 != 1720 GNUNET_break (0 !=
1755 GNUNET_memcmp (&pp[i], 1721 GNUNET_memcmp (&pp[i].pred,
1756 &pp[j])); 1722 &pp[j].pred));
1757 } 1723 }
1758 GNUNET_break (0 != 1724 GNUNET_break (0 !=
1759 GNUNET_memcmp (&pp[i], 1725 GNUNET_memcmp (&pp[i].pred,
1760 peer->id)); 1726 peer->id));
1761 } 1727 }
1762#endif 1728#endif
1763 GNUNET_memcpy (pp, 1729 GNUNET_memcpy (pp,
1764 put_path, 1730 put_path,
1765 putlen * sizeof(struct GNUNET_PeerIdentity)); 1731 putlen * sizeof(struct GNUNET_DHT_PathElement));
1766 pp[putlen] = *peer->id; 1732 pp[putlen].pred = *peer->id;
1733 /* zero-out signature, not valid until we actually do forward! */
1734 memset (&pp[putlen].sig,
1735 0,
1736 sizeof (pp[putlen].sig));
1767 putlen++; 1737 putlen++;
1768 } 1738 }
1769 else 1739 else
@@ -1938,17 +1908,6 @@ handle_local_result (void *cls,
1938{ 1908{
1939 struct PeerInfo *peer = cls; 1909 struct PeerInfo *peer = cls;
1940 1910
1941 {
1942 char *pp;
1943
1944 pp = GNUNET_STRINGS_pp2s (bd->put_path,
1945 bd->put_path_length);
1946 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1947 "Found local result for %s (PP: %s)\n",
1948 GNUNET_h2s (&bd->key),
1949 pp);
1950 GNUNET_free (pp);
1951 }
1952 GDS_NEIGHBOURS_handle_reply (peer, 1911 GDS_NEIGHBOURS_handle_reply (peer,
1953 bd, 1912 bd,
1954 &bd->key, 1913 &bd->key,
@@ -1996,7 +1955,8 @@ handle_dht_p2p_get (void *cls,
1996 uint32_t hop_count = ntohl (get->hop_count); 1955 uint32_t hop_count = ntohl (get->hop_count);
1997 size_t reply_bf_size = msize - (sizeof(*get) + xquery_size); 1956 size_t reply_bf_size = msize - (sizeof(*get) + xquery_size);
1998 enum GNUNET_BLOCK_Type type = (enum GNUNET_BLOCK_Type) ntohl (get->type); 1957 enum GNUNET_BLOCK_Type type = (enum GNUNET_BLOCK_Type) ntohl (get->type);
1999 enum GNUNET_DHT_RouteOption options = (enum GNUNET_DHT_RouteOption) ntohl (get->options); 1958 enum GNUNET_DHT_RouteOption options = (enum GNUNET_DHT_RouteOption) ntohl (
1959 get->options);
2000 enum GNUNET_BLOCK_ReplyEvaluationResult eval = GNUNET_BLOCK_REPLY_OK_MORE; 1960 enum GNUNET_BLOCK_ReplyEvaluationResult eval = GNUNET_BLOCK_REPLY_OK_MORE;
2001 const void *xquery = (const void *) &get[1]; 1961 const void *xquery = (const void *) &get[1];
2002 1962
@@ -2009,31 +1969,6 @@ handle_dht_p2p_get (void *cls,
2009 "# P2P GET bytes received", 1969 "# P2P GET bytes received",
2010 msize, 1970 msize,
2011 GNUNET_NO); 1971 GNUNET_NO);
2012 if (GNUNET_YES == log_route_details_stderr)
2013 {
2014 char *tmp;
2015 struct GNUNET_HashCode mxor;
2016 struct GNUNET_HashCode pxor;
2017
2018 GNUNET_CRYPTO_hash_xor (&my_identity_hash,
2019 &get->key,
2020 &mxor);
2021 GNUNET_CRYPTO_hash_xor (&peer->phash,
2022 &get->key,
2023 &pxor);
2024 tmp = GNUNET_strdup (GNUNET_i2s (&my_identity));
2025 LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG,
2026 "R5N GET %s: %s->%s (%u, %u=>%u) xq: %.*s\n",
2027 GNUNET_h2s (&get->key),
2028 GNUNET_i2s (peer->id),
2029 tmp,
2030 hop_count,
2031 GNUNET_CRYPTO_hash_count_leading_zeros (&pxor),
2032 GNUNET_CRYPTO_hash_count_leading_zeros (&mxor),
2033 ntohl (get->xquery_size),
2034 (const char *) xquery);
2035 GNUNET_free (tmp);
2036 }
2037 if (GNUNET_NO == 1972 if (GNUNET_NO ==
2038 GNUNET_BLOCK_check_query (GDS_block_context, 1973 GNUNET_BLOCK_check_query (GDS_block_context,
2039 type, 1974 type,
@@ -2096,13 +2031,13 @@ handle_dht_p2p_get (void *cls,
2096 } 2031 }
2097 } 2032 }
2098 else 2033 else
2099 { 2034 {
2100 GNUNET_STATISTICS_update (GDS_stats, 2035 GNUNET_STATISTICS_update (GDS_stats,
2101 "# P2P GET requests ONLY routed", 2036 "# P2P GET requests ONLY routed",
2102 1, 2037 1,
2103 GNUNET_NO); 2038 GNUNET_NO);
2104 } 2039 }
2105 2040
2106 /* remember request for routing replies */ 2041 /* remember request for routing replies */
2107 GDS_ROUTING_add (peer->id, 2042 GDS_ROUTING_add (peer->id,
2108 type, 2043 type,
@@ -2115,7 +2050,8 @@ handle_dht_p2p_get (void *cls,
2115 /* P2P forwarding */ 2050 /* P2P forwarding */
2116 { 2051 {
2117 bool forwarded = false; 2052 bool forwarded = false;
2118 uint32_t desired_replication_level = ntohl (get->desired_replication_level); 2053 uint32_t desired_replication_level = ntohl (
2054 get->desired_replication_level);
2119 2055
2120 if (eval != GNUNET_BLOCK_REPLY_OK_LAST) 2056 if (eval != GNUNET_BLOCK_REPLY_OK_LAST)
2121 forwarded = (GNUNET_OK == 2057 forwarded = (GNUNET_OK ==
@@ -2129,8 +2065,8 @@ handle_dht_p2p_get (void *cls,
2129 bg, 2065 bg,
2130 peer_bf)); 2066 peer_bf));
2131 GDS_CLIENTS_process_get ( 2067 GDS_CLIENTS_process_get (
2132 options | 2068 options
2133 (forwarded 2069 | (forwarded
2134 ? 0 2070 ? 0
2135 : GNUNET_DHT_RO_LAST_HOP), 2071 : GNUNET_DHT_RO_LAST_HOP),
2136 type, 2072 type,
@@ -2158,7 +2094,7 @@ static void
2158process_reply_with_path (const struct GDS_DATACACHE_BlockData *bd, 2094process_reply_with_path (const struct GDS_DATACACHE_BlockData *bd,
2159 const struct GNUNET_HashCode *query_hash, 2095 const struct GNUNET_HashCode *query_hash,
2160 unsigned int get_path_length, 2096 unsigned int get_path_length,
2161 const struct GNUNET_PeerIdentity *get_path) 2097 const struct GNUNET_DHT_PathElement *get_path)
2162{ 2098{
2163 /* forward to local clients */ 2099 /* forward to local clients */
2164 GDS_CLIENTS_handle_reply (bd, 2100 GDS_CLIENTS_handle_reply (bd,
@@ -2170,16 +2106,16 @@ process_reply_with_path (const struct GDS_DATACACHE_BlockData *bd,
2170 get_path_length); 2106 get_path_length);
2171 if (GNUNET_YES == cache_results) 2107 if (GNUNET_YES == cache_results)
2172 { 2108 {
2173 struct GNUNET_PeerIdentity xput_path[GNUNET_NZL (get_path_length 2109 struct GNUNET_DHT_PathElement xput_path[GNUNET_NZL (get_path_length
2174 + bd->put_path_length)]; 2110 + bd->put_path_length)];
2175 struct GDS_DATACACHE_BlockData bdx = *bd; 2111 struct GDS_DATACACHE_BlockData bdx = *bd;
2176 2112
2177 GNUNET_memcpy (xput_path, 2113 GNUNET_memcpy (xput_path,
2178 bd->put_path, 2114 bd->put_path,
2179 bd->put_path_length * sizeof(struct GNUNET_PeerIdentity)); 2115 bd->put_path_length * sizeof(struct GNUNET_DHT_PathElement));
2180 GNUNET_memcpy (&xput_path[bd->put_path_length], 2116 GNUNET_memcpy (&xput_path[bd->put_path_length],
2181 get_path, 2117 get_path,
2182 get_path_length * sizeof(struct GNUNET_PeerIdentity)); 2118 get_path_length * sizeof(struct GNUNET_DHT_PathElement));
2183 bdx.put_path = xput_path; 2119 bdx.put_path = xput_path;
2184 bdx.put_path_length += get_path_length; 2120 bdx.put_path_length += get_path_length;
2185 GDS_DATACACHE_handle_put (&bdx); 2121 GDS_DATACACHE_handle_put (&bdx);
@@ -2211,11 +2147,11 @@ check_dht_p2p_result (void *cls,
2211 if ( (msize < 2147 if ( (msize <
2212 sizeof(struct PeerResultMessage) 2148 sizeof(struct PeerResultMessage)
2213 + (get_path_length + put_path_length) 2149 + (get_path_length + put_path_length)
2214 * sizeof(struct GNUNET_PeerIdentity)) || 2150 * sizeof(struct GNUNET_DHT_PathElement)) ||
2215 (get_path_length > 2151 (get_path_length >
2216 GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_PeerIdentity)) || 2152 GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) ||
2217 (put_path_length > 2153 (put_path_length >
2218 GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_PeerIdentity)) ) 2154 GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) )
2219 { 2155 {
2220 GNUNET_break_op (0); 2156 GNUNET_break_op (0);
2221 return GNUNET_SYSERR; 2157 return GNUNET_SYSERR;
@@ -2239,11 +2175,11 @@ handle_dht_p2p_result (void *cls,
2239 uint32_t get_path_length = ntohl (prm->get_path_length); 2175 uint32_t get_path_length = ntohl (prm->get_path_length);
2240 struct GDS_DATACACHE_BlockData bd = { 2176 struct GDS_DATACACHE_BlockData bd = {
2241 .expiration_time = GNUNET_TIME_absolute_ntoh (prm->expiration_time), 2177 .expiration_time = GNUNET_TIME_absolute_ntoh (prm->expiration_time),
2242 .put_path = (const struct GNUNET_PeerIdentity *) &prm[1], 2178 .put_path = (const struct GNUNET_DHT_PathElement *) &prm[1],
2243 .put_path_length = ntohl (prm->put_path_length), 2179 .put_path_length = ntohl (prm->put_path_length),
2244 .type = ntohl (prm->type) 2180 .type = ntohl (prm->type)
2245 }; 2181 };
2246 const struct GNUNET_PeerIdentity *get_path 2182 const struct GNUNET_DHT_PathElement *get_path
2247 = &bd.put_path[bd.put_path_length]; 2183 = &bd.put_path[bd.put_path_length];
2248 2184
2249 /* parse and validate message */ 2185 /* parse and validate message */
@@ -2259,7 +2195,7 @@ handle_dht_p2p_result (void *cls,
2259 bd.data = (const void *) &get_path[get_path_length]; 2195 bd.data = (const void *) &get_path[get_path_length];
2260 bd.data_size = msize - (sizeof(struct PeerResultMessage) 2196 bd.data_size = msize - (sizeof(struct PeerResultMessage)
2261 + (get_path_length + bd.put_path_length) 2197 + (get_path_length + bd.put_path_length)
2262 * sizeof(struct GNUNET_PeerIdentity)); 2198 * sizeof(struct GNUNET_DHT_PathElement));
2263 GNUNET_STATISTICS_update (GDS_stats, 2199 GNUNET_STATISTICS_update (GDS_stats,
2264 "# P2P RESULTS received", 2200 "# P2P RESULTS received",
2265 1, 2201 1,
@@ -2295,29 +2231,6 @@ handle_dht_p2p_result (void *cls,
2295 } 2231 }
2296 } 2232 }
2297 2233
2298 if (GNUNET_YES == log_route_details_stderr)
2299 {
2300 char *tmp;
2301 char *pp;
2302 char *gp;
2303
2304 gp = GNUNET_STRINGS_pp2s (get_path,
2305 get_path_length);
2306 pp = GNUNET_STRINGS_pp2s (bd.put_path,
2307 bd.put_path_length);
2308 tmp = GNUNET_strdup (GNUNET_i2s (&my_identity));
2309 LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG,
2310 "R5N RESULT %s: %s->%s (GP: %s, PP: %s)\n",
2311 GNUNET_h2s (&prm->key),
2312 GNUNET_i2s (peer->id),
2313 tmp,
2314 gp,
2315 pp);
2316 GNUNET_free (gp);
2317 GNUNET_free (pp);
2318 GNUNET_free (tmp);
2319 }
2320
2321 /* if we got a HELLO, consider it for our own routing table */ 2234 /* if we got a HELLO, consider it for our own routing table */
2322 if (GNUNET_BLOCK_TYPE_DHT_HELLO == bd.type) 2235 if (GNUNET_BLOCK_TYPE_DHT_HELLO == bd.type)
2323 { 2236 {
@@ -2352,7 +2265,7 @@ handle_dht_p2p_result (void *cls,
2352 /* First, check if 'peer' is already on the path, and if 2265 /* First, check if 'peer' is already on the path, and if
2353 so, truncate it instead of expanding. */ 2266 so, truncate it instead of expanding. */
2354 for (unsigned int i = 0; i <= get_path_length; i++) 2267 for (unsigned int i = 0; i <= get_path_length; i++)
2355 if (0 == GNUNET_memcmp (&get_path[i], 2268 if (0 == GNUNET_memcmp (&get_path[i].pred,
2356 peer->id)) 2269 peer->id))
2357 { 2270 {
2358 process_reply_with_path (&bd, 2271 process_reply_with_path (&bd,
@@ -2363,12 +2276,15 @@ handle_dht_p2p_result (void *cls,
2363 2276
2364 /* Need to append 'peer' to 'get_path' (normal case) */ 2277 /* Need to append 'peer' to 'get_path' (normal case) */
2365 { 2278 {
2366 struct GNUNET_PeerIdentity xget_path[get_path_length + 1]; 2279 struct GNUNET_DHT_PathElement xget_path[get_path_length + 1];
2367 2280
2368 GNUNET_memcpy (xget_path, 2281 GNUNET_memcpy (xget_path,
2369 get_path, 2282 get_path,
2370 get_path_length * sizeof(struct GNUNET_PeerIdentity)); 2283 get_path_length * sizeof(struct GNUNET_DHT_PathElement));
2371 xget_path[get_path_length] = *peer->id; 2284 xget_path[get_path_length].pred = *peer->id;
2285 memset (&xget_path[get_path_length].sig,
2286 0,
2287 sizeof (xget_path[get_path_length].sig));
2372 process_reply_with_path (&bd, 2288 process_reply_with_path (&bd,
2373 &prm->key, 2289 &prm->key,
2374 get_path_length + 1, xget_path); 2290 get_path_length + 1, xget_path);
@@ -2411,8 +2327,6 @@ GDS_NEIGHBOURS_init ()
2411 "DHT", 2327 "DHT",
2412 "CACHE_RESULTS"); 2328 "CACHE_RESULTS");
2413 2329
2414 log_route_details_stderr =
2415 (NULL != getenv ("GNUNET_DHT_ROUTE_DEBUG")) ? GNUNET_YES : GNUNET_NO;
2416 ats_ch = GNUNET_ATS_connectivity_init (GDS_cfg); 2330 ats_ch = GNUNET_ATS_connectivity_init (GDS_cfg);
2417 core_api = GNUNET_CORE_connect (GDS_cfg, 2331 core_api = GNUNET_CORE_connect (GDS_cfg,
2418 NULL, 2332 NULL,