diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-13 16:40:41 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-13 16:40:41 +0000 |
commit | ee32003b7e606767f9b89715cb956d863fe067d9 (patch) | |
tree | eca3af3ac8a6c0852352861a69ea9e919343b03c | |
parent | 597dc76d129d291cd9dbe2fbd6914e54ae0ef118 (diff) | |
download | gnunet-ee32003b7e606767f9b89715cb956d863fe067d9.tar.gz gnunet-ee32003b7e606767f9b89715cb956d863fe067d9.zip |
-working on new, simplified GNS API
-rw-r--r-- | src/gns/gnunet-service-gns.c | 1 | ||||
-rw-r--r-- | src/gns/plugin_block_gns.c | 201 | ||||
-rw-r--r-- | src/include/Makefile.am | 1 | ||||
-rw-r--r-- | src/include/block_gns.h | 61 | ||||
-rw-r--r-- | src/include/gnunet_gns_service.h | 110 | ||||
-rw-r--r-- | src/include/gnunet_namestore_service.h | 5 |
6 files changed, 74 insertions, 305 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 1bff3e51d..1bd6d33d1 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include "gnunet_namestore_service.h" | 31 | #include "gnunet_namestore_service.h" |
32 | #include "gnunet_gns_service.h" | 32 | #include "gnunet_gns_service.h" |
33 | #include "gnunet_statistics_service.h" | 33 | #include "gnunet_statistics_service.h" |
34 | #include "block_gns.h" | ||
35 | #include "gns.h" | 34 | #include "gns.h" |
36 | #include "gns_common.h" | 35 | #include "gns_common.h" |
37 | #include "gnunet-service-gns_resolver.h" | 36 | #include "gnunet-service-gns_resolver.h" |
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c index 4d12f02df..22e3d61fd 100644 --- a/src/gns/plugin_block_gns.c +++ b/src/gns/plugin_block_gns.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | (C) 2010, 2012 Christian Grothoff (and other contributing authors) | 3 | (C) 2010-2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -27,7 +27,6 @@ | |||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_block_plugin.h" | 28 | #include "gnunet_block_plugin.h" |
29 | #include "gnunet_namestore_service.h" | 29 | #include "gnunet_namestore_service.h" |
30 | #include "block_gns.h" | ||
31 | #include "gnunet_signatures.h" | 30 | #include "gnunet_signatures.h" |
32 | #include "gns_common.h" | 31 | #include "gns_common.h" |
33 | 32 | ||
@@ -47,49 +46,32 @@ | |||
47 | * @param cls closure | 46 | * @param cls closure |
48 | * @param type block type | 47 | * @param type block type |
49 | * @param query original query (hash) | 48 | * @param query original query (hash) |
50 | * @param bf pointer to bloom filter associated with query; possibly updated (!) | 49 | * @param bf pointer to bloom filter associated with @a query; possibly updated (!) |
51 | * @param bf_mutator mutation value for bf | 50 | * @param bf_mutator mutation value for @a bf |
52 | * @param xquery extrended query data (can be NULL, depending on type) | 51 | * @param xquery extrended query data (can be NULL, depending on @a type) |
53 | * @param xquery_size number of bytes in xquery | 52 | * @param xquery_size number of bytes in @a xquery |
54 | * @param reply_block response to validate | 53 | * @param reply_block response to validate |
55 | * @param reply_block_size number of bytes in reply block | 54 | * @param reply_block_size number of bytes in @a reply_block |
56 | * @return characterization of result | 55 | * @return characterization of result |
57 | */ | 56 | */ |
58 | static enum GNUNET_BLOCK_EvaluationResult | 57 | static enum GNUNET_BLOCK_EvaluationResult |
59 | block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | 58 | block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, |
60 | const struct GNUNET_HashCode * query, | 59 | const struct GNUNET_HashCode *query, |
61 | struct GNUNET_CONTAINER_BloomFilter **bf, | 60 | struct GNUNET_CONTAINER_BloomFilter **bf, |
62 | int32_t bf_mutator, const void *xquery, | 61 | int32_t bf_mutator, const void *xquery, |
63 | size_t xquery_size, const void *reply_block, | 62 | size_t xquery_size, const void *reply_block, |
64 | size_t reply_block_size) | 63 | size_t reply_block_size) |
65 | { | 64 | { |
66 | const struct GNSNameRecordBlock *nrb; | 65 | const struct GNUNET_NAMESTORE_Block *block; |
67 | const char* name; | 66 | struct GNUNET_HashCode h; |
68 | const char *name_end; | ||
69 | const char *rd_data; | ||
70 | struct GNUNET_HashCode query_key; | ||
71 | struct GNUNET_HashCode mhash; | ||
72 | struct GNUNET_HashCode chash; | 67 | struct GNUNET_HashCode chash; |
73 | struct GNUNET_CRYPTO_ShortHashCode pkey_hash; | 68 | struct GNUNET_HashCode mhash; |
74 | struct GNUNET_CRYPTO_HashAsciiEncoded xor_exp; | ||
75 | struct GNUNET_CRYPTO_HashAsciiEncoded xor_got; | ||
76 | uint32_t rd_count; | ||
77 | size_t rd_len; | ||
78 | size_t name_len; | ||
79 | uint32_t record_xquery; | ||
80 | unsigned int record_match; | ||
81 | |||
82 | //GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "RB SIZE %d\n", reply_block_size); | ||
83 | 69 | ||
84 | if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD) | 70 | if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD) |
85 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | 71 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; |
86 | if (reply_block == NULL) | 72 | if (NULL == reply_block) |
87 | { | 73 | { |
88 | /** | 74 | if (0 != xquery_size) |
89 | * check if request is valid | ||
90 | * FIXME we could check for the record types here | ||
91 | **/ | ||
92 | if (xquery_size < sizeof(uint32_t)) | ||
93 | { | 75 | { |
94 | GNUNET_break_op (0); | 76 | GNUNET_break_op (0); |
95 | return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; | 77 | return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; |
@@ -98,111 +80,47 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
98 | } | 80 | } |
99 | 81 | ||
100 | /* this is a reply */ | 82 | /* this is a reply */ |
101 | 83 | if (reply_block_size < sizeof (struct GNUNET_NAMESTORE_Block)) | |
102 | nrb = (const struct GNSNameRecordBlock *)reply_block; | ||
103 | name = (const char*) &nrb[1]; | ||
104 | name_end = memchr (name, 0, reply_block_size - sizeof (struct GNSNameRecordBlock)); | ||
105 | if (NULL == name_end) | ||
106 | { | ||
107 | GNUNET_break_op (0); | ||
108 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
109 | } | ||
110 | name_len = (name_end - name) + 1; | ||
111 | GNUNET_CRYPTO_short_hash (&nrb->public_key, | ||
112 | sizeof(nrb->public_key), | ||
113 | &pkey_hash); | ||
114 | GNUNET_GNS_get_key_for_record (name, &pkey_hash, &query_key); | ||
115 | |||
116 | GNUNET_CRYPTO_hash_to_enc (&query_key, &xor_exp); | ||
117 | GNUNET_CRYPTO_hash_to_enc (query, &xor_got); | ||
118 | |||
119 | //GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
120 | // "BLOCK_TEST for %s got %s expected %s\n", | ||
121 | // name, (char*) &xor_got, (char*) &xor_exp); | ||
122 | |||
123 | /* Check query key against public key */ | ||
124 | if (0 != GNUNET_CRYPTO_hash_cmp(query, &query_key)) | ||
125 | { | ||
126 | GNUNET_break_op (0); | ||
127 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
128 | } | ||
129 | |||
130 | record_match = 0; | ||
131 | rd_count = ntohl(nrb->rd_count); | ||
132 | rd_data = &name[name_len]; | ||
133 | rd_len = reply_block_size - (name_len | ||
134 | + sizeof(struct GNSNameRecordBlock)); | ||
135 | { | ||
136 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; | ||
137 | unsigned int i; | ||
138 | uint64_t exp = UINT64_MAX; | ||
139 | struct GNUNET_TIME_Absolute et = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
140 | |||
141 | if (GNUNET_SYSERR == GNUNET_NAMESTORE_records_deserialize (rd_len, | ||
142 | rd_data, | ||
143 | rd_count, | ||
144 | rd)) | ||
145 | { | 84 | { |
146 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 85 | GNUNET_break_op (0); |
147 | "Data invalid (%d bytes, %d records)\n", rd_len, rd_count); | ||
148 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | 86 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
149 | } | 87 | } |
150 | 88 | block = reply_block; | |
151 | if (xquery_size < sizeof(uint32_t)) | 89 | if (ntohs (block->purpose.size) + sizeof (struct GNUNET_CRYPTO_EccSignature) + sizeof (struct GNUNET_CRYPTO_EccPublicKey) != |
152 | record_xquery = 0; | 90 | reply_block_size) |
153 | else | 91 | { |
154 | record_xquery = ntohl(*((uint32_t*)xquery)); | 92 | GNUNET_break_op (0); |
155 | 93 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | |
156 | for (i=0; i<rd_count; i++) | ||
157 | { | ||
158 | GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION)); | ||
159 | exp = GNUNET_MIN (exp, rd[i].expiration_time); | ||
160 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
161 | "Got record of size %d expiration %u\n", | ||
162 | rd[i].data_size, rd[i].expiration_time); | ||
163 | if ((record_xquery != 0) | ||
164 | && (rd[i].record_type == record_xquery)) | ||
165 | { | ||
166 | record_match++; | ||
167 | } | ||
168 | } | 94 | } |
169 | et.abs_value_us = exp; | 95 | GNUNET_CRYPTO_hash (&block->derived_key, |
170 | 96 | sizeof (block->derived_key), | |
171 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 97 | &h); |
172 | "Verifying signature of %d records for name %s with expiration of %s\n", | 98 | if (0 != memcmp (&h, query, sizeof (struct GNUNET_HashCode))) |
173 | rd_count, name, | ||
174 | GNUNET_STRINGS_absolute_time_to_string (et)); | ||
175 | |||
176 | if (GNUNET_OK != | ||
177 | GNUNET_NAMESTORE_verify_signature (&nrb->public_key, | ||
178 | et, | ||
179 | name, | ||
180 | rd_count, | ||
181 | rd, | ||
182 | &nrb->signature)) | ||
183 | { | 99 | { |
184 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
185 | "Signature invalid for %s\n", name); | ||
186 | GNUNET_break_op (0); | 100 | GNUNET_break_op (0); |
187 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | 101 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
188 | } | 102 | } |
189 | } | 103 | if (GNUNET_OK != |
190 | 104 | GNUNET_NAMESTORE_block_verify (block)) | |
191 | if (NULL != bf) | ||
192 | { | ||
193 | GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash); | ||
194 | GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash); | ||
195 | if (NULL != *bf) | ||
196 | { | 105 | { |
197 | if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test(*bf, &mhash)) | 106 | GNUNET_break_op (0); |
198 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; | 107 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
199 | } | 108 | } |
200 | else | 109 | if (NULL != bf) |
201 | { | 110 | { |
202 | *bf = GNUNET_CONTAINER_bloomfilter_init(NULL, 8, BLOOMFILTER_K); | 111 | GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash); |
112 | GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash); | ||
113 | if (NULL != *bf) | ||
114 | { | ||
115 | if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test(*bf, &mhash)) | ||
116 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; | ||
117 | } | ||
118 | else | ||
119 | { | ||
120 | *bf = GNUNET_CONTAINER_bloomfilter_init(NULL, 8, BLOOMFILTER_K); | ||
121 | } | ||
122 | GNUNET_CONTAINER_bloomfilter_add(*bf, &mhash); | ||
203 | } | 123 | } |
204 | GNUNET_CONTAINER_bloomfilter_add(*bf, &mhash); | ||
205 | } | ||
206 | return GNUNET_BLOCK_EVALUATION_OK_MORE; | 124 | return GNUNET_BLOCK_EVALUATION_OK_MORE; |
207 | } | 125 | } |
208 | 126 | ||
@@ -212,35 +130,30 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
212 | * | 130 | * |
213 | * @param cls closure | 131 | * @param cls closure |
214 | * @param type block type | 132 | * @param type block type |
215 | * @param block block to get the key for | 133 | * @param reply_block block to get the key for |
216 | * @param block_size number of bytes in block | 134 | * @param reply_block_size number of bytes in @a reply_block |
217 | * @param key set to the key (query) for the given block | 135 | * @param key set to the key (query) for the given block |
218 | * @return GNUNET_OK on success, GNUNET_SYSERR if type not supported | 136 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported |
219 | * (or if extracting a key from a block of this type does not work) | 137 | * (or if extracting a key from a block of this type does not work) |
220 | */ | 138 | */ |
221 | static int | 139 | static int |
222 | block_plugin_gns_get_key (void *cls, enum GNUNET_BLOCK_Type type, | 140 | block_plugin_gns_get_key (void *cls, enum GNUNET_BLOCK_Type type, |
223 | const void *block, size_t block_size, | 141 | const void *reply_block, size_t reply_block_size, |
224 | struct GNUNET_HashCode * key) | 142 | struct GNUNET_HashCode *key) |
225 | { | 143 | { |
226 | struct GNUNET_CRYPTO_ShortHashCode pkey_hash; | 144 | const struct GNUNET_NAMESTORE_Block *block; |
227 | const struct GNSNameRecordBlock *nrb = block; | ||
228 | const char *name; | ||
229 | 145 | ||
230 | if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD) | 146 | if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD) |
231 | return GNUNET_SYSERR; | 147 | return GNUNET_SYSERR; |
232 | name = (const char *) &nrb[1]; | 148 | if (reply_block_size < sizeof (struct GNUNET_NAMESTORE_Block)) |
233 | if (NULL == memchr (name, '\0', | 149 | { |
234 | block_size - sizeof (struct GNSNameRecordBlock))) | 150 | GNUNET_break_op (0); |
235 | { | 151 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
236 | /* malformed, no 0-termination in name */ | 152 | } |
237 | GNUNET_break_op (0); | 153 | block = reply_block; |
238 | return GNUNET_SYSERR; | 154 | GNUNET_CRYPTO_hash (&block->derived_key, |
239 | } | 155 | sizeof (block->derived_key), |
240 | GNUNET_CRYPTO_short_hash (&nrb->public_key, | 156 | key); |
241 | sizeof (struct GNUNET_CRYPTO_EccPublicKey), | ||
242 | &pkey_hash); | ||
243 | GNUNET_GNS_get_key_for_record (name, &pkey_hash, key); | ||
244 | return GNUNET_OK; | 157 | return GNUNET_OK; |
245 | } | 158 | } |
246 | 159 | ||
@@ -258,7 +171,7 @@ libgnunet_plugin_block_gns_init (void *cls) | |||
258 | }; | 171 | }; |
259 | struct GNUNET_BLOCK_PluginFunctions *api; | 172 | struct GNUNET_BLOCK_PluginFunctions *api; |
260 | 173 | ||
261 | api = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_PluginFunctions)); | 174 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); |
262 | api->evaluate = &block_plugin_gns_evaluate; | 175 | api->evaluate = &block_plugin_gns_evaluate; |
263 | api->get_key = &block_plugin_gns_get_key; | 176 | api->get_key = &block_plugin_gns_get_key; |
264 | api->types = types; | 177 | api->types = types; |
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index bdf752382..63f7c3bb5 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -13,7 +13,6 @@ EXTRA_DIST = \ | |||
13 | gauger.h \ | 13 | gauger.h \ |
14 | block_fs.h \ | 14 | block_fs.h \ |
15 | block_dns.h \ | 15 | block_dns.h \ |
16 | block_gns.h \ | ||
17 | block_mesh.h \ | 16 | block_mesh.h \ |
18 | block_regex.h | 17 | block_regex.h |
19 | 18 | ||
diff --git a/src/include/block_gns.h b/src/include/block_gns.h deleted file mode 100644 index 21f0b097c..000000000 --- a/src/include/block_gns.h +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file include/block_gns.h | ||
23 | * @brief fs block formats (shared between fs and block) | ||
24 | * @author Martin Schanzenbach | ||
25 | */ | ||
26 | #ifndef BLOCK_GNS_H | ||
27 | #define BLOCK_GNS_H | ||
28 | |||
29 | #include "gnunet_util_lib.h" | ||
30 | |||
31 | GNUNET_NETWORK_STRUCT_BEGIN | ||
32 | |||
33 | /** | ||
34 | * @brief a record block for a given name of a single authority | ||
35 | */ | ||
36 | struct GNSNameRecordBlock | ||
37 | { | ||
38 | |||
39 | /** | ||
40 | * The public key of the authority | ||
41 | */ | ||
42 | struct GNUNET_CRYPTO_EccPublicKey public_key; | ||
43 | |||
44 | /** | ||
45 | * GNUNET_RSA_Signature using RSA-key generated from the records. | ||
46 | */ | ||
47 | struct GNUNET_CRYPTO_EccSignature signature; | ||
48 | |||
49 | /** | ||
50 | * number of records that follow | ||
51 | */ | ||
52 | uint32_t rd_count GNUNET_PACKED; | ||
53 | |||
54 | /* 0-terminated name here */ | ||
55 | |||
56 | /* variable-size serialized namestore record data */ | ||
57 | |||
58 | }; | ||
59 | |||
60 | GNUNET_NETWORK_STRUCT_END | ||
61 | #endif | ||
diff --git a/src/include/gnunet_gns_service.h b/src/include/gnunet_gns_service.h index 34af525c8..47d02ac7c 100644 --- a/src/include/gnunet_gns_service.h +++ b/src/include/gnunet_gns_service.h | |||
@@ -154,7 +154,6 @@ enum GNUNET_GNS_RecordType | |||
154 | * Initialize the connection with the GNS service. | 154 | * Initialize the connection with the GNS service. |
155 | * | 155 | * |
156 | * @param cfg configuration to use | 156 | * @param cfg configuration to use |
157 | * | ||
158 | * @return handle to the GNS service, or NULL on error | 157 | * @return handle to the GNS service, or NULL on error |
159 | */ | 158 | */ |
160 | struct GNUNET_GNS_Handle * | 159 | struct GNUNET_GNS_Handle * |
@@ -187,56 +186,34 @@ typedef void (*GNUNET_GNS_LookupResultProcessor) (void *cls, | |||
187 | 186 | ||
188 | 187 | ||
189 | /** | 188 | /** |
190 | * Perform an asynchronous lookup operation on the GNS | 189 | * Perform an asynchronous lookup operation on the GNS. |
191 | * in the default zone. | ||
192 | * | 190 | * |
193 | * @param handle handle to the GNS service | 191 | * @param handle handle to the GNS service |
194 | * @param name the name to look up | 192 | * @param name the name to look up |
195 | * @param type the GNUNET_GNS_RecordType to look for | 193 | * @param zone zone to look in |
196 | * @param only_cached GNUNET_NO to only check locally not DHT for performance | 194 | * @param type the record type to look for |
197 | * @param shorten_key the private key of the shorten zone (can be NULL) | 195 | * @param only_cached #GNUNET_NO to only check locally (not in the DHT) |
196 | * @param shorten_zone_key the private key of the shorten zone (can be NULL); | ||
197 | * specify to enable automatic shortening (given a PSEU | ||
198 | * record, if a given pseudonym is not yet used in the | ||
199 | * shorten zone, we automatically add the respective zone | ||
200 | * under that name) | ||
198 | * @param proc function to call on result | 201 | * @param proc function to call on result |
199 | * @param proc_cls closure for processor | 202 | * @param proc_cls closure for processor |
200 | * | ||
201 | * @return handle to the queued request | 203 | * @return handle to the queued request |
202 | */ | 204 | */ |
203 | struct GNUNET_GNS_LookupRequest* | 205 | struct GNUNET_GNS_LookupRequest* |
204 | GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, | 206 | GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, |
205 | const char * name, | 207 | const char *name, |
208 | const struct GNUNET_CRYPTO_EccPublicKey *zone, | ||
206 | enum GNUNET_GNS_RecordType type, | 209 | enum GNUNET_GNS_RecordType type, |
207 | int only_cached, | 210 | int only_cached, |
208 | struct GNUNET_CRYPTO_EccPrivateKey *shorten_key, | 211 | struct GNUNET_CRYPTO_EccPrivateKey *shorten_zone_key, |
209 | GNUNET_GNS_LookupResultProcessor proc, | 212 | GNUNET_GNS_LookupResultProcessor proc, |
210 | void *proc_cls); | 213 | void *proc_cls); |
211 | 214 | ||
212 | 215 | ||
213 | /** | 216 | /** |
214 | * Perform an asynchronous lookup operation on the GNS | ||
215 | * in the zone specified by 'zone'. | ||
216 | * | ||
217 | * @param handle handle to the GNS service | ||
218 | * @param name the name to look up | ||
219 | * @param zone the zone to start the resolution in | ||
220 | * @param type the GNUNET_GNS_RecordType to look for | ||
221 | * @param only_cached GNUNET_YES to only check locally not DHT for performance | ||
222 | * @param shorten_key the private key of the shorten zone (can be NULL) | ||
223 | * @param proc function to call on result | ||
224 | * @param proc_cls closure for processor | ||
225 | * | ||
226 | * @return handle to the queued request | ||
227 | */ | ||
228 | struct GNUNET_GNS_LookupRequest* | ||
229 | GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle, | ||
230 | const char * name, | ||
231 | struct GNUNET_CRYPTO_ShortHashCode *zone, | ||
232 | enum GNUNET_GNS_RecordType type, | ||
233 | int only_cached, | ||
234 | struct GNUNET_CRYPTO_EccPrivateKey *shorten_key, | ||
235 | GNUNET_GNS_LookupResultProcessor proc, | ||
236 | void *proc_cls); | ||
237 | |||
238 | |||
239 | /** | ||
240 | * Cancel pending lookup request | 217 | * Cancel pending lookup request |
241 | * | 218 | * |
242 | * @param lr the lookup request to cancel | 219 | * @param lr the lookup request to cancel |
@@ -244,69 +221,6 @@ GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle, | |||
244 | void | 221 | void |
245 | GNUNET_GNS_cancel_lookup_request (struct GNUNET_GNS_LookupRequest *lr); | 222 | GNUNET_GNS_cancel_lookup_request (struct GNUNET_GNS_LookupRequest *lr); |
246 | 223 | ||
247 | /* *************** Standard API: shorten ******************* */ | ||
248 | |||
249 | |||
250 | /** | ||
251 | * Processor called on for a name shortening result | ||
252 | * called only once | ||
253 | * | ||
254 | * @param cls closure | ||
255 | * @param short_name the shortened name or NULL if no result / error | ||
256 | */ | ||
257 | typedef void (*GNUNET_GNS_ShortenResultProcessor) (void *cls, | ||
258 | const char* short_name); | ||
259 | |||
260 | |||
261 | /** | ||
262 | * Perform a name shortening operation on the GNS. | ||
263 | * | ||
264 | * @param handle handle to the GNS service | ||
265 | * @param name the name to look up | ||
266 | * @param private_zone the public zone of the private zone | ||
267 | * @param shorten_zone the public zone of the shorten zone | ||
268 | * @param proc function to call on result | ||
269 | * @param proc_cls closure for processor | ||
270 | * @return handle to the operation | ||
271 | */ | ||
272 | struct GNUNET_GNS_ShortenRequest* | ||
273 | GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle, | ||
274 | const char * name, | ||
275 | struct GNUNET_CRYPTO_ShortHashCode *private_zone, | ||
276 | struct GNUNET_CRYPTO_ShortHashCode *shorten_zone, | ||
277 | GNUNET_GNS_ShortenResultProcessor proc, | ||
278 | void *proc_cls); | ||
279 | |||
280 | |||
281 | /** | ||
282 | * Perform a name shortening operation on the GNS. | ||
283 | * | ||
284 | * @param handle handle to the GNS service | ||
285 | * @param name the name to look up | ||
286 | * @param private_zone the public zone of the private zone | ||
287 | * @param shorten_zone the public zone of the shorten zone | ||
288 | * @param zone the zone to start the resolution in | ||
289 | * @param proc function to call on result | ||
290 | * @param proc_cls closure for processor | ||
291 | * @return handle to the operation | ||
292 | */ | ||
293 | struct GNUNET_GNS_ShortenRequest* | ||
294 | GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle, | ||
295 | const char * name, | ||
296 | struct GNUNET_CRYPTO_ShortHashCode *private_zone, | ||
297 | struct GNUNET_CRYPTO_ShortHashCode *shorten_zone, | ||
298 | struct GNUNET_CRYPTO_ShortHashCode *zone, | ||
299 | GNUNET_GNS_ShortenResultProcessor proc, | ||
300 | void *proc_cls); | ||
301 | |||
302 | |||
303 | /** | ||
304 | * Cancel pending shorten request | ||
305 | * | ||
306 | * @param sr the lookup request to cancel | ||
307 | */ | ||
308 | void | ||
309 | GNUNET_GNS_cancel_shorten_request (struct GNUNET_GNS_ShortenRequest *sr); | ||
310 | 224 | ||
311 | 225 | ||
312 | /* *************** Standard API: get authority ******************* */ | 226 | /* *************** Standard API: get authority ******************* */ |
diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h index e47b1ee3d..c9eb004e1 100644 --- a/src/include/gnunet_namestore_service.h +++ b/src/include/gnunet_namestore_service.h | |||
@@ -226,6 +226,10 @@ struct GNUNET_NAMESTORE_RecordData | |||
226 | }; | 226 | }; |
227 | 227 | ||
228 | 228 | ||
229 | |||
230 | GNUNET_NETWORK_STRUCT_BEGIN | ||
231 | |||
232 | |||
229 | /** | 233 | /** |
230 | * Information we have in an encrypted block with record data (i.e. in the DHT). | 234 | * Information we have in an encrypted block with record data (i.e. in the DHT). |
231 | */ | 235 | */ |
@@ -256,6 +260,7 @@ struct GNUNET_NAMESTORE_Block | |||
256 | /* followed by encrypted data */ | 260 | /* followed by encrypted data */ |
257 | }; | 261 | }; |
258 | 262 | ||
263 | GNUNET_NETWORK_STRUCT_END | ||
259 | 264 | ||
260 | /** | 265 | /** |
261 | * Store an item in the namestore. If the item is already present, | 266 | * Store an item in the namestore. If the item is already present, |