2 This file is part of GNUnet.
3 (C) 2009-2014 Christian Grothoff (and other contributing authors)
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.
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.
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.
22 * @file include/gnunet_transport_service.h
23 * @brief low-level P2P IO
24 * @author Christian Grothoff
27 #ifndef GNUNET_TRANSPORT_SERVICE_H
28 #define GNUNET_TRANSPORT_SERVICE_H
33 #if 0 /* keep Emacsens' auto-indent happy */
38 #include "gnunet_util_lib.h"
39 #include "gnunet_ats_service.h"
42 * Version number of the transport API.
44 #define GNUNET_TRANSPORT_VERSION 0x00000001
48 * Possible state of a neighbour. Initially, we are #GNUNET_TRANSPORT_PS_NOT_CONNECTED.
50 * Then, there are two main paths. If we receive a CONNECT message, we give
51 * the inbound address to ATS. After the check we ask ATS for a suggestion
52 * (#GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS). If ATS makes a suggestion, we
53 * send our CONNECT_ACK and go to #GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK.
54 * If we receive a SESSION_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED
55 * (and notify everyone about the new connection). If the operation times out,
56 * we go to #GNUNET_TRANSPORT_PS_DISCONNECT.
58 * The other case is where we transmit a CONNECT message first. We
59 * start with #GNUNET_TRANSPORT_PS_INIT_ATS. If we get an address, we send
60 * the CONNECT message and go to state #GNUNET_TRANSPORT_PS_CONNECT_SENT.
61 * Once we receive a CONNECT_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED
62 * (and notify everyone about the new connection and send
63 * back a SESSION_ACK). If the operation times out, we go to
64 * #GNUNET_TRANSPORT_PS_DISCONNECT.
66 * If the session is in trouble (i.e. transport-level disconnect or
67 * timeout), we go to #GNUNET_TRANSPORT_PS_RECONNECT_ATS where we ask ATS for a new
68 * address (we don't notify anyone about the disconnect yet). Once we
69 * have a new address, we enter #GNUNET_TRANSPORT_PS_RECONNECT_SENT and send a
70 * CONNECT message. If we receive a
71 * CONNECT_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED and nobody noticed that we had
72 * trouble; we also send a SESSION_ACK at this time just in case. If
73 * the operation times out, we go to #GNUNET_TRANSPORT_PS_DISCONNECT (and notify everyone
74 * about the lost connection).
76 * If ATS decides to switch addresses while we have a normal
77 * connection, we go to #GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT
78 * and send a SESSION_CONNECT. If we get a SESSION_ACK back, we switch the
79 * primary connection to the suggested alternative from ATS, go back
80 * to #GNUNET_TRANSPORT_PS_CONNECTED and send a SESSION_ACK to the other peer just to be
81 * sure. If the operation times out
82 * we go to #GNUNET_TRANSPORT_PS_CONNECTED (and notify ATS that the given alternative
83 * address is "invalid").
85 * Once a session is in #GNUNET_TRANSPORT_PS_DISCONNECT, it is cleaned up and then goes
86 * to (#GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED). If we receive an explicit disconnect
87 * request, we can go from any state to #GNUNET_TRANSPORT_PS_DISCONNECT, possibly after
88 * generating disconnect notifications.
90 * Note that it is quite possible that while we are in any of these
91 * states, we could receive a 'CONNECT' request from the other peer.
92 * We then enter a 'weird' state where we pursue our own primary state
93 * machine (as described above), but with the 'send_connect_ack' flag
94 * set to 1. If our state machine allows us to send a 'CONNECT_ACK'
95 * (because we have an acceptable address), we send the 'CONNECT_ACK'
96 * and set the 'send_connect_ack' to 2. If we then receive a
97 * 'SESSION_ACK', we go to #GNUNET_TRANSPORT_PS_CONNECTED (and reset 'send_connect_ack'
101 enum GNUNET_TRANSPORT_PeerState
104 * Fresh peer or completely disconnected
106 GNUNET_TRANSPORT_PS_NOT_CONNECTED = 0,
109 * Asked to initiate connection, trying to get address from ATS
111 GNUNET_TRANSPORT_PS_INIT_ATS,
114 * Sent CONNECT message to other peer, waiting for CONNECT_ACK
116 GNUNET_TRANSPORT_PS_CONNECT_SENT,
119 * Received a CONNECT, asking ATS about address suggestions.
121 GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS,
124 * CONNECT request from other peer was CONNECT_ACK'ed, waiting for
127 GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK,
130 * Got our CONNECT_ACK/SESSION_ACK, connection is up.
132 GNUNET_TRANSPORT_PS_CONNECTED,
135 * Connection got into trouble, rest of the system still believes
136 * it to be up, but we're getting a new address from ATS.
138 GNUNET_TRANSPORT_PS_RECONNECT_ATS,
141 * Sent CONNECT over new address (either by ATS telling us to switch
142 * addresses or from RECONNECT_ATS); if this fails, we need to tell
143 * the rest of the system about a disconnect.
145 GNUNET_TRANSPORT_PS_RECONNECT_SENT,
148 * We have some primary connection, but ATS suggested we switch
149 * to some alternative; we now sent a CONNECT message for the
150 * alternative session to the other peer and waiting for a
151 * CONNECT_ACK to make this our primary connection.
153 GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT,
156 * Disconnect in progress (we're sending the DISCONNECT message to the
157 * other peer; after that is finished, the state will be cleaned up).
159 GNUNET_TRANSPORT_PS_DISCONNECT,
162 * We're finished with the disconnect; and are cleaning up the state
163 * now! We put the struct into this state when we are really in the
164 * task that calls 'free' on it and are about to remove the record
165 * from the map. We should never find a 'struct NeighbourMapEntry'
166 * in this state in the map. Accessing a 'struct NeighbourMapEntry'
167 * in this state virtually always means using memory that has been
168 * freed (the exception being the cleanup code in #free_neighbour()).
170 GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED
175 * Current state of a validation process.
177 * FIXME: what state is used to indicate that a validation
178 * was successful? If that is clarified/determined, "UGH" in
179 * ~gnunet-peerinfo-gtk.c:1103 should be resolved.
181 enum GNUNET_TRANSPORT_ValidationState
186 * Used for final callback indicating operation done
188 GNUNET_TRANSPORT_VS_NONE,
191 * Fresh validation entry
193 * Entry was just created, no validation process was executed
195 GNUNET_TRANSPORT_VS_NEW,
198 * Updated validation entry
200 * This is an update for an existing validation entry
202 GNUNET_TRANSPORT_VS_UPDATE,
205 * Timeout for validation entry
207 * A timeout occured during the validation process
209 GNUNET_TRANSPORT_VS_TIMEOUT,
212 * Validation entry is removed
214 * The validation entry is getting removed due to a failed validation
216 GNUNET_TRANSPORT_VS_REMOVE
221 * Function called by the transport for each received message.
224 * @param peer (claimed) identity of the other peer
225 * @param message the message
226 * @param ats performance data
227 * @param ats_count number of entries in @a ats
230 (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls,
231 const struct GNUNET_PeerIdentity *peer,
232 const struct GNUNET_MessageHeader *message);
236 * Opaque handle to the service.
238 struct GNUNET_TRANSPORT_Handle;
242 * Function called to notify transport users that another
243 * peer connected to us.
246 * @param peer the peer that connected
247 * @param ats performance data
248 * @param ats_count number of entries in @a ats (excluding 0-termination)
251 (*GNUNET_TRANSPORT_NotifyConnect) (void *cls,
252 const struct GNUNET_PeerIdentity *peer);
255 * Function called to notify transport users that another
256 * peer disconnected from us.
259 * @param peer the peer that disconnected
262 (*GNUNET_TRANSPORT_NotifyDisconnect) (void *cls,
263 const struct GNUNET_PeerIdentity *peer);
267 * Function to call with result of the try connect request.
271 * @param result #GNUNET_OK if message was transmitted to transport service
272 * #GNUNET_SYSERR if message was not transmitted to transport service
275 (*GNUNET_TRANSPORT_TryConnectCallback) (void *cls,
280 * Function to call with a textual representation of an address. This
281 * function will be called several times with different possible
282 * textual representations, and a last time with @address being NULL
283 * to signal the end of the iteration. Note that @address NULL
284 * always is the last call, regardless of the value in @a res.
287 * @param address NULL on end of iteration,
288 * otherwise 0-terminated printable UTF-8 string,
289 * in particular an empty string if @a res is #GNUNET_NO
290 * @param res result of the address to string conversion:
291 * if #GNUNET_OK: conversion successful
292 * if #GNUNET_NO: address was invalid (or not supported)
293 * if #GNUNET_SYSERR: communication error (IPC error)
296 (*GNUNET_TRANSPORT_AddressToStringCallback) (void *cls,
302 * Function to call with information about a peer
304 * If one_shot was set to #GNUNET_YES to iterate over all peers once,
305 * a final call with NULL for peer and address will follow when done.
306 * In this case state and timeout do not contain valid values.
308 * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called from
309 * within this function!
313 * @param peer peer this update is about,
314 * NULL if this is the final last callback for a iteration operation
315 * @param address address, NULL for disconnect notification in monitor mode
316 * @param state current state this peer is in
317 * @param state_timeout timeout for the current state of the peer
320 (*GNUNET_TRANSPORT_PeerIterateCallback) (void *cls,
321 const struct GNUNET_PeerIdentity *peer,
322 const struct GNUNET_HELLO_Address *address,
323 enum GNUNET_TRANSPORT_PeerState state,
324 struct GNUNET_TIME_Absolute state_timeout);
328 * Function to call with validation information about a peer
330 * This function is called by the transport validation monitoring api to
331 * indicate a change to a validation entry. The information included represent
332 * the current state of the validation entry,
334 * If the monitoring was called with one_shot=GNUNET_YES, a final callback
335 * with peer==NULL and address==NULL is executed.
338 * @param peer peer this update is about,
339 * NULL if this is the final last callback for a iteration operation
340 * @param address address,
341 * NULL for disconnect notification in monitor mode
342 * @param last_validation when was this address last validated
343 * @param valid_until when does this address expire
344 * @param next_validation time of the next validation operation
345 * @param state state in the validation state machine
348 (*GNUNET_TRANSPORT_ValidationIterateCallback) (void *cls,
349 const struct GNUNET_PeerIdentity *peer,
350 const struct GNUNET_HELLO_Address *address,
351 struct GNUNET_TIME_Absolute last_validation,
352 struct GNUNET_TIME_Absolute valid_until,
353 struct GNUNET_TIME_Absolute next_validation,
354 enum GNUNET_TRANSPORT_ValidationState state);
358 * Connect to the transport service. Note that the connection may
359 * complete (or fail) asynchronously.
361 * @param cfg configuration to use
362 * @param self our own identity (API should check that it matches
363 * the identity found by transport), or NULL (no check)
364 * @param cls closure for the callbacks
365 * @param rec receive function to call, or NULL
366 * @param nc function to call on connect events, or NULL
367 * @param nd function to call on disconnect events, or NULL
368 * @return NULL on error
370 struct GNUNET_TRANSPORT_Handle *
371 GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
372 const struct GNUNET_PeerIdentity *self,
374 GNUNET_TRANSPORT_ReceiveCallback rec,
375 GNUNET_TRANSPORT_NotifyConnect nc,
376 GNUNET_TRANSPORT_NotifyDisconnect nd);
380 * Function called if we have "excess" bandwidth to a peer.
381 * The notification will happen the first time we have excess
382 * bandwidth, and then only again after the client has performed
383 * some transmission to the peer.
385 * Excess bandwidth is defined as being allowed (by ATS) to send
386 * more data, and us reaching the limit of the capacity build-up
387 * (which, if we go past it, means we don't use available bandwidth).
388 * See also the "max carry" in `struct GNUNET_BANDWIDTH_Tracker`.
390 * @param cls the closure
391 * @param peer peer that we have excess bandwidth to
394 (*GNUNET_TRANSPORT_NotifyExcessBandwidth)(void *cls,
395 const struct GNUNET_PeerIdentity *neighbour);
399 * Connect to the transport service. Note that the connection may
400 * complete (or fail) asynchronously.
402 * @param cfg configuration to use
403 * @param self our own identity (API should check that it matches
404 * the identity found by transport), or NULL (no check)
405 * @param cls closure for the callbacks
406 * @param rec receive function to call, or NULL
407 * @param nc function to call on connect events, or NULL
408 * @param nd function to call on disconnect events, or NULL
409 * @param neb function to call if we have excess bandwidth to a peer
410 * @return NULL on error
412 struct GNUNET_TRANSPORT_Handle *
413 GNUNET_TRANSPORT_connect2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
414 const struct GNUNET_PeerIdentity *self,
416 GNUNET_TRANSPORT_ReceiveCallback rec,
417 GNUNET_TRANSPORT_NotifyConnect nc,
418 GNUNET_TRANSPORT_NotifyDisconnect nd,
419 GNUNET_TRANSPORT_NotifyExcessBandwidth neb);
423 * Disconnect from the transport service.
425 * @param handle handle returned from connect
428 GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle);
432 * Opaque handle for a transmission-ready request.
434 struct GNUNET_TRANSPORT_TryConnectHandle;
438 * Ask the transport service to establish a connection to
441 * @param handle connection to transport service
442 * @param target who we should try to connect to
443 * @param cb callback to be called when request was transmitted to transport
445 * @param cb_cls closure for the callback @a cb
446 * @return a `struct GNUNET_TRANSPORT_TryConnectHandle` handle or
447 * NULL on failure (@a cb will not be called)
449 struct GNUNET_TRANSPORT_TryConnectHandle *
450 GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle,
451 const struct GNUNET_PeerIdentity *target,
452 GNUNET_TRANSPORT_TryConnectCallback cb,
457 * Cancel the request to transport to try a connect
458 * Callback will not be called
460 * @param tch handle to cancel
463 GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *tch);
467 * Ask the transport service to establish a disconnect from
470 * @param handle connection to transport service
471 * @param target who we should try to disconnect from
472 * @param cb callback to be called when request was transmitted to transport
474 * @param cb_cls closure for the callback @a cb
475 * @return a `struct GNUNET_TRANSPORT_TryConnectHandle` handle or
476 * NULL on failure (@a cb will not be called)
478 struct GNUNET_TRANSPORT_TryConnectHandle *
479 GNUNET_TRANSPORT_try_disconnect (struct GNUNET_TRANSPORT_Handle *handle,
480 const struct GNUNET_PeerIdentity *target,
481 GNUNET_TRANSPORT_TryConnectCallback cb,
486 * Cancel the request to transport to try a disconnect
487 * Callback will not be called
489 * @param tch handle for operation to cancel
492 GNUNET_TRANSPORT_try_disconnect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *tch);
496 * Opaque handle for a transmission-ready request.
498 struct GNUNET_TRANSPORT_TransmitHandle;
502 * Function called to notify a client about the connection begin ready
503 * to queue more data. @a buf will be NULL and @a size zero if the
504 * connection was closed for writing in the meantime.
507 * @param size number of bytes available in @a buf
508 * @param buf where the callee should write the message
509 * @return number of bytes written to @a buf
512 (*GNUNET_TRANSPORT_TransmitReadyNotify) (void *cls,
518 * Check if we could queue a message of the given size for
519 * transmission. The transport service will take both its internal
520 * buffers and bandwidth limits imposed by the other peer into
521 * consideration when answering this query.
523 * @param handle connection to transport service
524 * @param target who should receive the message
525 * @param size how big is the message we want to transmit?
526 * @param timeout after how long should we give up (and call
527 * notify with buf NULL and size 0)?
528 * @param notify function to call when we are ready to
529 * send such a message
530 * @param notify_cls closure for @a notify
531 * @return NULL if someone else is already waiting to be notified
532 * non-NULL if the notify callback was queued (can be used to cancel
533 * using GNUNET_TRANSPORT_notify_transmit_ready_cancel)
535 struct GNUNET_TRANSPORT_TransmitHandle *
536 GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *handle,
537 const struct GNUNET_PeerIdentity *target,
539 struct GNUNET_TIME_Relative timeout,
540 GNUNET_TRANSPORT_TransmitReadyNotify notify,
545 * Cancel the specified transmission-ready notification.
547 * @param th handle of the transmission notification request to cancel
550 GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct GNUNET_TRANSPORT_TransmitHandle *th);
554 * Function called whenever there is an update to the
555 * HELLO of this peer.
558 * @param hello our updated HELLO
561 (*GNUNET_TRANSPORT_HelloUpdateCallback) (void *cls,
562 const struct GNUNET_MessageHeader *hello);
566 * Handle to cancel a #GNUNET_TRANSPORT_get_hello() operation.
568 struct GNUNET_TRANSPORT_GetHelloHandle;
572 * Checks if a given peer is connected to us
574 * @param handle connection to transport service
575 * @param peer the peer to check
576 * @return #GNUNET_YES (connected) or #GNUNET_NO (disconnected)
579 GNUNET_TRANSPORT_check_peer_connected (struct GNUNET_TRANSPORT_Handle *handle,
580 const struct GNUNET_PeerIdentity *peer);
584 * Set transport metrics for a peer and a direction
586 * @param handle transport handle
587 * @param peer the peer to set the metric for
588 * @param inbound set inbound direction (#GNUNET_YES or #GNUNET_NO)
589 * @param outbound set outbound direction (#GNUNET_YES or #GNUNET_NO)
590 * @param ats the metric as ATS information
591 * @param ats_count the number of metrics
593 * Supported ATS values:
594 * #GNUNET_ATS_QUALITY_NET_DELAY (value in ms)
595 * #GNUNET_ATS_QUALITY_NET_DISTANCE (value in count(hops))
598 * To enforce a delay of 10 ms for peer p1 in sending direction use:
600 * struct GNUNET_ATS_Information ats;
601 * ats.type = ntohl (GNUNET_ATS_QUALITY_NET_DELAY);
602 * ats.value = ntohl (10);
603 * GNUNET_TRANSPORT_set_traffic_metric (th, p1, TM_SEND, &ats, 1);
606 * Delay restrictions in receiving direction will be enforced with
610 GNUNET_TRANSPORT_set_traffic_metric (struct GNUNET_TRANSPORT_Handle *handle,
611 const struct GNUNET_PeerIdentity *peer,
614 const struct GNUNET_ATS_Information *ats,
619 * Obtain updates on changes to the HELLO message for this peer. The callback
620 * given in this function is never called synchronously.
622 * @param handle connection to transport service
623 * @param rec function to call with the HELLO
624 * @param rec_cls closure for @a rec
625 * @return handle to cancel the operation
627 struct GNUNET_TRANSPORT_GetHelloHandle *
628 GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
629 GNUNET_TRANSPORT_HelloUpdateCallback rec,
634 * Stop receiving updates about changes to our HELLO message.
636 * @param ghh handle to cancel
639 GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *ghh);
643 * Handle for a #GNUNET_TRANSPORT_offer_hello operation
645 struct GNUNET_TRANSPORT_OfferHelloHandle;
648 * Offer the transport service the HELLO of another peer. Note that
649 * the transport service may just ignore this message if the HELLO is
650 * malformed or useless due to our local configuration.
652 * @param handle connection to transport service
653 * @param hello the hello message
654 * @param cont continuation to call when HELLO has been sent,
655 * tc reason #GNUNET_SCHEDULER_REASON_TIMEOUT for fail
656 * tc reasong #GNUNET_SCHEDULER_REASON_READ_READY for success
657 * @param cls closure for continuation
658 * @return a GNUNET_TRANSPORT_OfferHelloHandle handle or NULL on failure,
659 * in case of failure cont will not be called
662 struct GNUNET_TRANSPORT_OfferHelloHandle *
663 GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
664 const struct GNUNET_MessageHeader *hello,
665 GNUNET_SCHEDULER_Task cont, void *cls);
669 * Cancel the request to transport to offer the HELLO message
671 * @param ohh the `struct GNUNET_TRANSPORT_OfferHelloHandle` to cancel
674 GNUNET_TRANSPORT_offer_hello_cancel (struct GNUNET_TRANSPORT_OfferHelloHandle *ohh);
678 * Handle to cancel a pending address lookup.
680 struct GNUNET_TRANSPORT_AddressToStringContext;
684 * Convert a binary address into a human readable address.
686 * @param cfg configuration to use
687 * @param address address to convert (binary format)
688 * @param numeric should (IP) addresses be displayed in numeric form
689 * (otherwise do reverse DNS lookup)
690 * @param timeout how long is the lookup allowed to take at most
691 * @param aluc function to call with the results
692 * @param aluc_cls closure for @a aluc
693 * @return handle to cancel the operation, NULL on error
695 struct GNUNET_TRANSPORT_AddressToStringContext *
696 GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cfg,
697 const struct GNUNET_HELLO_Address *address,
699 struct GNUNET_TIME_Relative timeout,
700 GNUNET_TRANSPORT_AddressToStringCallback aluc,
705 * Cancel request for address conversion.
707 * @param pic the context handle
710 GNUNET_TRANSPORT_address_to_string_cancel (struct GNUNET_TRANSPORT_AddressToStringContext *pic);
714 * Convert a transport state to a human readable string.
716 * @param state the state
719 GNUNET_TRANSPORT_ps2s (enum GNUNET_TRANSPORT_PeerState state);
723 * Check if a state is defined as connected
725 * @param state the state value
726 * @return #GNUNET_YES or #GNUNET_NO
729 GNUNET_TRANSPORT_is_connected (enum GNUNET_TRANSPORT_PeerState state);
733 * Convert validation state to human-readable string.
735 * @param state the state value
736 * @return corresponding string
739 GNUNET_TRANSPORT_vs2s (enum GNUNET_TRANSPORT_ValidationState state);
743 * Handle for a #GNUNET_TRANSPORT_monitor_peers operation.
745 struct GNUNET_TRANSPORT_PeerMonitoringContext;
748 * Return information about a specific peer or all peers currently known to
749 * transport service once or in monitoring mode. To obtain information about
750 * a specific peer, a peer identity can be passed. To obtain information about
751 * all peers currently known to transport service, NULL can be passed as peer
754 * For each peer, the callback is called with information about the address used
755 * to communicate with this peer, the state this peer is currently in and the
756 * the current timeout for this state.
758 * Upon completion, the 'GNUNET_TRANSPORT_PeerIterateCallback' is called one
759 * more time with 'NULL'. After this, the operation must no longer be
760 * explicitly canceled.
762 * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called in the
765 * @param cfg configuration to use
766 * @param peer a specific peer identity to obtain information for,
768 * @param one_shot #GNUNET_YES to return the current state and then end (with NULL+NULL),
769 * #GNUNET_NO to monitor peers continuously
770 * @param timeout how long is the lookup allowed to take at most
771 * @param peer_callback function to call with the results
772 * @param peer_callback_cls closure for @a peer_callback
774 struct GNUNET_TRANSPORT_PeerMonitoringContext *
775 GNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
776 const struct GNUNET_PeerIdentity *peer,
778 struct GNUNET_TIME_Relative timeout,
779 GNUNET_TRANSPORT_PeerIterateCallback peer_callback,
780 void *peer_callback_cls);
784 * Cancel request to monitor peers
786 * @param pic handle for the request to cancel
789 GNUNET_TRANSPORT_monitor_peers_cancel (struct GNUNET_TRANSPORT_PeerMonitoringContext *pic);
793 * Handle for a #GNUNET_TRANSPORT_monitor_validation_entries() operation.
795 struct GNUNET_TRANSPORT_ValidationMonitoringContext;
798 * Return information about pending address validation operations for a specific
801 * @param cfg configuration to use
802 * @param peer a specific peer identity to obtain validation entries for,
804 * @param one_shot #GNUNET_YES to return all entries and then end (with NULL+NULL),
805 * #GNUNET_NO to monitor validation entries continuously
806 * @param timeout how long is the lookup allowed to take at most
807 * @param validation_callback function to call with the results
808 * @param validation_callback_cls closure for @a validation_callback
810 struct GNUNET_TRANSPORT_ValidationMonitoringContext *
811 GNUNET_TRANSPORT_monitor_validation_entries (const struct GNUNET_CONFIGURATION_Handle *cfg,
812 const struct GNUNET_PeerIdentity *peer,
814 struct GNUNET_TIME_Relative timeout,
815 GNUNET_TRANSPORT_ValidationIterateCallback validation_callback,
816 void *validation_callback_cls);
820 * Return information about all current pending validation operations
822 * @param vic handle for the request to cancel
825 GNUNET_TRANSPORT_monitor_validation_entries_cancel (struct GNUNET_TRANSPORT_ValidationMonitoringContext *vic);
829 * Handle for blacklisting peers.
831 struct GNUNET_TRANSPORT_Blacklist;
835 * Function that decides if a connection is acceptable or not.
838 * @param pid peer to approve or disapproave
839 * @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not
842 (*GNUNET_TRANSPORT_BlacklistCallback) (void *cls,
844 GNUNET_PeerIdentity * pid);
848 * Install a blacklist callback. The service will be queried for all
849 * existing connections as well as any fresh connections to check if
850 * they are permitted. If the blacklisting callback is unregistered,
851 * all hosts that were denied in the past will automatically be
852 * whitelisted again. Cancelling the blacklist handle is also the
853 * only way to re-enable connections from peers that were previously
856 * @param cfg configuration to use
857 * @param cb callback to invoke to check if connections are allowed
858 * @param cb_cls closure for @a cb
859 * @return NULL on error, otherwise handle for cancellation
861 struct GNUNET_TRANSPORT_Blacklist *
862 GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg,
863 GNUNET_TRANSPORT_BlacklistCallback cb,
868 * Abort the blacklist. Note that this function is the only way for
869 * removing a peer from the blacklist.
871 * @param br handle of the request that is to be cancelled
874 GNUNET_TRANSPORT_blacklist_cancel (struct GNUNET_TRANSPORT_Blacklist *br);
878 #if 0 /* keep Emacsens' auto-indent happy */
885 /* ifndef GNUNET_TRANSPORT_SERVICE_H */
887 /* end of gnunet_transport_service.h */