aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-04-18 20:23:40 +0000
committerChristian Grothoff <christian@grothoff.org>2010-04-18 20:23:40 +0000
commit541caf3dec54aaee621fed935e667f9ee423ef31 (patch)
tree6f80958e68541ce071bc557bbfc168644963c473 /src/include
parente8bc962b2ed43e194ba124537573da236786e82c (diff)
downloadgnunet-541caf3dec54aaee621fed935e667f9ee423ef31.tar.gz
gnunet-541caf3dec54aaee621fed935e667f9ee423ef31.zip
towards fixing blacklisting APIs and implementation
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_core_service.h4
-rw-r--r--src/include/gnunet_protocols.h15
-rw-r--r--src/include/gnunet_transport_service.h97
3 files changed, 35 insertions, 81 deletions
diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h
index 47b8d6f98..b7dc6f7da 100644
--- a/src/include/gnunet_core_service.h
+++ b/src/include/gnunet_core_service.h
@@ -51,7 +51,7 @@ struct GNUNET_CORE_Handle;
51 51
52 52
53/** 53/**
54 * Method called whenever a given peer either connects. 54 * Method called whenever a given peer connects.
55 * 55 *
56 * @param cls closure 56 * @param cls closure
57 * @param peer peer identity this notification is about 57 * @param peer peer identity this notification is about
@@ -164,7 +164,6 @@ typedef void
164 * @param cls closure for the various callbacks that follow (including handlers in the handlers array) 164 * @param cls closure for the various callbacks that follow (including handlers in the handlers array)
165 * @param init callback to call on timeout or once we have successfully 165 * @param init callback to call on timeout or once we have successfully
166 * connected to the core service; note that timeout is only meaningful if init is not NULL 166 * connected to the core service; note that timeout is only meaningful if init is not NULL
167 * @param pre_connects function to call on peer pre-connect (no session key yet), can be NULL
168 * @param connects function to call on peer connect, can be NULL 167 * @param connects function to call on peer connect, can be NULL
169 * @param disconnects function to call on peer disconnect / timeout, can be NULL 168 * @param disconnects function to call on peer disconnect / timeout, can be NULL
170 * @param inbound_notify function to call for all inbound messages, can be NULL 169 * @param inbound_notify function to call for all inbound messages, can be NULL
@@ -200,7 +199,6 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched,
200 struct GNUNET_TIME_Relative timeout, 199 struct GNUNET_TIME_Relative timeout,
201 void *cls, 200 void *cls,
202 GNUNET_CORE_StartupCallback init, 201 GNUNET_CORE_StartupCallback init,
203 GNUNET_CORE_ConnectEventHandler pre_connects,
204 GNUNET_CORE_ConnectEventHandler connects, 202 GNUNET_CORE_ConnectEventHandler connects,
205 GNUNET_CORE_DisconnectEventHandler disconnects, 203 GNUNET_CORE_DisconnectEventHandler disconnects,
206 GNUNET_CORE_MessageCallback inbound_notify, 204 GNUNET_CORE_MessageCallback inbound_notify,
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 602137f98..d992c9fb7 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -174,16 +174,19 @@ extern "C"
174#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY 28 174#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY 28
175 175
176/** 176/**
177 * Change in blacklisting status of a peer. 177 * Register a client that wants to do blacklisting.
178 */ 178 */
179#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST 29 179#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT 29
180 180
181/** 181/**
182 * Request to transport to notify us about any blacklisting status 182 * Query to a blacklisting client (is this peer blacklisted)?
183 * changes on this connection (and to immediately send all
184 * active blacklist entries).
185 */ 183 */
186#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_NOTIFY 30 184#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY 30
185
186/**
187 * Reply from blacklisting client (answer to blacklist query).
188 */
189#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY 31
187 190
188/** 191/**
189 * Transport PING message 192 * Transport PING message
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