[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20460 - in gnunet/src: gns namestore
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20460 - in gnunet/src: gns namestore |
Date: |
Mon, 12 Mar 2012 14:12:37 +0100 |
Author: schanzen
Date: 2012-03-12 14:12:37 +0100 (Mon, 12 Mar 2012)
New Revision: 20460
Modified:
gnunet/src/gns/Makefile.am
gnunet/src/gns/gns_api.c
gnunet/src/gns/gnunet-service-gns.c
gnunet/src/gns/plugin_block_gns.c
gnunet/src/gns/test_gns_dht_delegated_lookup.c
gnunet/src/namestore/namestore_common.c
Log:
-bugfixes, tests
Modified: gnunet/src/gns/Makefile.am
===================================================================
--- gnunet/src/gns/Makefile.am 2012-03-12 12:56:54 UTC (rev 20459)
+++ gnunet/src/gns/Makefile.am 2012-03-12 13:12:37 UTC (rev 20460)
@@ -30,7 +30,8 @@
test_gns_simple_shorten \
test_gns_simple_get_authority \
test_gns_simple_lookup \
- test_gns_simple_delegated_lookup
+ test_gns_simple_delegated_lookup \
+ test_gns_dht_delegated_lookup
# test_gns_simple_lookup
@@ -78,18 +79,20 @@
$(top_builddir)/src/gns/libgnunetgns.la \
$(top_builddir)/src/testing/libgnunettesting.la
-#test_gns_dht_delegated_lookup_SOURCES = \
-# test_gns_dht_delegated_lookup.c
-#test_gns_dht_delegated_lookup_LDADD = \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/namestore/libgnunetnamestore.la \
-# $(top_builddir)/src/dht/libgnunetdht.la \
-# $(top_builddir)/src/testing/libgnunettesting.la
-#test_gns_dht_delegated_lookup_DEPENDENCIES = \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/namestore/libgnunetnamestore.la \
-# $(top_builddir)/src/dht/libgnunetdht.la \
-# $(top_builddir)/src/testing/libgnunettesting.la
+test_gns_dht_delegated_lookup_SOURCES = \
+ test_gns_dht_delegated_lookup.c
+test_gns_dht_delegated_lookup_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/namestore/libgnunetnamestore.la \
+ $(top_builddir)/src/dht/libgnunetdht.la \
+ $(top_builddir)/src/gns/libgnunetgns.la \
+ $(top_builddir)/src/testing/libgnunettesting.la
+test_gns_dht_delegated_lookup_DEPENDENCIES = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/namestore/libgnunetnamestore.la \
+ $(top_builddir)/src/dht/libgnunetdht.la \
+ $(top_builddir)/src/gns/libgnunetgns.la \
+ $(top_builddir)/src/testing/libgnunettesting.la
test_gns_simple_shorten_SOURCES = \
test_gns_simple_shorten.c
Modified: gnunet/src/gns/gns_api.c
===================================================================
--- gnunet/src/gns/gns_api.c 2012-03-12 12:56:54 UTC (rev 20459)
+++ gnunet/src/gns/gns_api.c 2012-03-12 13:12:37 UTC (rev 20460)
@@ -636,7 +636,7 @@
}
msize = sizeof (struct GNUNET_GNS_ClientLookupMessage) + strlen(name) + 1;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to shorten %s in GNS\n", name);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to lookup %s in GNS\n", name);
qe = GNUNET_malloc(sizeof (struct GNUNET_GNS_QueueEntry));
qe->gns_handle = handle;
Modified: gnunet/src/gns/gnunet-service-gns.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns.c 2012-03-12 12:56:54 UTC (rev 20459)
+++ gnunet/src/gns/gnunet-service-gns.c 2012-03-12 13:12:37 UTC (rev 20460)
@@ -863,6 +863,8 @@
int rd_size;
GNUNET_HashCode zone, name_hash;
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Got DHT result\n");
+
if (data == NULL)
return;
Modified: gnunet/src/gns/plugin_block_gns.c
===================================================================
--- gnunet/src/gns/plugin_block_gns.c 2012-03-12 12:56:54 UTC (rev 20459)
+++ gnunet/src/gns/plugin_block_gns.c 2012-03-12 13:12:37 UTC (rev 20460)
@@ -75,6 +75,9 @@
uint32_t record_xquery;
unsigned int record_match;
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "BLOCK_TEST\n");
+
if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD)
return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
if (reply_block_size == 0)
@@ -90,6 +93,15 @@
GNUNET_CRYPTO_hash_xor(&pkey_hash, &name_hash, &query_key);
+ struct GNUNET_CRYPTO_HashAsciiEncoded xor_exp;
+ struct GNUNET_CRYPTO_HashAsciiEncoded xor_got;
+ GNUNET_CRYPTO_hash_to_enc (&query_key, &xor_exp);
+ GNUNET_CRYPTO_hash_to_enc (query, &xor_got);
+
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "BLOCK_TEST for %s got %s expected %s\n",
+ name, (char*) &xor_got, (char*) &xor_exp);
+
/* Check query key against public key */
if (0 != GNUNET_CRYPTO_hash_cmp(query, &query_key))
return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
@@ -124,6 +136,9 @@
{
exp = GNUNET_TIME_absolute_min (exp, rd[i].expiration);
+
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Got record of size %d\n", rd[i].data_size);
if ((record_xquery != 0)
&& (rd[i].record_type == record_xquery))
@@ -131,6 +146,10 @@
record_match++;
}
}
+
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Verifying signature of %d records for name %s\n",
+ rd_count, name);
if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&nrb->public_key,
exp,
@@ -144,9 +163,12 @@
}
}
- //No record matches query
if ((record_xquery != 0) && (record_match == 0))
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "No record matches query!\n");
return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
+ }
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Records match\n");
Modified: gnunet/src/gns/test_gns_dht_delegated_lookup.c
===================================================================
--- gnunet/src/gns/test_gns_dht_delegated_lookup.c 2012-03-12 12:56:54 UTC
(rev 20459)
+++ gnunet/src/gns/test_gns_dht_delegated_lookup.c 2012-03-12 13:12:37 UTC
(rev 20460)
@@ -83,6 +83,8 @@
static struct GNUNET_NAMESTORE_Handle *namestore_handle;
+static struct GNUNET_GNS_Handle *gns_handle;
+
static struct GNUNET_DHT_Handle *dht_handle;
const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -108,42 +110,39 @@
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "done(ret=%d)!\n", ok);
}
-/**
- * Function scheduled to be run on the successful start of services
- * tries to look up the dns record for TEST_DOMAIN
- */
+
static void
-finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+on_lookup_result(void *cls, uint32_t rd_count,
+ const struct GNUNET_NAMESTORE_RecordData *rd)
{
- struct hostent *he;
struct in_addr a;
+ int i;
char* addr;
-
- GNUNET_NAMESTORE_disconnect(namestore_handle, GNUNET_YES);
- GNUNET_DHT_disconnect(dht_handle);
-
- he = gethostbyname (TEST_DOMAIN);
-
- if (!he)
+
+ if (rd_count == 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "gethostbyname failed, rp_filtering?\n");
+ "Lookup failed, rp_filtering?\n");
ok = 2;
}
else
{
ok = 1;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "name: %s\n", he->h_name);
- while (*he->h_addr_list)
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "name: %s\n", (char*)cls);
+ for (i=0; i<rd_count; i++)
{
- memcpy(&a, *he->h_addr_list++, sizeof(a));
- addr = inet_ntoa(a);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "address: %s\n", addr);
- if (0 == strcmp(addr, TEST_IP))
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "type: %d\n", rd[i].record_type);
+ if (rd[i].record_type == GNUNET_GNS_RECORD_TYPE_A)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ memcpy(&a, rd[i].data, sizeof(a));
+ addr = inet_ntoa(a);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "address: %s\n", addr);
+ if (0 == strcmp(addr, TEST_IP))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"%s correctly resolved to %s!\n", TEST_DOMAIN, addr);
- ok = 0;
+ ok = 0;
+ }
}
else
{
@@ -156,7 +155,29 @@
GNUNET_YES, GNUNET_NO);
}
+
/**
+ * Function scheduled to be run on the successful start of services
+ * tries to look up the dns record for TEST_DOMAIN
+ */
+static void
+commence_testing (void *cls, int32_t success, const char *emsg)
+{
+ GNUNET_NAMESTORE_disconnect(namestore_handle, GNUNET_YES);
+
+ gns_handle = GNUNET_GNS_connect(cfg);
+
+ if (NULL == gns_handle)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to connect to GNS!\n");
+ }
+
+ GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A,
+ &on_lookup_result, TEST_DOMAIN);
+}
+
+/**
* Continuation for the GNUNET_DHT_get_stop call, so that we don't shut
* down the peers without freeing memory associated with GET request.
*/
@@ -214,7 +235,7 @@
nrb->public_key = bob_pkey;
nrb->rd_count = htonl(1);
memset(&nrb[1], 0, strlen(TEST_RECORD_NAME) + 1);
- memcpy(&nrb[1], TEST_RECORD_NAME, strlen(TEST_RECORD_NAME));
+ strcpy(&nrb[1], TEST_RECORD_NAME);
nrb_data = (char*)&nrb[1];
nrb_data += strlen(TEST_RECORD_NAME) + 1;
@@ -247,7 +268,7 @@
NULL,
NULL);
GNUNET_free (nrb);
- GNUNET_SCHEDULER_add_delayed(TIMEOUT, &finish_testing, NULL);
+ GNUNET_SCHEDULER_add_delayed(TIMEOUT, &commence_testing, NULL);
}
static void
@@ -345,7 +366,7 @@
int ret;
/* Arguments for GNUNET_PROGRAM_run */
- char *const argv[] = { "test-gns-simple-lookup", /* Name to give running
binary */
+ char *const argv[] = { "test-gns-dht-delegated-lookup", /* Name to give
running binary */
"-c",
"test_gns_simple_lookup.conf", /* Config file to use */
#if VERBOSE
@@ -359,12 +380,12 @@
/* Run the run function as a new program */
ret =
GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
- "test-gns-simple-lookup", "nohelp", options, &run,
+ "test-gns-dht-delegated-lookup", "nohelp", options,
&run,
&ok);
if (ret != GNUNET_OK)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "`test-gns-simple-lookup': Failed with error code %d\n", ret);
+ "`test-gns-dht-delegated-lookup': Failed with error code
%d\n", ret);
}
return ok;
}
Modified: gnunet/src/namestore/namestore_common.c
===================================================================
--- gnunet/src/namestore/namestore_common.c 2012-03-12 12:56:54 UTC (rev
20459)
+++ gnunet/src/namestore/namestore_common.c 2012-03-12 13:12:37 UTC (rev
20460)
@@ -86,7 +86,7 @@
ret = sizeof (struct NetworkRecord) * rd_count;
for (i=0;i<rd_count;i++)
{
- GNUNET_assert (ret + rd[i].data_size >= ret);
+ GNUNET_assert ((ret + rd[i].data_size) >= ret);
ret += rd[i].data_size;
}
return ret;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20460 - in gnunet/src: gns namestore,
gnunet <=