From 3d8f372adbd1f765b2c4e0fadb4d7152e9301588 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Thu, 23 Feb 2012 10:35:45 +0000 Subject: [PATCH] -new api --- src/gns/gnunet-service-gns.c | 32 +-- src/gns/namestore_stub_api.c | 194 +++++---------- src/include/gnunet_namestore_service.h | 322 +++++++------------------ 3 files changed, 151 insertions(+), 397 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, const char *name, uint32_t record_type, struct GNUNET_TIME_Absolute expiration, enum GNUNET_NAMESTORE_RecordFlags flags, - const struct GNUNET_NAMESTORE_SignatureLocation *sig_loc, size_t size, const void *data) { struct GNUNET_GNS_PendingQuery *query; @@ -344,7 +343,7 @@ process_authority_lookup(void* cls, const GNUNET_HashCode *zone, */ if (GNUNET_CRYPTO_hash_cmp(zone, &zone_hash)) { - GNUNET_log(GNUNET_ERROR_TYPE_INFO, "NX record\n"); + GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Authority unknown\n"); //FIXME return NX answer return; } @@ -420,10 +419,10 @@ reply_to_dns(struct GNUNET_GNS_PendingQuery *answer) { GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Answering DNS request\n"); - //GNUNET_DNS_request_answer(answer->request_handle, - // len, - // buf); - GNUNET_free(answer); + GNUNET_DNS_request_answer(answer->request_handle, + len, + buf); + //GNUNET_free(answer); GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Answered DNS request\n"); //FIXME return code, free datastructures } @@ -454,7 +453,6 @@ process_authoritative_result(void* cls, const GNUNET_HashCode *zone, const char *name, uint32_t record_type, struct GNUNET_TIME_Absolute expiration, enum GNUNET_NAMESTORE_RecordFlags flags, - const struct GNUNET_NAMESTORE_SignatureLocation *sig_loc, size_t size, const void *data) { struct GNUNET_GNS_PendingQuery *query; @@ -621,7 +619,7 @@ resolve_name(struct GNUNET_GNS_PendingQuery *query, GNUNET_HashCode *zone) if (is_canonical(query->name)) { //We only need to check this zone's ns - GNUNET_NAMESTORE_lookup_name(namestore_handle, + GNUNET_NAMESTORE_lookup_record(namestore_handle, zone, query->name, query->type, @@ -632,7 +630,7 @@ resolve_name(struct GNUNET_GNS_PendingQuery *query, GNUNET_HashCode *zone) { //We have to resolve the authoritative entity char *new_authority = move_up(query->name); - GNUNET_NAMESTORE_lookup_name(namestore_handle, + GNUNET_NAMESTORE_lookup_record(namestore_handle, zone, new_authority, GNUNET_GNS_RECORD_PKEY, @@ -761,7 +759,6 @@ put_some_records(void) GNUNET_GNS_RECORD_TYPE_A, GNUNET_TIME_absolute_get_forever(), GNUNET_NAMESTORE_RF_AUTHORITY, - NULL, //sig loc sizeof(struct in_addr), alice, NULL, @@ -772,7 +769,6 @@ put_some_records(void) GNUNET_GNS_RECORD_TYPE_A, GNUNET_TIME_absolute_get_forever(), GNUNET_NAMESTORE_RF_AUTHORITY, - NULL, //sig loc sizeof(struct in_addr), bob, NULL, @@ -802,7 +798,6 @@ void put_gns_record(void *cls, const GNUNET_HashCode *zone, const char *name, uint32_t record_type, struct GNUNET_TIME_Absolute expiration, enum GNUNET_NAMESTORE_RecordFlags flags, - const struct GNUNET_NAMESTORE_SignatureLocation *sig_loc, size_t size, const void *record_data) { 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, exp_nbo = GNUNET_TIME_absolute_hton (expiration); uint32_t namelen = htonl(strlen(name)); uint16_t flags_nbo = htons(flags); - uint64_t offset = GNUNET_htonll(sig_loc->offset); - uint32_t depth = htonl(sig_loc->depth); - uint32_t revision = htonl(sig_loc->revision); GNUNET_HashCode name_hash; GNUNET_HashCode xor_hash; @@ -826,7 +818,6 @@ put_gns_record(void *cls, const GNUNET_HashCode *zone, const char *name, */ size_t record_len = sizeof(size_t) + sizeof(uint32_t) + sizeof(uint16_t) + - sizeof(struct GNUNET_NAMESTORE_SignatureLocation) + sizeof(uint32_t) + strlen(name) + size; record_type = htonl(record_type); @@ -850,15 +841,6 @@ put_gns_record(void *cls, const GNUNET_HashCode *zone, const char *name, memcpy(data_ptr, &flags_nbo, sizeof(uint16_t)); data_ptr += sizeof(uint16_t); - memcpy(data_ptr, &offset, sizeof(uint64_t)); - data_ptr += sizeof(uint64_t); - - memcpy(data_ptr, &depth, sizeof(uint32_t)); - data_ptr += sizeof(uint32_t); - - memcpy(data_ptr, &revision, sizeof(uint32_t)); - data_ptr += sizeof(uint32_t); - memcpy(data_ptr, &size, sizeof(uint32_t)); data_ptr += sizeof(uint32_t); 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 }; +struct GNUNET_NAMESTORE_ZoneIterator +{ + struct GNUNET_NAMESTORE_Handle *handle; +}; + struct GNUNET_NAMESTORE_SimpleRecord { /** @@ -118,111 +123,6 @@ GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *handle, int drop) GNUNET_free(handle); } -/** - * Sign a record. This function is used by the authority of the zone - * to add a record. - * - * @param h handle to the namestore - * @param zone_privkey private key of the zone - * @param record_hash hash of the record to be signed - * @param cont continuation to call when done - * @param cont_cls closure for cont - * @return handle to abort the request - */ -struct GNUNET_NAMESTORE_QueueEntry * -GNUNET_NAMESTORE_stree_extend (struct GNUNET_NAMESTORE_Handle *h, - const struct GNUNET_CRYPTO_RsaPrivateKey *zone_privkey, - const GNUNET_HashCode *record_hash, - GNUNET_NAMESTORE_ContinuationWithSignature cont, - void *cont_cls) -{ - struct GNUNET_NAMESTORE_QueueEntry *qe; - qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry)); - return qe; -} - -/** - * Rebalance the signature tree of our zone. This function should - * be called "rarely" to rebalance the tree. - * - * @param h handle to the namestore - * @param zone_privkey private key for the zone to rebalance - * @param cont continuation to call when done - * @param cont_cls closure for cont - * @return handle to abort the request - */ -struct GNUNET_NAMESTORE_QueueEntry * -GNUNET_NAMESTORE_stree_rebalance (struct GNUNET_NAMESTORE_Handle *h, - const struct GNUNET_CRYPTO_RsaPrivateKey *zone_privkey, - GNUNET_NAMESTORE_ContinuationWithStatus cont, - void *cont_cls) -{ - struct GNUNET_NAMESTORE_QueueEntry *qe; - qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry)); - return qe; -} - -/** - * Provide the root of a signature tree. This function is - * used by non-authorities as the first operation when - * adding a foreign zone. - * - * @param h handle to the namestore - * @param zone_key public key of the zone - * @param signature signature of the top-level entry of the zone - * @param revision revision number of the zone - * @param top_hash top-level hash of the zone - * @param cont continuation to call when done - * @param cont_cls closure for cont - * @return handle to abort the request - */ -struct GNUNET_NAMESTORE_QueueEntry * -GNUNET_NAMESTORE_stree_start (struct GNUNET_NAMESTORE_Handle *h, - const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, - const struct GNUNET_CRYPTO_RsaSignature *signature, - uint32_t revision, - const GNUNET_HashCode *top_hash, - GNUNET_NAMESTORE_ContinuationWithSignature cont, - void *cont_cls) -{ - struct GNUNET_NAMESTORE_QueueEntry *qe; - qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry)); - return qe; -} - -/** - * Store part of a signature B-tree in the namestore. This function - * is used by non-authorities to cache parts of a zone's signature tree. - * Note that the tree must be build top-down. This function must check - * that the nodes being added are valid, and if not refuse the operation. - * - * @param h handle to the namestore - * @param zone_key public key of the zone - * @param loc location in the B-tree - * @param ploc parent's location in the B-tree (must have depth = loc.depth - 1), NULL for root - * @param top_sig signature at the top, NULL if 'loc.depth > 0' - * @param num_entries number of entries at this node in the B-tree - * @param entries the 'num_entries' entries to store (hashes over the - * records) - * @param cont continuation to call when done - * @param cont_cls closure for cont - * @return handle to abort the request - */ -struct GNUNET_NAMESTORE_QueueEntry * -GNUNET_NAMESTORE_stree_put (struct GNUNET_NAMESTORE_Handle *h, - const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, - const struct GNUNET_NAMESTORE_SignatureLocation *loc, - const struct GNUNET_NAMESTORE_SignatureLocation *ploc, - unsigned int num_entries, - const GNUNET_HashCode *entries, - GNUNET_NAMESTORE_ContinuationWithStatus cont, - void *cont_cls) -{ - struct GNUNET_NAMESTORE_QueueEntry *qe; - qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry)); - return qe; -} - /** * Store an item in the namestore. If the item is already present, * the expiration time is updated to the max of the existing time and @@ -235,7 +135,6 @@ GNUNET_NAMESTORE_stree_put (struct GNUNET_NAMESTORE_Handle *h, * @param record_type type of the record (A, AAAA, PKEY, etc.) * @param expiration expiration time for the content * @param flags flags for the content - * @param sig_loc where is the information about the signature for this record stored? * @param data_size number of bytes in data * @param data value, semantics depend on 'record_type' (see RFCs for DNS and * GNS specification for GNS extensions) @@ -250,7 +149,6 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h, uint32_t record_type, struct GNUNET_TIME_Absolute expiration, enum GNUNET_NAMESTORE_RecordFlags flags, - const struct GNUNET_NAMESTORE_SignatureLocation *sig_loc, size_t data_size, const void *data, GNUNET_NAMESTORE_ContinuationWithStatus cont, @@ -271,6 +169,36 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h, return qe; } +/** + * Store a signature in the namestore. + * + * @param h handle to the namestore + * @param zone hash of the public key of the zone + * @param name name that is being mapped (at most 255 characters long) + * @param record_type type of the record (A, AAAA, PKEY, etc.) + * @param expiration expiration time for the content + * @param flags flags for the content + * @param data_size number of bytes in data + * @param data value, semantics depend on 'record_type' (see RFCs for DNS and + * GNS specification for GNS extensions) + * @param cont continuation to call when done + * @param cont_cls closure for cont + * @return handle to abort the request + */ +struct GNUNET_NAMESTORE_QueueEntry * +GNUNET_NAMESTORE_signature_put (struct GNUNET_NAMESTORE_Handle *h, + const GNUNET_HashCode *zone, + const char *name, + struct GNUNET_CRYPTO_RsaSignature sig, + GNUNET_NAMESTORE_ContinuationWithStatus cont, + void *cont_cls) +{ + struct GNUNET_NAMESTORE_QueueEntry *qe; + qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry)); + + return qe; +} + /** * Explicitly remove some content from the database. The * "cont"inuation will be called with status "GNUNET_OK" if content @@ -331,7 +259,7 @@ GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h, * cancel */ struct GNUNET_NAMESTORE_QueueEntry * -GNUNET_NAMESTORE_lookup_name (struct GNUNET_NAMESTORE_Handle *h, +GNUNET_NAMESTORE_lookup_record (struct GNUNET_NAMESTORE_Handle *h, const GNUNET_HashCode *zone, const char *name, uint32_t record_type, @@ -352,16 +280,25 @@ GNUNET_NAMESTORE_lookup_name (struct GNUNET_NAMESTORE_Handle *h, proc(proc_cls, iter->zone, iter->name, iter->record_type, iter->expiration, iter->flags, - NULL /*sig loc*/, iter->data_size /*size*/, iter->data /* data */); } proc(proc_cls, zone, name, record_type, - GNUNET_TIME_absolute_get_forever(), 0, NULL, 0, NULL); /*TERMINATE*/ + GNUNET_TIME_absolute_get_forever(), 0, 0, NULL); /*TERMINATE*/ return qe; } +struct GNUNET_NAMESTORE_QueueEntry * +GNUNET_NAMESTORE_lookup_signature (struct GNUNET_NAMESTORE_Handle *h, + const GNUNET_HashCode *zone, + const char* name, + GNUNET_NAMESTORE_SignatureProcessor proc, + void *proc_cls) +{ + return NULL; +} + /** * 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, GNUNET_CRYPTO_hash(teststring, strlen(teststring), record_hash); } -/** - * Obtain part of a signature B-tree. The processor - * will only be called once. - * - * @param h handle to the namestore - * @param zone zone to look up a record from - * @param sig_loc location to look up - * @param proc function to call on each matching value; - * will be called once with a NULL value at the end - * @param proc_cls closure for proc - * @return a handle that can be used to - * cancel - */ -struct GNUNET_NAMESTORE_QueueEntry * -GNUNET_NAMESTORE_lookup_stree (struct GNUNET_NAMESTORE_Handle *h, - const GNUNET_HashCode *zone, - const struct GNUNET_NAMESTORE_SignatureLocation *sig_loc, - GNUNET_NAMESTORE_StreeProcessor proc, void *proc_cls) -{ - struct GNUNET_NAMESTORE_QueueEntry *qe; - qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry)); - return qe; -} - /** * Get all records of a zone. @@ -440,7 +353,20 @@ GNUNET_NAMESTORE_zone_transfer (struct GNUNET_NAMESTORE_Handle *h, return qe; } +struct GNUNET_NAMESTORE_ZoneIterator * +GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, + const GNUNET_HashCode *zone, + GNUNET_NAMESTORE_RecordProcessor proc, + void *proc_cls); + +int +GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it); +void +GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it); + +void +GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe); /** diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h index 9bda0f6f0..894397543 100644 --- a/src/include/gnunet_namestore_service.h +++ b/src/include/gnunet_namestore_service.h @@ -53,6 +53,11 @@ struct GNUNET_NAMESTORE_QueueEntry; */ struct GNUNET_NAMESTORE_Handle; +/** + * Handle to the namestore zone iterator. + */ +struct GNUNET_NAMESTORE_ZoneIterator; + /** * Maximum size of a value that can be stored in the namestore. */ @@ -122,45 +127,7 @@ enum GNUNET_NAMESTORE_RecordFlags /** - * We formally store records in a B-tree for signing. This struct - * identifies the location of a record in the B-tree. - */ -struct GNUNET_NAMESTORE_SignatureLocation -{ - /** - * Offset in the B-tree. - */ - uint64_t offset; - - /** - * Depth in the B-tree. - */ - uint32_t depth; - - /** - * Revision of the B-tree. - */ - uint32_t revision; -}; - - -/** - * Continuation called to notify client about result of the - * signing operation. - * - * @param cls closure - * @param sig where the signature is now located in the S-tree - */ -typedef void (*GNUNET_NAMESTORE_ContinuationWithSignature) (void *cls, - const struct GNUNET_NAMESTORE_SignatureLocation *sig); - - - - - -/** - * Get the hash of a record (what will be signed in the Stree for - * the record). + * Get the hash of a record * * @param zone hash of the public key of the zone * @param name name that is being mapped (at most 255 characters long) @@ -184,126 +151,10 @@ GNUNET_NAMESTORE_record_hash (struct GNUNET_NAMESTORE_Handle *h, GNUNET_HashCode *record_hash); -/** - * Sign a record. This function is used by the authority of the zone - * to add a record. - * - * @param h handle to the namestore - * @param zone_privkey private key of the zone - * @param record_hash hash of the record to be signed - * @param cont continuation to call when done - * @param cont_cls closure for cont - * @return handle to abort the request - */ -struct GNUNET_NAMESTORE_QueueEntry * -GNUNET_NAMESTORE_stree_extend (struct GNUNET_NAMESTORE_Handle *h, - const struct GNUNET_CRYPTO_RsaPrivateKey *zone_privkey, - const GNUNET_HashCode *record_hash, - GNUNET_NAMESTORE_ContinuationWithSignature cont, - void *cont_cls); - - -/** - * Rebalance the signature tree of our zone. This function should - * be called "rarely" to rebalance the tree. - * - * @param h handle to the namestore - * @param zone_privkey private key for the zone to rebalance - * @param cont continuation to call when done - * @param cont_cls closure for cont - * @return handle to abort the request - */ -struct GNUNET_NAMESTORE_QueueEntry * -GNUNET_NAMESTORE_stree_rebalance (struct GNUNET_NAMESTORE_Handle *h, - const struct GNUNET_CRYPTO_RsaPrivateKey *zone_privkey, - GNUNET_NAMESTORE_ContinuationWithStatus cont, - void *cont_cls); - - -/** - * Provide the root of a signature tree. This function is - * used by non-authorities as the first operation when - * adding a foreign zone. - * - * @param h handle to the namestore - * @param zone_key public key of the zone - * @param signature signature of the top-level entry of the zone - * @param revision revision number of the zone - * @param top_hash top-level hash of the zone - * @param cont continuation to call when done - * @param cont_cls closure for cont - * @return handle to abort the request - */ -struct GNUNET_NAMESTORE_QueueEntry * -GNUNET_NAMESTORE_stree_start (struct GNUNET_NAMESTORE_Handle *h, - const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, - const struct GNUNET_CRYPTO_RsaSignature *signature, - uint32_t revision, - const GNUNET_HashCode *top_hash, - GNUNET_NAMESTORE_ContinuationWithSignature cont, - void *cont_cls); - - -/** - * Store part of a signature B-tree in the namestore. This function - * is used by non-authorities to cache parts of a zone's signature tree. - * Note that the tree must be build top-down. This function must check - * that the nodes being added are valid, and if not refuse the operation. - * - * @param h handle to the namestore - * @param zone_key public key of the zone - * @param loc location in the B-tree - * @param ploc parent's location in the B-tree (must have depth = loc.depth - 1) - * @param num_entries number of entries at this node in the B-tree - * @param entries the 'num_entries' entries to store (hashes over the - * records) - * @param cont continuation to call when done - * @param cont_cls closure for cont - * @return handle to abort the request - */ -struct GNUNET_NAMESTORE_QueueEntry * -GNUNET_NAMESTORE_stree_put (struct GNUNET_NAMESTORE_Handle *h, - const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, - const struct GNUNET_NAMESTORE_SignatureLocation *loc, - const struct GNUNET_NAMESTORE_SignatureLocation *ploc, - unsigned int num_entries, - const GNUNET_HashCode *entries, - GNUNET_NAMESTORE_ContinuationWithStatus cont, - void *cont_cls); - - -/** - * Store current zone signature in the namestore. This function - * is used by non-authorities to cache the top of a zone's signature tree. - * Note that the tree must be build top-down, so this function is called - * first for a given zone and revision. - * - * @param h handle to the namestore - * @param zone_key public key of the zone - * @param loc identifies the top of the B-tree (depth and revision) - * @param time time of the signature creation - * @param top_sig signature at the top - * @param root_hash top level hash code in the Merkle-tree / stree - * @param cont continuation to call when done - * @param cont_cls closure for cont - * @return handle to abort the request - */ -struct GNUNET_NAMESTORE_QueueEntry * -GNUNET_NAMESTORE_signature_put (struct GNUNET_NAMESTORE_Handle *h, - const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, - const struct GNUNET_NAMESTORE_SignatureLocation *loc, - struct GNUNET_TIME_Absolute time, - const struct GNUNET_CRYPTO_RsaSignature *top_sig, - const GNUNET_HashCode *root_hash, - GNUNET_NAMESTORE_ContinuationWithStatus cont, - void *cont_cls); - - /** * Store an item in the namestore. If the item is already present, * the expiration time is updated to the max of the existing time and - * the new time. The operation must fail if there is no matching - * entry in the signature tree. + * the new time. * * @param h handle to the namestore * @param zone hash of the public key of the zone @@ -311,7 +162,6 @@ GNUNET_NAMESTORE_signature_put (struct GNUNET_NAMESTORE_Handle *h, * @param record_type type of the record (A, AAAA, PKEY, etc.) * @param expiration expiration time for the content * @param flags flags for the content - * @param sig_loc where is the information about the signature for this record stored? * @param data_size number of bytes in data * @param data value, semantics depend on 'record_type' (see RFCs for DNS and * GNS specification for GNS extensions) @@ -326,12 +176,31 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h, uint32_t record_type, struct GNUNET_TIME_Absolute expiration, enum GNUNET_NAMESTORE_RecordFlags flags, - const struct GNUNET_NAMESTORE_SignatureLocation *sig_loc, size_t data_size, const void *data, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls); +/** + * Store a signature for 'name' in the namestore. + * Used by non-authorities to store signatures for cached name records. + * + * @param h handle to the namestore + * @param zone hash of the public key of the zone + * @param name name that is being mapped (at most 255 characters long) + * @param sig the signature + * @param cont continuation to call when done + * @param cont_cls closure for cont + * @return handle to abort the request + */ +struct GNUNET_NAMESTORE_QueueEntry * +GNUNET_NAMESTORE_signature_put (struct GNUNET_NAMESTORE_Handle *h, + const GNUNET_HashCode *zone, + const char *name, + struct GNUNET_CRYPTO_RsaSignature sig, + GNUNET_NAMESTORE_ContinuationWithStatus cont, + void *cont_cls); + /** * Explicitly remove some content from the database. The @@ -369,7 +238,6 @@ GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h, * @param record_type type of the record (A, AAAA, PKEY, etc.) * @param expiration expiration time for the content * @param flags flags for the content - * @param sig_loc where is the information about the signature for this record stored? * @param size number of bytes in data * @param data content stored */ @@ -379,9 +247,22 @@ typedef void (*GNUNET_NAMESTORE_RecordProcessor) (void *cls, uint32_t record_type, struct GNUNET_TIME_Absolute expiration, enum GNUNET_NAMESTORE_RecordFlags flags, - const struct GNUNET_NAMESTORE_SignatureLocation *sig_loc, size_t size, const void *data); +/** + * Process a signature for a given name + * + * @param cls closure + * @param zone hash of the public key of the zone + * @param name name of the records that were signed + * @param sig the signature + */ +typedef void (*GNUNET_NAMESTORE_SignatureProcessor) (void *cls, + const GNUNET_HashCode *zone, + const char *name, + struct GNUNET_CRYPTO_RsaSignature sig); + + /** * Get a result for a particular key from the namestore. The processor @@ -398,94 +279,20 @@ typedef void (*GNUNET_NAMESTORE_RecordProcessor) (void *cls, * cancel */ struct GNUNET_NAMESTORE_QueueEntry * -GNUNET_NAMESTORE_lookup_name (struct GNUNET_NAMESTORE_Handle *h, +GNUNET_NAMESTORE_lookup_record (struct GNUNET_NAMESTORE_Handle *h, const GNUNET_HashCode *zone, const char *name, uint32_t record_type, GNUNET_NAMESTORE_RecordProcessor proc, void *proc_cls); - -/** - * Get the hash of a subtree in the STree (what will be signed in the parent - * location). FIXME naming conflict! - * - * @param zone hash of the public key of the zone - * @param loc where we are in the signature tree - * @param num_entries number of entries being stored here - * @param entries the entries themselves - * @param st_hash hash of the stree node (set) - */ -void -GNUNET_NAMESTORE_record_hash_dup (struct GNUNET_NAMESTORE_Handle *h, - const GNUNET_HashCode *zone, - const struct GNUNET_NAMESTORE_SignatureLocation *loc, - unsigned int num_entries, - const GNUNET_HashCode *entries, - GNUNET_HashCode *st_hash); - - -/** - * Process a Stree node that was stored in the namestore. - * - * @param cls closure - * @param zone hash of the public key of the zone - * @param loc where we are in the signature tree - * @param ploc location of our parent in the signature tree - * @param num_entries number of entries being stored here - * @param entries the entries themselves - */ -typedef void (*GNUNET_NAMESTORE_StreeProcessor) (void *cls, - const GNUNET_HashCode *zone, - const struct GNUNET_NAMESTORE_SignatureLocation *loc, - const struct GNUNET_NAMESTORE_SignatureLocation *ploc, - unsigned int num_entries, - const GNUNET_HashCode *entries); - - -/** - * Obtain part of a signature B-tree. The processor - * will only be called once. - * - * @param h handle to the namestore - * @param zone zone to look up a record from - * @param sig_loc location to look up - * @param proc function to call on each matching value; - * will be called once with a NULL value at the end - * @param proc_cls closure for proc - * @return a handle that can be used to - * cancel - */ -struct GNUNET_NAMESTORE_QueueEntry * -GNUNET_NAMESTORE_lookup_stree (struct GNUNET_NAMESTORE_Handle *h, - const GNUNET_HashCode *zone, - const struct GNUNET_NAMESTORE_SignatureLocation *sig_loc, - GNUNET_NAMESTORE_StreeProcessor proc, void *proc_cls); - -/** - * Process zone signature information that was stored in the namestore. - * - * @param cls closure - * @param zone hash of the public key of the zone - * @param loc where we are in the signature tree (identifies top) - * @param top_sig signature at the root - * @param time timestamp of the signature - * @param top_hash hash at the top of the tree - */ -typedef void (*GNUNET_NAMESTORE_SignatureProcessor) (void *cls, - const GNUNET_HashCode *zone, - const struct GNUNET_NAMESTORE_SignatureLocation *loc, - const struct GNUNET_CRYPTO_RsaSignature *top_sig, - struct GNUNET_TIME_Absolute time, - const GNUNET_HashCode *top_hash); - - /** - * Obtain latest/current signature of a zone. The processor + * Obtain latest/current signature of a zone's name. The processor * will only be called once. * * @param h handle to the namestore - * @param zone zone to look up a record from + * @param zone zone to look up a signature from + * @param the common name of the records the signature is for * @param proc function to call on each matching value; * will be called once with a NULL value at the end * @param proc_cls closure for proc @@ -495,6 +302,7 @@ typedef void (*GNUNET_NAMESTORE_SignatureProcessor) (void *cls, struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_lookup_signature (struct GNUNET_NAMESTORE_Handle *h, const GNUNET_HashCode *zone, + const char* name, GNUNET_NAMESTORE_SignatureProcessor proc, void *proc_cls); @@ -517,6 +325,44 @@ GNUNET_NAMESTORE_zone_transfer (struct GNUNET_NAMESTORE_Handle *h, void *proc_cls); +/** + * Starts a new zone iteration. This MUST lock the GNUNET_NAMESTORE_Handle + * for any other calls than + * GNUNET_NAMESTORE_zone_iterator_next + * and + * GNUNET_NAMESTORE_zone_iteration_stop + * + * @param h handle to the namestore + * @param zone zone to access + * @param proc function to call on a random value; it + * will be called repeatedly with a value (if available) + * and always once at the end with a zone and name of NULL. + * @param proc_cls closure for proc + * @return an iterator handle to use for iteration + */ +struct GNUNET_NAMESTORE_ZoneIterator * +GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, + const GNUNET_HashCode *zone, + GNUNET_NAMESTORE_RecordProcessor proc, + void *proc_cls); + +/** + * Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start + * for the next record. + * + * @param it the iterator + * @return 0 if no more records are available to iterate + */ +int +GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it); + +/** + * Stops iteration and releases the namestore handle for further calls. + * + * @param it the iterator + */ +void +GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it); /** -- 2.25.1