2 This file is part of GNUnet.
3 Copyright (C) 2012, 2017 GNUnet e.V.
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.
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.
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/>.
20 * @file fs/gnunet-service-fs_cadet.h
21 * @brief non-anonymous file-transfer
22 * @author Christian Grothoff
24 #ifndef GNUNET_SERVICE_FS_CADET_H
25 #define GNUNET_SERVICE_FS_CADET_H
28 * Handle for a request that is going out via cadet API.
30 struct GSF_CadetRequest;
34 * Function called with a reply from the cadet.
37 * @param type type of the block, ANY on error
38 * @param expiration expiration time for the block
39 * @param data_size number of bytes in @a data, 0 on error
40 * @param data reply block data, NULL on error
43 (*GSF_CadetReplyProcessor)(void *cls,
44 enum GNUNET_BLOCK_Type type,
45 struct GNUNET_TIME_Absolute expiration,
51 * Look for a block by directly contacting a particular peer.
53 * @param target peer that should have the block
54 * @param query hash to query for the block
55 * @param type desired type for the block
56 * @param proc function to call with result
57 * @param proc_cls closure for @a proc
58 * @return handle to cancel the operation
60 struct GSF_CadetRequest *
61 GSF_cadet_query (const struct GNUNET_PeerIdentity *target,
62 const struct GNUNET_HashCode *query,
63 enum GNUNET_BLOCK_Type type,
64 GSF_CadetReplyProcessor proc,
68 * Function called on each active cadets to shut them down.
71 * @param key target peer, unused
72 * @param value the `struct CadetHandle` to destroy
73 * @return #GNUNET_YES (continue to iterate)
76 GSF_cadet_release_clients (void *cls,
77 const struct GNUNET_PeerIdentity *key,
82 * Cancel an active request; must not be called after 'proc'
85 * @param sr request to cancel
88 GSF_cadet_query_cancel (struct GSF_CadetRequest *sr);
92 * Initialize subsystem for non-anonymous file-sharing.
95 GSF_cadet_start_server (void);
99 * Shutdown subsystem for non-anonymous file-sharing.
102 GSF_cadet_stop_server (void);
105 * Cadet channel for creating outbound channels.
107 extern struct GNUNET_CADET_Handle *cadet_handle;
110 * Map from peer identities to 'struct CadetHandles' with cadet
111 * channels to those peers.
113 extern struct GNUNET_CONTAINER_MultiPeerMap *cadet_map;
116 GNUNET_NETWORK_STRUCT_BEGIN
119 * Query from one peer, asking the other for CHK-data.
121 struct CadetQueryMessage
125 * Type is GNUNET_MESSAGE_TYPE_FS_CADET_QUERY.
127 struct GNUNET_MessageHeader header;
130 * Block type must be DBLOCK or IBLOCK.
132 uint32_t type GNUNET_PACKED;
135 * Query hash from CHK (hash of encrypted block).
137 struct GNUNET_HashCode query;
143 * Reply to a CadetQueryMessage.
145 struct CadetReplyMessage
149 * Type is GNUNET_MESSAGE_TYPE_FS_CADET_REPLY.
151 struct GNUNET_MessageHeader header;
154 * Block type must be DBLOCK or IBLOCK.
156 uint32_t type GNUNET_PACKED;
159 * Expiration time for the block.
161 struct GNUNET_TIME_AbsoluteNBO expiration;
163 /* followed by the encrypted block */
167 GNUNET_NETWORK_STRUCT_END