diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-02-08 00:10:36 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-02-08 00:10:36 +0000 |
commit | 1a11ec73bfe097463b60b41ceed503e3d2924a44 (patch) | |
tree | 7bf27c684adefa0af13fae69ad1c547bc568085b | |
parent | 86d7f49fc64f0c766d4bec6b3f34879f108fc8a9 (diff) | |
download | gnunet-1a11ec73bfe097463b60b41ceed503e3d2924a44.tar.gz gnunet-1a11ec73bfe097463b60b41ceed503e3d2924a44.zip |
stuff
-rw-r--r-- | src/fs/gnunet-service-fs_cp.c | 22 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_cp.h | 16 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_lc.c | 49 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_lc.h | 10 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_pr.c | 195 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_pr.h | 31 |
6 files changed, 293 insertions, 30 deletions
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index 0bacb3ec3..2361cd4fc 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c | |||
@@ -427,6 +427,28 @@ GSF_handle_p2p_migration_stop_ (void *cls, | |||
427 | 427 | ||
428 | 428 | ||
429 | /** | 429 | /** |
430 | * Handle P2P "QUERY" message. | ||
431 | * | ||
432 | * @param other the other peer involved (sender or receiver, NULL | ||
433 | * for loopback messages where we are both sender and receiver) | ||
434 | * @param message the actual message | ||
435 | * @return pending request handle, NULL on error | ||
436 | */ | ||
437 | struct GSF_PendingRequest * | ||
438 | GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, | ||
439 | const struct GNUNET_MessageHeader *message) | ||
440 | { | ||
441 | // FIXME! | ||
442 | // parse request | ||
443 | // setup pending request | ||
444 | // track pending request to cancel it on peer disconnect (!) | ||
445 | // return it! | ||
446 | // (actual planning & execution up to caller!) | ||
447 | return NULL; | ||
448 | } | ||
449 | |||
450 | |||
451 | /** | ||
430 | * Function called if there has been a timeout trying to satisfy | 452 | * Function called if there has been a timeout trying to satisfy |
431 | * a transmission request. | 453 | * a transmission request. |
432 | * | 454 | * |
diff --git a/src/fs/gnunet-service-fs_cp.h b/src/fs/gnunet-service-fs_cp.h index 4ad27afd8..9bf36186c 100644 --- a/src/fs/gnunet-service-fs_cp.h +++ b/src/fs/gnunet-service-fs_cp.h | |||
@@ -249,6 +249,22 @@ GSF_handle_p2p_migration_stop_ (void *cls, | |||
249 | 249 | ||
250 | 250 | ||
251 | /** | 251 | /** |
252 | * Handle P2P "QUERY" message. Only responsible for creating the | ||
253 | * request entry itself and setting up reply callback and cancellation | ||
254 | * on peer disconnect. Does NOT execute the actual request strategy | ||
255 | * (planning). | ||
256 | * | ||
257 | * @param other the other peer involved (sender or receiver, NULL | ||
258 | * for loopback messages where we are both sender and receiver) | ||
259 | * @param message the actual message | ||
260 | * @return pending request handle, NULL on error | ||
261 | */ | ||
262 | struct GSF_PendingRequest * | ||
263 | GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, | ||
264 | const struct GNUNET_MessageHeader *message); | ||
265 | |||
266 | |||
267 | /** | ||
252 | * A peer disconnected from us. Tear down the connected peer | 268 | * A peer disconnected from us. Tear down the connected peer |
253 | * record. | 269 | * record. |
254 | * | 270 | * |
diff --git a/src/fs/gnunet-service-fs_lc.c b/src/fs/gnunet-service-fs_lc.c index 2113a4498..9c9c0d568 100644 --- a/src/fs/gnunet-service-fs_lc.c +++ b/src/fs/gnunet-service-fs_lc.c | |||
@@ -181,13 +181,12 @@ GSF_local_client_lookup_ (struct GNUNET_SERVER_Client *client) | |||
181 | /** | 181 | /** |
182 | * Handle START_SEARCH-message (search request from local client). | 182 | * Handle START_SEARCH-message (search request from local client). |
183 | * | 183 | * |
184 | * @param cls closure | ||
185 | * @param client identification of the client | 184 | * @param client identification of the client |
186 | * @param message the actual message | 185 | * @param message the actual message |
186 | * @return pending request handle for the request, NULL on error | ||
187 | */ | 187 | */ |
188 | void | 188 | struct GSF_PendingRequest * |
189 | GSF_local_client_start_search_handler_ (void *cls, | 189 | GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client, |
190 | struct GNUNET_SERVER_Client *client, | ||
191 | const struct GNUNET_MessageHeader *message) | 190 | const struct GNUNET_MessageHeader *message) |
192 | { | 191 | { |
193 | static GNUNET_HashCode all_zeros; | 192 | static GNUNET_HashCode all_zeros; |
@@ -207,7 +206,7 @@ GSF_local_client_start_search_handler_ (void *cls, | |||
207 | GNUNET_break (0); | 206 | GNUNET_break (0); |
208 | GNUNET_SERVER_receive_done (client, | 207 | GNUNET_SERVER_receive_done (client, |
209 | GNUNET_SYSERR); | 208 | GNUNET_SYSERR); |
210 | return; | 209 | return NULL; |
211 | } | 210 | } |
212 | GNUNET_STATISTICS_update (stats, | 211 | GNUNET_STATISTICS_update (stats, |
213 | gettext_noop ("# client searches received"), | 212 | gettext_noop ("# client searches received"), |
@@ -224,7 +223,6 @@ GSF_local_client_start_search_handler_ (void *cls, | |||
224 | #endif | 223 | #endif |
225 | lc = GSF_local_client_lookup_ (client); | 224 | lc = GSF_local_client_lookup_ (client); |
226 | 225 | ||
227 | |||
228 | /* detect duplicate KBLOCK requests */ | 226 | /* detect duplicate KBLOCK requests */ |
229 | if ( (type == GNUNET_BLOCK_TYPE_FS_KBLOCK) || | 227 | if ( (type == GNUNET_BLOCK_TYPE_FS_KBLOCK) || |
230 | (type == GNUNET_BLOCK_TYPE_FS_NBLOCK) || | 228 | (type == GNUNET_BLOCK_TYPE_FS_NBLOCK) || |
@@ -252,7 +250,7 @@ GSF_local_client_start_search_handler_ (void *cls, | |||
252 | GNUNET_NO); | 250 | GNUNET_NO); |
253 | GNUNET_SERVER_receive_done (client, | 251 | GNUNET_SERVER_receive_done (client, |
254 | GNUNET_OK); | 252 | GNUNET_OK); |
255 | return; | 253 | return NULL; |
256 | } | 254 | } |
257 | } | 255 | } |
258 | 256 | ||
@@ -268,25 +266,24 @@ GSF_local_client_start_search_handler_ (void *cls, | |||
268 | options = GSF_PRO_LOCAL_REQUEST; | 266 | options = GSF_PRO_LOCAL_REQUEST; |
269 | if (0 != (1 & ntohl (sm->options))) | 267 | if (0 != (1 & ntohl (sm->options))) |
270 | options |= GSF_PRO_LOCAL_ONLY; | 268 | options |= GSF_PRO_LOCAL_ONLY; |
271 | cr->pr = GSF_pending_request_create (options, | 269 | cr->pr = GSF_pending_request_create_ (options, |
272 | 270 | type, | |
273 | type, | 271 | &sm->query, |
274 | &sm->query, | 272 | (type == GNUNET_BLOCK_TYPE_SBLOCK) |
275 | (type == GNUNET_BLOCK_TYPE_SBLOCK) | 273 | ? &sm->target /* namespace */ |
276 | ? &sm->target /* namespace */ | 274 | : NULL, |
277 | : NULL, | 275 | (0 != memcmp (&sm->target, |
278 | (0 != memcmp (&sm->target, | 276 | &all_zeros, |
279 | &all_zeros, | 277 | sizeof (GNUNET_HashCode))) |
280 | sizeof (GNUNET_HashCode))) | 278 | ? &sm->target, |
281 | ? &sm->target, | 279 | : NULL, |
282 | : NULL, | 280 | NULL /* bf */, 0 /* mingle */, |
283 | NULL /* bf */, 0 /* mingle */, | 281 | ntohl (sm->anonymity_level), |
284 | ntohl (sm->anonymity_level), | 282 | 0 /* priority */, |
285 | 0 /* priority */, | 283 | &sm[1], sc, |
286 | &sm[1], sc, | 284 | &client_response_handler, |
287 | &client_response_handler, | 285 | cr); |
288 | cr); | 286 | return cr->pr; |
289 | // FIXME: start local processing and/or P2P processing? | ||
290 | } | 287 | } |
291 | 288 | ||
292 | 289 | ||
diff --git a/src/fs/gnunet-service-fs_lc.h b/src/fs/gnunet-service-fs_lc.h index e9b77aa59..35d8a839a 100644 --- a/src/fs/gnunet-service-fs_lc.h +++ b/src/fs/gnunet-service-fs_lc.h | |||
@@ -42,14 +42,16 @@ GSF_local_client_lookup_ (struct GNUNET_SERVER_Client *client); | |||
42 | 42 | ||
43 | /** | 43 | /** |
44 | * Handle START_SEARCH-message (search request from local client). | 44 | * Handle START_SEARCH-message (search request from local client). |
45 | * Only responsible for creating the request entry itself and setting | ||
46 | * up reply callback and cancellation on client disconnect. Does NOT | ||
47 | * execute the actual request strategy (planning). | ||
45 | * | 48 | * |
46 | * @param cls closure | ||
47 | * @param client identification of the client | 49 | * @param client identification of the client |
48 | * @param message the actual message | 50 | * @param message the actual message |
51 | * @return pending request handle for the request, NULL on error | ||
49 | */ | 52 | */ |
50 | void | 53 | struct GSF_PendingRequest * |
51 | GSF_local_client_start_search_handler_ (void *cls, | 54 | GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client, |
52 | struct GNUNET_SERVER_Client *client, | ||
53 | const struct GNUNET_MessageHeader *message); | 55 | const struct GNUNET_MessageHeader *message); |
54 | 56 | ||
55 | 57 | ||
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c new file mode 100644 index 000000000..343ec3ada --- /dev/null +++ b/src/fs/gnunet-service-fs_pr.c | |||
@@ -0,0 +1,195 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors) | ||
4 | |||
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. | ||
9 | |||
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. | ||
14 | |||
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. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file fs/gnunet-service-fs_pr.c | ||
23 | * @brief API to handle pending requests | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet-service-fs_pr.h" | ||
28 | |||
29 | |||
30 | /** | ||
31 | * Create a new pending request. | ||
32 | * | ||
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 | ||
47 | */ | ||
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, | ||
55 | int32_t mingle, | ||
56 | uint32_t anonymity_level, | ||
57 | uint32_t priority, | ||
58 | const GNUNET_HashCode *replies_seen, | ||
59 | unsigned int replies_seen_count, | ||
60 | GSF_PendingRequestReplyHandler rh, | ||
61 | void *rh_cls) | ||
62 | { | ||
63 | return NULL; // FIXME | ||
64 | } | ||
65 | |||
66 | |||
67 | /** | ||
68 | * Update a given pending request with additional replies | ||
69 | * that have been seen. | ||
70 | * | ||
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 | ||
74 | */ | ||
75 | void | ||
76 | GSF_pending_request_update_ (struct GSF_PendingRequest *pr, | ||
77 | const GNUNET_HashCode *replies_seen, | ||
78 | unsigned int replies_seen_count) | ||
79 | { | ||
80 | // FIXME | ||
81 | } | ||
82 | |||
83 | |||
84 | |||
85 | /** | ||
86 | * Get the query for a given pending request. | ||
87 | * | ||
88 | * @param pr the request | ||
89 | * @return pointer to the query (only valid as long as pr is valid) | ||
90 | */ | ||
91 | const GNUNET_HashCode * | ||
92 | GSF_pending_request_get_query_ (const struct GSF_PendingRequest *pr) | ||
93 | { | ||
94 | return NULL; // FIXME | ||
95 | } | ||
96 | |||
97 | |||
98 | /** | ||
99 | * Get the type of a given pending request. | ||
100 | * | ||
101 | * @param pr the request | ||
102 | * @return query type | ||
103 | */ | ||
104 | enum GNUNET_BLOCK_Type | ||
105 | GSF_pending_request_get_type_ (const struct GSF_PendingRequest *pr) | ||
106 | { | ||
107 | return 0; // FIXME | ||
108 | } | ||
109 | |||
110 | |||
111 | /** | ||
112 | * Generate the message corresponding to the given pending request for | ||
113 | * transmission to other peers (or at least determine its size). | ||
114 | * | ||
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 | ||
119 | */ | ||
120 | size_t | ||
121 | GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr, | ||
122 | size_t buf_size, | ||
123 | void *buf) | ||
124 | { | ||
125 | return 0; // FIXME | ||
126 | } | ||
127 | |||
128 | |||
129 | /** | ||
130 | * Explicitly cancel a pending request. | ||
131 | * | ||
132 | * @param pr request to cancel | ||
133 | */ | ||
134 | void | ||
135 | GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr) | ||
136 | { | ||
137 | } | ||
138 | |||
139 | |||
140 | /** | ||
141 | * Iterate over all pending requests. | ||
142 | * | ||
143 | * @param it function to call for each request | ||
144 | * @param cls closure for it | ||
145 | */ | ||
146 | void | ||
147 | GSF_iterate_pending_requests_ (GSF_PendingRequestIterator it, | ||
148 | void *cls) | ||
149 | { | ||
150 | // FIXME | ||
151 | } | ||
152 | |||
153 | |||
154 | /** | ||
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). | ||
159 | * | ||
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) | ||
166 | */ | ||
167 | int | ||
168 | GSF_handle_p2p_content_ (const struct GNUNET_PeerIdentity *other, | ||
169 | const struct GNUNET_MessageHeader *message) | ||
170 | { | ||
171 | return GNUNET_SYSERR; // FIXME | ||
172 | } | ||
173 | |||
174 | |||
175 | /** | ||
176 | * Setup the subsystem. | ||
177 | */ | ||
178 | void | ||
179 | GSF_pending_request_init_ () | ||
180 | { | ||
181 | // FIXME | ||
182 | } | ||
183 | |||
184 | |||
185 | /** | ||
186 | * Shutdown the subsystem. | ||
187 | */ | ||
188 | void | ||
189 | GSF_pending_request_done_ () | ||
190 | { | ||
191 | // FIXME | ||
192 | } | ||
193 | |||
194 | |||
195 | /* end of gnunet-service-fs_pr.c */ | ||
diff --git a/src/fs/gnunet-service-fs_pr.h b/src/fs/gnunet-service-fs_pr.h index 24107534f..ee5124a90 100644 --- a/src/fs/gnunet-service-fs_pr.h +++ b/src/fs/gnunet-service-fs_pr.h | |||
@@ -200,6 +200,37 @@ GSF_iterate_pending_requests_ (GSF_PendingRequestIterator it, | |||
200 | void *cls); | 200 | void *cls); |
201 | 201 | ||
202 | 202 | ||
203 | /** | ||
204 | * Handle P2P "CONTENT" message. Checks that the message is | ||
205 | * well-formed and then checks if there are any pending requests for | ||
206 | * this content and possibly passes it on (to local clients or other | ||
207 | * peers). Does NOT perform migration (content caching at this peer). | ||
208 | * | ||
209 | * @param other the other peer involved (sender or receiver, NULL | ||
210 | * for loopback messages where we are both sender and receiver) | ||
211 | * @param message the actual message | ||
212 | * @return how valueable was the content to us (0 for not at all), | ||
213 | * GNUNET_SYSERR if the message was malformed (close connection, | ||
214 | * do not cache under any circumstances) | ||
215 | */ | ||
216 | int | ||
217 | GSF_handle_p2p_content_ (const struct GNUNET_PeerIdentity *other, | ||
218 | const struct GNUNET_MessageHeader *message); | ||
219 | |||
220 | |||
221 | /** | ||
222 | * Setup the subsystem. | ||
223 | */ | ||
224 | void | ||
225 | GSF_pending_request_init_ (void); | ||
226 | |||
227 | |||
228 | /** | ||
229 | * Shutdown the subsystem. | ||
230 | */ | ||
231 | void | ||
232 | GSF_pending_request_done_ (void); | ||
233 | |||
203 | 234 | ||
204 | #endif | 235 | #endif |
205 | /* end of gnunet-service-fs_pr.h */ | 236 | /* end of gnunet-service-fs_pr.h */ |