diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-01-25 22:58:30 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-01-25 22:58:30 +0000 |
commit | 143cde208ce477883102bf23f67a1d31aaa4ed11 (patch) | |
tree | 962c46c9e701944fd3ea34337a35d67eaa704a0c /src/fs | |
parent | bf0a4b7fa0587deb75111cf1cdaaef2b3b3a39a6 (diff) | |
download | gnunet-143cde208ce477883102bf23f67a1d31aaa4ed11.tar.gz gnunet-143cde208ce477883102bf23f67a1d31aaa4ed11.zip |
hdrs
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/gnunet-service-fs.c | 2 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs.h | 55 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_cp.h | 188 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_lc.h | 119 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_pe.h | 59 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_pr.h | 197 |
6 files changed, 619 insertions, 1 deletions
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 80445e9bf..fb275f1b4 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -719,7 +719,7 @@ struct PendingRequest | |||
719 | int8_t local_only; | 719 | int8_t local_only; |
720 | 720 | ||
721 | /** | 721 | /** |
722 | * GNUNET_YES if we should not forward this request to other peers. | 722 | * GNUNET_YES if we should not forward this request to other peers. (HUH?) |
723 | */ | 723 | */ |
724 | int8_t forward_only; | 724 | int8_t forward_only; |
725 | 725 | ||
diff --git a/src/fs/gnunet-service-fs.h b/src/fs/gnunet-service-fs.h new file mode 100644 index 000000000..a66339b91 --- /dev/null +++ b/src/fs/gnunet-service-fs.h | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2009, 2010 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.h | ||
23 | * @brief shared data structures of gnunet-service-fs.c | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef GNUNET_SERVICE_FS_H | ||
27 | #define GNUNET_SERVICE_FS_H | ||
28 | |||
29 | /** | ||
30 | * A connected peer. | ||
31 | */ | ||
32 | struct GSF_ConnectedPeer; | ||
33 | |||
34 | |||
35 | /** | ||
36 | * An active request. | ||
37 | */ | ||
38 | struct GSF_PendingRequest; | ||
39 | |||
40 | |||
41 | /** | ||
42 | * A local client. | ||
43 | */ | ||
44 | struct GSF_LocalClient; | ||
45 | |||
46 | |||
47 | /** | ||
48 | * Entry in the query transmission plan. | ||
49 | */ | ||
50 | struct GSF_PlanEntry; | ||
51 | |||
52 | |||
53 | |||
54 | #endif | ||
55 | /* end of gnunet-service-fs.h */ | ||
diff --git a/src/fs/gnunet-service-fs_cp.h b/src/fs/gnunet-service-fs_cp.h new file mode 100644 index 000000000..f6d6e7a0a --- /dev/null +++ b/src/fs/gnunet-service-fs_cp.h | |||
@@ -0,0 +1,188 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 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_cp.h | ||
23 | * @brief API to handle 'connected peers' | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef GNUNET_SERVICE_FS_CP_H | ||
27 | #define GNUNET_SERVICE_FS_CP_H | ||
28 | |||
29 | #include "gnunet-service-fs.h" | ||
30 | |||
31 | |||
32 | /** | ||
33 | * A peer connected to us. Setup the connected peer | ||
34 | * records. | ||
35 | * | ||
36 | * @param peer identity of peer that connected | ||
37 | * @param atsi performance data for the connection | ||
38 | * @return handle to connected peer entry | ||
39 | */ | ||
40 | struct GSF_ConnectedPeer * | ||
41 | GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, | ||
42 | const struct GNUNET_TRANSPORT_ATS_Information *atsi); | ||
43 | |||
44 | |||
45 | /** | ||
46 | * Function called to get a message for transmission. | ||
47 | * | ||
48 | * @param cls closure | ||
49 | * @param buf_size number of bytes available in buf | ||
50 | * @param buf where to copy the message, NULL on error (peer disconnect) | ||
51 | * @return number of bytes copied to 'buf', can be 0 (without indicating an error) | ||
52 | */ | ||
53 | typedef size_t (*GSF_GetMessageCallback)(void *cls, | ||
54 | size_t buf_size, | ||
55 | void *buf); | ||
56 | |||
57 | |||
58 | /** | ||
59 | * Transmit a message to the given peer as soon as possible. | ||
60 | * If the peer disconnects before the transmission can happen, | ||
61 | * the callback is invoked with a 'NULL' buffer. | ||
62 | * | ||
63 | * @param peer target peer | ||
64 | * @param size number of bytes we would like to send to the peer | ||
65 | * @param gmc function to call to get the message | ||
66 | * @param gmc_cls closure for gmc | ||
67 | */ | ||
68 | void | ||
69 | GSF_peer_transmit_ (struct GSF_ConnectedPeer *peer, | ||
70 | size_t size, | ||
71 | GSF_GetMessageCallback gmc, | ||
72 | void *gmc_cls); | ||
73 | |||
74 | |||
75 | /** | ||
76 | * Method called whenever a given peer has a status change. | ||
77 | * | ||
78 | * @param cls closure | ||
79 | * @param peer peer identity this notification is about | ||
80 | * @param bandwidth_in available amount of inbound bandwidth | ||
81 | * @param bandwidth_out available amount of outbound bandwidth | ||
82 | * @param timeout absolute time when this peer will time out | ||
83 | * unless we see some further activity from it | ||
84 | * @param atsi status information | ||
85 | */ | ||
86 | void | ||
87 | GSF_peer_status_handler_ (void *cls, | ||
88 | const struct GNUNET_PeerIdentity *peer, | ||
89 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
90 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | ||
91 | struct GNUNET_TIME_Absolute timeout, | ||
92 | const struct GNUNET_TRANSPORT_ATS_Information *atsi); | ||
93 | |||
94 | |||
95 | /** | ||
96 | * A peer disconnected from us. Tear down the connected peer | ||
97 | * record. | ||
98 | * | ||
99 | * @param cls unused | ||
100 | * @param peer identity of peer that connected | ||
101 | */ | ||
102 | void | ||
103 | GSF_peer_disconnect_handler_ (void *cls, | ||
104 | const struct GNUNET_PeerIdentity *peer); | ||
105 | |||
106 | |||
107 | /** | ||
108 | * Signature of function called on a connected peer. | ||
109 | * | ||
110 | * @param cls closure | ||
111 | * @param peer identity of the peer | ||
112 | * @param cp handle to the connected peer record | ||
113 | */ | ||
114 | typedef void (*GSF_ConnectedPeerIterator)(void *cls, | ||
115 | const struct GNUNET_PeerIdentity *peer, | ||
116 | struct GSF_ConnectedPeer *cp); | ||
117 | |||
118 | |||
119 | /** | ||
120 | * Iterate over all connected peers. | ||
121 | * | ||
122 | * @param it function to call for each peer | ||
123 | * @param it_cls closure for it | ||
124 | */ | ||
125 | void | ||
126 | GSF_iterate_connected_peers_ (GSF_ConnectedPeerIterator it, | ||
127 | void *it_cls); | ||
128 | |||
129 | |||
130 | /** | ||
131 | * Register callback to invoke on peer disconnect. | ||
132 | * | ||
133 | * @param cp peer to monitor | ||
134 | * @param it function to call on disconnect | ||
135 | * @param it_cls closure for it | ||
136 | */ | ||
137 | void | ||
138 | GSF_connected_peer_register_disconnect_callback_ (struct GSF_ConnectedPeer *cp, | ||
139 | GSF_ConnectedPeerIterator it, | ||
140 | void *it_cls); | ||
141 | |||
142 | |||
143 | /** | ||
144 | * Unregister callback to invoke on peer disconnect. | ||
145 | * | ||
146 | * @param cp peer to stop monitoring | ||
147 | * @param it function to no longer call on disconnect | ||
148 | * @param it_cls closure for it | ||
149 | */ | ||
150 | void | ||
151 | GSF_connected_peer_unregister_disconnect_callback_ (struct GSF_ConnectedPeer *cp, | ||
152 | GSF_ConnectedPeerIterator it, | ||
153 | void *it_cls); | ||
154 | |||
155 | |||
156 | /** | ||
157 | * Signature of function called on a reservation success. | ||
158 | * | ||
159 | * @param cls closure | ||
160 | * @param cp handle to the connected peer record | ||
161 | */ | ||
162 | typedef void (*GSF_PeerReserveCallback)(void *cls, | ||
163 | struct GSF_ConnectedPeer *cp); | ||
164 | |||
165 | |||
166 | /** | ||
167 | * Try to reserve bandwidth (to receive data FROM the given peer). | ||
168 | * This function must only be called ONCE per connected peer at a | ||
169 | * time; it can be called again after the 'rc' callback was invoked. | ||
170 | * If the peer disconnects, the request is (silently!) ignored (and | ||
171 | * the requester is responsible to register for notification about the | ||
172 | * peer disconnect if any special action needs to be taken in this | ||
173 | * case). | ||
174 | * | ||
175 | * @param cp peer to reserve bandwidth from | ||
176 | * @param size number of bytes to reserve | ||
177 | * @param rc function to call upon reservation success | ||
178 | * @param rc_cls closure for rc | ||
179 | */ | ||
180 | void | ||
181 | GSF_connected_peer_reserve_ (struct GSF_ConnectedPeer *cp, | ||
182 | size_t size, | ||
183 | GSF_PeerReserveCallback rc, | ||
184 | void *rc_cls); | ||
185 | |||
186 | |||
187 | #endif | ||
188 | /* end of gnunet-service-fs_cp.h */ | ||
diff --git a/src/fs/gnunet-service-fs_lc.h b/src/fs/gnunet-service-fs_lc.h new file mode 100644 index 000000000..edc199fd8 --- /dev/null +++ b/src/fs/gnunet-service-fs_lc.h | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 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_lc.h | ||
23 | * @brief API to handle 'connected peers' | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef GNUNET_SERVICE_FS_LC_H | ||
27 | #define GNUNET_SERVICE_FS_LC_H | ||
28 | |||
29 | #include "gnunet-service-fs.h" | ||
30 | |||
31 | |||
32 | /** | ||
33 | * Look up a local client record or create one if it | ||
34 | * doesn't exist yet. | ||
35 | * | ||
36 | * @param client handle of the client | ||
37 | * @return handle to local client entry | ||
38 | */ | ||
39 | struct GSF_LocalClient * | ||
40 | GSF_local_client_lookup_ (struct GNUNET_SERVER_Client *client); | ||
41 | |||
42 | |||
43 | /** | ||
44 | * Handle START_SEARCH-message (search request from local client). | ||
45 | * | ||
46 | * @param cls closure | ||
47 | * @param client identification of the client | ||
48 | * @param message the actual message | ||
49 | */ | ||
50 | void | ||
51 | GSF_local_client_start_search_handler_ (void *cls, | ||
52 | struct GNUNET_SERVER_Client *client, | ||
53 | const struct GNUNET_MessageHeader *message); | ||
54 | |||
55 | |||
56 | /** | ||
57 | * Transmit a message to the given local client as soon as possible. | ||
58 | * If the client disconnects before transmission, the message is | ||
59 | * simply discarded. | ||
60 | * | ||
61 | * @param lc recipient | ||
62 | * @param msg message to transmit to client | ||
63 | */ | ||
64 | void | ||
65 | GSF_local_client_transmit_ (struct GSF_LocalClient *lc, | ||
66 | const struct GNUNET_MessageHeader *msg); | ||
67 | |||
68 | |||
69 | /** | ||
70 | * A local client disconnected from us. Tear down the local client | ||
71 | * record. | ||
72 | * | ||
73 | * @param cls unused | ||
74 | * @param client handle of the client | ||
75 | */ | ||
76 | void | ||
77 | GSF_local_client_disconnect_handler_ (void *cls, | ||
78 | const struct GNUNET_SERVER_Client *client); | ||
79 | |||
80 | |||
81 | |||
82 | /** | ||
83 | * Signature of function called on a local client | ||
84 | * | ||
85 | * @param cls closure | ||
86 | * @param lc local client handle | ||
87 | */ | ||
88 | typedef int (*GSF_LocalClientIterator)(void *cls, | ||
89 | struct GSF_LocalClient *lc); | ||
90 | |||
91 | |||
92 | |||
93 | /** | ||
94 | * Register callback to invoke on local client disconnect. | ||
95 | * | ||
96 | * @param lc client to monitor | ||
97 | * @param it function to call on disconnect | ||
98 | * @param it_cls closure for it | ||
99 | */ | ||
100 | void | ||
101 | GSF_local_client_register_disconnect_callback_ (struct GSF_LocalClient *lc, | ||
102 | GSF_LocalClientIterator it, | ||
103 | void *it_cls); | ||
104 | |||
105 | |||
106 | /** | ||
107 | * Register callback to invoke on local client disconnect. | ||
108 | * | ||
109 | * @param lc client to stop monitoring | ||
110 | * @param it function to no longer call on disconnect | ||
111 | * @param it_cls closure for it | ||
112 | */ | ||
113 | void | ||
114 | GSF_connected_peer_unregister_disconnect_callback_ (struct GSF_ConnectedPeer *cp, | ||
115 | GSF_PendingRequestIterator it, | ||
116 | void *it_cls); | ||
117 | |||
118 | #endif | ||
119 | /* end of gnunet-service-fs_lc.h */ | ||
diff --git a/src/fs/gnunet-service-fs_pe.h b/src/fs/gnunet-service-fs_pe.h new file mode 100644 index 000000000..9f62ece76 --- /dev/null +++ b/src/fs/gnunet-service-fs_pe.h | |||
@@ -0,0 +1,59 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 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_pe.h | ||
23 | * @brief API to manage query plan | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef GNUNET_SERVICE_FS_PE_H | ||
27 | #define GNUNET_SERVICE_FS_PE_H | ||
28 | |||
29 | #include "gnunet-service-fs.h" | ||
30 | |||
31 | |||
32 | /** | ||
33 | * Create a new query plan entry. | ||
34 | * | ||
35 | * @param cp peer with the entry | ||
36 | * @param pr request with the entry | ||
37 | * @param position position of the entry in the cp queue | ||
38 | * @return handle for the new plan entry | ||
39 | */ | ||
40 | struct GSF_PlanEntry * | ||
41 | GSF_plan_entry_create_ (struct GSF_ConnectedPeer *cp, | ||
42 | struct GSF_PendingRequest *pr, | ||
43 | unsigned int position); | ||
44 | |||
45 | |||
46 | /** | ||
47 | * Get the first plan entry for the given connected peer. | ||
48 | * FIXME... | ||
49 | * | ||
50 | * @param cp connected peer | ||
51 | * @return NULL if there is no request planned for this peer | ||
52 | */ | ||
53 | struct GSF_PendingRequest * | ||
54 | GSF_plan_get_ (struct GSF_ConnectedPeer *cp); | ||
55 | |||
56 | |||
57 | |||
58 | #endif | ||
59 | /* end of gnunet-service-fs_pe.h */ | ||
diff --git a/src/fs/gnunet-service-fs_pr.h b/src/fs/gnunet-service-fs_pr.h new file mode 100644 index 000000000..b4dd82839 --- /dev/null +++ b/src/fs/gnunet-service-fs_pr.h | |||
@@ -0,0 +1,197 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2009, 2010 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.h | ||
23 | * @brief API to handle pending requests | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef GNUNET_SERVICE_FS_PR_H | ||
27 | #define GNUNET_SERVICE_FS_PR_H | ||
28 | |||
29 | #include "gnunet-service-fs.h" | ||
30 | |||
31 | |||
32 | /** | ||
33 | * Options for pending requests (bits to be ORed). | ||
34 | */ | ||
35 | enum GSF_PendingRequestOptions | ||
36 | { | ||
37 | /** | ||
38 | * Request must only be processed locally. | ||
39 | */ | ||
40 | GSF_PRO_LOCAL_ONLY = 1, | ||
41 | |||
42 | /** | ||
43 | * Request must only be forwarded (no routing) | ||
44 | */ | ||
45 | GSF_PRO_FORWARD_ONLY = 2, | ||
46 | |||
47 | /** | ||
48 | * Request persists indefinitely (no expiration). | ||
49 | */ | ||
50 | GSF_PRO_REQUEST_EXPIRES = 4, | ||
51 | |||
52 | /** | ||
53 | * Request is allowed to refresh bloomfilter and change mingle value. | ||
54 | */ | ||
55 | GSF_PRO_BLOOMFILTER_FULL_REFRESH = 8, | ||
56 | |||
57 | /** | ||
58 | * Request priority is allowed to be exceeded. | ||
59 | */ | ||
60 | GSF_PRO_PRIORITY_UNLIMITED = 16, | ||
61 | |||
62 | /** | ||
63 | * Option mask for typical local requests. | ||
64 | */ | ||
65 | GSF_PRO_LOCAL_REQUEST = (GSF_PRO_BLOOMFILTER_FULL_REFRESH | GSF_PRO_PRIORITY_UNLIMITED) | ||
66 | }; | ||
67 | |||
68 | |||
69 | /** | ||
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 | ||
75 | * expiration. | ||
76 | * | ||
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 | ||
81 | */ | ||
82 | typedef void (*GSF_PendingRequestReplyHandler)(void *cls, | ||
83 | struct GSF_PendingRequest *pr, | ||
84 | const void *data, | ||
85 | size_t data_len); | ||
86 | |||
87 | |||
88 | /** | ||
89 | * Create a new pending request. | ||
90 | * | ||
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 | ||
105 | */ | ||
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, | ||
113 | int32_t mingle, | ||
114 | uint32_t anonymity_level, | ||
115 | uint32_t priority, | ||
116 | const GNUNET_HashCode *replies_seen, | ||
117 | unsigned int replies_seen_count, | ||
118 | GSF_PendingRequestReplyHandler rh, | ||
119 | void *rh_cls); | ||
120 | |||
121 | |||
122 | /** | ||
123 | * Generate the message corresponding to the given pending request for | ||
124 | * transmission to other peers (or at least determine its size). | ||
125 | * | ||
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 | ||
130 | */ | ||
131 | size_t | ||
132 | GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr, | ||
133 | size_t buf_size, | ||
134 | void *buf); | ||
135 | |||
136 | |||
137 | /** | ||
138 | * Explicitly cancel a pending request. | ||
139 | * | ||
140 | * @param pr request to cancel | ||
141 | */ | ||
142 | void | ||
143 | GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr); | ||
144 | |||
145 | |||
146 | /** | ||
147 | * Signature of function called on each request. | ||
148 | * | ||
149 | * @param cls closure | ||
150 | * @param key query for the request | ||
151 | * @param pr handle to the pending request | ||
152 | */ | ||
153 | typedef int (*GSF_PendingRequestIterator)(void *cls, | ||
154 | const GNUNET_HashCode *key, | ||
155 | struct GSF_PendingRequest *pr); | ||
156 | |||
157 | |||
158 | /** | ||
159 | * Iterate over all pending requests. | ||
160 | * | ||
161 | * @param it function to call for each request | ||
162 | * @param cls closure for it | ||
163 | */ | ||
164 | void | ||
165 | GSF_iterate_pending_requests_ (GSF_PendingRequestIterator it, | ||
166 | void *cls); | ||
167 | |||
168 | |||
169 | |||
170 | /** | ||
171 | * Register callback to invoke on request destruction. | ||
172 | * | ||
173 | * @param pr request to monitor | ||
174 | * @param it function to call on destruction | ||
175 | * @param it_cls closure for it | ||
176 | */ | ||
177 | void | ||
178 | GSF_pending_request_register_destroy_callback_ (struct GSF_PendingRequest *pr, | ||
179 | GSF_PendingRequestIterator it, | ||
180 | void *it_cls); | ||
181 | |||
182 | |||
183 | /** | ||
184 | * Unregister callback to invoke on request destruction. | ||
185 | * | ||
186 | * @param pr request to stop monitoring | ||
187 | * @param it function to no longer call on destruction | ||
188 | * @param it_cls closure for it | ||
189 | */ | ||
190 | void | ||
191 | GSF_pending_request_unregister_destroy_callback_ (struct GSF_PendingRequest *pr, | ||
192 | GSF_PendingRequestIterator it, | ||
193 | void *it_cls); | ||
194 | |||
195 | |||
196 | #endif | ||
197 | /* end of gnunet-service-fs_pr.h */ | ||