2 This file is part of GNUnet.
3 (C) 2009, 2010, 2011 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.c
23 * @brief API to handle pending requests
24 * @author Christian Grothoff
27 #include "gnunet-service-fs_pr.h"
31 * Create a new pending request.
33 * @param options request options
34 * @param type type of the block that is being requested
35 * @param query key for the lookup
36 * @param namespace namespace to lookup, NULL for no namespace
37 * @param target preferred target for the request, NULL for none
38 * @param bf bloom filter for known replies, can be NULL
39 * @param mingle mingle value for bf
40 * @param anonymity_level desired anonymity level
41 * @param priority maximum outgoing cummulative request priority to use
42 * @param replies_seen hash codes of known local replies
43 * @param replies_seen_count size of the 'replies_seen' array
44 * @param rh handle to call when we get a reply
45 * @param rh_cls closure for rh
46 * @return handle for the new pending request
48 struct GSF_PendingRequest *
49 GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
50 enum GNUNET_BLOCK_Type type,
51 const GNUNET_HashCode *query,
52 const GNUNET_HashCode *namespace,
53 const struct GNUNET_PeerIdentity *target,
54 struct GNUNET_CONTAINER_BloomFilter *bf,
56 uint32_t anonymity_level,
58 const GNUNET_HashCode *replies_seen,
59 unsigned int replies_seen_count,
60 GSF_PendingRequestReplyHandler rh,
68 * Update a given pending request with additional replies
69 * that have been seen.
71 * @param pr request to update
72 * @param replies_seen hash codes of replies that we've seen
73 * @param replies_seen_count size of the replies_seen array
76 GSF_pending_request_update_ (struct GSF_PendingRequest *pr,
77 const GNUNET_HashCode *replies_seen,
78 unsigned int replies_seen_count)
86 * Get the query for a given pending request.
88 * @param pr the request
89 * @return pointer to the query (only valid as long as pr is valid)
91 const GNUNET_HashCode *
92 GSF_pending_request_get_query_ (const struct GSF_PendingRequest *pr)
99 * Get the type of a given pending request.
101 * @param pr the request
104 enum GNUNET_BLOCK_Type
105 GSF_pending_request_get_type_ (const struct GSF_PendingRequest *pr)
112 * Generate the message corresponding to the given pending request for
113 * transmission to other peers (or at least determine its size).
115 * @param pr request to generate the message for
116 * @param buf_size number of bytes available in buf
117 * @param buf where to copy the message (can be NULL)
118 * @return number of bytes needed (if > buf_size) or used
121 GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr,
130 * Explicitly cancel a pending request.
132 * @param pr request to cancel
135 GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr)
141 * Iterate over all pending requests.
143 * @param it function to call for each request
144 * @param cls closure for it
147 GSF_iterate_pending_requests_ (GSF_PendingRequestIterator it,
155 * Handle P2P "CONTENT" message. Checks that the message is
156 * well-formed and then checks if there are any pending requests for
157 * this content and possibly passes it on (to local clients or other
158 * peers). Does NOT perform migration (content caching at this peer).
160 * @param other the other peer involved (sender or receiver, NULL
161 * for loopback messages where we are both sender and receiver)
162 * @param message the actual message
163 * @return how valueable was the content to us (0 for not at all),
164 * GNUNET_SYSERR if the message was malformed (close connection,
165 * do not cache under any circumstances)
168 GSF_handle_p2p_content_ (const struct GNUNET_PeerIdentity *other,
169 const struct GNUNET_MessageHeader *message)
171 return GNUNET_SYSERR; // FIXME
176 * Setup the subsystem.
179 GSF_pending_request_init_ ()
186 * Shutdown the subsystem.
189 GSF_pending_request_done_ ()
195 /* end of gnunet-service-fs_pr.c */