aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-02-23 10:35:45 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-02-23 10:35:45 +0000
commit3d8f372adbd1f765b2c4e0fadb4d7152e9301588 (patch)
tree9a2776f70ec7a6cdd304cb6f754d32a488de048a /src/gns
parent6f82910681a10defdfd2c98fdb7b721cc7677109 (diff)
downloadgnunet-3d8f372adbd1f765b2c4e0fadb4d7152e9301588.tar.gz
gnunet-3d8f372adbd1f765b2c4e0fadb4d7152e9301588.zip
-new api
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/gnunet-service-gns.c32
-rw-r--r--src/gns/namestore_stub_api.c194
2 files changed, 67 insertions, 159 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 02613dbb1..198e4c33b 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -317,7 +317,6 @@ process_authority_lookup(void* cls, const GNUNET_HashCode *zone,
317 const char *name, uint32_t record_type, 317 const char *name, uint32_t record_type,
318 struct GNUNET_TIME_Absolute expiration, 318 struct GNUNET_TIME_Absolute expiration,
319 enum GNUNET_NAMESTORE_RecordFlags flags, 319 enum GNUNET_NAMESTORE_RecordFlags flags,
320 const struct GNUNET_NAMESTORE_SignatureLocation *sig_loc,
321 size_t size, const void *data) 320 size_t size, const void *data)
322{ 321{
323 struct GNUNET_GNS_PendingQuery *query; 322 struct GNUNET_GNS_PendingQuery *query;
@@ -344,7 +343,7 @@ process_authority_lookup(void* cls, const GNUNET_HashCode *zone,
344 */ 343 */
345 if (GNUNET_CRYPTO_hash_cmp(zone, &zone_hash)) 344 if (GNUNET_CRYPTO_hash_cmp(zone, &zone_hash))
346 { 345 {
347 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "NX record\n"); 346 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Authority unknown\n");
348 //FIXME return NX answer 347 //FIXME return NX answer
349 return; 348 return;
350 } 349 }
@@ -420,10 +419,10 @@ reply_to_dns(struct GNUNET_GNS_PendingQuery *answer)
420 { 419 {
421 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 420 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
422 "Answering DNS request\n"); 421 "Answering DNS request\n");
423 //GNUNET_DNS_request_answer(answer->request_handle, 422 GNUNET_DNS_request_answer(answer->request_handle,
424 // len, 423 len,
425 // buf); 424 buf);
426 GNUNET_free(answer); 425 //GNUNET_free(answer);
427 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Answered DNS request\n"); 426 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Answered DNS request\n");
428 //FIXME return code, free datastructures 427 //FIXME return code, free datastructures
429 } 428 }
@@ -454,7 +453,6 @@ process_authoritative_result(void* cls, const GNUNET_HashCode *zone,
454 const char *name, uint32_t record_type, 453 const char *name, uint32_t record_type,
455 struct GNUNET_TIME_Absolute expiration, 454 struct GNUNET_TIME_Absolute expiration,
456 enum GNUNET_NAMESTORE_RecordFlags flags, 455 enum GNUNET_NAMESTORE_RecordFlags flags,
457 const struct GNUNET_NAMESTORE_SignatureLocation *sig_loc,
458 size_t size, const void *data) 456 size_t size, const void *data)
459{ 457{
460 struct GNUNET_GNS_PendingQuery *query; 458 struct GNUNET_GNS_PendingQuery *query;
@@ -621,7 +619,7 @@ resolve_name(struct GNUNET_GNS_PendingQuery *query, GNUNET_HashCode *zone)
621 if (is_canonical(query->name)) 619 if (is_canonical(query->name))
622 { 620 {
623 //We only need to check this zone's ns 621 //We only need to check this zone's ns
624 GNUNET_NAMESTORE_lookup_name(namestore_handle, 622 GNUNET_NAMESTORE_lookup_record(namestore_handle,
625 zone, 623 zone,
626 query->name, 624 query->name,
627 query->type, 625 query->type,
@@ -632,7 +630,7 @@ resolve_name(struct GNUNET_GNS_PendingQuery *query, GNUNET_HashCode *zone)
632 { 630 {
633 //We have to resolve the authoritative entity 631 //We have to resolve the authoritative entity
634 char *new_authority = move_up(query->name); 632 char *new_authority = move_up(query->name);
635 GNUNET_NAMESTORE_lookup_name(namestore_handle, 633 GNUNET_NAMESTORE_lookup_record(namestore_handle,
636 zone, 634 zone,
637 new_authority, 635 new_authority,
638 GNUNET_GNS_RECORD_PKEY, 636 GNUNET_GNS_RECORD_PKEY,
@@ -761,7 +759,6 @@ put_some_records(void)
761 GNUNET_GNS_RECORD_TYPE_A, 759 GNUNET_GNS_RECORD_TYPE_A,
762 GNUNET_TIME_absolute_get_forever(), 760 GNUNET_TIME_absolute_get_forever(),
763 GNUNET_NAMESTORE_RF_AUTHORITY, 761 GNUNET_NAMESTORE_RF_AUTHORITY,
764 NULL, //sig loc
765 sizeof(struct in_addr), 762 sizeof(struct in_addr),
766 alice, 763 alice,
767 NULL, 764 NULL,
@@ -772,7 +769,6 @@ put_some_records(void)
772 GNUNET_GNS_RECORD_TYPE_A, 769 GNUNET_GNS_RECORD_TYPE_A,
773 GNUNET_TIME_absolute_get_forever(), 770 GNUNET_TIME_absolute_get_forever(),
774 GNUNET_NAMESTORE_RF_AUTHORITY, 771 GNUNET_NAMESTORE_RF_AUTHORITY,
775 NULL, //sig loc
776 sizeof(struct in_addr), 772 sizeof(struct in_addr),
777 bob, 773 bob,
778 NULL, 774 NULL,
@@ -802,7 +798,6 @@ void
802put_gns_record(void *cls, const GNUNET_HashCode *zone, const char *name, 798put_gns_record(void *cls, const GNUNET_HashCode *zone, const char *name,
803 uint32_t record_type, struct GNUNET_TIME_Absolute expiration, 799 uint32_t record_type, struct GNUNET_TIME_Absolute expiration,
804 enum GNUNET_NAMESTORE_RecordFlags flags, 800 enum GNUNET_NAMESTORE_RecordFlags flags,
805 const struct GNUNET_NAMESTORE_SignatureLocation *sig_loc,
806 size_t size, const void *record_data) 801 size_t size, const void *record_data)
807{ 802{
808 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Putting a record into the DHT\n"); 803 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Putting a record into the DHT\n");
@@ -814,9 +809,6 @@ put_gns_record(void *cls, const GNUNET_HashCode *zone, const char *name,
814 exp_nbo = GNUNET_TIME_absolute_hton (expiration); 809 exp_nbo = GNUNET_TIME_absolute_hton (expiration);
815 uint32_t namelen = htonl(strlen(name)); 810 uint32_t namelen = htonl(strlen(name));
816 uint16_t flags_nbo = htons(flags); 811 uint16_t flags_nbo = htons(flags);
817 uint64_t offset = GNUNET_htonll(sig_loc->offset);
818 uint32_t depth = htonl(sig_loc->depth);
819 uint32_t revision = htonl(sig_loc->revision);
820 GNUNET_HashCode name_hash; 812 GNUNET_HashCode name_hash;
821 GNUNET_HashCode xor_hash; 813 GNUNET_HashCode xor_hash;
822 814
@@ -826,7 +818,6 @@ put_gns_record(void *cls, const GNUNET_HashCode *zone, const char *name,
826 */ 818 */
827 size_t record_len = sizeof(size_t) + sizeof(uint32_t) + 819 size_t record_len = sizeof(size_t) + sizeof(uint32_t) +
828 sizeof(uint16_t) + 820 sizeof(uint16_t) +
829 sizeof(struct GNUNET_NAMESTORE_SignatureLocation) +
830 sizeof(uint32_t) + strlen(name) + size; 821 sizeof(uint32_t) + strlen(name) + size;
831 822
832 record_type = htonl(record_type); 823 record_type = htonl(record_type);
@@ -850,15 +841,6 @@ put_gns_record(void *cls, const GNUNET_HashCode *zone, const char *name,
850 memcpy(data_ptr, &flags_nbo, sizeof(uint16_t)); 841 memcpy(data_ptr, &flags_nbo, sizeof(uint16_t));
851 data_ptr += sizeof(uint16_t); 842 data_ptr += sizeof(uint16_t);
852 843
853 memcpy(data_ptr, &offset, sizeof(uint64_t));
854 data_ptr += sizeof(uint64_t);
855
856 memcpy(data_ptr, &depth, sizeof(uint32_t));
857 data_ptr += sizeof(uint32_t);
858
859 memcpy(data_ptr, &revision, sizeof(uint32_t));
860 data_ptr += sizeof(uint32_t);
861
862 memcpy(data_ptr, &size, sizeof(uint32_t)); 844 memcpy(data_ptr, &size, sizeof(uint32_t));
863 data_ptr += sizeof(uint32_t); 845 data_ptr += sizeof(uint32_t);
864 846
diff --git a/src/gns/namestore_stub_api.c b/src/gns/namestore_stub_api.c
index f829b8db9..29a785a8a 100644
--- a/src/gns/namestore_stub_api.c
+++ b/src/gns/namestore_stub_api.c
@@ -69,6 +69,11 @@ struct GNUNET_NAMESTORE_Handle
69 69
70}; 70};
71 71
72struct GNUNET_NAMESTORE_ZoneIterator
73{
74 struct GNUNET_NAMESTORE_Handle *handle;
75};
76
72struct GNUNET_NAMESTORE_SimpleRecord 77struct GNUNET_NAMESTORE_SimpleRecord
73{ 78{
74 /** 79 /**
@@ -119,111 +124,6 @@ GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *handle, int drop)
119} 124}
120 125
121/** 126/**
122 * Sign a record. This function is used by the authority of the zone
123 * to add a record.
124 *
125 * @param h handle to the namestore
126 * @param zone_privkey private key of the zone
127 * @param record_hash hash of the record to be signed
128 * @param cont continuation to call when done
129 * @param cont_cls closure for cont
130 * @return handle to abort the request
131 */
132struct GNUNET_NAMESTORE_QueueEntry *
133GNUNET_NAMESTORE_stree_extend (struct GNUNET_NAMESTORE_Handle *h,
134 const struct GNUNET_CRYPTO_RsaPrivateKey *zone_privkey,
135 const GNUNET_HashCode *record_hash,
136 GNUNET_NAMESTORE_ContinuationWithSignature cont,
137 void *cont_cls)
138{
139 struct GNUNET_NAMESTORE_QueueEntry *qe;
140 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
141 return qe;
142}
143
144/**
145 * Rebalance the signature tree of our zone. This function should
146 * be called "rarely" to rebalance the tree.
147 *
148 * @param h handle to the namestore
149 * @param zone_privkey private key for the zone to rebalance
150 * @param cont continuation to call when done
151 * @param cont_cls closure for cont
152 * @return handle to abort the request
153 */
154struct GNUNET_NAMESTORE_QueueEntry *
155GNUNET_NAMESTORE_stree_rebalance (struct GNUNET_NAMESTORE_Handle *h,
156 const struct GNUNET_CRYPTO_RsaPrivateKey *zone_privkey,
157 GNUNET_NAMESTORE_ContinuationWithStatus cont,
158 void *cont_cls)
159{
160 struct GNUNET_NAMESTORE_QueueEntry *qe;
161 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
162 return qe;
163}
164
165/**
166 * Provide the root of a signature tree. This function is
167 * used by non-authorities as the first operation when
168 * adding a foreign zone.
169 *
170 * @param h handle to the namestore
171 * @param zone_key public key of the zone
172 * @param signature signature of the top-level entry of the zone
173 * @param revision revision number of the zone
174 * @param top_hash top-level hash of the zone
175 * @param cont continuation to call when done
176 * @param cont_cls closure for cont
177 * @return handle to abort the request
178 */
179struct GNUNET_NAMESTORE_QueueEntry *
180GNUNET_NAMESTORE_stree_start (struct GNUNET_NAMESTORE_Handle *h,
181 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
182 const struct GNUNET_CRYPTO_RsaSignature *signature,
183 uint32_t revision,
184 const GNUNET_HashCode *top_hash,
185 GNUNET_NAMESTORE_ContinuationWithSignature cont,
186 void *cont_cls)
187{
188 struct GNUNET_NAMESTORE_QueueEntry *qe;
189 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
190 return qe;
191}
192
193/**
194 * Store part of a signature B-tree in the namestore. This function
195 * is used by non-authorities to cache parts of a zone's signature tree.
196 * Note that the tree must be build top-down. This function must check
197 * that the nodes being added are valid, and if not refuse the operation.
198 *
199 * @param h handle to the namestore
200 * @param zone_key public key of the zone
201 * @param loc location in the B-tree
202 * @param ploc parent's location in the B-tree (must have depth = loc.depth - 1), NULL for root
203 * @param top_sig signature at the top, NULL if 'loc.depth > 0'
204 * @param num_entries number of entries at this node in the B-tree
205 * @param entries the 'num_entries' entries to store (hashes over the
206 * records)
207 * @param cont continuation to call when done
208 * @param cont_cls closure for cont
209 * @return handle to abort the request
210 */
211struct GNUNET_NAMESTORE_QueueEntry *
212GNUNET_NAMESTORE_stree_put (struct GNUNET_NAMESTORE_Handle *h,
213 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
214 const struct GNUNET_NAMESTORE_SignatureLocation *loc,
215 const struct GNUNET_NAMESTORE_SignatureLocation *ploc,
216 unsigned int num_entries,
217 const GNUNET_HashCode *entries,
218 GNUNET_NAMESTORE_ContinuationWithStatus cont,
219 void *cont_cls)
220{
221 struct GNUNET_NAMESTORE_QueueEntry *qe;
222 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
223 return qe;
224}
225
226/**
227 * Store an item in the namestore. If the item is already present, 127 * Store an item in the namestore. If the item is already present,
228 * the expiration time is updated to the max of the existing time and 128 * the expiration time is updated to the max of the existing time and
229 * the new time. The operation must fail if there is no matching 129 * the new time. The operation must fail if there is no matching
@@ -235,7 +135,6 @@ GNUNET_NAMESTORE_stree_put (struct GNUNET_NAMESTORE_Handle *h,
235 * @param record_type type of the record (A, AAAA, PKEY, etc.) 135 * @param record_type type of the record (A, AAAA, PKEY, etc.)
236 * @param expiration expiration time for the content 136 * @param expiration expiration time for the content
237 * @param flags flags for the content 137 * @param flags flags for the content
238 * @param sig_loc where is the information about the signature for this record stored?
239 * @param data_size number of bytes in data 138 * @param data_size number of bytes in data
240 * @param data value, semantics depend on 'record_type' (see RFCs for DNS and 139 * @param data value, semantics depend on 'record_type' (see RFCs for DNS and
241 * GNS specification for GNS extensions) 140 * GNS specification for GNS extensions)
@@ -250,7 +149,6 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
250 uint32_t record_type, 149 uint32_t record_type,
251 struct GNUNET_TIME_Absolute expiration, 150 struct GNUNET_TIME_Absolute expiration,
252 enum GNUNET_NAMESTORE_RecordFlags flags, 151 enum GNUNET_NAMESTORE_RecordFlags flags,
253 const struct GNUNET_NAMESTORE_SignatureLocation *sig_loc,
254 size_t data_size, 152 size_t data_size,
255 const void *data, 153 const void *data,
256 GNUNET_NAMESTORE_ContinuationWithStatus cont, 154 GNUNET_NAMESTORE_ContinuationWithStatus cont,
@@ -272,6 +170,36 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
272} 170}
273 171
274/** 172/**
173 * Store a signature in the namestore.
174 *
175 * @param h handle to the namestore
176 * @param zone hash of the public key of the zone
177 * @param name name that is being mapped (at most 255 characters long)
178 * @param record_type type of the record (A, AAAA, PKEY, etc.)
179 * @param expiration expiration time for the content
180 * @param flags flags for the content
181 * @param data_size number of bytes in data
182 * @param data value, semantics depend on 'record_type' (see RFCs for DNS and
183 * GNS specification for GNS extensions)
184 * @param cont continuation to call when done
185 * @param cont_cls closure for cont
186 * @return handle to abort the request
187 */
188struct GNUNET_NAMESTORE_QueueEntry *
189GNUNET_NAMESTORE_signature_put (struct GNUNET_NAMESTORE_Handle *h,
190 const GNUNET_HashCode *zone,
191 const char *name,
192 struct GNUNET_CRYPTO_RsaSignature sig,
193 GNUNET_NAMESTORE_ContinuationWithStatus cont,
194 void *cont_cls)
195{
196 struct GNUNET_NAMESTORE_QueueEntry *qe;
197 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
198
199 return qe;
200}
201
202/**
275 * Explicitly remove some content from the database. The 203 * Explicitly remove some content from the database. The
276 * "cont"inuation will be called with status "GNUNET_OK" if content 204 * "cont"inuation will be called with status "GNUNET_OK" if content
277 * was removed, "GNUNET_NO" if no matching entry was found and 205 * was removed, "GNUNET_NO" if no matching entry was found and
@@ -331,7 +259,7 @@ GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h,
331 * cancel 259 * cancel
332 */ 260 */
333struct GNUNET_NAMESTORE_QueueEntry * 261struct GNUNET_NAMESTORE_QueueEntry *
334GNUNET_NAMESTORE_lookup_name (struct GNUNET_NAMESTORE_Handle *h, 262GNUNET_NAMESTORE_lookup_record (struct GNUNET_NAMESTORE_Handle *h,
335 const GNUNET_HashCode *zone, 263 const GNUNET_HashCode *zone,
336 const char *name, 264 const char *name,
337 uint32_t record_type, 265 uint32_t record_type,
@@ -352,16 +280,25 @@ GNUNET_NAMESTORE_lookup_name (struct GNUNET_NAMESTORE_Handle *h,
352 proc(proc_cls, iter->zone, iter->name, iter->record_type, 280 proc(proc_cls, iter->zone, iter->name, iter->record_type,
353 iter->expiration, 281 iter->expiration,
354 iter->flags, 282 iter->flags,
355 NULL /*sig loc*/,
356 iter->data_size /*size*/, 283 iter->data_size /*size*/,
357 iter->data /* data */); 284 iter->data /* data */);
358 } 285 }
359 proc(proc_cls, zone, name, record_type, 286 proc(proc_cls, zone, name, record_type,
360 GNUNET_TIME_absolute_get_forever(), 0, NULL, 0, NULL); /*TERMINATE*/ 287 GNUNET_TIME_absolute_get_forever(), 0, 0, NULL); /*TERMINATE*/
361 288
362 return qe; 289 return qe;
363} 290}
364 291
292struct GNUNET_NAMESTORE_QueueEntry *
293GNUNET_NAMESTORE_lookup_signature (struct GNUNET_NAMESTORE_Handle *h,
294 const GNUNET_HashCode *zone,
295 const char* name,
296 GNUNET_NAMESTORE_SignatureProcessor proc,
297 void *proc_cls)
298{
299 return NULL;
300}
301
365 302
366/** 303/**
367 * Get the hash of a record (what will be signed in the Stree for 304 * Get the hash of a record (what will be signed in the Stree for
@@ -392,30 +329,6 @@ GNUNET_NAMESTORE_record_hash (struct GNUNET_NAMESTORE_Handle *h,
392 GNUNET_CRYPTO_hash(teststring, strlen(teststring), record_hash); 329 GNUNET_CRYPTO_hash(teststring, strlen(teststring), record_hash);
393} 330}
394 331
395/**
396 * Obtain part of a signature B-tree. The processor
397 * will only be called once.
398 *
399 * @param h handle to the namestore
400 * @param zone zone to look up a record from
401 * @param sig_loc location to look up
402 * @param proc function to call on each matching value;
403 * will be called once with a NULL value at the end
404 * @param proc_cls closure for proc
405 * @return a handle that can be used to
406 * cancel
407 */
408struct GNUNET_NAMESTORE_QueueEntry *
409GNUNET_NAMESTORE_lookup_stree (struct GNUNET_NAMESTORE_Handle *h,
410 const GNUNET_HashCode *zone,
411 const struct GNUNET_NAMESTORE_SignatureLocation *sig_loc,
412 GNUNET_NAMESTORE_StreeProcessor proc, void *proc_cls)
413{
414 struct GNUNET_NAMESTORE_QueueEntry *qe;
415 qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
416 return qe;
417}
418
419 332
420/** 333/**
421 * Get all records of a zone. 334 * Get all records of a zone.
@@ -440,7 +353,20 @@ GNUNET_NAMESTORE_zone_transfer (struct GNUNET_NAMESTORE_Handle *h,
440 return qe; 353 return qe;
441} 354}
442 355
356struct GNUNET_NAMESTORE_ZoneIterator *
357GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h,
358 const GNUNET_HashCode *zone,
359 GNUNET_NAMESTORE_RecordProcessor proc,
360 void *proc_cls);
361
362int
363GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it);
443 364
365void
366GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it);
367
368void
369GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe);
444 370
445 371
446/** 372/**