2 This file is part of GNUnet.
3 (C) 2009, 2010 Christian Grothoff (and other contributing authors)
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file fs/gnunet-service-fs_pr.h
23 * @brief API to handle pending requests
24 * @author Christian Grothoff
26 #ifndef GNUNET_SERVICE_FS_PR_H
27 #define GNUNET_SERVICE_FS_PR_H
29 #include "gnunet-service-fs.h"
33 * Options for pending requests (bits to be ORed).
35 enum GSF_PendingRequestOptions
38 * Request must only be processed locally.
40 GSF_PRO_LOCAL_ONLY = 1,
43 * Request must only be forwarded (no routing)
45 GSF_PRO_FORWARD_ONLY = 2,
48 * Request persists indefinitely (no expiration).
50 GSF_PRO_REQUEST_EXPIRES = 4,
53 * Request is allowed to refresh bloomfilter and change mingle value.
55 GSF_PRO_BLOOMFILTER_FULL_REFRESH = 8,
58 * Request priority is allowed to be exceeded.
60 GSF_PRO_PRIORITY_UNLIMITED = 16,
63 * Option mask for typical local requests.
65 GSF_PRO_LOCAL_REQUEST = (GSF_PRO_BLOOMFILTER_FULL_REFRESH | GSF_PRO_PRIORITY_UNLIMITED)
70 * Handle a reply to a pending request. Also called if a request
71 * expires (then with data == NULL). The handler may be called
72 * many times (depending on the request type), but will not be
73 * called during or after a call to GSF_pending_request_cancel
74 * and will also not be called anymore after a call signalling
77 * @param cls user-specified closure
78 * @param pr handle to the original pending request
79 * @param data response data, NULL on request expiration
80 * @param data_len number of bytes in data
82 typedef void (*GSF_PendingRequestReplyHandler)(void *cls,
83 struct GSF_PendingRequest *pr,
89 * Create a new pending request.
91 * @param options request options
92 * @param type type of the block that is being requested
93 * @param query key for the lookup
94 * @param namespace namespace to lookup, NULL for no namespace
95 * @param target preferred target for the request, NULL for none
96 * @param bf bloom filter for known replies, can be NULL
97 * @param mingle mingle value for bf
98 * @param anonymity_level desired anonymity level
99 * @param priority maximum outgoing cummulative request priority to use
100 * @param replies_seen hash codes of known local replies
101 * @param replies_seen_count size of the 'replies_seen' array
102 * @param rh handle to call when we get a reply
103 * @param rh_cls closure for rh
104 * @return handle for the new pending request
106 struct GSF_PendingRequest *
107 GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
108 enum GNUNET_BLOCK_Type type,
109 const GNUNET_HashCode *query,
110 const GNUNET_HashCode *namespace,
111 const struct GNUNET_PeerIdentity *target,
112 struct GNUNET_CONTAINER_BloomFilter *bf,
114 uint32_t anonymity_level,
116 const GNUNET_HashCode *replies_seen,
117 unsigned int replies_seen_count,
118 GSF_PendingRequestReplyHandler rh,
123 * Generate the message corresponding to the given pending request for
124 * transmission to other peers (or at least determine its size).
126 * @param pr request to generate the message for
127 * @param buf_size number of bytes available in buf
128 * @param buf where to copy the message (can be NULL)
129 * @return number of bytes needed (if > buf_size) or used
132 GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr,
138 * Explicitly cancel a pending request.
140 * @param pr request to cancel
143 GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr);
147 * Signature of function called on each request.
150 * @param key query for the request
151 * @param pr handle to the pending request
153 typedef int (*GSF_PendingRequestIterator)(void *cls,
154 const GNUNET_HashCode *key,
155 struct GSF_PendingRequest *pr);
159 * Iterate over all pending requests.
161 * @param it function to call for each request
162 * @param cls closure for it
165 GSF_iterate_pending_requests_ (GSF_PendingRequestIterator it,
171 * Register callback to invoke on request destruction.
173 * @param pr request to monitor
174 * @param it function to call on destruction
175 * @param it_cls closure for it
178 GSF_pending_request_register_destroy_callback_ (struct GSF_PendingRequest *pr,
179 GSF_PendingRequestIterator it,
184 * Unregister callback to invoke on request destruction.
186 * @param pr request to stop monitoring
187 * @param it function to no longer call on destruction
188 * @param it_cls closure for it
191 GSF_pending_request_unregister_destroy_callback_ (struct GSF_PendingRequest *pr,
192 GSF_PendingRequestIterator it,
197 /* end of gnunet-service-fs_pr.h */