-remove deprecated GNUNET_NAMESTORE_RF_AUTHORITY
[oweals/gnunet.git] / src / namestore / namestore.h
index 8e2625c109cbfa5a07270df4bbb1b376471653c3..7d406df61d56be3c0124da9736c05e9bcbb4407c 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2009 Christian Grothoff (and other contributing authors)
+     (C) 2011-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
@@ -22,6 +22,7 @@
  * @file namestore/namestore.h
  * @brief common internal definitions for namestore service
  * @author Matthias Wachs
+ * @author Christian Grothoff
  */
 #ifndef NAMESTORE_H
 #define NAMESTORE_H
 
 GNUNET_NETWORK_STRUCT_BEGIN
 
-
-/**
- * A GNS record serialized for network transmission.
- *
- * Layout is [struct GNUNET_NAMESTORE_NetworkRecord][char[data_size] data]
- */
-struct GNUNET_NAMESTORE_NetworkRecord
-{
-  /**
-   * Expiration time for the DNS record.
-   */
-  struct GNUNET_TIME_AbsoluteNBO expiration;
-
-  /**
-   * Number of bytes in 'data'.
-   */
-  uint32_t data_size;
-
-  /**
-   * Type of the GNS/DNS record.
-   */
-  uint32_t record_type;
-
-  /**
-   * Flags for the record.
-   */
-  uint32_t flags;
-};
-
-
-
-/**
- * Connect to namestore service.  FIXME: UNNECESSARY.
- */
-struct StartMessage
-{
-
-  /**
-   * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_START
-   */
-  struct GNUNET_MessageHeader header;
-
-};
-
-
 /**
  * Generic namestore message with op id
  */
@@ -97,38 +53,30 @@ struct GNUNET_NAMESTORE_Header
 
 
 /**
- * Lookup a name in the namestore
+ * Lookup a block in the namestore
  */
-struct LookupNameMessage
+struct LookupBlockMessage
 {
-  struct GNUNET_NAMESTORE_Header gns_header;
-
-  /**
-   * The zone 
-   */
-  struct GNUNET_CRYPTO_ShortHashCode zone;
-
   /**
-   * Requested record type 
+   * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_BLOCK
    */
-  uint32_t record_type;
+  struct GNUNET_NAMESTORE_Header gns_header;
 
   /**
-   * Length of the name
+   * The query.
    */
-  uint32_t name_len;
+  struct GNUNET_HashCode query;
 
-  /* 0-terminated name here */
 };
 
 
 /**
  * Lookup response
  */
-struct LookupNameResponseMessage
+struct LookupBlockResponseMessage
 {
   /**
-   * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE
+   * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_BLOCK_RESPONSE
    */
   struct GNUNET_NAMESTORE_Header gns_header;
 
@@ -138,48 +86,26 @@ struct LookupNameResponseMessage
   struct GNUNET_TIME_AbsoluteNBO expire;
 
   /**
-   * Name length
-   */
-  uint16_t name_len;
-
-  /**
-   * Bytes of serialized record data
-   */
-  uint16_t rd_len;
-
-  /**
-   * Number of records contained
-   */
-  uint16_t rd_count;
-
-  /**
-   * Is the signature valid
-   * GNUNET_YES or GNUNET_NO
-   */
-  int16_t contains_sig;
-
-  /**
-   * All zeros if 'contains_sig' is GNUNET_NO.
+   * Signature.
    */
   struct GNUNET_CRYPTO_EccSignature signature;
 
   /**
-   * The public key for the name
+   * Derived public key.
    */
-  struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key;
+  struct GNUNET_CRYPTO_EccPublicKey derived_key;
 
-  /* 0-terminated name and serialized record data */
-  /* rd_len bytes serialized record data */
+  /* follwed by encrypted block data */
 };
 
 
 /**
- * Put a record to the namestore
+ * Cache a record in the namestore.
  */
