aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-03-11 15:37:46 +0000
committerBart Polot <bart@net.in.tum.de>2013-03-11 15:37:46 +0000
commitce686a9d156f2509bc0bcc103869a4de9d4f2b5d (patch)
tree360e47e0f9d7356b70a0b48721c5f363bdeb5e9d /src/dht
parent8d1e0e240f2e843c0689d3dfe72fa251ef7c709a (diff)
downloadgnunet-ce686a9d156f2509bc0bcc103869a4de9d4f2b5d.tar.gz
gnunet-ce686a9d156f2509bc0bcc103869a4de9d4f2b5d.zip
BLOCK_EVALUATE regex PUT messages
- reorder debug info for easier following
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c115
1 files changed, 68 insertions, 47 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index 82ca5f549..12eebe753 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -49,6 +49,8 @@
49#include <fenv.h> 49#include <fenv.h>
50#include "dht.h" 50#include "dht.h"
51 51
52#include "../regex/regex_block_lib.h"
53
52 54
53#define LOG_TRAFFIC(kind,...) GNUNET_log_from (kind, "dht-traffic",__VA_ARGS__) 55#define LOG_TRAFFIC(kind,...) GNUNET_log_from (kind, "dht-traffic",__VA_ARGS__)
54 56
@@ -1586,6 +1588,21 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
1586 payload_size = 1588 payload_size =
1587 msize - (sizeof (struct PeerPutMessage) + 1589 msize - (sizeof (struct PeerPutMessage) +
1588 putlen * sizeof (struct GNUNET_PeerIdentity)); 1590 putlen * sizeof (struct GNUNET_PeerIdentity));
1591 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PUT for `%s' from %s\n",
1592 GNUNET_h2s (&put->key), GNUNET_i2s (peer));
1593 if (GNUNET_YES == log_route_details_stderr)
1594 {
1595 char *tmp;
1596
1597 tmp = GNUNET_strdup (GNUNET_i2s (&my_identity));
1598 LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, "XDHT PUT %s: %s->%s (%u, %u=>%u)\n",
1599 GNUNET_h2s (&put->key), GNUNET_i2s (peer), tmp,
1600 ntohl(put->hop_count),
1601 GNUNET_CRYPTO_hash_matching_bits (&peer->hashPubKey, &put->key),
1602 GNUNET_CRYPTO_hash_matching_bits (&my_identity.hashPubKey, &put->key)
1603 );
1604 GNUNET_free (tmp);
1605 }
1589 switch (GNUNET_BLOCK_get_key 1606 switch (GNUNET_BLOCK_get_key
1590 (GDS_block_context, ntohl (put->type), payload, payload_size, 1607 (GDS_block_context, ntohl (put->type), payload, payload_size,
1591 &test_key)) 1608 &test_key))
@@ -1604,24 +1621,31 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
1604 /* cannot verify, good luck */ 1621 /* cannot verify, good luck */
1605 break; 1622 break;
1606 } 1623 }
1607 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PUT for `%s' from %s\n", 1624 if (ntohl (put->type) == GNUNET_BLOCK_TYPE_REGEX) /* FIXME: do for all tpyes */
1608 GNUNET_h2s (&put->key), GNUNET_i2s (peer));
1609
1610 if (GNUNET_YES == log_route_details_stderr)
1611 { 1625 {
1612 char *tmp; 1626 switch (GNUNET_BLOCK_evaluate (GDS_block_context,
1627 ntohl (put->type),
1628 NULL, /* query */
1629 NULL, 0, /* bloom filer */
1630 NULL, 0, /* xquery */
1631 payload, payload_size))
1632 {
1633 case GNUNET_BLOCK_EVALUATION_OK_MORE:
1634 case GNUNET_BLOCK_EVALUATION_OK_LAST:
1635 break;
1613 1636
1614 tmp = GNUNET_strdup (GNUNET_i2s (&my_identity)); 1637 case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
1615 LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, "XDHT PUT %s: %s->%s (%u, %u=>%u)\n", 1638 case GNUNET_BLOCK_EVALUATION_RESULT_INVALID:
1616 GNUNET_h2s (&put->key), GNUNET_i2s (peer), tmp, 1639 case GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT:
1617 ntohl(put->hop_count), 1640 case GNUNET_BLOCK_EVALUATION_REQUEST_VALID:
1618 GNUNET_CRYPTO_hash_matching_bits (&peer->hashPubKey, &put->key), 1641 case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID:
1619 GNUNET_CRYPTO_hash_matching_bits (&my_identity.hashPubKey, &put->key) 1642 case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
1620 ); 1643 default:
1621 GNUNET_free (tmp); 1644 GNUNET_break_op (0);
1645 return GNUNET_OK;
1646 }
1622 } 1647 }
1623 1648
1624
1625 bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter, DHT_BLOOM_SIZE, 1649 bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter, DHT_BLOOM_SIZE,
1626 GNUNET_CONSTANTS_BLOOMFILTER_K); 1650 GNUNET_CONSTANTS_BLOOMFILTER_K);
1627 GNUNET_break_op (GNUNET_YES == 1651 GNUNET_break_op (GNUNET_YES ==
@@ -1809,14 +1833,30 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
1809 GNUNET_break_op (0); 1833 GNUNET_break_op (0);
1810 return GNUNET_YES; 1834 return GNUNET_YES;
1811 } 1835 }
1812 GNUNET_STATISTICS_update (GDS_stats,
1813 gettext_noop ("# P2P GET requests received"), 1,
1814 GNUNET_NO);
1815 reply_bf_size = msize - (sizeof (struct PeerGetMessage) + xquery_size); 1836 reply_bf_size = msize - (sizeof (struct PeerGetMessage) + xquery_size);
1816 type = ntohl (get->type); 1837 type = ntohl (get->type);
1817 options = ntohl (get->options); 1838 options = ntohl (get->options);
1818 xquery = (const char *) &get[1]; 1839 xquery = (const char *) &get[1];
1819 reply_bf = NULL; 1840 reply_bf = NULL;
1841 GNUNET_STATISTICS_update (GDS_stats,
1842 gettext_noop ("# P2P GET requests received"), 1,
1843 GNUNET_NO);
1844 if (GNUNET_YES == log_route_details_stderr)
1845 {
1846 char *tmp;
1847
1848 tmp = GNUNET_strdup (GNUNET_i2s (&my_identity));
1849 LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG,
1850 "XDHT GET %s: %s->%s (%u, %u=>%u) xq: %.*s\n",
1851 GNUNET_h2s (&get->key), GNUNET_i2s (peer), tmp,
1852 ntohl(get->hop_count),
1853 GNUNET_CRYPTO_hash_matching_bits (&peer->hashPubKey, &get->key),
1854 GNUNET_CRYPTO_hash_matching_bits (&my_identity.hashPubKey, &get->key),
1855 ntohl(get->xquery_size), xquery
1856 );
1857 GNUNET_free (tmp);
1858 }
1859
1820 if (reply_bf_size > 0) 1860 if (reply_bf_size > 0)
1821 reply_bf = 1861 reply_bf =
1822 GNUNET_CONTAINER_bloomfilter_init (&xquery[xquery_size], reply_bf_size, 1862 GNUNET_CONTAINER_bloomfilter_init (&xquery[xquery_size], reply_bf_size,
@@ -1870,22 +1910,6 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
1870 1, GNUNET_NO); 1910 1, GNUNET_NO);
1871 } 1911 }
1872 1912
1873 if (GNUNET_YES == log_route_details_stderr)
1874 {
1875 char *tmp;
1876
1877 tmp = GNUNET_strdup (GNUNET_i2s (&my_identity));
1878 LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG,
1879 "XDHT GET %s: %s->%s (%u, %u=>%u) xq: %.*s\n",
1880 GNUNET_h2s (&get->key), GNUNET_i2s (peer), tmp,
1881 ntohl(get->hop_count),
1882 GNUNET_CRYPTO_hash_matching_bits (&peer->hashPubKey, &get->key),
1883 GNUNET_CRYPTO_hash_matching_bits (&my_identity.hashPubKey, &get->key),
1884 ntohl(get->xquery_size), xquery
1885 );
1886 GNUNET_free (tmp);
1887 }
1888
1889 GDS_CLIENTS_process_get (options, 1913 GDS_CLIENTS_process_get (options,
1890 type, 1914 type,
1891 ntohl(get->hop_count), 1915 ntohl(get->hop_count),
@@ -1955,8 +1979,6 @@ handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer,
1955 GNUNET_break_op (0); 1979 GNUNET_break_op (0);
1956 return GNUNET_YES; 1980 return GNUNET_YES;
1957 } 1981 }
1958 GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# P2P RESULTS received"),
1959 1, GNUNET_NO);
1960 put_path = (const struct GNUNET_PeerIdentity *) &prm[1]; 1982 put_path = (const struct GNUNET_PeerIdentity *) &prm[1];
1961 get_path = &put_path[put_path_length]; 1983 get_path = &put_path[put_path_length];
1962 type = ntohl (prm->type); 1984 type = ntohl (prm->type);
@@ -1965,7 +1987,18 @@ handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer,
1965 msize - (sizeof (struct PeerResultMessage) + 1987 msize - (sizeof (struct PeerResultMessage) +
1966 (get_path_length + 1988 (get_path_length +
1967 put_path_length) * sizeof (struct GNUNET_PeerIdentity)); 1989 put_path_length) * sizeof (struct GNUNET_PeerIdentity));
1990 GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# P2P RESULTS received"),
1991 1, GNUNET_NO);
1992 if (GNUNET_YES == log_route_details_stderr)
1993 {
1994 char *tmp;
1968 1995
1996 tmp = GNUNET_strdup (GNUNET_i2s (&my_identity));
1997 LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, "XDHT RESULT %s: %s->%s (%u)\n",
1998 GNUNET_h2s (&prm->key), GNUNET_i2s (peer), tmp,
1999 get_path_length + 1);
2000 GNUNET_free (tmp);
2001 }
1969 /* if we got a HELLO, consider it for our own routing table */ 2002 /* if we got a HELLO, consider it for our own routing table */
1970 if (type == GNUNET_BLOCK_TYPE_DHT_HELLO) 2003 if (type == GNUNET_BLOCK_TYPE_DHT_HELLO)
1971 { 2004 {
@@ -2005,18 +2038,6 @@ handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer,
2005 } 2038 }
2006 } 2039 }
2007 2040
2008
2009 if (GNUNET_YES == log_route_details_stderr)
2010 {
2011 char *tmp;
2012
2013 tmp = GNUNET_strdup (GNUNET_i2s (&my_identity));
2014 LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, "XDHT RESULT %s: %s->%s (%u)\n",
2015 GNUNET_h2s (&prm->key), GNUNET_i2s (peer), tmp,
2016 get_path_length + 1);
2017 GNUNET_free (tmp);
2018 }
2019
2020 /* append 'peer' to 'get_path' */ 2041 /* append 'peer' to 'get_path' */
2021 { 2042 {
2022 struct GNUNET_PeerIdentity xget_path[get_path_length + 1]; 2043 struct GNUNET_PeerIdentity xget_path[get_path_length + 1];