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
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.
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.
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.
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
127 * Type is GNUNET_MESSAGE_TYPE_FS_CADET_QUERY.
129 struct GNUNET_MessageHeader header;
132 * Block type must be DBLOCK or IBLOCK.
134 uint32_t type GNUNET_PACKED;
137 * Query hash from CHK (hash of encrypted block).
139 struct GNUNET_HashCode query;
145 * Reply to a CadetQueryMessage.
147 struct CadetReplyMessage
151 * Type is GNUNET_MESSAGE_TYPE_FS_CADET_REPLY.
153 struct GNUNET_MessageHeader header;
156 * Block type must be DBLOCK or IBLOCK.
158 uint32_t type GNUNET_PACKED;
161 * Expiration time for the block.
163 struct GNUNET_TIME_AbsoluteNBO expiration;
165 /* followed by the encrypted block */
169 GNUNET_NETWORK_STRUCT_END