-struct RecordPutMessage
+struct BlockCacheMessage
 {
   /**
-   * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_RECORD_PUT
+   * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_BLOCK_CACHE
    */
   struct GNUNET_NAMESTORE_Header gns_header;
 
@@ -189,70 +115,49 @@ struct RecordPutMessage
   struct GNUNET_TIME_AbsoluteNBO expire;
 
   /**
-   * Name length
-   */
-  uint16_t name_len;
-
-  /**
-   * Length of serialized record data
-   */
-  uint16_t rd_len;
-
-  /**
-   * Number of records contained 
-   */
-  uint16_t rd_count;
-
-  /**
-   * always zero (for alignment)
-   */
-  uint16_t reserved;
-
-  /**
-   * The signature
+   * Signature.
    */
   struct GNUNET_CRYPTO_EccSignature signature;
 
   /**
-   * The public key
+   * Derived public key.
    */
-  struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key;
-
-  /* name (0-terminated) followed by "rd_count" serialized records */
+  struct GNUNET_CRYPTO_EccPublicKey derived_key;
 
+  /* follwed by encrypted block data */
 };
 
 
 /**
- * Put a record to the namestore response
+ * Response to a request to cache a block.
  */
-struct RecordPutResponseMessage
+struct BlockCacheResponseMessage
 {
   /**
-   * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE
+   * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_BLOCK_CACHE_RESPONSE
    */
   struct GNUNET_NAMESTORE_Header gns_header;
 
   /**
-   * result:
-   * GNUNET_SYSERR on failure
-   * GNUNET_OK on success
+   * #GNUNET_OK on success, #GNUNET_SYSERR error
    */
   int32_t op_result;
 };
 
 
 /**
- * Create a record and put it to the namestore
- * Memory layout:
+ * Store a record to the namestore (as authority).
  */
-struct RecordCreateMessage
+struct RecordStoreMessage
 {
   /**
-   * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE
+   * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE
    */
   struct GNUNET_NAMESTORE_Header gns_header;
 
+  /**
+   * Expiration time
+   */
   struct GNUNET_TIME_AbsoluteNBO expire;
 
   /**
@@ -266,76 +171,77 @@ struct RecordCreateMessage
   uint16_t rd_len;
 
   /**
-   * Record count 
+   * Number of records contained 
    */
   uint16_t rd_count;
 
   /**
-   * private key length 
+   * always zero (for alignment)
    */
-  uint16_t pkey_len;
+  uint16_t reserved;
+
+  /**
+   * The private key of the authority.
+   */
+  struct GNUNET_CRYPTO_EccPrivateKey private_key;
 
   /* followed by:
-   * GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded private key with length pkey_len
    * name with length name_len
-   * serialized record data with length rd_len
-   * */
+   * serialized record data with rd_count records
+   */
 };
 
 
 /**
- * Create a record to the namestore response
+ * Response to a record storage request.
  */
-struct RecordCreateResponseMessage
+struct RecordStoreResponseMessage
 {
   /**
-   * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE
+   * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE
    */
   struct GNUNET_NAMESTORE_Header gns_header;
 
   /**
-   *  name length: GNUNET_NO already exists, GNUNET_YES on success, GNUNET_SYSERR error
+   * #GNUNET_SYSERR on failure, #GNUNET_OK on success
    */
   int32_t op_result;
 };
 
 
+
 /**
  * Lookup a name for a zone hash
  */
 struct ZoneToNameMessage
 {
   /**
-   * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
+   * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
    */
   struct GNUNET_NAMESTORE_Header gns_header;
 
   /**
-   * The hash of public key of the zone to look up in 
+   * The private key of the zone to look up in 
    */
-  struct GNUNET_CRYPTO_ShortHashCode zone;
+  struct GNUNET_CRYPTO_EccPrivateKey zone;
 
   /**
-   * The  hash of the public key of the target zone  
+   * The public key of the target zone  
    */
-  struct GNUNET_CRYPTO_ShortHashCode value_zone;
+  struct GNUNET_CRYPTO_EccPublicKey value_zone;
 };
 
