diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-10-30 14:12:44 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-10-30 14:12:44 +0000 |
commit | a93b33d6b2caa662d4f97ce8066512500a2c9986 (patch) | |
tree | 4f928194bb35986981cb392b156d996eb8cfea8b | |
parent | f4b7eb1607fc0f7a03088a1da028c0b8e7ef3633 (diff) | |
download | gnunet-a93b33d6b2caa662d4f97ce8066512500a2c9986.tar.gz gnunet-a93b33d6b2caa662d4f97ce8066512500a2c9986.zip |
-some gns code cleanup, still a mess
-rw-r--r-- | src/gns/gnunet-service-gns.c | 4 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_interceptor.c | 2 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 123 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.h | 4 | ||||
-rw-r--r-- | src/gns/test_gns_dht_delegated_lookup.c | 35 | ||||
-rw-r--r-- | src/gns/test_gns_dht_three_peers.c | 28 | ||||
-rw-r--r-- | src/gns/test_gns_max_queries.c | 5 | ||||
-rw-r--r-- | src/gns/test_gns_pseu_shorten.c | 56 | ||||
-rw-r--r-- | src/gns/test_gns_revocation.c | 26 | ||||
-rw-r--r-- | src/gns/test_gns_simple_delegated_lookup.c | 189 | ||||
-rw-r--r-- | src/gns/test_gns_simple_get_authority.c | 20 | ||||
-rw-r--r-- | src/gns/test_gns_simple_mx_lookup.c | 25 | ||||
-rw-r--r-- | src/gns/test_gns_simple_shorten.c | 19 | ||||
-rw-r--r-- | src/gns/test_gns_simple_srv_lookup.c | 12 | ||||
-rw-r--r-- | src/gns/test_gns_simple_zkey_lookup.c | 34 |
15 files changed, 235 insertions, 347 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index dc22efdab..79c453406 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -815,7 +815,7 @@ handle_shorten (void *cls, | |||
815 | GNUNET_CONTAINER_DLL_insert (csh_head, csh_tail, csh); | 815 | GNUNET_CONTAINER_DLL_insert (csh_head, csh_tail, csh); |
816 | GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr); | 816 | GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr); |
817 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 817 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
818 | "SHORTEN: Converted `%s' to `%s'\n", | 818 | "SHORTEN: Converted `%s' to `%s'\n", |
819 | utf_in, | 819 | utf_in, |
820 | nameptr); | 820 | nameptr); |
821 | GNUNET_SERVER_notification_context_add (nc, client); | 821 | GNUNET_SERVER_notification_context_add (nc, client); |
@@ -837,7 +837,7 @@ handle_shorten (void *cls, | |||
837 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 837 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
838 | return; | 838 | return; |
839 | } | 839 | } |
840 | if ( (! is_gnunet_tld (name)) && | 840 | if ( (! is_gads_tld (name)) && |
841 | (! is_zkey_tld (name)) ) | 841 | (! is_zkey_tld (name)) ) |
842 | { | 842 | { |
843 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 843 | 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 9c1c3a666..828efc39e 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, | |||
312 | * Check for .gads/.zkey | 312 | * Check for .gads/.zkey |
313 | */ | 313 | */ |
314 | 314 | ||
315 | if ((is_gnunet_tld(p->queries[0].name) == GNUNET_YES) || | 315 | if ((is_gads_tld(p->queries[0].name) == GNUNET_YES) || |
316 | (is_zkey_tld(p->queries[0].name) == GNUNET_YES) || | 316 | (is_zkey_tld(p->queries[0].name) == GNUNET_YES) || |
317 | (strcmp(p->queries[0].name, GNUNET_GNS_TLD) == 0)) | 317 | (strcmp(p->queries[0].name, GNUNET_GNS_TLD) == 0)) |
318 | { | 318 | { |
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 40efc8bd8..641e042ba 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) | |||
953 | char new_name[MAX_DNS_NAME_LENGTH]; | 953 | char new_name[MAX_DNS_NAME_LENGTH]; |
954 | 954 | ||
955 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 955 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
956 | "GNS_PHASE_REC-%llu: dht lookup for query %s (%llus)timed out.\n", | 956 | "GNS_PHASE_REC-%llu: dht lookup for query %s (%llus) timed out.\n", |
957 | rh->id, rh->name, rh->timeout.rel_value); | 957 | rh->id, rh->name, rh->timeout.rel_value); |
958 | /** | 958 | /** |
959 | * Start resolution in bg | 959 | * Start resolution in bg |
@@ -2037,7 +2037,8 @@ dht_authority_lookup_timeout(void *cls, | |||
2037 | * | 2037 | * |
2038 | * @param rh the pending gns query | 2038 | * @param rh the pending gns query |
2039 | */ | 2039 | */ |
2040 | static void resolve_delegation_dht(struct ResolverHandle *rh); | 2040 | static void |
2041 | resolve_delegation_dht(struct ResolverHandle *rh); | ||
2041 | 2042 | ||
2042 | 2043 | ||
2043 | /** | 2044 | /** |
@@ -2045,7 +2046,8 @@ static void resolve_delegation_dht(struct ResolverHandle *rh); | |||
2045 | * | 2046 | * |
2046 | * @param rh the resolver handle | 2047 | * @param rh the resolver handle |
2047 | */ | 2048 | */ |
2048 | static void resolve_delegation_ns(struct ResolverHandle *rh); | 2049 | static void |
2050 | resolve_delegation_ns(struct ResolverHandle *rh); | ||
2049 | 2051 | ||
2050 | 2052 | ||
2051 | /** | 2053 | /** |
@@ -2192,15 +2194,15 @@ on_namestore_delegation_put_result(void *cls, | |||
2192 | * @param data the record data | 2194 | * @param data the record data |
2193 | */ | 2195 | */ |
2194 | static void | 2196 | static void |
2195 | process_delegation_result_dht(void* cls, | 2197 | process_delegation_result_dht (void* cls, |
2196 | struct GNUNET_TIME_Absolute exp, | 2198 | struct GNUNET_TIME_Absolute exp, |
2197 | const struct GNUNET_HashCode * key, | 2199 | const struct GNUNET_HashCode * key, |
2198 | const struct GNUNET_PeerIdentity *get_path, | 2200 | const struct GNUNET_PeerIdentity *get_path, |
2199 | unsigned int get_path_length, | 2201 | unsigned int get_path_length, |
2200 | const struct GNUNET_PeerIdentity *put_path, | 2202 | const struct GNUNET_PeerIdentity *put_path, |
2201 | unsigned int put_path_length, | 2203 | unsigned int put_path_length, |
2202 | enum GNUNET_BLOCK_Type type, | 2204 | enum GNUNET_BLOCK_Type type, |
2203 | size_t size, const void *data) | 2205 | size_t size, const void *data) |
2204 | { | 2206 | { |
2205 | struct ResolverHandle *rh = cls; | 2207 | struct ResolverHandle *rh = cls; |
2206 | struct GNSNameRecordBlock *nrb; | 2208 | struct GNSNameRecordBlock *nrb; |
@@ -2478,7 +2480,7 @@ finish_lookup (struct ResolverHandle *rh, | |||
2478 | unsigned int rd_count, | 2480 | unsigned int rd_count, |
2479 | const struct GNUNET_NAMESTORE_RecordData *rd) | 2481 | const struct GNUNET_NAMESTORE_RecordData *rd) |
2480 | { | 2482 | { |
2481 | int i; | 2483 | unsigned int i; |
2482 | char new_rr_data[MAX_DNS_NAME_LENGTH]; | 2484 | char new_rr_data[MAX_DNS_NAME_LENGTH]; |
2483 | char new_mx_data[MAX_MX_LENGTH]; | 2485 | char new_mx_data[MAX_MX_LENGTH]; |
2484 | char new_soa_data[MAX_SOA_LENGTH]; | 2486 | char new_soa_data[MAX_SOA_LENGTH]; |
@@ -2709,8 +2711,8 @@ handle_record_ns (void* cls, struct ResolverHandle *rh, | |||
2709 | * @param name the domain | 2711 | * @param name the domain |
2710 | * @param dest the destination where the tld will be put | 2712 | * @param dest the destination where the tld will be put |
2711 | */ | 2713 | */ |
2712 | void | 2714 | static void |
2713 | pop_tld(char* name, char* dest) | 2715 | pop_tld (char* name, char* dest) |
2714 | { | 2716 | { |
2715 | uint32_t len; | 2717 | uint32_t len; |
2716 | 2718 | ||
@@ -2776,10 +2778,8 @@ handle_delegation_dht(void* cls, struct ResolverHandle *rh, | |||
2776 | unsigned int rd_count, | 2778 | unsigned int rd_count, |
2777 | const struct GNUNET_NAMESTORE_RecordData *rd) | 2779 | const struct GNUNET_NAMESTORE_RecordData *rd) |
2778 | { | 2780 | { |
2779 | struct RecordLookupHandle* rlh; | 2781 | struct RecordLookupHandle* rlh = cls; |
2780 | rlh = cls; | ||
2781 | 2782 | ||
2782 | |||
2783 | if (0 == strcmp(rh->name, "")) | 2783 | if (0 == strcmp(rh->name, "")) |
2784 | { | 2784 | { |
2785 | if (GNUNET_GNS_RECORD_PKEY == rlh->record_type) | 2785 | if (GNUNET_GNS_RECORD_PKEY == rlh->record_type) |
@@ -3114,25 +3114,24 @@ handle_delegation_ns (void* cls, struct ResolverHandle *rh, | |||
3114 | */ | 3114 | */ |
3115 | static void | 3115 | static void |
3116 | process_delegation_result_ns (void* cls, | 3116 | process_delegation_result_ns (void* cls, |
3117 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, | 3117 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, |
3118 | struct GNUNET_TIME_Absolute expiration, | 3118 | struct GNUNET_TIME_Absolute expiration, |
3119 | const char *name, | 3119 | const char *name, |
3120 | unsigned int rd_count, | 3120 | unsigned int rd_count, |
3121 | const struct GNUNET_NAMESTORE_RecordData *rd, | 3121 | const struct GNUNET_NAMESTORE_RecordData *rd, |
3122 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 3122 | const struct GNUNET_CRYPTO_RsaSignature *signature) |
3123 | { | 3123 | { |
3124 | struct ResolverHandle *rh; | 3124 | struct ResolverHandle *rh = cls; |
3125 | struct GNUNET_TIME_Relative remaining_time; | 3125 | struct GNUNET_TIME_Relative remaining_time; |
3126 | struct GNUNET_CRYPTO_ShortHashCode zone; | 3126 | struct GNUNET_CRYPTO_ShortHashCode zone; |
3127 | char new_name[MAX_DNS_NAME_LENGTH]; | 3127 | char new_name[MAX_DNS_NAME_LENGTH]; |
3128 | unsigned int i; | 3128 | unsigned int i; |
3129 | struct GNUNET_TIME_Absolute et; | 3129 | struct GNUNET_TIME_Absolute et; |
3130 | 3130 | ||
3131 | rh = (struct ResolverHandle *)cls; | ||
3132 | rh->namestore_task = NULL; | 3131 | rh->namestore_task = NULL; |
3133 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3132 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3134 | "GNS_PHASE_DELEGATE_NS-%llu: Got %d records from authority lookup\n", | 3133 | "GNS_PHASE_DELEGATE_NS-%llu: Got %d records from authority lookup\n", |
3135 | rh->id, rd_count); | 3134 | rh->id, rd_count); |
3136 | 3135 | ||
3137 | GNUNET_CRYPTO_short_hash (key, | 3136 | GNUNET_CRYPTO_short_hash (key, |
3138 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 3137 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
@@ -3305,13 +3304,12 @@ process_delegation_result_ns (void* cls, | |||
3305 | rh->rd_count = 1; | 3304 | rh->rd_count = 1; |
3306 | /* Check for key revocation and delegate */ | 3305 | /* Check for key revocation and delegate */ |
3307 | rh->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle, | 3306 | rh->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle, |
3308 | &rh->authority, | 3307 | &rh->authority, |
3309 | "+", | 3308 | "+", |
3310 | GNUNET_GNS_RECORD_REV, | 3309 | GNUNET_GNS_RECORD_REV, |
3311 | &process_pkey_revocation_result_ns, | 3310 | &process_pkey_revocation_result_ns, |
3312 | rh); | 3311 | rh); |
3313 | return; | 3312 | return; |
3314 | |||
3315 | } | 3313 | } |
3316 | 3314 | ||
3317 | /** | 3315 | /** |
@@ -3360,17 +3358,17 @@ process_delegation_result_ns (void* cls, | |||
3360 | static void | 3358 | static void |
3361 | resolve_delegation_ns (struct ResolverHandle *rh) | 3359 | resolve_delegation_ns (struct ResolverHandle *rh) |
3362 | { | 3360 | { |
3363 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 3361 | pop_tld (rh->name, rh->authority_name); |
3364 | "GNS_PHASE_DELEGATE_NS-%llu: Resolving delegation for %s\n", | 3362 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3365 | rh->id, rh->name); | 3363 | "GNS_PHASE_DELEGATE_NS-%llu: Resolving delegation for %s by looking up %s\n", |
3366 | pop_tld(rh->name, rh->authority_name); | 3364 | rh->id, rh->name, |
3367 | rh->namestore_task = GNUNET_NAMESTORE_lookup_record(namestore_handle, | 3365 | rh->authority_name); |
3368 | &rh->authority, | 3366 | rh->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle, |
3369 | rh->authority_name, | 3367 | &rh->authority, |
3370 | GNUNET_GNS_RECORD_ANY, | 3368 | rh->authority_name, |
3371 | &process_delegation_result_ns, | 3369 | GNUNET_GNS_RECORD_ANY, |
3372 | rh); | 3370 | &process_delegation_result_ns, |
3373 | 3371 | rh); | |
3374 | } | 3372 | } |
3375 | 3373 | ||
3376 | 3374 | ||
@@ -3409,7 +3407,6 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone, | |||
3409 | "Starting resolution for %s (type=%d)!\n", | 3407 | "Starting resolution for %s (type=%d)!\n", |
3410 | name, record_type); | 3408 | name, record_type); |
3411 | 3409 | ||
3412 | |||
3413 | if ((is_canonical ((char*)name) == GNUNET_YES) && | 3410 | if ((is_canonical ((char*)name) == GNUNET_YES) && |
3414 | (strcmp(GNUNET_GNS_TLD, name) != 0)) | 3411 | (strcmp(GNUNET_GNS_TLD, name) != 0)) |
3415 | { | 3412 | { |
@@ -3421,18 +3418,13 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone, | |||
3421 | 3418 | ||
3422 | rlh = GNUNET_malloc (sizeof(struct RecordLookupHandle)); | 3419 | rlh = GNUNET_malloc (sizeof(struct RecordLookupHandle)); |
3423 | rh = GNUNET_malloc (sizeof (struct ResolverHandle)); | 3420 | rh = GNUNET_malloc (sizeof (struct ResolverHandle)); |
3424 | |||
3425 | memset (rh, 0, sizeof (struct ResolverHandle)); | ||
3426 | rh->authority = zone; | 3421 | rh->authority = zone; |
3427 | rh->id = rid++; | 3422 | rh->id = rid++; |
3428 | rh->proc_cls = rlh; | 3423 | rh->proc_cls = rlh; |
3429 | rh->priv_key = key; | 3424 | rh->priv_key = key; |
3430 | rh->timeout = timeout; | 3425 | rh->timeout = timeout; |
3431 | rh->get_handle = NULL; | ||
3432 | rh->private_local_zone = pzone; | 3426 | rh->private_local_zone = pzone; |
3433 | rh->only_cached = only_cached; | 3427 | rh->only_cached = only_cached; |
3434 | rh->namestore_task = NULL; | ||
3435 | rh->rd.data = NULL; | ||
3436 | 3428 | ||
3437 | GNUNET_CONTAINER_DLL_insert (rlh_head, rlh_tail, rh); | 3429 | GNUNET_CONTAINER_DLL_insert (rlh_head, rlh_tail, rh); |
3438 | 3430 | ||
@@ -3506,17 +3498,16 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone, | |||
3506 | } | 3498 | } |
3507 | 3499 | ||
3508 | } | 3500 | } |
3509 | else if (is_gnunet_tld (name) == GNUNET_YES) | 3501 | else if (is_gads_tld (name) == GNUNET_YES) |
3510 | { | 3502 | { |
3511 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3503 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3512 | "TLD is gnunet\n"); | 3504 | "TLD is gads\n"); |
3513 | /** | 3505 | /** |
3514 | * Presumably GNUNET tld | 3506 | * Presumably GADS tld |
3515 | */ | 3507 | */ |
3516 | memset (rh->name, 0, | ||
3517 | strlen(name)-strlen(GNUNET_GNS_TLD)); | ||
3518 | memcpy (rh->name, name, | 3508 | memcpy (rh->name, name, |
3519 | strlen(name)-strlen(GNUNET_GNS_TLD) - 1); | 3509 | strlen (name) - strlen(GNUNET_GNS_TLD) - 1); |
3510 | rh->name[strlen (name) - strlen(GNUNET_GNS_TLD) - 1] = '\0'; | ||
3520 | } | 3511 | } |
3521 | else | 3512 | else |
3522 | { | 3513 | { |
@@ -3536,9 +3527,7 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone, | |||
3536 | /** | 3527 | /** |
3537 | * Initialize authority chain | 3528 | * Initialize authority chain |
3538 | */ | 3529 | */ |
3539 | rh->authority_chain_head = GNUNET_malloc(sizeof(struct AuthorityChain)); | 3530 | rh->authority_chain_head = GNUNET_malloc (sizeof(struct AuthorityChain)); |
3540 | rh->authority_chain_head->prev = NULL; | ||
3541 | rh->authority_chain_head->next = NULL; | ||
3542 | rh->authority_chain_tail = rh->authority_chain_head; | 3531 | rh->authority_chain_tail = rh->authority_chain_head; |
3543 | rh->authority_chain_head->zone = rh->authority; | 3532 | rh->authority_chain_head->zone = rh->authority; |
3544 | strcpy (rh->authority_chain_head->name, ""); | 3533 | strcpy (rh->authority_chain_head->name, ""); |
@@ -3614,7 +3603,7 @@ process_zone_to_name_shorten_shorten (void *cls, | |||
3614 | const struct GNUNET_NAMESTORE_RecordData *rd, | 3603 | const struct GNUNET_NAMESTORE_RecordData *rd, |
3615 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 3604 | const struct GNUNET_CRYPTO_RsaSignature *signature) |
3616 | { | 3605 | { |
3617 | struct ResolverHandle *rh = (struct ResolverHandle *)cls; | 3606 | struct ResolverHandle *rh = cls; |
3618 | struct NameShortenHandle* nsh = (struct NameShortenHandle*)rh->proc_cls; | 3607 | struct NameShortenHandle* nsh = (struct NameShortenHandle*)rh->proc_cls; |
3619 | struct AuthorityChain *next_authority; | 3608 | struct AuthorityChain *next_authority; |
3620 | 3609 | ||
@@ -3730,7 +3719,7 @@ process_zone_to_name_shorten_private (void *cls, | |||
3730 | const struct GNUNET_NAMESTORE_RecordData *rd, | 3719 | const struct GNUNET_NAMESTORE_RecordData *rd, |
3731 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 3720 | const struct GNUNET_CRYPTO_RsaSignature *signature) |
3732 | { | 3721 | { |
3733 | struct ResolverHandle *rh = (struct ResolverHandle *)cls; | 3722 | struct ResolverHandle *rh = cls; |
3734 | struct NameShortenHandle* nsh = (struct NameShortenHandle*)rh->proc_cls; | 3723 | struct NameShortenHandle* nsh = (struct NameShortenHandle*)rh->proc_cls; |
3735 | struct AuthorityChain *next_authority; | 3724 | struct AuthorityChain *next_authority; |
3736 | 3725 | ||
@@ -3845,10 +3834,9 @@ process_zone_to_name_shorten_root (void *cls, | |||
3845 | const struct GNUNET_NAMESTORE_RecordData *rd, | 3834 | const struct GNUNET_NAMESTORE_RecordData *rd, |
3846 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 3835 | const struct GNUNET_CRYPTO_RsaSignature *signature) |
3847 | { | 3836 | { |
3848 | struct ResolverHandle *rh = (struct ResolverHandle *)cls; | 3837 | struct ResolverHandle *rh = cls; |
3849 | struct NameShortenHandle* nsh = (struct NameShortenHandle*)rh->proc_cls; | 3838 | struct NameShortenHandle* nsh = (struct NameShortenHandle*)rh->proc_cls; |
3850 | struct AuthorityChain *next_authority; | 3839 | struct AuthorityChain *next_authority; |
3851 | |||
3852 | char result[MAX_DNS_NAME_LENGTH]; | 3840 | char result[MAX_DNS_NAME_LENGTH]; |
3853 | char tmp_name[MAX_DNS_NAME_LENGTH]; | 3841 | char tmp_name[MAX_DNS_NAME_LENGTH]; |
3854 | size_t answer_len; | 3842 | size_t answer_len; |
@@ -4150,7 +4138,6 @@ gns_resolver_shorten_name (struct GNUNET_CRYPTO_ShortHashCode *zone, | |||
4150 | char nzkey[MAX_DNS_LABEL_LENGTH]; | 4138 | char nzkey[MAX_DNS_LABEL_LENGTH]; |
4151 | char* nzkey_ptr = nzkey; | 4139 | char* nzkey_ptr = nzkey; |
4152 | 4140 | ||
4153 | |||
4154 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4141 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4155 | "Starting shorten for %s!\n", name); | 4142 | "Starting shorten for %s!\n", name); |
4156 | 4143 | ||
@@ -4224,7 +4211,7 @@ gns_resolver_shorten_name (struct GNUNET_CRYPTO_ShortHashCode *zone, | |||
4224 | return; | 4211 | return; |
4225 | 4212 | ||
4226 | } | 4213 | } |
4227 | else if (is_gnunet_tld (name) == GNUNET_YES) | 4214 | else if (is_gads_tld (name) == GNUNET_YES) |
4228 | { | 4215 | { |
4229 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4216 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4230 | "TLD is gnunet\n"); | 4217 | "TLD is gnunet\n"); |
@@ -4276,6 +4263,7 @@ finish_get_auth (struct ResolverHandle *rh, | |||
4276 | free_resolver_handle (rh); | 4263 | free_resolver_handle (rh); |
4277 | } | 4264 | } |
4278 | 4265 | ||
4266 | |||
4279 | /** | 4267 | /** |
4280 | * Process result from namestore delegation lookup | 4268 | * Process result from namestore delegation lookup |
4281 | * for get authority operation | 4269 | * for get authority operation |
@@ -4338,8 +4326,6 @@ handle_delegation_result_ns_get_auth(void* cls, | |||
4338 | strcpy(nah->result, ""); | 4326 | strcpy(nah->result, ""); |
4339 | finish_get_auth (rh, nah); | 4327 | finish_get_auth (rh, nah); |
4340 | } | 4328 | } |
4341 | |||
4342 | |||
4343 | } | 4329 | } |
4344 | 4330 | ||
4345 | 4331 | ||
@@ -4371,7 +4357,6 @@ gns_resolver_get_authority(struct GNUNET_CRYPTO_ShortHashCode zone, | |||
4371 | rh->authority = zone; | 4357 | rh->authority = zone; |
4372 | rh->id = rid++; | 4358 | rh->id = rid++; |
4373 | rh->private_local_zone = pzone; | 4359 | rh->private_local_zone = pzone; |
4374 | rh->namestore_task = NULL; | ||
4375 | 4360 | ||
4376 | GNUNET_CONTAINER_DLL_insert (nah_head, nah_tail, rh); | 4361 | GNUNET_CONTAINER_DLL_insert (nah_head, nah_tail, rh); |
4377 | 4362 | ||
diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h index e8bb74697..466e93175 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, | |||
637 | 637 | ||
638 | 638 | ||
639 | /** | 639 | /** |
640 | * Checks for gnunet/zkey | 640 | * Checks for gads/zkey |
641 | */ | 641 | */ |
642 | #define is_gnunet_tld(name) is_tld(name, GNUNET_GNS_TLD) | 642 | #define is_gads_tld(name) is_tld(name, GNUNET_GNS_TLD) |
643 | #define is_zkey_tld(name) is_tld(name, GNUNET_GNS_TLD_ZKEY) | 643 | #define is_zkey_tld(name) is_tld(name, GNUNET_GNS_TLD_ZKEY) |
644 | 644 | ||
645 | 645 | ||
diff --git a/src/gns/test_gns_dht_delegated_lookup.c b/src/gns/test_gns_dht_delegated_lookup.c index 0fcd723e3..f9531751a 100644 --- a/src/gns/test_gns_dht_delegated_lookup.c +++ b/src/gns/test_gns_dht_delegated_lookup.c | |||
@@ -33,18 +33,12 @@ | |||
33 | #include "gnunet_dht_service.h" | 33 | #include "gnunet_dht_service.h" |
34 | #include "gnunet_gns_service.h" | 34 | #include "gnunet_gns_service.h" |
35 | 35 | ||
36 | /* DEFINES */ | ||
37 | #define VERBOSE GNUNET_YES | ||
38 | |||
39 | /* Timeout for entire testcase */ | 36 | /* Timeout for entire testcase */ |
40 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) | 37 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) |
41 | 38 | ||
42 | /* Timeout for entire testcase */ | 39 | /* Timeout for entire testcase */ |
43 | #define DHT_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) | 40 | #define DHT_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) |
44 | 41 | ||
45 | /* If number of peers not in config file, use this number */ | ||
46 | #define DEFAULT_NUM_PEERS 2 | ||
47 | |||
48 | /* test records to resolve */ | 42 | /* test records to resolve */ |
49 | #define TEST_DOMAIN "www.bob.gads" | 43 | #define TEST_DOMAIN "www.bob.gads" |
50 | #define TEST_IP "127.0.0.1" | 44 | #define TEST_IP "127.0.0.1" |
@@ -56,11 +50,9 @@ | |||
56 | 50 | ||
57 | #define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey" | 51 | #define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey" |
58 | 52 | ||
59 | /* Globals */ | ||
60 | |||
61 | /* Task handle to use to schedule test failure */ | 53 | /* Task handle to use to schedule test failure */ |
62 | GNUNET_SCHEDULER_TaskIdentifier die_task; | 54 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
63 | GNUNET_SCHEDULER_TaskIdentifier wait_task; | 55 | static GNUNET_SCHEDULER_TaskIdentifier wait_task; |
64 | 56 | ||
65 | /* Global return value (0 for success, anything else for failure) */ | 57 | /* Global return value (0 for success, anything else for failure) */ |
66 | static int ok; | 58 | static int ok; |
@@ -71,12 +63,12 @@ static struct GNUNET_GNS_Handle *gns_handle; | |||
71 | 63 | ||
72 | static struct GNUNET_DHT_Handle *dht_handle; | 64 | static struct GNUNET_DHT_Handle *dht_handle; |
73 | 65 | ||
74 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 66 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
75 | 67 | ||
76 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; | 68 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; |
77 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey; | 69 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey; |
78 | struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; | 70 | static struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; |
79 | struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; | 71 | static struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; |
80 | 72 | ||
81 | 73 | ||
82 | /** | 74 | /** |
@@ -110,6 +102,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
110 | ok = 1; | 102 | ok = 1; |
111 | } | 103 | } |
112 | 104 | ||
105 | |||
113 | static void | 106 | static void |
114 | end_badly_now () | 107 | end_badly_now () |
115 | { | 108 | { |
@@ -123,14 +116,17 @@ end_badly_now () | |||
123 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | 116 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); |
124 | } | 117 | } |
125 | 118 | ||
126 | static void shutdown_task (void *cls, | 119 | |
127 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 120 | static void |
121 | shutdown_task (void *cls, | ||
122 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
128 | { | 123 | { |
129 | GNUNET_GNS_disconnect(gns_handle); | 124 | GNUNET_GNS_disconnect(gns_handle); |
130 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n"); | 125 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n"); |
131 | GNUNET_SCHEDULER_shutdown (); | 126 | GNUNET_SCHEDULER_shutdown (); |
132 | } | 127 | } |
133 | 128 | ||
129 | |||
134 | static void | 130 | static void |
135 | on_lookup_result(void *cls, uint32_t rd_count, | 131 | on_lookup_result(void *cls, uint32_t rd_count, |
136 | const struct GNUNET_NAMESTORE_RecordData *rd) | 132 | const struct GNUNET_NAMESTORE_RecordData *rd) |
@@ -295,6 +291,7 @@ put_dht(void *cls, int32_t success, const char *emsg) | |||
295 | wait_task = GNUNET_SCHEDULER_add_delayed(DHT_DELAY, &commence_testing, NULL); | 291 | wait_task = GNUNET_SCHEDULER_add_delayed(DHT_DELAY, &commence_testing, NULL); |
296 | } | 292 | } |
297 | 293 | ||
294 | |||
298 | static void | 295 | static void |
299 | do_check (void *cls, | 296 | do_check (void *cls, |
300 | const struct GNUNET_CONFIGURATION_Handle *ccfg, | 297 | const struct GNUNET_CONFIGURATION_Handle *ccfg, |
@@ -364,11 +361,7 @@ main (int argc, char *argv[]) | |||
364 | ok = 1; | 361 | ok = 1; |
365 | 362 | ||
366 | GNUNET_log_setup ("test-gns-dht-delegated-lookup", | 363 | GNUNET_log_setup ("test-gns-dht-delegated-lookup", |
367 | #if VERBOSE | ||
368 | "DEBUG", | ||
369 | #else | ||
370 | "WARNING", | 364 | "WARNING", |
371 | #endif | ||
372 | NULL); | 365 | NULL); |
373 | GNUNET_TESTING_peer_run ("test-gns-dht-delegated-lookup", "test_gns_simple_lookup.conf", &do_check, NULL); | 366 | GNUNET_TESTING_peer_run ("test-gns-dht-delegated-lookup", "test_gns_simple_lookup.conf", &do_check, NULL); |
374 | return ok; | 367 | return ok; |
diff --git a/src/gns/test_gns_dht_three_peers.c b/src/gns/test_gns_dht_three_peers.c index a7bad9bba..2a109559f 100644 --- a/src/gns/test_gns_dht_three_peers.c +++ b/src/gns/test_gns_dht_three_peers.c | |||
@@ -42,14 +42,9 @@ | |||
42 | 42 | ||
43 | #define ZONE_PUT_WAIT_TIME GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) | 43 | #define ZONE_PUT_WAIT_TIME GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) |
44 | 44 | ||
45 | /* If number of peers not in config file, use this number */ | ||
46 | #define DEFAULT_NUM_PEERS 2 | ||
47 | |||
48 | #define TEST_DOMAIN "www.buddy.bob.gads" | 45 | #define TEST_DOMAIN "www.buddy.bob.gads" |
49 | #define TEST_IP "1.1.1.1" | 46 | #define TEST_IP "1.1.1.1" |
50 | #define TEST_DAVE_PSEU "hagbard" | 47 | #define TEST_DAVE_PSEU "hagbard" |
51 | #define TEST_NUM_PEERS 3 | ||
52 | #define TEST_NUM_CON 3 | ||
53 | 48 | ||
54 | 49 | ||
55 | /* Timeout for entire testcase */ | 50 | /* Timeout for entire testcase */ |
@@ -59,22 +54,23 @@ | |||
59 | static int ok; | 54 | static int ok; |
60 | 55 | ||
61 | /* Task handle to use to schedule test failure */ | 56 | /* Task handle to use to schedule test failure */ |
62 | GNUNET_SCHEDULER_TaskIdentifier die_task; | 57 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
63 | GNUNET_SCHEDULER_TaskIdentifier wait_task; | 58 | |
59 | static GNUNET_SCHEDULER_TaskIdentifier wait_task; | ||
64 | 60 | ||
65 | struct GNUNET_CRYPTO_ShortHashCode dave_hash; | 61 | static struct GNUNET_CRYPTO_ShortHashCode dave_hash; |
66 | 62 | ||
67 | struct GNUNET_CRYPTO_ShortHashCode bob_hash; | 63 | static struct GNUNET_CRYPTO_ShortHashCode bob_hash; |
68 | 64 | ||
69 | struct GNUNET_TESTBED_Peer **cpeers; | 65 | static struct GNUNET_TESTBED_Peer **cpeers; |
70 | 66 | ||
71 | struct GNUNET_GNS_Handle *gh; | 67 | static struct GNUNET_GNS_Handle *gh; |
72 | struct GNUNET_GNS_LookupRequest *lookup_handle; | 68 | static struct GNUNET_GNS_LookupRequest *lookup_handle; |
73 | 69 | ||
74 | struct GNUNET_TESTBED_Operation *get_cfg_ops[3]; | 70 | static struct GNUNET_TESTBED_Operation *get_cfg_ops[3]; |
75 | struct GNUNET_TESTBED_Operation *connect_ops[3]; | 71 | static struct GNUNET_TESTBED_Operation *connect_ops[3]; |
76 | struct GNUNET_CONFIGURATION_Handle *cfg_handles[3]; | 72 | static struct GNUNET_CONFIGURATION_Handle *cfg_handles[3]; |
77 | struct GNUNET_NAMESTORE_Handle *nh[3]; | 73 | static struct GNUNET_NAMESTORE_Handle *nh[3]; |
78 | 74 | ||
79 | static int dave_is_setup; | 75 | static int dave_is_setup; |
80 | static int bob_is_setup; | 76 | static int bob_is_setup; |
diff --git a/src/gns/test_gns_max_queries.c b/src/gns/test_gns_max_queries.c index d06f4ebed..fae90bf72 100644 --- a/src/gns/test_gns_max_queries.c +++ b/src/gns/test_gns_max_queries.c | |||
@@ -36,9 +36,6 @@ | |||
36 | /* Timeout for entire testcase */ | 36 | /* Timeout for entire testcase */ |
37 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) | 37 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) |
38 | 38 | ||
39 | /* If number of peers not in config file, use this number */ | ||
40 | #define DEFAULT_NUM_PEERS 2 | ||
41 | |||
42 | /* test records to resolve */ | 39 | /* test records to resolve */ |
43 | #define TEST_DOMAIN "www.gads" | 40 | #define TEST_DOMAIN "www.gads" |
44 | #define TEST_DOMAIN_NACK "doesnotexist.bob.gads" | 41 | #define TEST_DOMAIN_NACK "doesnotexist.bob.gads" |
@@ -49,8 +46,6 @@ | |||
49 | 46 | ||
50 | #define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey" | 47 | #define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey" |
51 | 48 | ||
52 | /* Globals */ | ||
53 | |||
54 | /* Task handle to use to schedule test failure */ | 49 | /* Task handle to use to schedule test failure */ |
55 | static GNUNET_SCHEDULER_TaskIdentifier die_task; | 50 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
56 | 51 | ||
diff --git a/src/gns/test_gns_pseu_shorten.c b/src/gns/test_gns_pseu_shorten.c index 8f279bb55..74f41398d 100644 --- a/src/gns/test_gns_pseu_shorten.c +++ b/src/gns/test_gns_pseu_shorten.c | |||
@@ -33,15 +33,9 @@ | |||
33 | #include "gnunet_dht_service.h" | 33 | #include "gnunet_dht_service.h" |
34 | #include "gnunet_gns_service.h" | 34 | #include "gnunet_gns_service.h" |
35 | 35 | ||
36 | /* DEFINES */ | ||
37 | #define VERBOSE GNUNET_YES | ||
38 | |||
39 | /* Timeout for entire testcase */ | 36 | /* Timeout for entire testcase */ |
40 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30) | 37 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30) |
41 | 38 | ||
42 | /* If number of peers not in config file, use this number */ | ||
43 | #define DEFAULT_NUM_PEERS 2 | ||
44 | |||
45 | /* test records to resolve */ | 39 | /* test records to resolve */ |
46 | #define TEST_DOMAIN "www.alicewonderland.bobbuilder.gads" | 40 | #define TEST_DOMAIN "www.alicewonderland.bobbuilder.gads" |
47 | #define TEST_IP "127.0.0.1" | 41 | #define TEST_IP "127.0.0.1" |
@@ -75,23 +69,23 @@ static struct GNUNET_GNS_Handle *gns_handle; | |||
75 | 69 | ||
76 | static struct GNUNET_DHT_Handle *dht_handle; | 70 | static struct GNUNET_DHT_Handle *dht_handle; |
77 | 71 | ||
78 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 72 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
79 | 73 | ||
80 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; | 74 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; |
81 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey; | 75 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey; |
82 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded our_pkey; | 76 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded our_pkey; |
83 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded priv_pkey; | 77 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded priv_pkey; |
84 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded short_pkey; | 78 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded short_pkey; |
85 | struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; | 79 | static struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; |
86 | struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; | 80 | static struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; |
87 | struct GNUNET_CRYPTO_RsaPrivateKey *our_key; | 81 | static struct GNUNET_CRYPTO_RsaPrivateKey *our_key; |
88 | struct GNUNET_CRYPTO_RsaPrivateKey *priv_key; | 82 | static struct GNUNET_CRYPTO_RsaPrivateKey *priv_key; |
89 | struct GNUNET_CRYPTO_RsaPrivateKey *short_key; | 83 | static struct GNUNET_CRYPTO_RsaPrivateKey *short_key; |
90 | struct GNUNET_CRYPTO_ShortHashCode alice_hash; | 84 | static struct GNUNET_CRYPTO_ShortHashCode alice_hash; |
91 | struct GNUNET_CRYPTO_ShortHashCode bob_hash; | 85 | static struct GNUNET_CRYPTO_ShortHashCode bob_hash; |
92 | struct GNUNET_CRYPTO_ShortHashCode our_zone; | 86 | static struct GNUNET_CRYPTO_ShortHashCode our_zone; |
93 | struct GNUNET_CRYPTO_ShortHashCode priv_zone; | 87 | static struct GNUNET_CRYPTO_ShortHashCode priv_zone; |
94 | struct GNUNET_CRYPTO_ShortHashCode short_zone; | 88 | static struct GNUNET_CRYPTO_ShortHashCode short_zone; |
95 | 89 | ||
96 | 90 | ||
97 | /** | 91 | /** |
@@ -126,6 +120,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
126 | ok = 1; | 120 | ok = 1; |
127 | } | 121 | } |
128 | 122 | ||
123 | |||
129 | static void | 124 | static void |
130 | end_badly_now () | 125 | end_badly_now () |
131 | { | 126 | { |
@@ -133,8 +128,10 @@ end_badly_now () | |||
133 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | 128 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); |
134 | } | 129 | } |
135 | 130 | ||
136 | static void shutdown_task (void *cls, | 131 | |
137 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 132 | static void |
133 | shutdown_task (void *cls, | ||
134 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
138 | { | 135 | { |
139 | GNUNET_GNS_disconnect(gns_handle); | 136 | GNUNET_GNS_disconnect(gns_handle); |
140 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n"); | 137 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n"); |
@@ -346,6 +343,7 @@ put_pseu_dht (void *cls, int success) | |||
346 | GNUNET_free (nrb); | 343 | GNUNET_free (nrb); |
347 | } | 344 | } |
348 | 345 | ||
346 | |||
349 | static void | 347 | static void |
350 | put_www_dht(void *cls, int success) | 348 | put_www_dht(void *cls, int success) |
351 | { | 349 | { |
@@ -514,6 +512,7 @@ put_pkey_dht(void *cls, int32_t success, const char *emsg) | |||
514 | GNUNET_free (nrb); | 512 | GNUNET_free (nrb); |
515 | } | 513 | } |
516 | 514 | ||
515 | |||
517 | static void | 516 | static void |
518 | fin_init_zone (void *cls, int32_t success, const char *emsg) | 517 | fin_init_zone (void *cls, int32_t success, const char *emsg) |
519 | { | 518 | { |
@@ -552,6 +551,7 @@ cont_init_zone (void *cls, int32_t success, const char *emsg) | |||
552 | NULL); | 551 | NULL); |
553 | } | 552 | } |
554 | 553 | ||
554 | |||
555 | static void | 555 | static void |
556 | do_check (void *cls, | 556 | do_check (void *cls, |
557 | const struct GNUNET_CONFIGURATION_Handle *ccfg, | 557 | const struct GNUNET_CONFIGURATION_Handle *ccfg, |
@@ -646,17 +646,13 @@ do_check (void *cls, | |||
646 | NULL); | 646 | NULL); |
647 | } | 647 | } |
648 | 648 | ||
649 | |||
649 | int | 650 | int |
650 | main (int argc, char *argv[]) | 651 | main (int argc, char *argv[]) |
651 | { | 652 | { |
652 | ok = 1; | 653 | ok = 1; |
653 | |||
654 | GNUNET_log_setup ("test-gns-pseu-shorten", | 654 | GNUNET_log_setup ("test-gns-pseu-shorten", |
655 | #if VERBOSE | ||
656 | "DEBUG", | ||
657 | #else | ||
658 | "WARNING", | 655 | "WARNING", |
659 | #endif | ||
660 | NULL); | 656 | NULL); |
661 | GNUNET_TESTING_peer_run ("test-gns-pseu-shorten", "test_gns_simple_lookup.conf", &do_check, NULL); | 657 | GNUNET_TESTING_peer_run ("test-gns-pseu-shorten", "test_gns_simple_lookup.conf", &do_check, NULL); |
662 | return ok; | 658 | return ok; |
diff --git a/src/gns/test_gns_revocation.c b/src/gns/test_gns_revocation.c index a538ab3e7..691d8c124 100644 --- a/src/gns/test_gns_revocation.c +++ b/src/gns/test_gns_revocation.c | |||
@@ -32,15 +32,9 @@ | |||
32 | #include "gnunet_dnsparser_lib.h" | 32 | #include "gnunet_dnsparser_lib.h" |
33 | #include "gnunet_gns_service.h" | 33 | #include "gnunet_gns_service.h" |
34 | 34 | ||
35 | /* DEFINES */ | ||
36 | #define VERBOSE GNUNET_YES | ||
37 | |||
38 | /* Timeout for entire testcase */ | 35 | /* Timeout for entire testcase */ |
39 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) | 36 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) |
40 | 37 | ||
41 | /* If number of peers not in config file, use this number */ | ||
42 | #define DEFAULT_NUM_PEERS 2 | ||
43 | |||
44 | /* test records to resolve */ | 38 | /* test records to resolve */ |
45 | #define TEST_DOMAIN "www.bob.gads" | 39 | #define TEST_DOMAIN "www.bob.gads" |
46 | #define TEST_IP "127.0.0.1" | 40 | #define TEST_IP "127.0.0.1" |
@@ -50,10 +44,8 @@ | |||
50 | 44 | ||
51 | #define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey" | 45 | #define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey" |
52 | 46 | ||
53 | /* Globals */ | ||
54 | |||
55 | /* Task handle to use to schedule test failure */ | 47 | /* Task handle to use to schedule test failure */ |
56 | GNUNET_SCHEDULER_TaskIdentifier die_task; | 48 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
57 | 49 | ||
58 | /* Global return value (0 for success, anything else for failure) */ | 50 | /* Global return value (0 for success, anything else for failure) */ |
59 | static int ok; | 51 | static int ok; |
@@ -62,7 +54,8 @@ static struct GNUNET_NAMESTORE_Handle *namestore_handle; | |||
62 | 54 | ||
63 | static struct GNUNET_GNS_Handle *gns_handle; | 55 | static struct GNUNET_GNS_Handle *gns_handle; |
64 | 56 | ||
65 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 57 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
58 | |||
66 | 59 | ||
67 | /** | 60 | /** |
68 | * Check if the get_handle is being used, if so stop the request. Either | 61 | * 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) | |||
89 | ok = 1; | 82 | ok = 1; |
90 | } | 83 | } |
91 | 84 | ||
85 | |||
92 | static void | 86 | static void |
93 | end_badly_now () | 87 | end_badly_now () |
94 | { | 88 | { |
@@ -96,14 +90,17 @@ end_badly_now () | |||
96 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | 90 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); |
97 | } | 91 | } |
98 | 92 | ||
99 | static void shutdown_task (void *cls, | 93 | |
100 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 94 | static void |
95 | shutdown_task (void *cls, | ||
96 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
101 | { | 97 | { |
102 | GNUNET_GNS_disconnect(gns_handle); | 98 | GNUNET_GNS_disconnect(gns_handle); |
103 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n"); | 99 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n"); |
104 | GNUNET_SCHEDULER_shutdown (); | 100 | GNUNET_SCHEDULER_shutdown (); |
105 | } | 101 | } |
106 | 102 | ||
103 | |||
107 | static void | 104 | static void |
108 | on_lookup_result(void *cls, uint32_t rd_count, | 105 | on_lookup_result(void *cls, uint32_t rd_count, |
109 | const struct GNUNET_NAMESTORE_RecordData *rd) | 106 | const struct GNUNET_NAMESTORE_RecordData *rd) |
@@ -272,18 +269,13 @@ do_check (void *cls, | |||
272 | } | 269 | } |
273 | 270 | ||
274 | 271 | ||
275 | |||
276 | int | 272 | int |
277 | main (int argc, char *argv[]) | 273 | main (int argc, char *argv[]) |
278 | { | 274 | { |
279 | ok = 1; | 275 | ok = 1; |
280 | 276 | ||
281 | GNUNET_log_setup ("test-gns-revocation", | 277 | GNUNET_log_setup ("test-gns-revocation", |
282 | #if VERBOSE | ||
283 | "DEBUG", | ||
284 | #else | ||
285 | "WARNING", | 278 | "WARNING", |
286 | #endif | ||
287 | NULL); | 279 | NULL); |
288 | GNUNET_TESTING_peer_run ("test-gns-revocation", "test_gns_simple_lookup.conf", &do_check, NULL); | 280 | GNUNET_TESTING_peer_run ("test-gns-revocation", "test_gns_simple_lookup.conf", &do_check, NULL); |
289 | return ok; | 281 | return ok; |
diff --git a/src/gns/test_gns_simple_delegated_lookup.c b/src/gns/test_gns_simple_delegated_lookup.c index b456e4112..c01bd8cce 100644 --- a/src/gns/test_gns_simple_delegated_lookup.c +++ b/src/gns/test_gns_simple_delegated_lookup.c | |||
@@ -18,7 +18,7 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file gns/test_gns_twopeer.c | 21 | * @file gns/test_gns_simple_delegated_lookup.c |
22 | * @brief base testcase for testing DHT service with | 22 | * @brief base testcase for testing DHT service with |
23 | * two running peers. | 23 | * two running peers. |
24 | * | 24 | * |
@@ -46,15 +46,9 @@ | |||
46 | #include "gnunet_dnsparser_lib.h" | 46 | #include "gnunet_dnsparser_lib.h" |
47 | #include "gnunet_gns_service.h" | 47 | #include "gnunet_gns_service.h" |
48 | 48 | ||
49 | /* DEFINES */ | ||
50 | #define VERBOSE GNUNET_YES | ||
51 | |||
52 | /* Timeout for entire testcase */ | 49 | /* Timeout for entire testcase */ |
53 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) | 50 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) |
54 | 51 | ||
55 | /* If number of peers not in config file, use this number */ | ||
56 | #define DEFAULT_NUM_PEERS 2 | ||
57 | |||
58 | /* test records to resolve */ | 52 | /* test records to resolve */ |
59 | #define TEST_DOMAIN "www.bob.gads" | 53 | #define TEST_DOMAIN "www.bob.gads" |
60 | #define TEST_IP "127.0.0.1" | 54 | #define TEST_IP "127.0.0.1" |
@@ -64,10 +58,8 @@ | |||
64 | 58 | ||
65 | #define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey" | 59 | #define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey" |
66 | 60 | ||
67 | /* Globals */ | ||
68 | |||
69 | /* Task handle to use to schedule test failure */ | 61 | /* Task handle to use to schedule test failure */ |
70 | GNUNET_SCHEDULER_TaskIdentifier die_task; | 62 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
71 | 63 | ||
72 | /* Global return value (0 for success, anything else for failure) */ | 64 | /* Global return value (0 for success, anything else for failure) */ |
73 | static int ok; | 65 | static int ok; |
@@ -76,7 +68,8 @@ static struct GNUNET_NAMESTORE_Handle *namestore_handle; | |||
76 | 68 | ||
77 | static struct GNUNET_GNS_Handle *gns_handle; | 69 | static struct GNUNET_GNS_Handle *gns_handle; |
78 | 70 | ||
79 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 71 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
72 | |||
80 | 73 | ||
81 | /** | 74 | /** |
82 | * Check if the get_handle is being used, if so stop the request. Either | 75 | * 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) | |||
92 | GNUNET_GNS_disconnect(gns_handle); | 85 | GNUNET_GNS_disconnect(gns_handle); |
93 | gns_handle = NULL; | 86 | gns_handle = NULL; |
94 | } | 87 | } |
95 | |||
96 | if (NULL != namestore_handle) | 88 | if (NULL != namestore_handle) |
97 | { | 89 | { |
98 | GNUNET_NAMESTORE_disconnect (namestore_handle); | 90 | GNUNET_NAMESTORE_disconnect (namestore_handle); |
@@ -103,66 +95,60 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
103 | ok = 1; | 95 | ok = 1; |
104 | } | 96 | } |
105 | 97 | ||
106 | void end_badly_now () | ||
107 | { | ||
108 | GNUNET_SCHEDULER_cancel (die_task); | ||
109 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | ||
110 | } | ||
111 | |||
112 | 98 | ||
113 | static void shutdown_task (void *cls, | 99 | static void |
114 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 100 | shutdown_task (void *cls, |
101 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
115 | { | 102 | { |
116 | GNUNET_GNS_disconnect(gns_handle); | 103 | GNUNET_GNS_disconnect (gns_handle); |
104 | gns_handle = NULL; | ||
117 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n"); | 105 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n"); |
118 | GNUNET_SCHEDULER_shutdown (); | 106 | GNUNET_SCHEDULER_shutdown (); |
119 | } | 107 | } |
120 | 108 | ||
109 | |||
121 | static void | 110 | static void |
122 | on_lookup_result(void *cls, uint32_t rd_count, | 111 | on_lookup_result (void *cls, uint32_t rd_count, |
123 | const struct GNUNET_NAMESTORE_RecordData *rd) | 112 | const struct GNUNET_NAMESTORE_RecordData *rd) |
124 | { | 113 | { |
114 | const char *name = cls; | ||
115 | uint32_t i; | ||
116 | const char* addr; | ||
125 | struct in_addr a; | 117 | struct in_addr a; |
126 | int i; | ||
127 | char* addr; | ||
128 | |||
129 | if (GNUNET_SCHEDULER_NO_TASK != die_task) | ||
130 | { | ||
131 | GNUNET_SCHEDULER_cancel (die_task); | ||
132 | die_task = GNUNET_SCHEDULER_NO_TASK; | ||
133 | } | ||
134 | 118 | ||
135 | GNUNET_NAMESTORE_disconnect (namestore_handle); | 119 | GNUNET_NAMESTORE_disconnect (namestore_handle); |
136 | if (rd_count == 0) | 120 | namestore_handle = NULL; |
121 | if (0 == rd_count) | ||
137 | { | 122 | { |
138 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 123 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
139 | "Lookup failed, rp_filtering?\n"); | 124 | "Lookup failed!\n"); |
140 | ok = 2; | 125 | ok = 2; |
126 | GNUNET_SCHEDULER_shutdown (); | ||
127 | return; | ||
128 | } | ||
129 | if (GNUNET_SCHEDULER_NO_TASK != die_task) | ||
130 | { | ||
131 | GNUNET_SCHEDULER_cancel (die_task); | ||
132 | die_task = GNUNET_SCHEDULER_NO_TASK; | ||
141 | } | 133 | } |
142 | else | 134 | ok = 1; |
135 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
136 | "name: %s\n", | ||
137 | name); | ||
138 | for (i=0; i<rd_count; i++) | ||
143 | { | 139 | { |
144 | ok = 1; | 140 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "type: %d\n", rd[i].record_type); |
145 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "name: %s\n", (char*)cls); | 141 | if (rd[i].record_type != GNUNET_GNS_RECORD_A) |
146 | for (i=0; i<rd_count; i++) | 142 | continue; |
147 | { | 143 | memcpy (&a, rd[i].data, sizeof (a)); |
148 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "type: %d\n", rd[i].record_type); | 144 | addr = inet_ntoa (a); |
149 | if (rd[i].record_type == GNUNET_GNS_RECORD_A) | 145 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
150 | { | 146 | "address: %s\n", addr); |
151 | memcpy(&a, rd[i].data, sizeof(a)); | 147 | if (0 != strcmp (addr, TEST_IP)) |
152 | addr = inet_ntoa(a); | 148 | continue; |
153 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "address: %s\n", addr); | 149 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
154 | if (0 == strcmp(addr, TEST_IP)) | 150 | "%s correctly resolved to %s!\n", TEST_DOMAIN, addr); |
155 | { | 151 | ok = 0; |
156 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
157 | "%s correctly resolved to %s!\n", TEST_DOMAIN, addr); | ||
158 | ok = 0; | ||
159 | } | ||
160 | } | ||
161 | else | ||
162 | { | ||
163 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No resolution!\n"); | ||
164 | } | ||
165 | } | ||
166 | } | 152 | } |
167 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 153 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
168 | } | 154 | } |
@@ -175,28 +161,33 @@ on_lookup_result(void *cls, uint32_t rd_count, | |||
175 | static void | 161 | static void |
176 | commence_testing (void *cls, int32_t success, const char *emsg) | 162 | commence_testing (void *cls, int32_t success, const char *emsg) |
177 | { | 163 | { |
178 | 164 | if (NULL != emsg) | |
165 | { | ||
166 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
167 | "Failed to store record in namestore: %s\n", | ||
168 | emsg); | ||
169 | GNUNET_SCHEDULER_shutdown (); | ||
170 | return; | ||
171 | } | ||
179 | gns_handle = GNUNET_GNS_connect(cfg); | 172 | gns_handle = GNUNET_GNS_connect(cfg); |
180 | |||
181 | if (NULL == gns_handle) | 173 | if (NULL == gns_handle) |
182 | { | 174 | { |
183 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 175 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
184 | "Failed to connect to GNS!\n"); | 176 | "Failed to connect to GNS!\n"); |
185 | end_badly_now(); | 177 | GNUNET_SCHEDULER_shutdown (); |
186 | return; | 178 | return; |
187 | } | 179 | } |
188 | 180 | GNUNET_GNS_lookup (gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_A, | |
189 | GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_A, | 181 | GNUNET_NO, |
190 | GNUNET_NO, | 182 | NULL, |
191 | NULL, | 183 | &on_lookup_result, TEST_DOMAIN); |
192 | &on_lookup_result, TEST_DOMAIN); | ||
193 | } | 184 | } |
194 | 185 | ||
195 | 186 | ||
196 | 187 | static void | |
197 | void do_check (void *cls, | 188 | do_check (void *cls, |
198 | const struct GNUNET_CONFIGURATION_Handle *ccfg, | 189 | const struct GNUNET_CONFIGURATION_Handle *ccfg, |
199 | struct GNUNET_TESTING_Peer *peer) | 190 | struct GNUNET_TESTING_Peer *peer) |
200 | { | 191 | { |
201 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; | 192 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; |
202 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey; | 193 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey; |
@@ -206,6 +197,9 @@ void do_check (void *cls, | |||
206 | struct GNUNET_CRYPTO_RsaSignature *sig; | 197 | struct GNUNET_CRYPTO_RsaSignature *sig; |
207 | char* alice_keyfile; | 198 | char* alice_keyfile; |
208 | struct GNUNET_TIME_Absolute et; | 199 | struct GNUNET_TIME_Absolute et; |
200 | struct GNUNET_NAMESTORE_RecordData rd; | ||
201 | const char* ip = TEST_IP; | ||
202 | struct in_addr web; | ||
209 | 203 | ||
210 | cfg = ccfg; | 204 | cfg = ccfg; |
211 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 205 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
@@ -214,53 +208,45 @@ void do_check (void *cls, | |||
214 | namestore_handle = GNUNET_NAMESTORE_connect(cfg); | 208 | namestore_handle = GNUNET_NAMESTORE_connect(cfg); |
215 | if (NULL == namestore_handle) | 209 | if (NULL == namestore_handle) |
216 | { | 210 | { |
217 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to namestore\n"); | 211 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
218 | end_badly_now () ; | 212 | "Failed to connect to namestore\n"); |
213 | GNUNET_SCHEDULER_shutdown (); | ||
219 | return; | 214 | return; |
220 | } | 215 | } |
221 | 216 | ||
222 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | 217 | if (GNUNET_OK != |
223 | "ZONEKEY", | 218 | GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", |
224 | &alice_keyfile)) | 219 | "ZONEKEY", |
220 | &alice_keyfile)) | ||
225 | { | 221 | { |
226 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n"); | 222 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n"); |
227 | end_badly_now () ; | 223 | GNUNET_SCHEDULER_shutdown (); |
228 | return; | 224 | return; |
229 | } | 225 | } |
230 | |||
231 | alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (alice_keyfile); | 226 | alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (alice_keyfile); |
232 | bob_key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE_BOB); | 227 | bob_key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE_BOB); |
233 | |||
234 | GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); | 228 | GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); |
235 | GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey); | 229 | GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey); |
236 | |||
237 | struct GNUNET_NAMESTORE_RecordData rd; | ||
238 | char* ip = TEST_IP; | ||
239 | struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr)); | ||
240 | rd.expiration_time = UINT64_MAX; | 230 | rd.expiration_time = UINT64_MAX; |
241 | GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); | 231 | GNUNET_assert (1 == inet_pton (AF_INET, ip, &web)); |
242 | 232 | GNUNET_CRYPTO_short_hash (&bob_pkey, sizeof(bob_pkey), &bob_hash); | |
243 | GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); | ||
244 | |||
245 | rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); | 233 | rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); |
246 | rd.data = &bob_hash; | 234 | rd.data = &bob_hash; |
247 | rd.record_type = GNUNET_GNS_RECORD_PKEY; | 235 | rd.record_type = GNUNET_GNS_RECORD_PKEY; |
248 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; | 236 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; |
249 | |||
250 | GNUNET_NAMESTORE_record_create (namestore_handle, | 237 | GNUNET_NAMESTORE_record_create (namestore_handle, |
251 | alice_key, | 238 | alice_key, |
252 | TEST_AUTHORITY_NAME, | 239 | TEST_AUTHORITY_NAME, |
253 | &rd, | 240 | &rd, |
254 | NULL, | 241 | NULL, |
255 | NULL); | 242 | NULL); |
256 | |||
257 | rd.data_size = sizeof(struct in_addr); | 243 | rd.data_size = sizeof(struct in_addr); |
258 | rd.data = web; | 244 | rd.data = &web; |
259 | rd.record_type = GNUNET_DNSPARSER_TYPE_A; | 245 | rd.record_type = GNUNET_DNSPARSER_TYPE_A; |
260 | sig = GNUNET_NAMESTORE_create_signature(bob_key, | 246 | sig = GNUNET_NAMESTORE_create_signature (bob_key, |
261 | GNUNET_TIME_UNIT_FOREVER_ABS, | 247 | GNUNET_TIME_UNIT_FOREVER_ABS, |
262 | TEST_RECORD_NAME, | 248 | TEST_RECORD_NAME, |
263 | &rd, 1); | 249 | &rd, 1); |
264 | et.abs_value = rd.expiration_time; | 250 | et.abs_value = rd.expiration_time; |
265 | GNUNET_NAMESTORE_record_put (namestore_handle, | 251 | GNUNET_NAMESTORE_record_put (namestore_handle, |
266 | &bob_pkey, | 252 | &bob_pkey, |
@@ -271,12 +257,10 @@ void do_check (void *cls, | |||
271 | sig, | 257 | sig, |
272 | &commence_testing, | 258 | &commence_testing, |
273 | NULL); | 259 | NULL); |
274 | |||
275 | GNUNET_free (web); | ||
276 | GNUNET_free (sig); | 260 | GNUNET_free (sig); |
277 | GNUNET_free (alice_keyfile); | 261 | GNUNET_free (alice_keyfile); |
278 | GNUNET_CRYPTO_rsa_key_free(bob_key); | 262 | GNUNET_CRYPTO_rsa_key_free (bob_key); |
279 | GNUNET_CRYPTO_rsa_key_free(alice_key); | 263 | GNUNET_CRYPTO_rsa_key_free (alice_key); |
280 | } | 264 | } |
281 | 265 | ||
282 | 266 | ||
@@ -284,18 +268,13 @@ int | |||
284 | main (int argc, char *argv[]) | 268 | main (int argc, char *argv[]) |
285 | { | 269 | { |
286 | ok = 1; | 270 | ok = 1; |
287 | |||
288 | GNUNET_log_setup ("test-gns-simple-delegated-lookup", | 271 | GNUNET_log_setup ("test-gns-simple-delegated-lookup", |
289 | #if VERBOSE | ||
290 | "DEBUG", | ||
291 | #else | ||
292 | "WARNING", | 272 | "WARNING", |
293 | #endif | ||
294 | NULL); | 273 | NULL); |
295 | 274 | GNUNET_TESTING_peer_run ("test-gns-simple-delegated-lookup", | |
296 | GNUNET_TESTING_peer_run ("test-gns-simple-delegated-lookup", "test_gns_simple_lookup.conf", &do_check, NULL); | 275 | "test_gns_simple_lookup.conf", |
297 | 276 | &do_check, NULL); | |
298 | return ok; | 277 | return ok; |
299 | } | 278 | } |
300 | 279 | ||
301 | /* end of test_gns_twopeer.c */ | 280 | /* 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 4a5406e98..66d93d6a2 100644 --- a/src/gns/test_gns_simple_get_authority.c +++ b/src/gns/test_gns_simple_get_authority.c | |||
@@ -18,7 +18,7 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file gns/test_gns_simple_shorten.c | 21 | * @file gns/test_gns_simple_get_authority.c |
22 | * @brief basic shorten test for gns api | 22 | * @brief basic shorten test for gns api |
23 | * | 23 | * |
24 | */ | 24 | */ |
@@ -32,15 +32,9 @@ | |||
32 | #include "gnunet_dnsparser_lib.h" | 32 | #include "gnunet_dnsparser_lib.h" |
33 | #include "gnunet_gns_service.h" | 33 | #include "gnunet_gns_service.h" |
34 | 34 | ||
35 | /* DEFINES */ | ||
36 | #define VERBOSE GNUNET_YES | ||
37 | |||
38 | /* Timeout for entire testcase */ | 35 | /* Timeout for entire testcase */ |
39 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) | 36 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) |
40 | 37 | ||
41 | /* If number of peers not in config file, use this number */ | ||
42 | #define DEFAULT_NUM_PEERS 2 | ||
43 | |||
44 | /* test records to resolve */ | 38 | /* test records to resolve */ |
45 | #define TEST_DOMAIN "www.alice.bob.gads" | 39 | #define TEST_DOMAIN "www.alice.bob.gads" |
46 | #define TEST_IP "127.0.0.1" | 40 | #define TEST_IP "127.0.0.1" |
@@ -309,21 +303,17 @@ void do_check (void *cls, | |||
309 | GNUNET_CRYPTO_rsa_key_free (our_key); | 303 | GNUNET_CRYPTO_rsa_key_free (our_key); |
310 | } | 304 | } |
311 | 305 | ||
306 | |||
312 | int | 307 | int |
313 | main (int argc, char *argv[]) | 308 | main (int argc, char *argv[]) |
314 | { | 309 | { |
315 | ok = 1; | 310 | ok = 1; |
316 | |||
317 | GNUNET_log_setup ("test-gns-simple-get-authority", | 311 | GNUNET_log_setup ("test-gns-simple-get-authority", |
318 | #if VERBOSE | ||
319 | "DEBUG", | ||
320 | #else | ||
321 | "WARNING", | 312 | "WARNING", |
322 | #endif | ||
323 | NULL); | 313 | NULL); |
324 | 314 | GNUNET_TESTING_peer_run ("test-gns-simple-get-authority", | |
325 | GNUNET_TESTING_peer_run ("test-gns-simple-get-authority", "test_gns_simple_lookup.conf", &do_check, NULL); | 315 | "test_gns_simple_lookup.conf", |
326 | 316 | &do_check, NULL); | |
327 | return ok; | 317 | return ok; |
328 | } | 318 | } |
329 | 319 | ||
diff --git a/src/gns/test_gns_simple_mx_lookup.c b/src/gns/test_gns_simple_mx_lookup.c index a2fc311d4..812a157db 100644 --- a/src/gns/test_gns_simple_mx_lookup.c +++ b/src/gns/test_gns_simple_mx_lookup.c | |||
@@ -32,15 +32,9 @@ | |||
32 | #include "gnunet_dnsparser_lib.h" | 32 | #include "gnunet_dnsparser_lib.h" |
33 | #include "gnunet_gns_service.h" | 33 | #include "gnunet_gns_service.h" |
34 | 34 | ||
35 | /* DEFINES */ | ||
36 | #define VERBOSE GNUNET_YES | ||
37 | |||
38 | /* Timeout for entire testcase */ | 35 | /* Timeout for entire testcase */ |
39 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) | 36 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) |
40 | 37 | ||
41 | /* If number of peers not in config file, use this number */ | ||
42 | #define DEFAULT_NUM_PEERS 2 | ||
43 | |||
44 | /* test records to resolve */ | 38 | /* test records to resolve */ |
45 | #define TEST_DOMAIN "bob.gads" | 39 | #define TEST_DOMAIN "bob.gads" |
46 | #define TEST_IP "127.0.0.1" | 40 | #define TEST_IP "127.0.0.1" |
@@ -52,11 +46,8 @@ | |||
52 | 46 | ||
53 | #define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey" | 47 | #define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey" |
54 | 48 | ||
55 | /* Globals */ | ||
56 | |||
57 | |||
58 | /* Task handle to use to schedule test failure */ | 49 | /* Task handle to use to schedule test failure */ |
59 | GNUNET_SCHEDULER_TaskIdentifier die_task; | 50 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
60 | 51 | ||
61 | /* Global return value (0 for success, anything else for failure) */ | 52 | /* Global return value (0 for success, anything else for failure) */ |
62 | static int ok; | 53 | static int ok; |
@@ -65,7 +56,7 @@ static struct GNUNET_NAMESTORE_Handle *namestore_handle; | |||
65 | 56 | ||
66 | static struct GNUNET_GNS_Handle *gns_handle; | 57 | static struct GNUNET_GNS_Handle *gns_handle; |
67 | 58 | ||
68 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 59 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
69 | 60 | ||
70 | 61 | ||
71 | /** | 62 | /** |
@@ -93,6 +84,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
93 | ok = 1; | 84 | ok = 1; |
94 | } | 85 | } |
95 | 86 | ||
87 | |||
96 | static void | 88 | static void |
97 | end_badly_now () | 89 | end_badly_now () |
98 | { | 90 | { |
@@ -101,14 +93,16 @@ end_badly_now () | |||
101 | } | 93 | } |
102 | 94 | ||
103 | 95 | ||
104 | static void shutdown_task (void *cls, | 96 | static void |
105 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 97 | shutdown_task (void *cls, |
98 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
106 | { | 99 | { |
107 | GNUNET_GNS_disconnect(gns_handle); | 100 | GNUNET_GNS_disconnect(gns_handle); |
108 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n"); | 101 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n"); |
109 | GNUNET_SCHEDULER_shutdown (); | 102 | GNUNET_SCHEDULER_shutdown (); |
110 | } | 103 | } |
111 | 104 | ||
105 | |||
112 | static void | 106 | static void |
113 | on_lookup_result(void *cls, uint32_t rd_count, | 107 | on_lookup_result(void *cls, uint32_t rd_count, |
114 | const struct GNUNET_NAMESTORE_RecordData *rd) | 108 | const struct GNUNET_NAMESTORE_RecordData *rd) |
@@ -297,13 +291,8 @@ int | |||
297 | main (int argc, char *argv[]) | 291 | main (int argc, char *argv[]) |
298 | { | 292 | { |
299 | ok = 1; | 293 | ok = 1; |
300 | |||
301 | GNUNET_log_setup ("test-gns-simple-mx-lookup", | 294 | GNUNET_log_setup ("test-gns-simple-mx-lookup", |
302 | #if VERBOSE | ||
303 | "DEBUG", | ||
304 | #else | ||
305 | "WARNING", | 295 | "WARNING", |
306 | #endif | ||
307 | NULL); | 296 | NULL); |
308 | GNUNET_TESTING_peer_run ("test-gns-simple-mx-lookup", "test_gns_simple_lookup.conf", &do_check, NULL); | 297 | GNUNET_TESTING_peer_run ("test-gns-simple-mx-lookup", "test_gns_simple_lookup.conf", &do_check, NULL); |
309 | return ok; | 298 | return ok; |
diff --git a/src/gns/test_gns_simple_shorten.c b/src/gns/test_gns_simple_shorten.c index 23305c889..649dea59b 100644 --- a/src/gns/test_gns_simple_shorten.c +++ b/src/gns/test_gns_simple_shorten.c | |||
@@ -32,15 +32,9 @@ | |||
32 | #include "gnunet_dnsparser_lib.h" | 32 | #include "gnunet_dnsparser_lib.h" |
33 | #include "gnunet_gns_service.h" | 33 | #include "gnunet_gns_service.h" |
34 | 34 | ||
35 | /* DEFINES */ | ||
36 | #define VERBOSE GNUNET_YES | ||
37 | |||
38 | /* Timeout for entire testcase */ | 35 | /* Timeout for entire testcase */ |
39 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) | 36 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) |
40 | 37 | ||
41 | /* If number of peers not in config file, use this number */ | ||
42 | #define DEFAULT_NUM_PEERS 2 | ||
43 | |||
44 | /* test records to resolve */ | 38 | /* test records to resolve */ |
45 | #define TEST_DOMAIN "www.alice.bob.gads" | 39 | #define TEST_DOMAIN "www.alice.bob.gads" |
46 | #define TEST_IP "127.0.0.1" | 40 | #define TEST_IP "127.0.0.1" |
@@ -332,21 +326,18 @@ void do_check (void *cls, | |||
332 | 326 | ||
333 | } | 327 | } |
334 | 328 | ||
329 | |||
335 | int | 330 | int |
336 | main (int argc, char *argv[]) | 331 | main (int argc, char *argv[]) |
337 | { | 332 | { |
338 | ok = 1; | 333 | ok = 1; |
339 | |||
340 | GNUNET_log_setup ("test-gns-simple-shorten", | 334 | GNUNET_log_setup ("test-gns-simple-shorten", |
341 | #if VERBOSE | ||
342 | "DEBUG", | ||
343 | #else | ||
344 | "WARNING", | 335 | "WARNING", |
345 | #endif | ||
346 | NULL); | 336 | NULL); |
347 | 337 | GNUNET_TESTING_peer_run ("test-gns-simple-shorten", | |
348 | GNUNET_TESTING_peer_run ("test-gns-simple-shorten", "test_gns_simple_lookup.conf", &do_check, NULL); | 338 | "test_gns_simple_lookup.conf", |
339 | &do_check, NULL); | ||
349 | return ok; | 340 | return ok; |
350 | } | 341 | } |
351 | 342 | ||
352 | /* end of test_gns_twopeer.c */ | 343 | /* 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 b3aec0e21..564179d19 100644 --- a/src/gns/test_gns_simple_srv_lookup.c +++ b/src/gns/test_gns_simple_srv_lookup.c | |||
@@ -33,15 +33,9 @@ | |||
33 | #include "gns_protocol.h" | 33 | #include "gns_protocol.h" |
34 | #include "gnunet_gns_service.h" | 34 | #include "gnunet_gns_service.h" |
35 | 35 | ||
36 | /* DEFINES */ | ||
37 | #define VERBOSE GNUNET_YES | ||
38 | |||
39 | /* Timeout for entire testcase */ | 36 | /* Timeout for entire testcase */ |
40 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) | 37 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) |
41 | 38 | ||
42 | /* If number of peers not in config file, use this number */ | ||
43 | #define DEFAULT_NUM_PEERS 2 | ||
44 | |||
45 | /* test records to resolve */ | 39 | /* test records to resolve */ |
46 | #define TEST_DOMAIN "_sip._tcp.bob.gads" | 40 | #define TEST_DOMAIN "_sip._tcp.bob.gads" |
47 | #define TEST_IP "127.0.0.1" | 41 | #define TEST_IP "127.0.0.1" |
@@ -299,18 +293,12 @@ do_check (void *cls, | |||
299 | } | 293 | } |
300 | 294 | ||
301 | 295 | ||
302 | |||
303 | int | 296 | int |
304 | main (int argc, char *argv[]) | 297 | main (int argc, char *argv[]) |
305 | { | 298 | { |
306 | ok = 1; | 299 | ok = 1; |
307 | |||
308 | GNUNET_log_setup ("test-gns-simple-srv-lookup", | 300 | GNUNET_log_setup ("test-gns-simple-srv-lookup", |
309 | #if VERBOSE | ||
310 | "DEBUG", | ||
311 | #else | ||
312 | "WARNING", | 301 | "WARNING", |
313 | #endif | ||
314 | NULL); | 302 | NULL); |
315 | GNUNET_TESTING_peer_run ("test-gns-simple-srv-lookup", "test_gns_simple_lookup.conf", &do_check, NULL); | 303 | GNUNET_TESTING_peer_run ("test-gns-simple-srv-lookup", "test_gns_simple_lookup.conf", &do_check, NULL); |
316 | GNUNET_DISK_directory_remove ("test-gns-simple-srv-lookup"); | 304 | 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 a1cef1828..4fbd6af72 100644 --- a/src/gns/test_gns_simple_zkey_lookup.c +++ b/src/gns/test_gns_simple_zkey_lookup.c | |||
@@ -33,15 +33,9 @@ | |||
33 | #include "gnunet_gns_service.h" | 33 | #include "gnunet_gns_service.h" |
34 | #include "gns.h" | 34 | #include "gns.h" |
35 | 35 | ||
36 | /* DEFINES */ | ||
37 | #define VERBOSE GNUNET_YES | ||
38 | |||
39 | /* Timeout for entire testcase */ | 36 | /* Timeout for entire testcase */ |
40 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 40) | 37 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 40) |
41 | 38 | ||
42 | /* If number of peers not in config file, use this number */ | ||
43 | #define DEFAULT_NUM_PEERS 2 | ||
44 | |||
45 | /* test records to resolve */ | 39 | /* test records to resolve */ |
46 | #define TEST_IP "127.0.0.1" | 40 | #define TEST_IP "127.0.0.1" |
47 | #define TEST_RECORD_NAME "www" | 41 | #define TEST_RECORD_NAME "www" |
@@ -50,10 +44,8 @@ | |||
50 | 44 | ||
51 | #define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey" | 45 | #define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey" |
52 | 46 | ||
53 | /* Globals */ | ||
54 | |||
55 | /* Task handle to use to schedule test failure */ | 47 | /* Task handle to use to schedule test failure */ |
56 | GNUNET_SCHEDULER_TaskIdentifier die_task; | 48 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
57 | 49 | ||
58 | /* Global return value (0 for success, anything else for failure) */ | 50 | /* Global return value (0 for success, anything else for failure) */ |
59 | static int ok; | 51 | static int ok; |
@@ -62,9 +54,9 @@ static struct GNUNET_NAMESTORE_Handle *namestore_handle; | |||
62 | 54 | ||
63 | static struct GNUNET_GNS_Handle *gns_handle; | 55 | static struct GNUNET_GNS_Handle *gns_handle; |
64 | 56 | ||
65 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 57 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
66 | 58 | ||
67 | struct GNUNET_CRYPTO_ShortHashCode bob_hash; | 59 | static struct GNUNET_CRYPTO_ShortHashCode bob_hash; |
68 | 60 | ||
69 | 61 | ||
70 | /** | 62 | /** |
@@ -92,6 +84,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
92 | ok = 1; | 84 | ok = 1; |
93 | } | 85 | } |
94 | 86 | ||
87 | |||
95 | static void | 88 | static void |
96 | end_badly_now () | 89 | end_badly_now () |
97 | { | 90 | { |
@@ -99,14 +92,17 @@ end_badly_now () | |||
99 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | 92 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); |
100 | } | 93 | } |
101 | 94 | ||
102 | static void shutdown_task (void *cls, | 95 | |
103 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 96 | static void |
97 | shutdown_task (void *cls, | ||
98 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
104 | { | 99 | { |
105 | GNUNET_GNS_disconnect(gns_handle); | 100 | GNUNET_GNS_disconnect(gns_handle); |
106 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n"); | 101 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n"); |
107 | GNUNET_SCHEDULER_shutdown (); | 102 | GNUNET_SCHEDULER_shutdown (); |
108 | } | 103 | } |
109 | 104 | ||
105 | |||
110 | static void | 106 | static void |
111 | on_lookup_result(void *cls, uint32_t rd_count, | 107 | on_lookup_result(void *cls, uint32_t rd_count, |
112 | const struct GNUNET_NAMESTORE_RecordData *rd) | 108 | const struct GNUNET_NAMESTORE_RecordData *rd) |
@@ -157,6 +153,8 @@ on_lookup_result(void *cls, uint32_t rd_count, | |||
157 | 153 | ||
158 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 154 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
159 | } | 155 | } |
156 | |||
157 | |||
160 | /** | 158 | /** |
161 | * Function scheduled to be run on the successful start of services | 159 | * Function scheduled to be run on the successful start of services |
162 | * tries to look up the dns record for TEST_DOMAIN | 160 | * tries to look up the dns record for TEST_DOMAIN |
@@ -280,21 +278,17 @@ do_check (void *cls, | |||
280 | } | 278 | } |
281 | 279 | ||
282 | 280 | ||
283 | |||
284 | |||
285 | int | 281 | int |
286 | main (int argc, char *argv[]) | 282 | main (int argc, char *argv[]) |
287 | { | 283 | { |
288 | ok = 1; | 284 | ok = 1; |
289 | 285 | ||
290 | GNUNET_log_setup ("test-gns-simple-zkey-lookup", | 286 | GNUNET_log_setup ("test-gns-simple-zkey-lookup", |
291 | #if VERBOSE | ||
292 | "DEBUG", | ||
293 | #else | ||
294 | "WARNING", | 287 | "WARNING", |
295 | #endif | ||
296 | NULL); | 288 | NULL); |
297 | GNUNET_TESTING_peer_run ("test-gns-simple-zkey-lookup", "test_gns_simple_lookup.conf", &do_check, NULL); | 289 | GNUNET_TESTING_peer_run ("test-gns-simple-zkey-lookup", |
290 | "test_gns_simple_lookup.conf", | ||
291 | &do_check, NULL); | ||
298 | return ok; | 292 | return ok; |
299 | } | 293 | } |
300 | 294 | ||