aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_transport_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_transport_service.h')
-rw-r--r--src/include/gnunet_transport_service.h97
1 files changed, 25 insertions, 72 deletions
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h
index 711ebb599..57bdecd17 100644
--- a/src/include/gnunet_transport_service.h
+++ b/src/include/gnunet_transport_service.h
@@ -299,99 +299,52 @@ GNUNET_TRANSPORT_address_lookup (struct GNUNET_SCHEDULER_Handle *sched,
299 299
300 300
301/** 301/**
302 * Handle for blacklisting requests. 302 * Handle for blacklisting peers.
303 */ 303 */
304struct GNUNET_TRANSPORT_BlacklistRequest; 304struct GNUNET_TRANSPORT_Blacklist;
305 305
306 306
307/** 307/**
308 * Blacklist a peer for a given period of time. All connections 308 * Function that decides if a connection is acceptable or not.
309 * (inbound and outbound) to a peer that is blacklisted will be
310 * dropped (as soon as we learn who the connection is for). A second
311 * call to this function for the same peer overrides previous
312 * blacklisting requests.
313 *
314 * @param sched scheduler to use
315 * @param cfg configuration to use
316 * @param peer identity of peer to blacklist
317 * @param duration how long to blacklist, use GNUNET_TIME_UNIT_ZERO to
318 * re-enable connections
319 * @param timeout when should this operation (trying to establish the
320 * blacklisting time out)
321 * @param cont continuation to call once the request has been processed
322 * @param cont_cls closure for cont
323 * @return NULL on error, otherwise handle for cancellation
324 */
325struct GNUNET_TRANSPORT_BlacklistRequest *
326GNUNET_TRANSPORT_blacklist (struct GNUNET_SCHEDULER_Handle *sched,
327 const struct GNUNET_CONFIGURATION_Handle *cfg,
328 const struct GNUNET_PeerIdentity *peer,
329 struct GNUNET_TIME_Relative duration,
330 struct GNUNET_TIME_Relative timeout,
331 GNUNET_SCHEDULER_Task cont,
332 void *cont_cls);
333
334
335/**
336 * Abort transmitting the blacklist request. Note that this function
337 * is NOT for removing a peer from the blacklist (for that, call
338 * GNUNET_TRANSPORT_blacklist with a duration of zero). This function
339 * is only for aborting the transmission of a blacklist request
340 * (i.e. because of shutdown).
341 *
342 * @param br handle of the request that is to be cancelled
343 */
344void
345GNUNET_TRANSPORT_blacklist_cancel (struct GNUNET_TRANSPORT_BlacklistRequest * br);
346
347
348/**
349 * Handle for blacklist notifications.
350 */
351struct GNUNET_TRANSPORT_BlacklistNotification;
352
353
354/**
355 * Signature of function called whenever the blacklist status of
356 * a peer changes. This includes changes to the duration of the
357 * blacklist status as well as the expiration of an existing
358 * blacklist status.
359 * 309 *
360 * @param cls closure 310 * @param cls closure
361 * @param peer identity of peer with the change 311 * @param pid peer to approve or disapproave
362 * @param until GNUNET_TIME_UNIT_ZERO_ABS if the peer is no 312 * @return GNUNET_OK if the connection is allowed
363 * longer blacklisted, otherwise the time at
364 * which the current blacklisting will expire
365 */ 313 */
366typedef void (*GNUNET_TRANSPORT_BlacklistCallback)(void *cls, 314typedef int (*GNUNET_TRANSPORT_BlacklistCallback)(void *cls,
367 const struct GNUNET_PeerIdentity *peer, 315 const struct GNUNET_PeerIdentity *pid);
368 struct GNUNET_TIME_Absolute until);
369 316
370 317
371/** 318/**
372 * Call a function whenever a peer's blacklisting status changes. 319 * Install a blacklist callback. The service will be queried for all
320 * existing connections as well as any fresh connections to check if
321 * they are permitted. If the blacklisting callback is unregistered,
322 * all hosts that were denied in the past will automatically be
323 * whitelisted again. Cancelling the blacklist handle is also the
324 * only way to re-enable connections from peers that were previously
325 * blacklisted.
373 * 326 *
374 * @param sched scheduler to use 327 * @param sched scheduler to use
375 * @param cfg configuration to use 328 * @param cfg configuration to use
376 * @param bc function to call on status changes 329 * @param cb callback to invoke to check if connections are allowed
377 * @param bc_cls closure for bc 330 * @param cb_cls closure for cb
378 * @return NULL on error, otherwise handle for cancellation 331 * @return NULL on error, otherwise handle for cancellation
379 */ 332 */
380struct GNUNET_TRANSPORT_BlacklistNotification * 333struct GNUNET_TRANSPORT_Blacklist *
381GNUNET_TRANSPORT_blacklist_notify (struct GNUNET_SCHEDULER_Handle *sched, 334GNUNET_TRANSPORT_blacklist (struct GNUNET_SCHEDULER_Handle *sched,
382 const struct GNUNET_CONFIGURATION_Handle *cfg, 335 const struct GNUNET_CONFIGURATION_Handle *cfg,
383 GNUNET_TRANSPORT_BlacklistCallback bc, 336 GNUNET_TRANSPORT_BlacklistCallback cb,
384 void *bc_cls); 337 void *cb_cls);
385 338
386 339
387/** 340/**
388 * Stop calling the notification callback associated with 341 * Abort the blacklist. Note that this function is the only way for
389 * the given blacklist notification. 342 * removing a peer from the blacklist.
390 * 343 *
391 * @param bn handle of the request that is to be cancelled 344 * @param br handle of the request that is to be cancelled
392 */ 345 */
393void 346void
394GNUNET_TRANSPORT_blacklist_notify_cancel (struct GNUNET_TRANSPORT_BlacklistNotification * bn); 347GNUNET_TRANSPORT_blacklist_cancel (struct GNUNET_TRANSPORT_Blacklist *br);
395 348
396 349
397 350