+
 /**
  * Respone for zone to name lookup
  */
 struct ZoneToNameResponseMessage
 {
   /**
-   * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
+   * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
    */
   struct GNUNET_NAMESTORE_Header gns_header;
 
-  /**
-   * Record block expiration
-   */
-  struct GNUNET_TIME_AbsoluteNBO expire;
-
   /**
    * Length of the name
    */
@@ -352,72 +258,99 @@ struct ZoneToNameResponseMessage
   uint16_t rd_count;
 
   /**
-   * result in NBO: GNUNET_OK on success, GNUNET_NO if there were no
-   * results, GNUNET_SYSERR on error 
+   * result in NBO: #GNUNET_OK on success, #GNUNET_NO if there were no
+   * results, #GNUNET_SYSERR on error 
    */
   int16_t res;
 
   /**
-   * Signature
+   * The private key of the zone that contained the name.
    */
-  struct GNUNET_CRYPTO_EccSignature signature;
+  struct GNUNET_CRYPTO_EccPrivateKey zone;
 
-  /**
-   * Publik key
+  /* followed by:
+   * name with length name_len
+   * serialized record data with rd_count records
    */
-  struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded zone_key;
 
 };
 
 
 /**
- * Start monitoring a zone.
+ * Record is returned from the namestore (as authority).
  */
-struct ZoneMonitorStartMessage
+struct RecordResultMessage
 {
   /**
-   * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START
+   * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT
    */
   struct GNUNET_NAMESTORE_Header gns_header;
 
   /**
-   * Zone hash
+   * Name length
    */
-  struct GNUNET_CRYPTO_ShortHashCode zone;
+  uint16_t name_len;
 
   /**
-   * All zones. GNUNET_YES to monitor all zones,
-   * GNUNET_NO to only monitor 'zone'.  In NBO.
+   * Length of serialized record data
+   */
+  uint16_t rd_len;
+
+  /**
+   * Number of records contained 
+   */
+  uint16_t rd_count;
+
+  /**
+   * always zero (for alignment)
+   */
+  uint16_t reserved;
+
+  /**
+   * The private key of the authority.
    */
-  uint32_t all_zones GNUNET_PACKED;
+  struct GNUNET_CRYPTO_EccPrivateKey private_key;
 
+  /* followed by:
+   * name with length name_len
+   * serialized record data with rd_count records
+   */
 };
 
 
 /**
- * Start a zone iteration for the given zone
+ * Start monitoring a zone.
  */
-struct ZoneIterationStartMessage
+struct ZoneMonitorStartMessage
 {
   /**
-   * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
+   * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START
    */
   struct GNUNET_NAMESTORE_Header gns_header;
 
   /**
-   * Zone hash
+   * Zone key.
    */
-  struct GNUNET_CRYPTO_ShortHashCode zone;
+  struct GNUNET_CRYPTO_EccPrivateKey zone;
+
+};
 
+
+/**
+ * Start a zone iteration for the given zone
+ */
+struct ZoneIterationStartMessage
+{
   /**
-   * Which flags must be included
+   * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
    */
-  uint16_t must_have_flags;
+  struct GNUNET_NAMESTORE_Header gns_header;
 
   /**
-   * Which flags must not be included
+   * Zone key.  All zeros for "all zones".
    */
-  uint16_t must_not_have_flags;
+  struct GNUNET_CRYPTO_EccPrivateKey zone;
+
 };
 
 
@@ -427,7 +360,7 @@ struct ZoneIterationStartMessage
 struct ZoneIterationNextMessage
 {
   /**
-   * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
+   * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
    */
   struct GNUNET_NAMESTORE_Header gns_header;
 };
@@ -439,7 +372,7 @@ struct ZoneIterationNextMessage
 struct ZoneIterationStopMessage
 {
   /**
-   * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
+   * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
    */
   struct GNUNET_NAMESTORE_Header gns_header;
 };