diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-01-20 13:51:20 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-01-20 13:51:20 +0000 |
commit | 7d9f187d106394b2451660294df9428eb50e82d7 (patch) | |
tree | 373a78f3c10529689791b65a5ab885d3f4c761b7 /src/include | |
parent | 924137ff73bab48b720d41cf73a1197df2d4b04d (diff) | |
download | gnunet-7d9f187d106394b2451660294df9428eb50e82d7.tar.gz gnunet-7d9f187d106394b2451660294df9428eb50e82d7.zip |
fixing core API issues
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_core_service.h | 76 | ||||
-rw-r--r-- | src/include/gnunet_protocols.h | 33 | ||||
-rw-r--r-- | src/include/gnunet_transport_service.h | 11 |
3 files changed, 94 insertions, 26 deletions
diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h index 94656b916..cffdf0a14 100644 --- a/src/include/gnunet_core_service.h +++ b/src/include/gnunet_core_service.h | |||
@@ -138,6 +138,7 @@ typedef void | |||
138 | * @param cls closure for the various callbacks that follow (including handlers in the handlers array) | 138 | * @param cls closure for the various callbacks that follow (including handlers in the handlers array) |
139 | * @param init callback to call on timeout or once we have successfully | 139 | * @param init callback to call on timeout or once we have successfully |
140 | * connected to the core service; note that timeout is only meaningful if init is not NULL | 140 | * connected to the core service; note that timeout is only meaningful if init is not NULL |
141 | * @param pre_connects function to call on peer pre-connect (no session key yet), can be NULL | ||
141 | * @param connects function to call on peer connect, can be NULL | 142 | * @param connects function to call on peer connect, can be NULL |
142 | * @param disconnects function to call on peer disconnect / timeout, can be NULL | 143 | * @param disconnects function to call on peer disconnect / timeout, can be NULL |
143 | * @param inbound_notify function to call for all inbound messages, can be NULL | 144 | * @param inbound_notify function to call for all inbound messages, can be NULL |
@@ -158,6 +159,7 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
158 | struct GNUNET_TIME_Relative timeout, | 159 | struct GNUNET_TIME_Relative timeout, |
159 | void *cls, | 160 | void *cls, |
160 | GNUNET_CORE_StartupCallback init, | 161 | GNUNET_CORE_StartupCallback init, |
162 | GNUNET_CORE_ClientEventHandler pre_connects, | ||
161 | GNUNET_CORE_ClientEventHandler connects, | 163 | GNUNET_CORE_ClientEventHandler connects, |
162 | GNUNET_CORE_ClientEventHandler disconnects, | 164 | GNUNET_CORE_ClientEventHandler disconnects, |
163 | GNUNET_CORE_MessageCallback inbound_notify, | 165 | GNUNET_CORE_MessageCallback inbound_notify, |
@@ -175,27 +177,77 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
175 | void GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle); | 177 | void GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle); |
176 | 178 | ||
177 | 179 | ||
178 | // FIXME | 180 | /** |
181 | * Handle for a request to the core to connect or disconnect | ||
182 | * from a particular peer. Can be used to cancel the request | ||
183 | * (before the 'cont'inuation is called). | ||
184 | */ | ||
179 | struct GNUNET_CORE_PeerRequestHandle; | 185 | struct GNUNET_CORE_PeerRequestHandle; |
180 | 186 | ||
181 | // FIXME | 187 | |
188 | /** | ||
189 | * Request that the core should try to connect to a particular peer. | ||
190 | * Once the request has been transmitted to the core, the continuation | ||
191 | * function will be called. Note that this does NOT mean that a | ||
192 | * connection was successfully established -- it only means that the | ||
193 | * core will now try. Successful establishment of the connection | ||
194 | * will be signalled to the 'connects' callback argument of | ||
195 | * 'GNUNET_CORE_connect' only. If the core service does not respond | ||
196 | * to our connection attempt within the given time frame, 'cont' will | ||
197 | * be called with the TIMEOUT reason code. | ||
198 | * | ||
199 | * @param sched scheduler to use | ||
200 | * @param cfg configuration to use | ||
201 | * @param timeout how long to try to talk to core | ||
202 | * @param cont function to call once the request has been completed (or timed out) | ||
203 | * @param cont_cls closure for cont | ||
204 | * @return NULL on error (cont will not be called), otherwise handle for cancellation | ||
205 | */ | ||
182 | struct GNUNET_CORE_PeerRequestHandle * | 206 | struct GNUNET_CORE_PeerRequestHandle * |
183 | GNUNET_CORE_peer_request_connect (struct GNUNET_SCHEDULER_Handle *sched, | 207 | GNUNET_CORE_peer_request_connect (struct GNUNET_SCHEDULER_Handle *sched, |
184 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 208 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
185 | const struct GNUNET_PeerIdentity * peer, | 209 | struct GNUNET_TIME_Relative timeout, |
186 | GNUNET_SCHEDULER_Task cont, | 210 | const struct GNUNET_PeerIdentity * peer, |
187 | void *cont_cls); | 211 | GNUNET_SCHEDULER_Task cont, |
212 | void *cont_cls); | ||
188 | 213 | ||
189 | 214 | ||
190 | // FIXME | 215 | /** |
216 | * Request that the core should try to disconnect from a particular | ||
217 | * peer. Once the request has been transmitted to the core, the | ||
218 | * continuation function will be called. Note that this does NOT mean | ||
219 | * that a connection was successfully cut -- it only means that the | ||
220 | * core will now try. Typically this will work pretty much | ||
221 | * immediately, but it is at least in theory also possible that a | ||
222 | * reconnect is also triggered rather quickly. Successful creation | ||
223 | * and destruction of connections will be signalled to the 'connects' | ||
224 | * and 'disconnects' callback arguments of 'GNUNET_CORE_connect' only. | ||
225 | * If the core service does not respond to our connection attempt | ||
226 | * within the given time frame, 'cont' will be called with the TIMEOUT | ||
227 | * reason code. | ||
228 | * | ||
229 | * @param sched scheduler to use | ||
230 | * @param cfg configuration to use | ||
231 | * @param timeout how long to try to talk to core | ||
232 | * @param cont function to call once the request has been completed (or timed out) | ||
233 | * @param cont_cls closure for cont | ||
234 | * @return NULL on error (cont will not be called), otherwise handle for cancellation | ||
235 | */ | ||
191 | struct GNUNET_CORE_PeerRequestHandle * | 236 | struct GNUNET_CORE_PeerRequestHandle * |
192 | GNUNET_CORE_peer_request_disconnect (struct GNUNET_SCHEDULER_Handle *sched, | 237 | GNUNET_CORE_peer_request_disconnect (struct GNUNET_SCHEDULER_Handle *sched, |
193 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 238 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
194 | const struct GNUNET_PeerIdentity * peer, | 239 | struct GNUNET_TIME_Relative timeout, |
195 | GNUNET_SCHEDULER_Task cont, | 240 | const struct GNUNET_PeerIdentity * peer, |
196 | void *cont_cls); | 241 | GNUNET_SCHEDULER_Task cont, |
242 | void *cont_cls); | ||
197 | 243 | ||
198 | // FIXME | 244 | |
245 | /** | ||
246 | * Cancel a pending request to connect or disconnect from/to a particular | ||
247 | * peer. Must not be called after the 'cont' function was invoked. | ||
248 | * | ||
249 | * @param req request handle that was returned for the original request | ||
250 | */ | ||
199 | void | 251 | void |
200 | GNUNET_CORE_peer_request_cancel (struct GNUNET_CORE_PeerRequestHandle *req); | 252 | GNUNET_CORE_peer_request_cancel (struct GNUNET_CORE_PeerRequestHandle *req); |
201 | 253 | ||
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index cdf5d0df3..28535587d 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -263,40 +263,57 @@ extern "C" | |||
263 | #define GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY 65 | 263 | #define GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY 65 |
264 | 264 | ||
265 | /** | 265 | /** |
266 | * Notify clients about new peer-to-peer connections. | 266 | * Notify clients about new peer-to-peer connections (before |
267 | * key exchange and authentication). | ||
267 | */ | 268 | */ |
268 | #define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT 66 | 269 | #define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_PRE_CONNECT 66 |
270 | |||
271 | /** | ||
272 | * Notify clients about new peer-to-peer connections (triggered | ||
273 | * after key exchange). | ||
274 | */ | ||
275 | #define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT 67 | ||
269 | 276 | ||
270 | /** | 277 | /** |
271 | * Notify clients about peer disconnecting. | 278 | * Notify clients about peer disconnecting. |
272 | */ | 279 | */ |
273 | #define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT 67 | 280 | #define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT 68 |
274 | 281 | ||
275 | /** | 282 | /** |
276 | * Notify clients about incoming P2P messages. | 283 | * Notify clients about incoming P2P messages. |
277 | */ | 284 | */ |
278 | #define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND 68 | 285 | #define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND 69 |
279 | 286 | ||
280 | /** | 287 | /** |
281 | * Notify clients about outgoing P2P transmissions. | 288 | * Notify clients about outgoing P2P transmissions. |
282 | */ | 289 | */ |
283 | #define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND 69 | 290 | #define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND 70 |
284 | 291 | ||
285 | /** | 292 | /** |
286 | * Request from client to "configure" P2P connection. | 293 | * Request from client to "configure" P2P connection. |
287 | */ | 294 | */ |
288 | #define GNUNET_MESSAGE_TYPE_CORE_REQUEST_INFO 70 | 295 | #define GNUNET_MESSAGE_TYPE_CORE_REQUEST_INFO 71 |
289 | 296 | ||
290 | /** | 297 | /** |
291 | * Response from server about (possibly updated) P2P | 298 | * Response from server about (possibly updated) P2P |
292 | * connection configuration. | 299 | * connection configuration. |
293 | */ | 300 | */ |
294 | #define GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO 71 | 301 | #define GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO 72 |
295 | 302 | ||
296 | /** | 303 | /** |
297 | * Request from client with message to transmit. | 304 | * Request from client with message to transmit. |
298 | */ | 305 | */ |
299 | #define GNUNET_MESSAGE_TYPE_CORE_SEND 72 | 306 | #define GNUNET_MESSAGE_TYPE_CORE_SEND 73 |
307 | |||
308 | /** | ||
309 | * Request from client asking to connect to a peer. | ||
310 | */ | ||
311 | #define GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONNECT 74 | ||
312 | |||
313 | /** | ||
314 | * Request from client asking to disconnect from a peer. | ||
315 | */ | ||
316 | #define GNUNET_MESSAGE_TYPE_CORE_REQUEST_DISCONNECT 75 | ||
300 | 317 | ||
301 | 318 | ||
302 | /** | 319 | /** |
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h index 726e03a95..344de582f 100644 --- a/src/include/gnunet_transport_service.h +++ b/src/include/gnunet_transport_service.h | |||
@@ -138,10 +138,8 @@ void GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle); | |||
138 | * | 138 | * |
139 | * @param handle connection to transport service | 139 | * @param handle connection to transport service |
140 | * @param target who's bandwidth quota is being changed | 140 | * @param target who's bandwidth quota is being changed |
141 | * @param quota_in incoming bandwidth quota in bytes per ms; 0 can | 141 | * @param quota_in incoming bandwidth quota in bytes per ms |
142 | * be used to force all traffic to be discarded | 142 | * @param quota_out outgoing bandwidth quota in bytes per ms |
143 | * @param quota_out outgoing bandwidth quota in bytes per ms; 0 can | ||
144 | * be used to force all traffic to be discarded | ||
145 | * @param timeout how long to wait until signaling failure if | 143 | * @param timeout how long to wait until signaling failure if |
146 | * we can not communicate the quota change | 144 | * we can not communicate the quota change |
147 | * @param cont continuation to call when done, will be called | 145 | * @param cont continuation to call when done, will be called |
@@ -195,8 +193,9 @@ struct GNUNET_TRANSPORT_TransmitHandle | |||
195 | 193 | ||
196 | 194 | ||
197 | /** | 195 | /** |
198 | * Cancel the specified transmission-ready | 196 | * Cancel the specified transmission-ready notification. |
199 | * notification. | 197 | * |
198 | * @param h handle of the transmission notification request to cancel | ||
200 | */ | 199 | */ |
201 | void | 200 | void |
202 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct | 201 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct |