-fix
[oweals/gnunet.git] / src / fs / fs.h
index bbe4e8660e3c9f5221dfa3ae028884aca71ddcea..ffd448d2b88b6858426bde1b2b6f8f1751bf820f 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors)
+     (C) 2003--2012 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
@@ -55,15 +55,17 @@ struct ContentHashKey
   /**
    * Hash of the original content, used for encryption.
    */
-  GNUNET_HashCode key;
+  struct GNUNET_HashCode key;
 
   /**
    * Hash of the encrypted content, used for querying.
    */
-  GNUNET_HashCode query;
+  struct GNUNET_HashCode query;
 };
 
 
+GNUNET_NETWORK_STRUCT_BEGIN
+
 /**
  * Message sent from a GNUnet (fs) publishing activity to the
  * gnunet-fs-service to initiate indexing of a file.  The service is
@@ -110,7 +112,7 @@ struct IndexStartMessage
   /**
    * Hash of the file that we would like to index.
    */
-  GNUNET_HashCode file_id;
+  struct GNUNET_HashCode file_id;
 
   /* this is followed by a 0-terminated
    * filename of a file with the hash
@@ -139,7 +141,7 @@ struct IndexInfoMessage
   /**
    * Hash of the indexed file.
    */
-  GNUNET_HashCode file_id;
+  struct GNUNET_HashCode file_id;
 
   /* this is followed by a 0-terminated
    * filename of a file with the hash
@@ -172,11 +174,30 @@ struct UnindexMessage
   /**
    * Hash of the file that we will unindex.
    */
-  GNUNET_HashCode file_id;
+  struct GNUNET_HashCode file_id;
 
 };
 
 
+/**
+ * No options.
+ */
+#define SEARCH_MESSAGE_OPTION_NONE 0
+
+/**
+ * Only search the local datastore (no network)
+ */
+#define SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY 1
+
+/**
+ * Request is too large to fit in 64k format.  The list of
+ * already-known search results will be continued in another message
+ * for the same type/query/target and additional already-known results
+ * following this one).
+ */
+#define SEARCH_MESSAGE_OPTION_CONTINUED 2
+
+
 /**
  * Message sent from a GNUnet (fs) search activity to the
  * gnunet-service-fs to start a search.
@@ -191,10 +212,15 @@ struct SearchMessage
   struct GNUNET_MessageHeader header;
 
   /**
-   * Bitmask with options.  Zero for no options, one for loopback-only.
+   * Bitmask with options.  Zero for no options, one for
+   * loopback-only, two for 'to be continued' (with a second search
+   * message for the same type/query/target and additional
+   * already-known results following this one).  See
+   * SEARCH_MESSAGE_OPTION_ defines.
+   *
    * Other bits are currently not defined.
    */
-  int32_t options GNUNET_PACKED;
+  uint32_t options GNUNET_PACKED;
 
   /**
    * Type of the content that we're looking for.
@@ -219,7 +245,7 @@ struct SearchMessage
    * <p>
    * If the request is for a KBLOCK, "target" must be all zeros.
    */
-  GNUNET_HashCode target;
+  struct GNUNET_HashCode target;
 
   /**
    * Hash of the keyword (aka query) for KBLOCKs; Hash of
@@ -227,7 +253,7 @@ struct SearchMessage
    * and hash of the identifier XORed with the target for
    * SBLOCKS (aka query).
    */
-  GNUNET_HashCode query;
+  struct GNUNET_HashCode query;
 
   /* this is followed by the hash codes of already-known
    * results (which should hence be excluded from what
@@ -241,7 +267,7 @@ struct SearchMessage
  * Response from FS service with a result for a previous FS search.
  * Note that queries for DBLOCKS and IBLOCKS that have received a
  * single response are considered done.  This message is transmitted
- * between peers as well as between the service and a client.
+ * between peers.
  */
 struct PutMessage
 {
@@ -265,6 +291,52 @@ struct PutMessage
 
 };
 
+/**
+ * Response from FS service with a result for a previous FS search.
+ * Note that queries for DBLOCKS and IBLOCKS that have received a
+ * single response are considered done.  This message is transmitted
+ * between the service and a client.
+ */
+struct ClientPutMessage
+{
+
+  /**
+   * Message type will be GNUNET_MESSAGE_TYPE_FS_PUT.
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Type of the block (in big endian).  Should never be zero.
+   */
+  uint32_t type GNUNET_PACKED;
+
+  /**
+   * When does this result expire?
+   */
+  struct GNUNET_TIME_AbsoluteNBO expiration;
+
+  /**
+   * When was the last time we've tried to download this block?
+   * (FOREVER if unknown/not relevant)
+   */
+  struct GNUNET_TIME_AbsoluteNBO last_transmission;
+
+  /**
+   * How often did we transmit this query before getting an
+   * answer (estimate).
+   */
+  uint32_t num_transmissions;
+
+  /**
+   * How much respect did we offer (in total) before getting an
+   * answer (estimate).
+   */
+  uint32_t respect_offered;
+
+  /* this is followed by the actual encrypted content */
+
+};
+GNUNET_NETWORK_STRUCT_END
 
 
 #endif