travelhacking
[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  * @brief content hash key
31  */
32 struct ContentHashKey 
33 {
34   GNUNET_HashCode key;
35   GNUNET_HashCode query;
36 };
37
38
39 /**
40  * @brief complete information needed
41  * to download a file.
42  */
43 struct FileIdentifier
44 {
45
46   /**
47    * Total size of the file in bytes. (network byte order (!))
48    */
49   unsigned long long file_length;
50
51   /**
52    * Query and key of the top GNUNET_EC_IBlock.
53    */
54   struct ContentHashKey chk;
55
56 };
57
58
59 /**
60  * Information about a file and its location
61  * (peer claiming to share the file).
62  */
63 struct Location
64 {
65   /**
66    * Information about the shared file.
67    */
68   struct FileIdentifier fi;
69
70   /**
71    * Identity of the peer sharing the file.
72    */
73   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded peer;
74
75   /**
76    * Time when the HELLO *and* this location URI
77    * expire (they expire together!).
78    */
79   struct GNUNET_TIME_Absolute expirationTime;
80
81   /**
82    * RSA signature over the GNUNET_EC_FileIdentifier,
83    * GNUNET_hash of the peer and expiration time.
84    */
85   struct GNUNET_CRYPTO_RsaSignature contentSignature;
86
87 };
88
89 enum uri_types
90 { chk, sks, ksk, loc };
91
92 /**
93  * A Universal Resource Identifier (URI), opaque.
94  */
95 struct GNUNET_FS_Uri
96 {
97   enum uri_types type;
98   union
99   {
100     struct
101     {
102       /**
103        * Keywords start with a '+' if they are
104        * mandatory (in which case the '+' is NOT
105        * part of the keyword) and with a
106        * simple space if they are optional
107        * (in which case the space is ALSO not
108        * part of the actual keyword).
109        *
110        * Double-quotes to protect spaces and
111        * %-encoding are NOT used internally
112        * (only in URI-strings).
113        */
114       char **keywords;
115       unsigned int keywordCount;
116     } ksk;
117     struct
118     {
119       GNUNET_HashCode namespace;
120       char *identifier;
121     } sks;
122     struct FileIdentifier chk;
123     struct Location loc;
124   } data;
125
126 };
127
128 #endif