-fix
[oweals/gnunet.git] / src / fs / gnunet-service-fs_cadet.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2012 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 3, 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., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, USA.
19 */
20
21 /**
22  * @file fs/gnunet-service-fs_cadet.h
23  * @brief non-anonymous file-transfer
24  * @author Christian Grothoff
25  */
26 #ifndef GNUNET_SERVICE_FS_CADET_H
27 #define GNUNET_SERVICE_FS_CADET_H
28
29 /**
30  * Handle for a request that is going out via cadet API.
31  */
32 struct GSF_CadetRequest;
33
34
35 /**
36  * Function called with a reply from the cadet.
37  *
38  * @param cls closure
39  * @param type type of the block, ANY on error
40  * @param expiration expiration time for the block
41  * @param data_size number of bytes in 'data', 0 on error
42  * @param data reply block data, NULL on error
43  */
44 typedef void (*GSF_CadetReplyProcessor)(void *cls,
45                                          enum GNUNET_BLOCK_Type type,
46                                          struct GNUNET_TIME_Absolute expiration,
47                                          size_t data_size,
48                                          const void *data);
49
50
51 /**
52  * Look for a block by directly contacting a particular peer.
53  *
54  * @param target peer that should have the block
55  * @param query hash to query for the block
56  * @param type desired type for the block
57  * @param proc function to call with result
58  * @param proc_cls closure for 'proc'
59  * @return handle to cancel the operation
60  */
61 struct GSF_CadetRequest *
62 GSF_cadet_query (const struct GNUNET_PeerIdentity *target,
63                   const struct GNUNET_HashCode *query,
64                   enum GNUNET_BLOCK_Type type,
65                   GSF_CadetReplyProcessor proc, void *proc_cls);
66
67
68 /**
69  * Cancel an active request; must not be called after 'proc'
70  * was calld.
71  *
72  * @param sr request to cancel
73  */
74 void
75 GSF_cadet_query_cancel (struct GSF_CadetRequest *sr);
76
77
78 /**
79  * Initialize subsystem for non-anonymous file-sharing.
80  */
81 void
82 GSF_cadet_start_server (void);
83
84
85 /**
86  * Shutdown subsystem for non-anonymous file-sharing.
87  */
88 void
89 GSF_cadet_stop_server (void);
90
91 /**
92  * Initialize subsystem for non-anonymous file-sharing.
93  */
94 void
95 GSF_cadet_start_client (void);
96
97
98 /**
99  * Shutdown subsystem for non-anonymous file-sharing.
100  */
101 void
102 GSF_cadet_stop_client (void);
103
104
105 GNUNET_NETWORK_STRUCT_BEGIN
106
107 /**
108  * Query from one peer, asking the other for CHK-data.
109  */
110 struct CadetQueryMessage
111 {
112
113   /**
114    * Type is GNUNET_MESSAGE_TYPE_FS_CADET_QUERY.
115    */
116   struct GNUNET_MessageHeader header;
117
118   /**
119    * Block type must be DBLOCK or IBLOCK.
120    */
121   uint32_t type GNUNET_PACKED;
122
123   /**
124    * Query hash from CHK (hash of encrypted block).
125    */
126   struct GNUNET_HashCode query;
127
128 };
129
130
131 /**
132  * Reply to a CadetQueryMessage.
133  */
134 struct CadetReplyMessage
135 {
136
137   /**
138    * Type is GNUNET_MESSAGE_TYPE_FS_CADET_REPLY.
139    */
140   struct GNUNET_MessageHeader header;
141
142   /**
143    * Block type must be DBLOCK or IBLOCK.
144    */
145   uint32_t type GNUNET_PACKED;
146
147   /**
148    * Expiration time for the block.
149    */
150   struct GNUNET_TIME_AbsoluteNBO expiration;
151
152   /* followed by the encrypted block */
153
154 };
155
156 GNUNET_NETWORK_STRUCT_END
157
158
159 #endif