aboutsummaryrefslogtreecommitdiff
path: root/src/gns/gnunet-service-gns_resolver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gns/gnunet-service-gns_resolver.c')
-rw-r--r--src/gns/gnunet-service-gns_resolver.c71
1 files changed, 38 insertions, 33 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index cb75b23c7..d9d0d3099 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -173,7 +173,7 @@ struct AuthorityChain
173 /** 173 /**
174 * The zone of the GNS authority 174 * The zone of the GNS authority
175 */ 175 */
176 struct GNUNET_CRYPTO_EcdsaPublicKey gns_authority; 176 struct GNUNET_IDENTITY_PublicKey gns_authority;
177 177
178 struct 178 struct
179 { 179 {
@@ -305,7 +305,7 @@ struct GNS_ResolverHandle
305 /** 305 /**
306 * The top-level GNS authoritative zone to query 306 * The top-level GNS authoritative zone to query
307 */ 307 */
308 struct GNUNET_CRYPTO_EcdsaPublicKey authority_zone; 308 struct GNUNET_IDENTITY_PublicKey authority_zone;
309 309
310 /** 310 /**
311 * called when resolution phase finishes 311 * called when resolution phase finishes
@@ -1251,7 +1251,7 @@ handle_gns_cname_result (struct GNS_ResolverHandle *rh,
1251 const char *tld; 1251 const char *tld;
1252 struct AuthorityChain *ac; 1252 struct AuthorityChain *ac;
1253 int af; 1253 int af;
1254 struct GNUNET_CRYPTO_EcdsaPublicKey zone; 1254 struct GNUNET_IDENTITY_PublicKey zone;
1255 1255
1256 nlen = strlen (cname); 1256 nlen = strlen (cname);
1257 tld = GNS_get_tld (cname); 1257 tld = GNS_get_tld (cname);
@@ -1296,7 +1296,7 @@ handle_gns_cname_result (struct GNS_ResolverHandle *rh,
1296 { 1296 {
1297 GNUNET_asprintf (&res, 1297 GNUNET_asprintf (&res,
1298 "%.*s", 1298 "%.*s",
1299 strlen (cname) - (strlen (tld) + 1), 1299 (int) (strlen (cname) - (strlen (tld) + 1)),
1300 cname); 1300 cname);
1301 } 1301 }
1302 else 1302 else
@@ -1305,7 +1305,7 @@ handle_gns_cname_result (struct GNS_ResolverHandle *rh,
1305 "%.*s.%.*s", 1305 "%.*s.%.*s",
1306 (int) rh->name_resolution_pos, 1306 (int) rh->name_resolution_pos,
1307 rh->name, 1307 rh->name,
1308 (int) strlen (cname) - (strlen (tld) + 1), 1308 (int) (strlen (cname) - (strlen (tld) + 1)),
1309 cname); 1309 cname);
1310 } 1310 }
1311 rh->name_resolution_pos = strlen (res); 1311 rh->name_resolution_pos = strlen (res);
@@ -1696,10 +1696,13 @@ recursive_pkey_resolution (struct GNS_ResolverHandle *rh,
1696 const struct GNUNET_GNSRECORD_Data *rd) 1696 const struct GNUNET_GNSRECORD_Data *rd)
1697{ 1697{
1698 struct AuthorityChain *ac; 1698 struct AuthorityChain *ac;
1699 struct GNUNET_IDENTITY_PublicKey auth;
1699 1700
1700 /* delegation to another zone */ 1701 /* delegation to another zone */
1701 if (sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey) != 1702 if (GNUNET_OK != GNUNET_GNSRECORD_identity_from_data (rd->data,
1702 rd->data_size) 1703 rd->data_size,
1704 rd->record_type,
1705 &auth))
1703 { 1706 {
1704 GNUNET_break_op (0); 1707 GNUNET_break_op (0);
1705 fail_resolution (rh); 1708 fail_resolution (rh);
@@ -1709,9 +1712,7 @@ recursive_pkey_resolution (struct GNS_ResolverHandle *rh,
1709 ac = GNUNET_new (struct AuthorityChain); 1712 ac = GNUNET_new (struct AuthorityChain);
1710 ac->rh = rh; 1713 ac->rh = rh;
1711 ac->gns_authority = GNUNET_YES; 1714 ac->gns_authority = GNUNET_YES;
1712 GNUNET_memcpy (&ac->authority_info.gns_authority, 1715 ac->authority_info.gns_authority = auth;
1713 rd->data,
1714 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey));
1715 ac->label = resolver_lookup_get_next_label (rh); 1716 ac->label = resolver_lookup_get_next_label (rh);
1716 /* add AC to tail */ 1717 /* add AC to tail */
1717 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, 1718 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
@@ -1754,7 +1755,7 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh,
1754 char *n; 1755 char *n;
1755 size_t off; 1756 size_t off;
1756 struct Gns2DnsPending *gp; 1757 struct Gns2DnsPending *gp;
1757 struct GNUNET_CRYPTO_EcdsaPublicKey zone; 1758 struct GNUNET_IDENTITY_PublicKey zone;
1758 struct sockaddr_in v4; 1759 struct sockaddr_in v4;
1759 struct sockaddr_in6 v6; 1760 struct sockaddr_in6 v6;
1760 1761
@@ -2257,19 +2258,25 @@ handle_gns_resolution_result (void *cls,
2257 break; 2258 break;
2258 2259
2259 case GNUNET_GNSRECORD_TYPE_PKEY: 2260 case GNUNET_GNSRECORD_TYPE_PKEY:
2261 case GNUNET_GNSRECORD_TYPE_EDKEY:
2260 { 2262 {
2261 struct GNUNET_CRYPTO_EcdsaPublicKey pub; 2263 struct GNUNET_IDENTITY_PublicKey pubkey;
2262 2264 if (rd[i].data_size < sizeof(uint32_t))
2263 if (rd[i].data_size != sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)) 2265 {
2266 GNUNET_break_op (0);
2267 break;
2268 }
2269 if (GNUNET_OK !=
2270 GNUNET_GNSRECORD_identity_from_data (rd[i].data,
2271 rd[i].data_size,
2272 rd[i].record_type,
2273 &pubkey))
2264 { 2274 {
2265 GNUNET_break_op (0); 2275 GNUNET_break_op (0);
2266 break; 2276 break;
2267 } 2277 }
2268 GNUNET_memcpy (&pub,
2269 rd[i].data,
2270 rd[i].data_size);
2271 rd_off++; 2278 rd_off++;
2272 if (GNUNET_GNSRECORD_TYPE_PKEY != rh->record_type) 2279 if (rd[i].record_type != rh->record_type)
2273 { 2280 {
2274 /* try to resolve "@" */ 2281 /* try to resolve "@" */
2275 struct AuthorityChain *ac; 2282 struct AuthorityChain *ac;
@@ -2277,7 +2284,7 @@ handle_gns_resolution_result (void *cls,
2277 ac = GNUNET_new (struct AuthorityChain); 2284 ac = GNUNET_new (struct AuthorityChain);
2278 ac->rh = rh; 2285 ac->rh = rh;
2279 ac->gns_authority = GNUNET_YES; 2286 ac->gns_authority = GNUNET_YES;
2280 ac->authority_info.gns_authority = pub; 2287 ac->authority_info.gns_authority = pubkey;
2281 ac->label = GNUNET_strdup (GNUNET_GNS_EMPTY_LABEL_AT); 2288 ac->label = GNUNET_strdup (GNUNET_GNS_EMPTY_LABEL_AT);
2282 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, 2289 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
2283 rh->ac_tail, 2290 rh->ac_tail,
@@ -2367,6 +2374,7 @@ handle_gns_resolution_result (void *cls,
2367 return; 2374 return;
2368 2375
2369 case GNUNET_GNSRECORD_TYPE_PKEY: 2376 case GNUNET_GNSRECORD_TYPE_PKEY:
2377 case GNUNET_GNSRECORD_TYPE_EDKEY:
2370 GNUNET_break_op (1 == rd_count); /* PKEY should be unique */ 2378 GNUNET_break_op (1 == rd_count); /* PKEY should be unique */
2371 recursive_pkey_resolution (rh, 2379 recursive_pkey_resolution (rh,
2372 &rd[0]); 2380 &rd[0]);
@@ -2469,10 +2477,7 @@ handle_dht_response (void *cls,
2469 return; 2477 return;
2470 } 2478 }
2471 block = data; 2479 block = data;
2472 if (size != 2480 if (size != GNUNET_GNSRECORD_block_get_size (block))
2473 ntohl (block->purpose.size)
2474 + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)
2475 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature))
2476 { 2481 {
2477 /* how did this pass DHT block validation!? */ 2482 /* how did this pass DHT block validation!? */
2478 GNUNET_break (0); 2483 GNUNET_break (0);
@@ -2480,8 +2485,8 @@ handle_dht_response (void *cls,
2480 return; 2485 return;
2481 } 2486 }
2482 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2487 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2483 "Decrypting DHT block of size %u for `%s', expires %s\n", 2488 "Decrypting DHT block of size %lu for `%s', expires %s\n",
2484 ntohl (block->purpose.size), 2489 GNUNET_GNSRECORD_block_get_size (block),
2485 rh->name, 2490 rh->name,
2486 GNUNET_STRINGS_absolute_time_to_string (exp)); 2491 GNUNET_STRINGS_absolute_time_to_string (exp));
2487 if (GNUNET_OK != 2492 if (GNUNET_OK !=
@@ -2495,8 +2500,8 @@ handle_dht_response (void *cls,
2495 fail_resolution (rh); 2500 fail_resolution (rh);
2496 return; 2501 return;
2497 } 2502 }
2498 if (0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh ( 2503 if (0 == GNUNET_TIME_absolute_get_remaining (
2499 block->expiration_time)). 2504 GNUNET_GNSRECORD_block_get_expiration (block)).
2500 rel_value_us) 2505 rel_value_us)
2501 { 2506 {
2502 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2507 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2594,7 +2599,7 @@ handle_namecache_block_response (void *cls,
2594 struct GNS_ResolverHandle *rh = cls; 2599 struct GNS_ResolverHandle *rh = cls;
2595 struct AuthorityChain *ac = rh->ac_tail; 2600 struct AuthorityChain *ac = rh->ac_tail;
2596 const char *label = ac->label; 2601 const char *label = ac->label;
2597 const struct GNUNET_CRYPTO_EcdsaPublicKey *auth = 2602 const struct GNUNET_IDENTITY_PublicKey *auth =
2598 &ac->authority_info.gns_authority; 2603 &ac->authority_info.gns_authority;
2599 struct GNUNET_HashCode query; 2604 struct GNUNET_HashCode query;
2600 2605
@@ -2604,8 +2609,8 @@ handle_namecache_block_response (void *cls,
2604 ((GNUNET_GNS_LO_LOCAL_MASTER == rh->options) && 2609 ((GNUNET_GNS_LO_LOCAL_MASTER == rh->options) &&
2605 (ac != rh->ac_head))) && 2610 (ac != rh->ac_head))) &&
2606 ((NULL == block) || 2611 ((NULL == block) ||
2607 (0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh ( 2612 (0 == GNUNET_TIME_absolute_get_remaining (
2608 block->expiration_time)). 2613 GNUNET_GNSRECORD_block_get_expiration (block)).
2609 rel_value_us))) 2614 rel_value_us)))
2610 { 2615 {
2611 /* namecache knows nothing; try DHT lookup */ 2616 /* namecache knows nothing; try DHT lookup */
@@ -2622,8 +2627,8 @@ handle_namecache_block_response (void *cls,
2622 } 2627 }
2623 2628
2624 if ((NULL == block) || 2629 if ((NULL == block) ||
2625 (0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh ( 2630 (0 == GNUNET_TIME_absolute_get_remaining (
2626 block->expiration_time)). 2631 GNUNET_GNSRECORD_block_get_expiration (block)).
2627 rel_value_us)) 2632 rel_value_us))
2628 { 2633 {
2629 /* DHT not permitted and no local result, fail */ 2634 /* DHT not permitted and no local result, fail */
@@ -2857,7 +2862,7 @@ start_resolver_lookup (void *cls)
2857 * @return handle to cancel operation 2862 * @return handle to cancel operation
2858 */ 2863 */
2859struct GNS_ResolverHandle * 2864struct GNS_ResolverHandle *
2860GNS_resolver_lookup (const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, 2865GNS_resolver_lookup (const struct GNUNET_IDENTITY_PublicKey *zone,
2861 uint32_t record_type, 2866 uint32_t record_type,
2862 const char *name, 2867 const char *name,
2863 enum GNUNET_GNS_LocalOptions options, 2868 enum GNUNET_GNS_LocalOptions options,