move-hacknig
[oweals/gnunet.git] / src / fs / fs.h
1 /*
2      This file is part of GNUnet.
3      (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 2, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file fs/fs.h
23  * @brief definitions for the entire fs module
24  * @author Igor Wronsky, Christian Grothoff
25  */
26 #ifndef FS_H
27 #define FS_H
28
29 /**
30  * Size of the individual blocks used for file-sharing.
31  */
32 #define GNUNET_FS_DBLOCK_SIZE (32*1024)
33
34 /**
35  * @brief content hash key
36  */
37 struct ContentHashKey 
38 {
39   GNUNET_HashCode key;
40   GNUNET_HashCode query;
41 };
42
43
44 /**
45  * @brief complete information needed
46  * to download a file.
47  */
48 struct FileIdentifier
49 {
50
51   /**
52    * Total size of the file in bytes. (network byte order (!))
53    */
54   unsigned long long file_length;
55
56   /**
57    * Query and key of the top GNUNET_EC_IBlock.
58    */
59   struct ContentHashKey chk;
60
61 };
62
63
64 /**
65  * Information about a file and its location
66  * (peer claiming to share the file).
67  */
68 struct Location
69 {
70   /**
71    * Information about the shared file.
72    */
73   struct FileIdentifier fi;
74
75   /**
76    * Identity of the peer sharing the file.
77    */
78   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded peer;
79
80   /**
81    * Time when this location URI expires.
82    */
83   struct GNUNET_TIME_Absolute expirationTime;
84
85   /**
86    * RSA signature over the GNUNET_EC_FileIdentifier,
87    * GNUNET_hash of the peer and expiration time.
88    */
89   struct GNUNET_CRYPTO_RsaSignature contentSignature;
90
91 };
92
93 enum uri_types
94 { chk, sks, ksk, loc };
95
96 /**
97  * A Universal Resource Identifier (URI), opaque.
98  */
99 struct GNUNET_FS_Uri
100 {
101   enum uri_types type;
102   union
103   {
104     struct
105     {
106       /**
107        * Keywords start with a '+' if they are
108        * mandatory (in which case the '+' is NOT
109        * part of the keyword) and with a
110        * simple space if they are optional
111        * (in which case the space is ALSO not
112        * part of the actual keyword).
113        *
114        * Double-quotes to protect spaces and
115        * %-encoding are NOT used internally
116        * (only in URI-strings).
117        */
118       char **keywords;
119       unsigned int keywordCount;
120     } ksk;
121     struct
122     {
123       GNUNET_HashCode namespace;
124       char *identifier;
125     } sks;
126     struct FileIdentifier chk;
127     struct Location loc;
128   } data;
129
130 };
131
132 #endif