diff options
Diffstat (limited to 'src/service/fs/gnunet-service-fs_cadet.h')
-rw-r--r-- | src/service/fs/gnunet-service-fs_cadet.h | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/src/service/fs/gnunet-service-fs_cadet.h b/src/service/fs/gnunet-service-fs_cadet.h new file mode 100644 index 000000000..c02021a0d --- /dev/null +++ b/src/service/fs/gnunet-service-fs_cadet.h | |||
@@ -0,0 +1,168 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2012, 2017 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
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 @a data, 0 on error | ||
42 | * @param data reply block data, NULL on error | ||
43 | */ | ||
44 | typedef void | ||
45 | (*GSF_CadetReplyProcessor)(void *cls, | ||
46 | enum GNUNET_BLOCK_Type type, | ||
47 | struct GNUNET_TIME_Absolute expiration, | ||
48 | size_t data_size, | ||
49 | const void *data); | ||
50 | |||
51 | |||
52 | /** | ||
53 | * Look for a block by directly contacting a particular peer. | ||
54 | * | ||
55 | * @param target peer that should have the block | ||
56 | * @param query hash to query for the block | ||
57 | * @param type desired type for the block | ||
58 | * @param proc function to call with result | ||
59 | * @param proc_cls closure for @a proc | ||
60 | * @return handle to cancel the operation | ||
61 | */ | ||
62 | struct GSF_CadetRequest * | ||
63 | GSF_cadet_query (const struct GNUNET_PeerIdentity *target, | ||
64 | const struct GNUNET_HashCode *query, | ||
65 | enum GNUNET_BLOCK_Type type, | ||
66 | GSF_CadetReplyProcessor proc, | ||
67 | void *proc_cls); | ||
68 | |||
69 | /** | ||
70 | * Function called on each active cadets to shut them down. | ||
71 | * | ||
72 | * @param cls NULL | ||
73 | * @param key target peer, unused | ||
74 | * @param value the `struct CadetHandle` to destroy | ||
75 | * @return #GNUNET_YES (continue to iterate) | ||
76 | */ | ||
77 | int | ||
78 | GSF_cadet_release_clients (void *cls, | ||
79 | const struct GNUNET_PeerIdentity *key, | ||
80 | void *value); | ||
81 | |||
82 | |||
83 | /** | ||
84 | * Cancel an active request; must not be called after 'proc' | ||
85 | * was called. | ||
86 | * | ||
87 | * @param sr request to cancel | ||
88 | */ | ||
89 | void | ||
90 | GSF_cadet_query_cancel (struct GSF_CadetRequest *sr); | ||
91 | |||
92 | |||
93 | /** | ||
94 | * Initialize subsystem for non-anonymous file-sharing. | ||
95 | */ | ||
96 | void | ||
97 | GSF_cadet_start_server (void); | ||
98 | |||
99 | |||
100 | /** | ||
101 | * Shutdown subsystem for non-anonymous file-sharing. | ||
102 | */ | ||
103 | void | ||
104 | GSF_cadet_stop_server (void); | ||
105 | |||
106 | /** | ||
107 | * Cadet channel for creating outbound channels. | ||
108 | */ | ||
109 | extern struct GNUNET_CADET_Handle *cadet_handle; | ||
110 | |||
111 | /** | ||
112 | * Map from peer identities to 'struct CadetHandles' with cadet | ||
113 | * channels to those peers. | ||
114 | */ | ||
115 | extern struct GNUNET_CONTAINER_MultiPeerMap *cadet_map; | ||
116 | |||
117 | |||
118 | GNUNET_NETWORK_STRUCT_BEGIN | ||
119 | |||
120 | /** | ||
121 | * Query from one peer, asking the other for CHK-data. | ||
122 | */ | ||
123 | struct CadetQueryMessage | ||
124 | { | ||
125 | /** | ||
126 | * Type is GNUNET_MESSAGE_TYPE_FS_CADET_QUERY. | ||
127 | */ | ||
128 | struct GNUNET_MessageHeader header; | ||
129 | |||
130 | /** | ||
131 | * Block type must be DBLOCK or IBLOCK. | ||
132 | */ | ||
133 | uint32_t type GNUNET_PACKED; | ||
134 | |||
135 | /** | ||
136 | * Query hash from CHK (hash of encrypted block). | ||
137 | */ | ||
138 | struct GNUNET_HashCode query; | ||
139 | }; | ||
140 | |||
141 | |||
142 | /** | ||
143 | * Reply to a CadetQueryMessage. | ||
144 | */ | ||
145 | struct CadetReplyMessage | ||
146 | { | ||
147 | /** | ||
148 | * Type is GNUNET_MESSAGE_TYPE_FS_CADET_REPLY. | ||
149 | */ | ||
150 | struct GNUNET_MessageHeader header; | ||
151 | |||
152 | /** | ||
153 | * Block type must be DBLOCK or IBLOCK. | ||
154 | */ | ||
155 | uint32_t type GNUNET_PACKED; | ||
156 | |||
157 | /** | ||
158 | * Expiration time for the block. | ||
159 | */ | ||
160 | struct GNUNET_TIME_AbsoluteNBO expiration; | ||
161 | |||
162 | /* followed by the encrypted block */ | ||
163 | }; | ||
164 | |||
165 | GNUNET_NETWORK_STRUCT_END | ||
166 | |||
167 | |||
168 | #endif | ||