aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorgrothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96>2012-10-30 14:12:44 +0000
committergrothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96>2012-10-30 14:12:44 +0000
commit88050a09341dfb3926254cbdcdee44dda62c52b6 (patch)
tree4f928194bb35986981cb392b156d996eb8cfea8b /src/gns
parent373a6400a90868afc365a1d4b51f00d7f6424236 (diff)
-some gns code cleanup, still a mess
git-svn-id: https://gnunet.org/svn/gnunet@24607 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/gnunet-service-gns.c4
-rw-r--r--src/gns/gnunet-service-gns_interceptor.c2
-rw-r--r--src/gns/gnunet-service-gns_resolver.c123
-rw-r--r--src/gns/gnunet-service-gns_resolver.h4
-rw-r--r--src/gns/test_gns_dht_delegated_lookup.c35
-rw-r--r--src/gns/test_gns_dht_three_peers.c28
-rw-r--r--src/gns/test_gns_max_queries.c5
-rw-r--r--src/gns/test_gns_pseu_shorten.c56
-rw-r--r--src/gns/test_gns_revocation.c26
-rw-r--r--src/gns/test_gns_simple_delegated_lookup.c189
-rw-r--r--src/gns/test_gns_simple_get_authority.c20
-rw-r--r--src/gns/test_gns_simple_mx_lookup.c25
-rw-r--r--src/gns/test_gns_simple_shorten.c19
-rw-r--r--src/gns/test_gns_simple_srv_lookup.c12
-rw-r--r--src/gns/test_gns_simple_zkey_lookup.c34
15 files changed, 235 insertions, 347 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index dc22efdab8..79c453406b 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -815,7 +815,7 @@ handle_shorten (void *cls,
GNUNET_CONTAINER_DLL_insert (csh_head, csh_tail, csh);
GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr);
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "SHORTEN: Converted `%s' to `%s'\n",
+ "SHORTEN: Converted `%s' to `%s'\n",
utf_in,
nameptr);
GNUNET_SERVER_notification_context_add (nc, client);
@@ -837,7 +837,7 @@ handle_shorten (void *cls,
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
- if ( (! is_gnunet_tld (name)) &&
+ if ( (! is_gads_tld (name)) &&
(! is_zkey_tld (name)) )
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/gns/gnunet-service-gns_interceptor.c b/src/gns/gnunet-service-gns_interceptor.c
index 9c1c3a6666..828efc39e2 100644
--- a/src/gns/gnunet-service-gns_interceptor.c
+++ b/src/gns/gnunet-service-gns_interceptor.c
@@ -312,7 +312,7 @@ handle_dns_request (void *cls,
* Check for .gads/.zkey
*/
- if ((is_gnunet_tld(p->queries[0].name) == GNUNET_YES) ||
+ if ((is_gads_tld(p->queries[0].name) == GNUNET_YES) ||
(is_zkey_tld(p->queries[0].name) == GNUNET_YES) ||
(strcmp(p->queries[0].name, GNUNET_GNS_TLD) == 0))
{
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 40efc8bd80..641e042ba5 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -953,7 +953,7 @@ dht_lookup_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
char new_name[MAX_DNS_NAME_LENGTH];
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_REC-%llu: dht lookup for query %s (%llus)timed out.\n",
+ "GNS_PHASE_REC-%llu: dht lookup for query %s (%llus) timed out.\n",
rh->id, rh->name, rh->timeout.rel_value);
/**
* Start resolution in bg
@@ -2037,7 +2037,8 @@ dht_authority_lookup_timeout(void *cls,
*
* @param rh the pending gns query
*/
-static void resolve_delegation_dht(struct ResolverHandle *rh);
+static void
+resolve_delegation_dht(struct ResolverHandle *rh);
/**
@@ -2045,7 +2046,8 @@ static void resolve_delegation_dht(struct ResolverHandle *rh);
*
* @param rh the resolver handle
*/
-static void resolve_delegation_ns(struct ResolverHandle *rh);
+static void
+resolve_delegation_ns(struct ResolverHandle *rh);
/**
@@ -2192,15 +2194,15 @@ on_namestore_delegation_put_result(void *cls,
* @param data the record data
*/
static void
-process_delegation_result_dht(void* cls,
- struct GNUNET_TIME_Absolute exp,
- const struct GNUNET_HashCode * key,
- const struct GNUNET_PeerIdentity *get_path,
- unsigned int get_path_length,
- const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_length,
- enum GNUNET_BLOCK_Type type,
- size_t size, const void *data)
+process_delegation_result_dht (void* cls,
+ struct GNUNET_TIME_Absolute exp,
+ const struct GNUNET_HashCode * key,
+ const struct GNUNET_PeerIdentity *get_path,
+ unsigned int get_path_length,
+ const struct GNUNET_PeerIdentity *put_path,
+ unsigned int put_path_length,
+ enum GNUNET_BLOCK_Type type,
+ size_t size, const void *data)
{
struct ResolverHandle *rh = cls;
struct GNSNameRecordBlock *nrb;
@@ -2478,7 +2480,7 @@ finish_lookup (struct ResolverHandle *rh,
unsigned int rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd)
{
- int i;
+ unsigned int i;
char new_rr_data[MAX_DNS_NAME_LENGTH];
char new_mx_data[MAX_MX_LENGTH];
char new_soa_data[MAX_SOA_LENGTH];
@@ -2709,8 +2711,8 @@ handle_record_ns (void* cls, struct ResolverHandle *rh,
* @param name the domain
* @param dest the destination where the tld will be put
*/
-void
-pop_tld(char* name, char* dest)
+static void
+pop_tld (char* name, char* dest)
{
uint32_t len;
@@ -2776,10 +2778,8 @@ handle_delegation_dht(void* cls, struct ResolverHandle *rh,
unsigned int rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd)
{
- struct RecordLookupHandle* rlh;
- rlh = cls;
+ struct RecordLookupHandle* rlh = cls;
-
if (0 == strcmp(rh->name, ""))
{
if (GNUNET_GNS_RECORD_PKEY == rlh->record_type)
@@ -3114,25 +3114,24 @@ handle_delegation_ns (void* cls, struct ResolverHandle *rh,
*/
static void
process_delegation_result_ns (void* cls,
- const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key,
- struct GNUNET_TIME_Absolute expiration,
- const char *name,
- unsigned int rd_count,
- const struct GNUNET_NAMESTORE_RecordData *rd,
- const struct GNUNET_CRYPTO_RsaSignature *signature)
+ const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key,
+ struct GNUNET_TIME_Absolute expiration,
+ const char *name,
+ unsigned int rd_count,
+ const struct GNUNET_NAMESTORE_RecordData *rd,
+ const struct GNUNET_CRYPTO_RsaSignature *signature)
{
- struct ResolverHandle *rh;
+ struct ResolverHandle *rh = cls;
struct GNUNET_TIME_Relative remaining_time;
struct GNUNET_CRYPTO_ShortHashCode zone;
char new_name[MAX_DNS_NAME_LENGTH];
unsigned int i;
struct GNUNET_TIME_Absolute et;
- rh = (struct ResolverHandle *)cls;
rh->namestore_task = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_DELEGATE_NS-%llu: Got %d records from authority lookup\n",
- rh->id, rd_count);
+ "GNS_PHASE_DELEGATE_NS-%llu: Got %d records from authority lookup\n",
+ rh->id, rd_count);
GNUNET_CRYPTO_short_hash (key,
sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
@@ -3305,13 +3304,12 @@ process_delegation_result_ns (void* cls,
rh->rd_count = 1;
/* Check for key revocation and delegate */
rh->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle,
- &rh->authority,
- "+",
- GNUNET_GNS_RECORD_REV,
- &process_pkey_revocation_result_ns,
- rh);
+ &rh->authority,
+ "+",
+ GNUNET_GNS_RECORD_REV,
+ &process_pkey_revocation_result_ns,
+ rh);
return;
-
}
/**
@@ -3360,17 +3358,17 @@ process_delegation_result_ns (void* cls,
static void
resolve_delegation_ns (struct ResolverHandle *rh)
{
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_DELEGATE_NS-%llu: Resolving delegation for %s\n",
- rh->id, rh->name);
- pop_tld(rh->name, rh->authority_name);
- rh->namestore_task = GNUNET_NAMESTORE_lookup_record(namestore_handle,
- &rh->authority,
- rh->authority_name,
- GNUNET_GNS_RECORD_ANY,
- &process_delegation_result_ns,
- rh);
-
+ pop_tld (rh->name, rh->authority_name);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "GNS_PHASE_DELEGATE_NS-%llu: Resolving delegation for %s by looking up %s\n",
+ rh->id, rh->name,
+ rh->authority_name);
+ rh->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle,
+ &rh->authority,
+ rh->authority_name,
+ GNUNET_GNS_RECORD_ANY,
+ &process_delegation_result_ns,
+ rh);
}
@@ -3409,7 +3407,6 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone,
"Starting resolution for %s (type=%d)!\n",
name, record_type);
-
if ((is_canonical ((char*)name) == GNUNET_YES) &&
(strcmp(GNUNET_GNS_TLD, name) != 0))
{
@@ -3421,18 +3418,13 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone,
rlh = GNUNET_malloc (sizeof(struct RecordLookupHandle));
rh = GNUNET_malloc (sizeof (struct ResolverHandle));
-
- memset (rh, 0, sizeof (struct ResolverHandle));
rh->authority = zone;
rh->id = rid++;
rh->proc_cls = rlh;
rh->priv_key = key;
rh->timeout = timeout;
- rh->get_handle = NULL;
rh->private_local_zone = pzone;
rh->only_cached = only_cached;
- rh->namestore_task = NULL;
- rh->rd.data = NULL;
GNUNET_CONTAINER_DLL_insert (rlh_head, rlh_tail, rh);
@@ -3506,17 +3498,16 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone,
}
}
- else if (is_gnunet_tld (name) == GNUNET_YES)
+ else if (is_gads_tld (name) == GNUNET_YES)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "TLD is gnunet\n");
+ "TLD is gads\n");
/**
- * Presumably GNUNET tld
+ * Presumably GADS tld
*/
- memset (rh->name, 0,
- strlen(name)-strlen(GNUNET_GNS_TLD));
memcpy (rh->name, name,
- strlen(name)-strlen(GNUNET_GNS_TLD) - 1);
+ strlen (name) - strlen(GNUNET_GNS_TLD) - 1);
+ rh->name[strlen (name) - strlen(GNUNET_GNS_TLD) - 1] = '\0';
}
else
{
@@ -3536,9 +3527,7 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone,
/**
* Initialize authority chain
*/
- rh->authority_chain_head = GNUNET_malloc(sizeof(struct AuthorityChain));
- rh->authority_chain_head->prev = NULL;
- rh->authority_chain_head->next = NULL;
+ rh->authority_chain_head = GNUNET_malloc (sizeof(struct AuthorityChain));
rh->authority_chain_tail = rh->authority_chain_head;
rh->authority_chain_head->zone = rh->authority;
strcpy (rh->authority_chain_head->name, "");
@@ -3614,7 +3603,7 @@ process_zone_to_name_shorten_shorten (void *cls,
const struct GNUNET_NAMESTORE_RecordData *rd,
const struct GNUNET_CRYPTO_RsaSignature *signature)
{
- struct ResolverHandle *rh = (struct ResolverHandle *)cls;
+ struct ResolverHandle *rh = cls;
struct NameShortenHandle* nsh = (struct NameShortenHandle*)rh->proc_cls;
struct AuthorityChain *next_authority;
@@ -3730,7 +3719,7 @@ process_zone_to_name_shorten_private (void *cls,
const struct GNUNET_NAMESTORE_RecordData *rd,
const struct GNUNET_CRYPTO_RsaSignature *signature)
{
- struct ResolverHandle *rh = (struct ResolverHandle *)cls;
+ struct ResolverHandle *rh = cls;
struct NameShortenHandle* nsh = (struct NameShortenHandle*)rh->proc_cls;
struct AuthorityChain *next_authority;
@@ -3845,10 +3834,9 @@ process_zone_to_name_shorten_root (void *cls,
const struct GNUNET_NAMESTORE_RecordData *rd,
const struct GNUNET_CRYPTO_RsaSignature *signature)
{
- struct ResolverHandle *rh = (struct ResolverHandle *)cls;
+ struct ResolverHandle *rh = cls;
struct NameShortenHandle* nsh = (struct NameShortenHandle*)rh->proc_cls;
struct AuthorityChain *next_authority;
-
char result[MAX_DNS_NAME_LENGTH];
char tmp_name[MAX_DNS_NAME_LENGTH];
size_t answer_len;
@@ -4150,7 +4138,6 @@ gns_resolver_shorten_name (struct GNUNET_CRYPTO_ShortHashCode *zone,
char nzkey[MAX_DNS_LABEL_LENGTH];
char* nzkey_ptr = nzkey;
-
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting shorten for %s!\n", name);
@@ -4224,7 +4211,7 @@ gns_resolver_shorten_name (struct GNUNET_CRYPTO_ShortHashCode *zone,
return;
}
- else if (is_gnunet_tld (name) == GNUNET_YES)
+ else if (is_gads_tld (name) == GNUNET_YES)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"TLD is gnunet\n");
@@ -4276,6 +4263,7 @@ finish_get_auth (struct ResolverHandle *rh,
free_resolver_handle (rh);
}
+
/**
* Process result from namestore delegation lookup
* for get authority operation
@@ -4338,8 +4326,6 @@ handle_delegation_result_ns_get_auth(void* cls,
strcpy(nah->result, "");
finish_get_auth (rh, nah);
}
-
-
}
@@ -4371,7 +4357,6 @@ gns_resolver_get_authority(struct GNUNET_CRYPTO_ShortHashCode zone,
rh->authority = zone;
rh->id = rid++;
rh->private_local_zone = pzone;
- rh->namestore_task = NULL;
GNUNET_CONTAINER_DLL_insert (nah_head, nah_tail, rh);
diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h
index e8bb746975..466e931756 100644
--- a/src/gns/gnunet-service-gns_resolver.h
+++ b/src/gns/gnunet-service-gns_resolver.h
@@ -637,9 +637,9 @@ is_tld (const char* name,
/**
- * Checks for gnunet/zkey
+ * Checks for gads/zkey
*/
-#define is_gnunet_tld(name) is_tld(name, GNUNET_GNS_TLD)
+#define is_gads_tld(name) is_tld(name, GNUNET_GNS_TLD)
#define is_zkey_tld(name) is_tld(name, GNUNET_GNS_TLD_ZKEY)
diff --git a/src/gns/test_gns_dht_delegated_lookup.c b/src/gns/test_gns_dht_delegated_lookup.c
index 0fcd723e34..f9531751ad 100644
--- a/src/gns/test_gns_dht_delegated_lookup.c
+++ b/src/gns/test_gns_dht_delegated_lookup.c
@@ -33,18 +33,12 @@
#include "gnunet_dht_service.h"
#include "gnunet_gns_service.h"
-/* DEFINES */
-#define VERBOSE GNUNET_YES
-
/* Timeout for entire testcase */
#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20)
/* Timeout for entire testcase */
#define DHT_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
-/* If number of peers not in config file, use this number */
-#define DEFAULT_NUM_PEERS 2
-
/* test records to resolve */
#define TEST_DOMAIN "www.bob.gads"
#define TEST_IP "127.0.0.1"
@@ -56,11 +50,9 @@
#define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"
-/* Globals */
-
/* Task handle to use to schedule test failure */
-GNUNET_SCHEDULER_TaskIdentifier die_task;
-GNUNET_SCHEDULER_TaskIdentifier wait_task;
+static GNUNET_SCHEDULER_TaskIdentifier die_task;
+static GNUNET_SCHEDULER_TaskIdentifier wait_task;
/* Global return value (0 for success, anything else for failure) */
static int ok;
@@ -71,12 +63,12 @@ static struct GNUNET_GNS_Handle *gns_handle;
static struct GNUNET_DHT_Handle *dht_handle;
-const struct GNUNET_CONFIGURATION_Handle *cfg;
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
-struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey;
-struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey;
-struct GNUNET_CRYPTO_RsaPrivateKey *alice_key;
-struct GNUNET_CRYPTO_RsaPrivateKey *bob_key;
+static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey;
+static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey;
+static struct GNUNET_CRYPTO_RsaPrivateKey *alice_key;
+static struct GNUNET_CRYPTO_RsaPrivateKey *bob_key;
/**
@@ -110,6 +102,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
ok = 1;
}
+
static void
end_badly_now ()
{
@@ -123,14 +116,17 @@ end_badly_now ()
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
}
-static void shutdown_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+
+static void
+shutdown_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_GNS_disconnect(gns_handle);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n");
GNUNET_SCHEDULER_shutdown ();
}
+
static void
on_lookup_result(void *cls, uint32_t rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd)
@@ -295,6 +291,7 @@ put_dht(void *cls, int32_t success, const char *emsg)
wait_task = GNUNET_SCHEDULER_add_delayed(DHT_DELAY, &commence_testing, NULL);
}
+
static void
do_check (void *cls,
const struct GNUNET_CONFIGURATION_Handle *ccfg,
@@ -364,11 +361,7 @@ main (int argc, char *argv[])
ok = 1;
GNUNET_log_setup ("test-gns-dht-delegated-lookup",
-#if VERBOSE
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
GNUNET_TESTING_peer_run ("test-gns-dht-delegated-lookup", "test_gns_simple_lookup.conf", &do_check, NULL);
return ok;
diff --git a/src/gns/test_gns_dht_three_peers.c b/src/gns/test_gns_dht_three_peers.c
index a7bad9bbac..2a109559fa 100644
--- a/src/gns/test_gns_dht_three_peers.c
+++ b/src/gns/test_gns_dht_three_peers.c
@@ -42,14 +42,9 @@
#define ZONE_PUT_WAIT_TIME GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
-/* If number of peers not in config file, use this number */
-#define DEFAULT_NUM_PEERS 2
-
#define TEST_DOMAIN "www.buddy.bob.gads"
#define TEST_IP "1.1.1.1"
#define TEST_DAVE_PSEU "hagbard"
-#define TEST_NUM_PEERS 3
-#define TEST_NUM_CON 3
/* Timeout for entire testcase */
@@ -59,22 +54,23 @@
static int ok;
/* Task handle to use to schedule test failure */
-GNUNET_SCHEDULER_TaskIdentifier die_task;
-GNUNET_SCHEDULER_TaskIdentifier wait_task;
+static GNUNET_SCHEDULER_TaskIdentifier die_task;
+
+static GNUNET_SCHEDULER_TaskIdentifier wait_task;
-struct GNUNET_CRYPTO_ShortHashCode dave_hash;
+static struct GNUNET_CRYPTO_ShortHashCode dave_hash;
-struct GNUNET_CRYPTO_ShortHashCode bob_hash;
+static struct GNUNET_CRYPTO_ShortHashCode bob_hash;
-struct GNUNET_TESTBED_Peer **cpeers;
+static struct GNUNET_TESTBED_Peer **cpeers;
-struct GNUNET_GNS_Handle *gh;
-struct GNUNET_GNS_LookupRequest *lookup_handle;
+static struct GNUNET_GNS_Handle *gh;
+static struct GNUNET_GNS_LookupRequest *lookup_handle;
-struct GNUNET_TESTBED_Operation *get_cfg_ops[3];
-struct GNUNET_TESTBED_Operation *connect_ops[3];
-struct GNUNET_CONFIGURATION_Handle *cfg_handles[3];
-struct GNUNET_NAMESTORE_Handle *nh[3];
+static struct GNUNET_TESTBED_Operation *get_cfg_ops[3];
+static struct GNUNET_TESTBED_Operation *connect_ops[3];
+static struct GNUNET_CONFIGURATION_Handle *cfg_handles[3];
+static struct GNUNET_NAMESTORE_Handle *nh[3];
static int dave_is_setup;
static int bob_is_setup;
diff --git a/src/gns/test_gns_max_queries.c b/src/gns/test_gns_max_queries.c
index d06f4ebed8..fae90bf72d 100644
--- a/src/gns/test_gns_max_queries.c
+++ b/src/gns/test_gns_max_queries.c
@@ -36,9 +36,6 @@
/* Timeout for entire testcase */
#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20)
-/* If number of peers not in config file, use this number */
-#define DEFAULT_NUM_PEERS 2
-
/* test records to resolve */
#define TEST_DOMAIN "www.gads"
#define TEST_DOMAIN_NACK "doesnotexist.bob.gads"
@@ -49,8 +46,6 @@
#define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"
-/* Globals */
-
/* Task handle to use to schedule test failure */
static GNUNET_SCHEDULER_TaskIdentifier die_task;
diff --git a/src/gns/test_gns_pseu_shorten.c b/src/gns/test_gns_pseu_shorten.c
index 8f279bb554..74f41398d0 100644
--- a/src/gns/test_gns_pseu_shorten.c
+++ b/src/gns/test_gns_pseu_shorten.c
@@ -33,15 +33,9 @@
#include "gnunet_dht_service.h"
#include "gnunet_gns_service.h"
-/* DEFINES */
-#define VERBOSE GNUNET_YES
-
/* Timeout for entire testcase */
#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30)
-/* If number of peers not in config file, use this number */
-#define DEFAULT_NUM_PEERS 2
-
/* test records to resolve */
#define TEST_DOMAIN "www.alicewonderland.bobbuilder.gads"
#define TEST_IP "127.0.0.1"
@@ -75,23 +69,23 @@ static struct GNUNET_GNS_Handle *gns_handle;
static struct GNUNET_DHT_Handle *dht_handle;
-const struct GNUNET_CONFIGURATION_Handle *cfg;
-
-struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey;
-struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey;
-struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded our_pkey;
-struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded priv_pkey;
-struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded short_pkey;
-struct GNUNET_CRYPTO_RsaPrivateKey *alice_key;
-struct GNUNET_CRYPTO_RsaPrivateKey *bob_key;
-struct GNUNET_CRYPTO_RsaPrivateKey *our_key;
-struct GNUNET_CRYPTO_RsaPrivateKey *priv_key;
-struct GNUNET_CRYPTO_RsaPrivateKey *short_key;
-struct GNUNET_CRYPTO_ShortHashCode alice_hash;
-struct GNUNET_CRYPTO_ShortHashCode bob_hash;
-struct GNUNET_CRYPTO_ShortHashCode our_zone;
-struct GNUNET_CRYPTO_ShortHashCode priv_zone;
-struct GNUNET_CRYPTO_ShortHashCode short_zone;
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey;
+static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey;
+static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded our_pkey;
+static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded priv_pkey;
+static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded short_pkey;
+static struct GNUNET_CRYPTO_RsaPrivateKey *alice_key;
+static struct GNUNET_CRYPTO_RsaPrivateKey *bob_key;
+static struct GNUNET_CRYPTO_RsaPrivateKey *our_key;
+static struct GNUNET_CRYPTO_RsaPrivateKey *priv_key;
+static struct GNUNET_CRYPTO_RsaPrivateKey *short_key;
+static struct GNUNET_CRYPTO_ShortHashCode alice_hash;
+static struct GNUNET_CRYPTO_ShortHashCode bob_hash;
+static struct GNUNET_CRYPTO_ShortHashCode our_zone;
+static struct GNUNET_CRYPTO_ShortHashCode priv_zone;
+static struct GNUNET_CRYPTO_ShortHashCode short_zone;
/**
@@ -126,6 +120,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
ok = 1;
}
+
static void
end_badly_now ()
{
@@ -133,8 +128,10 @@ end_badly_now ()
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
}
-static void shutdown_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+
+static void
+shutdown_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_GNS_disconnect(gns_handle);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n");
@@ -346,6 +343,7 @@ put_pseu_dht (void *cls, int success)
GNUNET_free (nrb);
}
+
static void
put_www_dht(void *cls, int success)
{
@@ -514,6 +512,7 @@ put_pkey_dht(void *cls, int32_t success, const char *emsg)
GNUNET_free (nrb);
}
+
static void
fin_init_zone (void *cls, int32_t success, const char *emsg)
{
@@ -552,6 +551,7 @@ cont_init_zone (void *cls, int32_t success, const char *emsg)
NULL);
}
+
static void
do_check (void *cls,
const struct GNUNET_CONFIGURATION_Handle *ccfg,
@@ -646,17 +646,13 @@ do_check (void *cls,
NULL);
}
+
int
main (int argc, char *argv[])
{
ok = 1;
-
GNUNET_log_setup ("test-gns-pseu-shorten",
-#if VERBOSE
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
GNUNET_TESTING_peer_run ("test-gns-pseu-shorten", "test_gns_simple_lookup.conf", &do_check, NULL);
return ok;
diff --git a/src/gns/test_gns_revocation.c b/src/gns/test_gns_revocation.c
index a538ab3e78..691d8c1240 100644
--- a/src/gns/test_gns_revocation.c
+++ b/src/gns/test_gns_revocation.c
@@ -32,15 +32,9 @@
#include "gnunet_dnsparser_lib.h"
#include "gnunet_gns_service.h"
-/* DEFINES */
-#define VERBOSE GNUNET_YES
-
/* Timeout for entire testcase */
#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20)
-/* If number of peers not in config file, use this number */
-#define DEFAULT_NUM_PEERS 2
-
/* test records to resolve */
#define TEST_DOMAIN "www.bob.gads"
#define TEST_IP "127.0.0.1"
@@ -50,10 +44,8 @@
#define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"
-/* Globals */
-
/* Task handle to use to schedule test failure */
-GNUNET_SCHEDULER_TaskIdentifier die_task;
+static GNUNET_SCHEDULER_TaskIdentifier die_task;
/* Global return value (0 for success, anything else for failure) */
static int ok;
@@ -62,7 +54,8 @@ static struct GNUNET_NAMESTORE_Handle *namestore_handle;
static struct GNUNET_GNS_Handle *gns_handle;
-const struct GNUNET_CONFIGURATION_Handle *cfg;
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
+
/**
* Check if the get_handle is being used, if so stop the request. Either
@@ -89,6 +82,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
ok = 1;
}
+
static void
end_badly_now ()
{
@@ -96,14 +90,17 @@ end_badly_now ()
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
}
-static void shutdown_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+
+static void
+shutdown_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_GNS_disconnect(gns_handle);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n");
GNUNET_SCHEDULER_shutdown ();
}
+
static void
on_lookup_result(void *cls, uint32_t rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd)
@@ -272,18 +269,13 @@ do_check (void *cls,
}
-
int
main (int argc, char *argv[])
{
ok = 1;
GNUNET_log_setup ("test-gns-revocation",
-#if VERBOSE
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
GNUNET_TESTING_peer_run ("test-gns-revocation", "test_gns_simple_lookup.conf", &do_check, NULL);
return ok;
diff --git a/src/gns/test_gns_simple_delegated_lookup.c b/src/gns/test_gns_simple_delegated_lookup.c
index b456e41120..c01bd8cce0 100644
--- a/src/gns/test_gns_simple_delegated_lookup.c
+++ b/src/gns/test_gns_simple_delegated_lookup.c
@@ -18,7 +18,7 @@
Boston, MA 02111-1307, USA.
*/
/**
- * @file gns/test_gns_twopeer.c
+ * @file gns/test_gns_simple_delegated_lookup.c
* @brief base testcase for testing DHT service with
* two running peers.
*
@@ -46,15 +46,9 @@
#include "gnunet_dnsparser_lib.h"
#include "gnunet_gns_service.h"
-/* DEFINES */
-#define VERBOSE GNUNET_YES
-
/* Timeout for entire testcase */
#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20)
-/* If number of peers not in config file, use this number */
-#define DEFAULT_NUM_PEERS 2
-
/* test records to resolve */
#define TEST_DOMAIN "www.bob.gads"
#define TEST_IP "127.0.0.1"
@@ -64,10 +58,8 @@
#define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"
-/* Globals */
-
/* Task handle to use to schedule test failure */
-GNUNET_SCHEDULER_TaskIdentifier die_task;
+static GNUNET_SCHEDULER_TaskIdentifier die_task;
/* Global return value (0 for success, anything else for failure) */
static int ok;
@@ -76,7 +68,8 @@ static struct GNUNET_NAMESTORE_Handle *namestore_handle;
static struct GNUNET_GNS_Handle *gns_handle;
-const struct GNUNET_CONFIGURATION_Handle *cfg;
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
+
/**
* Check if the get_handle is being used, if so stop the request. Either
@@ -92,7 +85,6 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_GNS_disconnect(gns_handle);
gns_handle = NULL;
}
-
if (NULL != namestore_handle)
{
GNUNET_NAMESTORE_disconnect (namestore_handle);
@@ -103,66 +95,60 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
ok = 1;
}
-void end_badly_now ()
-{
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
-}
-
-static void shutdown_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+static void
+shutdown_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- GNUNET_GNS_disconnect(gns_handle);
+ GNUNET_GNS_disconnect (gns_handle);
+ gns_handle = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n");
GNUNET_SCHEDULER_shutdown ();
}
+
static void
-on_lookup_result(void *cls, uint32_t rd_count,
- const struct GNUNET_NAMESTORE_RecordData *rd)
+on_lookup_result (void *cls, uint32_t rd_count,
+ const struct GNUNET_NAMESTORE_RecordData *rd)
{
+ const char *name = cls;
+ uint32_t i;
+ const char* addr;
struct in_addr a;
- int i;
- char* addr;
-
- if (GNUNET_SCHEDULER_NO_TASK != die_task)
- {
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_NO_TASK;
- }
GNUNET_NAMESTORE_disconnect (namestore_handle);
- if (rd_count == 0)
+ namestore_handle = NULL;
+ if (0 == rd_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Lookup failed, rp_filtering?\n");
+ "Lookup failed!\n");
ok = 2;
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ if (GNUNET_SCHEDULER_NO_TASK != die_task)
+ {
+ GNUNET_SCHEDULER_cancel (die_task);
+ die_task = GNUNET_SCHEDULER_NO_TASK;
}
- else
+ ok = 1;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "name: %s\n",
+ name);
+ for (i=0; i<rd_count; i++)
{
- ok = 1;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "name: %s\n", (char*)cls);
- for (i=0; i<rd_count; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "type: %d\n", rd[i].record_type);
- if (rd[i].record_type == GNUNET_GNS_RECORD_A)
- {
- 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;
- }
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No resolution!\n");
- }
- }
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "type: %d\n", rd[i].record_type);
+ if (rd[i].record_type != GNUNET_GNS_RECORD_A)
+ continue;
+ memcpy (&a, rd[i].data, sizeof (a));
+ addr = inet_ntoa (a);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "address: %s\n", addr);
+ if (0 != strcmp (addr, TEST_IP))
+ continue;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "%s correctly resolved to %s!\n", TEST_DOMAIN, addr);
+ ok = 0;
}
GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
}
@@ -175,28 +161,33 @@ on_lookup_result(void *cls, uint32_t rd_count,
static void
commence_testing (void *cls, int32_t success, const char *emsg)
{
-
+ if (NULL != emsg)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to store record in namestore: %s\n",
+ emsg);
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
gns_handle = GNUNET_GNS_connect(cfg);
-
if (NULL == gns_handle)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to connect to GNS!\n");
- end_badly_now();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
-
- GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_A,
- GNUNET_NO,
- NULL,
- &on_lookup_result, TEST_DOMAIN);
+ GNUNET_GNS_lookup (gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_A,
+ GNUNET_NO,
+ NULL,
+ &on_lookup_result, TEST_DOMAIN);
}
-
-void do_check (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *ccfg,
- struct GNUNET_TESTING_Peer *peer)
+static void
+do_check (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *ccfg,
+ struct GNUNET_TESTING_Peer *peer)
{
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey;
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey;
@@ -206,6 +197,9 @@ void do_check (void *cls,
struct GNUNET_CRYPTO_RsaSignature *sig;
char* alice_keyfile;
struct GNUNET_TIME_Absolute et;
+ struct GNUNET_NAMESTORE_RecordData rd;
+ const char* ip = TEST_IP;
+ struct in_addr web;
cfg = ccfg;
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
@@ -214,53 +208,45 @@ void do_check (void *cls,
namestore_handle = GNUNET_NAMESTORE_connect(cfg);
if (NULL == namestore_handle)
{
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to namestore\n");
- end_badly_now () ;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to connect to namestore\n");
+ GNUNET_SCHEDULER_shutdown ();
return;
}
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
- "ZONEKEY",
- &alice_keyfile))
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
+ "ZONEKEY",
+ &alice_keyfile))
{
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n");
- end_badly_now () ;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n");
+ GNUNET_SCHEDULER_shutdown ();
return;
}
-
alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (alice_keyfile);
bob_key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE_BOB);
-
GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey);
GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey);
-
- struct GNUNET_NAMESTORE_RecordData rd;
- char* ip = TEST_IP;
- struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr));
rd.expiration_time = UINT64_MAX;
- GNUNET_assert(1 == inet_pton (AF_INET, ip, web));
-
- GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
-
+ GNUNET_assert (1 == inet_pton (AF_INET, ip, &web));
+ GNUNET_CRYPTO_short_hash (&bob_pkey, sizeof(bob_pkey), &bob_hash);
rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
rd.data = &bob_hash;
rd.record_type = GNUNET_GNS_RECORD_PKEY;
rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
-
GNUNET_NAMESTORE_record_create (namestore_handle,
alice_key,
TEST_AUTHORITY_NAME,
&rd,
NULL,
NULL);
-
rd.data_size = sizeof(struct in_addr);
- rd.data = web;
+ rd.data = &web;
rd.record_type = GNUNET_DNSPARSER_TYPE_A;
- sig = GNUNET_NAMESTORE_create_signature(bob_key,
- GNUNET_TIME_UNIT_FOREVER_ABS,
- TEST_RECORD_NAME,
- &rd, 1);
+ sig = GNUNET_NAMESTORE_create_signature (bob_key,
+ GNUNET_TIME_UNIT_FOREVER_ABS,
+ TEST_RECORD_NAME,
+ &rd, 1);
et.abs_value = rd.expiration_time;
GNUNET_NAMESTORE_record_put (namestore_handle,
&bob_pkey,
@@ -271,12 +257,10 @@ void do_check (void *cls,
sig,
&commence_testing,
NULL);
-
- GNUNET_free (web);
GNUNET_free (sig);
GNUNET_free (alice_keyfile);
- GNUNET_CRYPTO_rsa_key_free(bob_key);
- GNUNET_CRYPTO_rsa_key_free(alice_key);
+ GNUNET_CRYPTO_rsa_key_free (bob_key);
+ GNUNET_CRYPTO_rsa_key_free (alice_key);
}
@@ -284,18 +268,13 @@ int
main (int argc, char *argv[])
{
ok = 1;
-
GNUNET_log_setup ("test-gns-simple-delegated-lookup",
-#if VERBOSE
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
-
- GNUNET_TESTING_peer_run ("test-gns-simple-delegated-lookup", "test_gns_simple_lookup.conf", &do_check, NULL);
-
+ GNUNET_TESTING_peer_run ("test-gns-simple-delegated-lookup",
+ "test_gns_simple_lookup.conf",
+ &do_check, NULL);
return ok;
}
-/* end of test_gns_twopeer.c */
+/* end of test_gns_simple_delegated_lookup.c */
diff --git a/src/gns/test_gns_simple_get_authority.c b/src/gns/test_gns_simple_get_authority.c
index 4a5406e987..66d93d6a2f 100644
--- a/src/gns/test_gns_simple_get_authority.c
+++ b/src/gns/test_gns_simple_get_authority.c
@@ -18,7 +18,7 @@
Boston, MA 02111-1307, USA.
*/
/**
- * @file gns/test_gns_simple_shorten.c
+ * @file gns/test_gns_simple_get_authority.c
* @brief basic shorten test for gns api
*
*/
@@ -32,15 +32,9 @@
#include "gnunet_dnsparser_lib.h"
#include "gnunet_gns_service.h"
-/* DEFINES */
-#define VERBOSE GNUNET_YES
-
/* Timeout for entire testcase */
#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20)
-/* If number of peers not in config file, use this number */
-#define DEFAULT_NUM_PEERS 2
-
/* test records to resolve */
#define TEST_DOMAIN "www.alice.bob.gads"
#define TEST_IP "127.0.0.1"
@@ -309,21 +303,17 @@ void do_check (void *cls,
GNUNET_CRYPTO_rsa_key_free (our_key);
}
+
int
main (int argc, char *argv[])
{
ok = 1;
-
GNUNET_log_setup ("test-gns-simple-get-authority",
-#if VERBOSE
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
-
- GNUNET_TESTING_peer_run ("test-gns-simple-get-authority", "test_gns_simple_lookup.conf", &do_check, NULL);
-
+ GNUNET_TESTING_peer_run ("test-gns-simple-get-authority",
+ "test_gns_simple_lookup.conf",
+ &do_check, NULL);
return ok;
}
diff --git a/src/gns/test_gns_simple_mx_lookup.c b/src/gns/test_gns_simple_mx_lookup.c
index a2fc311d47..812a157dbd 100644
--- a/src/gns/test_gns_simple_mx_lookup.c
+++ b/src/gns/test_gns_simple_mx_lookup.c
@@ -32,15 +32,9 @@
#include "gnunet_dnsparser_lib.h"
#include "gnunet_gns_service.h"
-/* DEFINES */
-#define VERBOSE GNUNET_YES
-
/* Timeout for entire testcase */
#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20)
-/* If number of peers not in config file, use this number */
-#define DEFAULT_NUM_PEERS 2
-
/* test records to resolve */
#define TEST_DOMAIN "bob.gads"
#define TEST_IP "127.0.0.1"
@@ -52,11 +46,8 @@
#define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"
-/* Globals */
-
-
/* Task handle to use to schedule test failure */
-GNUNET_SCHEDULER_TaskIdentifier die_task;
+static GNUNET_SCHEDULER_TaskIdentifier die_task;
/* Global return value (0 for success, anything else for failure) */
static int ok;
@@ -65,7 +56,7 @@ static struct GNUNET_NAMESTORE_Handle *namestore_handle;
static struct GNUNET_GNS_Handle *gns_handle;
-const struct GNUNET_CONFIGURATION_Handle *cfg;
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
/**
@@ -93,6 +84,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
ok = 1;
}
+
static void
end_badly_now ()
{
@@ -101,14 +93,16 @@ end_badly_now ()
}
-static void shutdown_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+static void
+shutdown_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_GNS_disconnect(gns_handle);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n");
GNUNET_SCHEDULER_shutdown ();
}
+
static void
on_lookup_result(void *cls, uint32_t rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd)
@@ -297,13 +291,8 @@ int
main (int argc, char *argv[])
{
ok = 1;
-
GNUNET_log_setup ("test-gns-simple-mx-lookup",
-#if VERBOSE
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
GNUNET_TESTING_peer_run ("test-gns-simple-mx-lookup", "test_gns_simple_lookup.conf", &do_check, NULL);
return ok;
diff --git a/src/gns/test_gns_simple_shorten.c b/src/gns/test_gns_simple_shorten.c
index 23305c8894..649dea59b1 100644
--- a/src/gns/test_gns_simple_shorten.c
+++ b/src/gns/test_gns_simple_shorten.c
@@ -32,15 +32,9 @@
#include "gnunet_dnsparser_lib.h"
#include "gnunet_gns_service.h"
-/* DEFINES */
-#define VERBOSE GNUNET_YES
-
/* Timeout for entire testcase */
#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20)
-/* If number of peers not in config file, use this number */
-#define DEFAULT_NUM_PEERS 2
-
/* test records to resolve */
#define TEST_DOMAIN "www.alice.bob.gads"
#define TEST_IP "127.0.0.1"
@@ -332,21 +326,18 @@ void do_check (void *cls,
}
+
int
main (int argc, char *argv[])
{
ok = 1;
-
GNUNET_log_setup ("test-gns-simple-shorten",
-#if VERBOSE
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
-
- GNUNET_TESTING_peer_run ("test-gns-simple-shorten", "test_gns_simple_lookup.conf", &do_check, NULL);
+ GNUNET_TESTING_peer_run ("test-gns-simple-shorten",
+ "test_gns_simple_lookup.conf",
+ &do_check, NULL);
return ok;
}
-/* end of test_gns_twopeer.c */
+/* end of test_gns_simple_shorten.c */
diff --git a/src/gns/test_gns_simple_srv_lookup.c b/src/gns/test_gns_simple_srv_lookup.c
index b3aec0e21c..564179d19f 100644
--- a/src/gns/test_gns_simple_srv_lookup.c
+++ b/src/gns/test_gns_simple_srv_lookup.c
@@ -33,15 +33,9 @@
#include "gns_protocol.h"
#include "gnunet_gns_service.h"
-/* DEFINES */
-#define VERBOSE GNUNET_YES
-
/* Timeout for entire testcase */
#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20)
-/* If number of peers not in config file, use this number */
-#define DEFAULT_NUM_PEERS 2
-
/* test records to resolve */
#define TEST_DOMAIN "_sip._tcp.bob.gads"
#define TEST_IP "127.0.0.1"
@@ -299,18 +293,12 @@ do_check (void *cls,
}
-
int
main (int argc, char *argv[])
{
ok = 1;
-
GNUNET_log_setup ("test-gns-simple-srv-lookup",
-#if VERBOSE
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
GNUNET_TESTING_peer_run ("test-gns-simple-srv-lookup", "test_gns_simple_lookup.conf", &do_check, NULL);
GNUNET_DISK_directory_remove ("test-gns-simple-srv-lookup");
diff --git a/src/gns/test_gns_simple_zkey_lookup.c b/src/gns/test_gns_simple_zkey_lookup.c
index a1cef1828d..4fbd6af729 100644
--- a/src/gns/test_gns_simple_zkey_lookup.c
+++ b/src/gns/test_gns_simple_zkey_lookup.c
@@ -33,15 +33,9 @@
#include "gnunet_gns_service.h"
#include "gns.h"
-/* DEFINES */
-#define VERBOSE GNUNET_YES
-
/* Timeout for entire testcase */
#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 40)
-/* If number of peers not in config file, use this number */
-#define DEFAULT_NUM_PEERS 2
-
/* test records to resolve */
#define TEST_IP "127.0.0.1"
#define TEST_RECORD_NAME "www"
@@ -50,10 +44,8 @@
#define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"
-/* Globals */
-
/* Task handle to use to schedule test failure */
-GNUNET_SCHEDULER_TaskIdentifier die_task;
+static GNUNET_SCHEDULER_TaskIdentifier die_task;
/* Global return value (0 for success, anything else for failure) */
static int ok;
@@ -62,9 +54,9 @@ static struct GNUNET_NAMESTORE_Handle *namestore_handle;
static struct GNUNET_GNS_Handle *gns_handle;
-const struct GNUNET_CONFIGURATION_Handle *cfg;
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
-struct GNUNET_CRYPTO_ShortHashCode bob_hash;
+static struct GNUNET_CRYPTO_ShortHashCode bob_hash;
/**
@@ -92,6 +84,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
ok = 1;
}
+
static void
end_badly_now ()
{
@@ -99,14 +92,17 @@ end_badly_now ()
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
}
-static void shutdown_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+
+static void
+shutdown_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_GNS_disconnect(gns_handle);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n");
GNUNET_SCHEDULER_shutdown ();
}
+
static void
on_lookup_result(void *cls, uint32_t rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd)
@@ -157,6 +153,8 @@ on_lookup_result(void *cls, uint32_t rd_count,
GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
}
+
+
/**
* Function scheduled to be run on the successful start of services
* tries to look up the dns record for TEST_DOMAIN
@@ -280,21 +278,17 @@ do_check (void *cls,
}
-
-
int
main (int argc, char *argv[])
{
ok = 1;
GNUNET_log_setup ("test-gns-simple-zkey-lookup",
-#if VERBOSE
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
- GNUNET_TESTING_peer_run ("test-gns-simple-zkey-lookup", "test_gns_simple_lookup.conf", &do_check, NULL);
+ GNUNET_TESTING_peer_run ("test-gns-simple-zkey-lookup",
+ "test_gns_simple_lookup.conf",
+ &do_check, NULL);
return ok;
}