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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @file fs/gnunet-service-fs_cadet.h
23 * @brief non-anonymous file-transfer
24 * @author Christian Grothoff
26 #ifndef GNUNET_SERVICE_FS_CADET_H
27 #define GNUNET_SERVICE_FS_CADET_H
30 * Handle for a request that is going out via cadet API.
32 struct GSF_CadetRequest;
36 * Function called with a reply from the cadet.
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
45 (*GSF_CadetReplyProcessor)(void *cls,
46 enum GNUNET_BLOCK_Type type,
47 struct GNUNET_TIME_Absolute expiration,
53 * Look for a block by directly contacting a particular peer.
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
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,
70 * Function called on each active cadets to shut them down.
73 * @param key target peer, unused
74 * @param value the `struct CadetHandle` to destroy
75 * @return #GNUNET_YES (continue to iterate)
78 GSF_cadet_release_clients(void *cls,
79 const struct GNUNET_PeerIdentity *key,
84 * Cancel an active request; must not be called after 'proc'
87 * @param sr request to cancel
90 GSF_cadet_query_cancel(struct GSF_CadetRequest *sr);
94 * Initialize subsystem for non-anonymous file-sharing.
97 GSF_cadet_start_server(void);
101 * Shutdown subsystem for non-anonymous file-sharing.
104 GSF_cadet_stop_server(void);
107 * Cadet channel for creating outbound channels.
109 extern struct GNUNET_CADET_Handle *cadet_handle;
112 * Map from peer identities to 'struct CadetHandles' with cadet
113 * channels to those peers.
115 extern struct GNUNET_CONTAINER_MultiPeerMap *cadet_map;
118 GNUNET_NETWORK_STRUCT_BEGIN
121 * Query from one peer, asking the other for CHK-data.
123 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;
142 * Reply to a CadetQueryMessage.
144 struct CadetReplyMessage {
146 * Type is GNUNET_MESSAGE_TYPE_FS_CADET_REPLY.
148 struct GNUNET_MessageHeader header;
151 * Block type must be DBLOCK or IBLOCK.
153 uint32_t type GNUNET_PACKED;
156 * Expiration time for the block.
158 struct GNUNET_TIME_AbsoluteNBO expiration;
160 /* followed by the encrypted block */
163 GNUNET_NETWORK_STRUCT_END