/*
This file is part of GNUnet
- (C) 2012 Christian Grothoff (and other contributing authors)
+ (C) 2012, 2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
* @file include/gnunet_namestore_plugin.h
* @brief plugin API for the namestore database backend
* @author Christian Grothoff
- *
- * Other functions we might want:
- * - enumerate all known zones
*/
#ifndef GNUNET_NAMESTORE_PLUGIN_H
#define GNUNET_NAMESTORE_PLUGIN_H
+#include "gnunet_util_lib.h"
#include "gnunet_namestore_service.h"
#ifdef __cplusplus
* Function called by for each matching record.
*
* @param cls closure
- * @param zone hash of the public key of the zone
- * @param record_hash hash of the record
- * @param record_key XOR of zone and hash of name
- * @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 zone_key private key of the zone
+ * @param label name that is being mapped (at most 255 characters long)
+ * @param rd_count number of entries in @a rd array
+ * @param rd array of records with data to store
*/
typedef void (*GNUNET_NAMESTORE_RecordIterator) (void *cls,
- const GNUNET_HashCode *zone,
- const GNUNET_HashCode *record_hash,
- const GNUNET_HashCode *record_key,
- const char *name,
- uint32_t record_type,
- struct GNUNET_TIME_Absolute expiration,
- enum GNUNET_NAMESTORE_RecordFlags flags,
- size_t data_size,
- const void *data);
-
-
-/**
- * Function called with the matching node.
- *
- * @param cls closure
- * @param zone hash of 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 num_entries number of entries at this node in the B-tree
- * @param entries the 'num_entries' entries to store (hashes over the
- * records)
- */
-typedef void (*GNUNET_NAMESTORE_NodeCallback) (void *cls,
- const struct GNUNET_HashCode *zone,
- const struct GNUNET_NAMESTORE_SignatureLocation *loc,
- const struct GNUNET_NAMESTORE_SignatureLocation *ploc,
- unsigned int num_entries,
- const GNUNET_HashCode *entries);
-
-
-/**
- * Function called with the matching signature.
- *
- * @param cls closure
- * @param zone public key of the zone
- * @param loc location of the root in the B-tree (depth, revision)
- * @param top_sig
- * @param root_hash top level hash that is being signed
- */
-typedef void (*GNUNET_NAMESTORE_SignatureCallback) (void *cls,
- const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
- const struct GNUNET_NAMESTORE_SignatureLocation *loc,
- const struct GNUNET_CRYPTO_RsaSignature *top_sig,
- const GNUNET_HashCode *root_hash);
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key,
+ const char *label,
+ unsigned int rd_count,
+ const struct GNUNET_GNSRECORD_Data *rd);
/**
void *cls;
/**
- * Store a record in the datastore.
- *
- * @param cls closure (internal context for the plugin)
- * @param zone hash of the public key of the zone
- * @param record_hash hash of the record
- * @param record_key XOR of zone and hash of name
- * @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)
- * @return GNUNET_OK on success
- */
- int (*put_record) (void *cls,
- const GNUNET_HashCode *zone,
- const GNUNET_HashCode *record_hash,
- const GNUNET_HashCode *record_key,
- const char *name,
- uint32_t record_type,
- struct GNUNET_TIME_Absolute expiration,
- enum GNUNET_NAMESTORE_RecordFlags flags,
- size_t data_size,
- const void *data);
-
-
- /**
- * Store a Merkle tree node in the datastore.
- *
- * @param cls closure (internal context for the plugin)
- * @param zone hash of 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 num_entries number of entries at this node in the B-tree
- * @param entries the 'num_entries' entries to store (hashes over the
- * records)
- * @return GNUNET_OK on success
- */
- int (*put_node) (void *cls,
- const struct GNUNET_HashCode *zone,
- const struct GNUNET_NAMESTORE_SignatureLocation *loc,
- const struct GNUNET_NAMESTORE_SignatureLocation *ploc,
- unsigned int num_entries,
- const GNUNET_HashCode *entries);
-
-
- /**
- * Store a zone signature in the datastore. If a signature for the zone with a
- * lower depth exists, the old signature is removed. If a signature for an
- * older revision of the zone exists, this will delete all records, nodes
- * and signatures for the older revision of the zone.
- *
- * @param cls closure (internal context for the plugin)
- * @param zone_key public key of the zone
- * @param loc location in the B-tree (top of the tree, offset 0, depth at 'maximum')
- * @param top_sig signature at the top, NULL if 'loc.depth > 0'
- * @param root_hash top level hash that is signed
- * @return GNUNET_OK on success
- */
- int (*put_signature) (void *cls,
- const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
- const struct GNUNET_NAMESTORE_SignatureLocation *loc,
- const struct GNUNET_CRYPTO_RsaSignature *top_sig,
- const GNUNET_HashCode *root_hash);
-
-
- /**
- * Iterate over the results for a particular key and zone in the
- * datastore. Will only query the latest revision known for the
- * zone (as adding a new zone revision will cause the plugin to
- * delete all records from previous revisions).
- *
- * @param cls closure (internal context for the plugin)
- * @param zone hash of public key of the zone
- * @param record_key key for the record (XOR of zone and hash of name);
- * NULL to iterate over all records of the zone
- * @param iter maybe NULL (to just count)
- * @param iter_cls closure for iter
- * @return the number of results found
- */
- unsigned int (*iterate_records) (void *cls,
- const GNUNET_HashCode *zone,
- const GNUNET_HashCode *record_key,
- GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls);
-
-
- /**
- * Get a particular node from the signature tree.
+ * Store a record in the datastore for which we are the authority.
+ * Removes any existing record in the same zone with the same name.
*
* @param cls closure (internal context for the plugin)
- * @param zone hash of public key of the zone
- * @param loc location of the node in the signature tree
- * @param cb function to call with the result
- * @param cb_cls closure for cont
+ * @param zone private key of the zone
+ * @param label name of the record in the zone
+ * @param rd_count number of entries in @a rd array, 0 to delete all records
+ * @param rd array of records with data to store
+ * @return #GNUNET_OK on success, else #GNUNET_SYSERR
*/
- void (*get_node) (void *cls,
- const GNUNET_HashCode *zone,
- const struct GNUNET_NAMESTORE_SignatureLocation *loc,
- GNUNET_NAMESTORE_NodeCallback cb, void *cb_cls);
+ int (*store_records) (void *cls,
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
+ const char *label,
+ unsigned int rd_count,
+ const struct GNUNET_GNSRECORD_Data *rd);
/**
- * Get the current signature for a zone.
+ * Iterate over the results for a particular zone in the
+ * datastore. Will return at most one result to the iterator.
*
* @param cls closure (internal context for the plugin)
- * @param zone hash of public key of the zone
- * @param cb function to call with the result
- * @param cb_cls closure for cont
+ * @param zone private key of the zone, NULL for all zones
+ * @param offset offset in the list of all matching records
+ * @param iter function to call with the result
+ * @param iter_cls closure for @a iter
+ * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
*/
- void (*get_signature) (void *cls,
- const GNUNET_HashCode *zone,
- GNUNET_NAMESTORE_SignatureCallback cb, void *cb_cls);
+ int (*iterate_records) (void *cls,
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
+ uint64_t offset,
+ GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls);
/**
- * Delete an entire zone (all revisions, all records, all nodes,
- * all signatures). Not used in normal operation.
+ * Look for an existing PKEY delegation record for a given public key.
+ * Returns at most one result to the iterator.
*
* @param cls closure (internal context for the plugin)
- * @param zone zone to delete
+ * @param zone private key of the zone to look up in, never NULL
+ * @param value_zone public key of the target zone (value), never NULL
+ * @param iter function to call with the result
+ * @param iter_cls closure for @a iter
+ * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
*/
- void (*delete_zone) (void *cls,
- const GNUNET_HashCode *zone);
+ int (*zone_to_name) (void *cls,
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
+ const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone,
+ GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls);
};