diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-01 10:37:47 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-01 10:37:47 +0000 |
commit | c93c582dfed6b36d507308a2b677753f37b1d31b (patch) | |
tree | 9b303394930f68bcea5d90a329680401b88d022b /src/gns | |
parent | 8e0a942237b701e2d03db2def2204417acdc6f4c (diff) | |
download | gnunet-c93c582dfed6b36d507308a2b677753f37b1d31b.tar.gz gnunet-c93c582dfed6b36d507308a2b677753f37b1d31b.zip |
-stuff
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/gnunet-service-gns.c | 12 | ||||
-rw-r--r-- | src/gns/plugin_block_gns.c | 57 |
2 files changed, 34 insertions, 35 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index b5649f35c..7eaf603d9 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -39,6 +39,8 @@ | |||
39 | #include "block_gns.h" | 39 | #include "block_gns.h" |
40 | #include "gns.h" | 40 | #include "gns.h" |
41 | 41 | ||
42 | #define DHT_LOOKUP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | ||
43 | |||
42 | /* Ignore for now not used anyway and probably never will */ | 44 | /* Ignore for now not used anyway and probably never will */ |
43 | #define GNUNET_MESSAGE_TYPE_GNS_CLIENT_LOOKUP 23 | 45 | #define GNUNET_MESSAGE_TYPE_GNS_CLIENT_LOOKUP 23 |
44 | #define GNUNET_MESSAGE_TYPE_GNS_CLIENT_RESULT 24 | 46 | #define GNUNET_MESSAGE_TYPE_GNS_CLIENT_RESULT 24 |
@@ -443,11 +445,10 @@ process_name_dht_result(void* cls, | |||
443 | * @param rh the pending gns query context | 445 | * @param rh the pending gns query context |
444 | * @param name the name to query record | 446 | * @param name the name to query record |
445 | */ | 447 | */ |
446 | void | 448 | static void |
447 | resolve_name_dht(struct GNUNET_GNS_ResolverHandle *rh, const char* name) | 449 | resolve_name_dht(struct GNUNET_GNS_ResolverHandle *rh, const char* name) |
448 | { | 450 | { |
449 | uint32_t xquery; | 451 | uint32_t xquery; |
450 | struct GNUNET_TIME_Relative timeout; | ||
451 | GNUNET_HashCode name_hash; | 452 | GNUNET_HashCode name_hash; |
452 | GNUNET_HashCode lookup_key; | 453 | GNUNET_HashCode lookup_key; |
453 | struct GNUNET_CRYPTO_HashAsciiEncoded lookup_key_string; | 454 | struct GNUNET_CRYPTO_HashAsciiEncoded lookup_key_string; |
@@ -460,16 +461,15 @@ resolve_name_dht(struct GNUNET_GNS_ResolverHandle *rh, const char* name) | |||
460 | "starting dht lookup for %s with key: %s\n", | 461 | "starting dht lookup for %s with key: %s\n", |
461 | name, (char*)&lookup_key_string); | 462 | name, (char*)&lookup_key_string); |
462 | 463 | ||
463 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5); | ||
464 | |||
465 | xquery = htonl(rh->query->type); | 464 | xquery = htonl(rh->query->type); |
466 | //FIXME how long to wait for results? | 465 | //FIXME how long to wait for results? |
467 | rh->get_handle = GNUNET_DHT_get_start(dht_handle, timeout, | 466 | rh->get_handle = GNUNET_DHT_get_start(dht_handle, |
467 | DHT_LOOKUP_TIMEOUT, | ||
468 | GNUNET_BLOCK_TYPE_GNS_NAMERECORD, | 468 | GNUNET_BLOCK_TYPE_GNS_NAMERECORD, |
469 | &lookup_key, | 469 | &lookup_key, |
470 | 5, //Replication level FIXME | 470 | 5, //Replication level FIXME |
471 | GNUNET_DHT_RO_NONE, | 471 | GNUNET_DHT_RO_NONE, |
472 | &xquery, //xquery FIXME is this bad? | 472 | &xquery, |
473 | sizeof(xquery), | 473 | sizeof(xquery), |
474 | &process_name_dht_result, | 474 | &process_name_dht_result, |
475 | rh); | 475 | rh); |
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c index a4d6ad9c8..e1677b35b 100644 --- a/src/gns/plugin_block_gns.c +++ b/src/gns/plugin_block_gns.c | |||
@@ -62,11 +62,6 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
62 | size_t xquery_size, const void *reply_block, | 62 | size_t xquery_size, const void *reply_block, |
63 | size_t reply_block_size) | 63 | size_t reply_block_size) |
64 | { | 64 | { |
65 | if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD) | ||
66 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | ||
67 | if (reply_block_size == 0) | ||
68 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | ||
69 | |||
70 | char* name; | 65 | char* name; |
71 | GNUNET_HashCode pkey_hash; | 66 | GNUNET_HashCode pkey_hash; |
72 | GNUNET_HashCode query_key; | 67 | GNUNET_HashCode query_key; |
@@ -76,7 +71,13 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
76 | struct GNSNameRecordBlock *nrb; | 71 | struct GNSNameRecordBlock *nrb; |
77 | struct GNSRecordBlock *rb; | 72 | struct GNSRecordBlock *rb; |
78 | uint32_t rd_count; | 73 | uint32_t rd_count; |
79 | 74 | unsigned int record_match; | |
75 | |||
76 | if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD) | ||
77 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | ||
78 | if (reply_block_size == 0) | ||
79 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | ||
80 | |||
80 | nrb = (struct GNSNameRecordBlock *)reply_block; | 81 | nrb = (struct GNSNameRecordBlock *)reply_block; |
81 | name = (char*)&nrb[1]; | 82 | name = (char*)&nrb[1]; |
82 | GNUNET_CRYPTO_hash(&nrb->public_key, | 83 | GNUNET_CRYPTO_hash(&nrb->public_key, |
@@ -91,33 +92,31 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
91 | if (0 != GNUNET_CRYPTO_hash_cmp(query, &query_key)) | 92 | if (0 != GNUNET_CRYPTO_hash_cmp(query, &query_key)) |
92 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | 93 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; |
93 | 94 | ||
95 | record_match = 0; | ||
94 | rd_count = ntohl(nrb->rd_count); | 96 | rd_count = ntohl(nrb->rd_count); |
95 | |||
96 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; | ||
97 | int i = 0; | ||
98 | int record_match = 0; | ||
99 | uint32_t record_xquery = ntohl(*((uint32_t*)xquery)); | ||
100 | rb = (struct GNSRecordBlock*)(&name[strlen(name) + 1]); | ||
101 | |||
102 | for (i=0; i<rd_count; i++) | ||
103 | { | 97 | { |
104 | rd[i].record_type = ntohl(rb->type); | 98 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; |
105 | rd[i].expiration = | 99 | unsigned int i; |
106 | GNUNET_TIME_absolute_ntoh(rb->expiration); | 100 | uint32_t record_xquery = ntohl(*((uint32_t*)xquery)); |
107 | rd[i].data_size = ntohl(rb->data_length); | 101 | |
108 | rd[i].flags = ntohl(rb->flags); | 102 | rb = (struct GNSRecordBlock*)(&name[strlen(name) + 1]); |
109 | rd[i].data = (char*)&rb[1]; | 103 | for (i=0; i<rd_count; i++) |
110 | rb = (struct GNSRecordBlock *)((char*)&rb[1] + rd[i].data_size); | ||
111 | |||
112 | if (xquery_size == 0) | ||
113 | continue; | ||
114 | |||
115 | if (rd[i].record_type == record_xquery) | ||
116 | { | 104 | { |
117 | record_match++; | 105 | rd[i].record_type = ntohl(rb->type); |
106 | rd[i].expiration = | ||
107 | GNUNET_TIME_absolute_ntoh(rb->expiration); | ||
108 | rd[i].data_size = ntohl(rb->data_length); | ||
109 | rd[i].flags = ntohl(rb->flags); | ||
110 | rd[i].data = (char*)&rb[1]; | ||
111 | rb = (struct GNSRecordBlock *)((char*)&rb[1] + rd[i].data_size); | ||
112 | |||
113 | if (xquery_size == 0) | ||
114 | continue; | ||
115 | |||
116 | if (rd[i].record_type == record_xquery) | ||
117 | record_match++; | ||
118 | } | 118 | } |
119 | } | 119 | } |
120 | |||
121 | 120 | ||
122 | /*if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&nrb->public_key, | 121 | /*if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&nrb->public_key, |
123 | name, | 122 | name, |