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
51 * first run a check against the blacklist (#GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST_INBOUND).
52 * If this check is successful, we give the inbound address to ATS.
53 * After the check we ask ATS for a suggestion (#GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS).
54 * If ATS makes a suggestion, we ALSO give that suggestion to the blacklist
55 * (#GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST). Once the blacklist approves the
56 * address we got from ATS, we send our CONNECT_ACK and go to
57 * #GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK. If we receive a SESSION_ACK, we go to
58 * #GNUNET_TRANSPORT_PS_CONNECTED (and notify everyone about the new connection).
59 * If the operation times out, we go to #GNUNET_TRANSPORT_PS_DISCONNECT.
61 * The other case is where we transmit a CONNECT message first. We
62 * start with #GNUNET_TRANSPORT_PS_INIT_ATS. If we get an address, we enter
63 * #GNUNET_TRANSPORT_PS_INIT_BLACKLIST and check the blacklist. If the blacklist is OK
64 * with the connection, we actually send the CONNECT message and go to
65 * state #GNUNET_TRANSPORT_PS_CONNECT_SENT. Once we receive a CONNECT_ACK, we go to
66 * #GNUNET_TRANSPORT_PS_CONNECTED (and notify everyone about the new connection and send
67 * back a SESSION_ACK). If the operation times out, we go to
68 * #GNUNET_TRANSPORT_PS_DISCONNECT.
70 * If the session is in trouble (i.e. transport-level disconnect or
71 * timeout), we go to #GNUNET_TRANSPORT_PS_RECONNECT_ATS where we ask ATS for a new
72 * address (we don't notify anyone about the disconnect yet). Once we
73 * have a new address, we go to #GNUNET_TRANSPORT_PS_RECONNECT_BLACKLIST to check the new
74 * address against the blacklist. If the blacklist approves, we enter
75 * #GNUNET_TRANSPORT_PS_RECONNECT_SENT and send a CONNECT message. If we receive a
76 * CONNECT_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED and nobody noticed that we had
77 * trouble; we also send a SESSION_ACK at this time just in case. If
78 * the operation times out, we go to #GNUNET_TRANSPORT_PS_DISCONNECT (and notify everyone
79 * about the lost connection).
81 * If ATS decides to switch addresses while we have a normal
82 * connection, we go to #GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_BLACKLIST to check the
83 * new address against the blacklist. If the blacklist approves, we
84 * go to #GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT and send a
85 * SESSION_CONNECT. If we get a SESSION_ACK back, we switch the
86 * primary connection to the suggested alternative from ATS, go back
87 * to #GNUNET_TRANSPORT_PS_CONNECTED and send a SESSION_ACK to the other peer just to be
88 * sure. If the operation times out (or the blacklist disapproves),
89 * we go to #GNUNET_TRANSPORT_PS_CONNECTED (and notify ATS that the given alternative
90 * address is "invalid").
92 * Once a session is in #GNUNET_TRANSPORT_PS_DISCONNECT, it is cleaned up and then goes
93 * to (#GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED). If we receive an explicit disconnect
94 * request, we can go from any state to #GNUNET_TRANSPORT_PS_DISCONNECT, possibly after
95 * generating disconnect notifications.
97 * Note that it is quite possible that while we are in any of these
98 * states, we could receive a 'CONNECT' request from the other peer.
99 * We then enter a 'weird' state where we pursue our own primary state
100 * machine (as described above), but with the 'send_connect_ack' flag
101 * set to 1. If our state machine allows us to send a 'CONNECT_ACK'
102 * (because we have an acceptable address), we send the 'CONNECT_ACK'
103 * and set the 'send_connect_ack' to 2. If we then receive a
104 * 'SESSION_ACK', we go to #GNUNET_TRANSPORT_PS_CONNECTED (and reset 'send_connect_ack'
108 enum GNUNET_TRANSPORT_PeerState
111 * Fresh peer or completely disconnected
113 GNUNET_TRANSPORT_PS_NOT_CONNECTED = 0,
116 * Asked to initiate connection, trying to get address from ATS
118 GNUNET_TRANSPORT_PS_INIT_ATS,
121 * Asked to initiate connection, trying to get address approved
124 GNUNET_TRANSPORT_PS_INIT_BLACKLIST,
127 * Sent CONNECT message to other peer, waiting for CONNECT_ACK
129 GNUNET_TRANSPORT_PS_CONNECT_SENT,
132 * Received a CONNECT, do a blacklist check for inbound address
134 GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST_INBOUND,
137 * Received a CONNECT, asking ATS about address suggestions.
139 GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS,
142 * Received CONNECT from other peer, got an address, checking with blacklist.
144 GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST,
147 * CONNECT request from other peer was SESSION_ACK'ed, waiting for
150 GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK,
153 * Got our CONNECT_ACK/SESSION_ACK, connection is up.
155 GNUNET_TRANSPORT_PS_CONNECTED,
158 * Connection got into trouble, rest of the system still believes
159 * it to be up, but we're getting a new address from ATS.
161 GNUNET_TRANSPORT_PS_RECONNECT_ATS,
164 * Connection got into trouble, rest of the system still believes
165 * it to be up; we are checking the new address against the blacklist.
167 GNUNET_TRANSPORT_PS_RECONNECT_BLACKLIST,
170 * Sent CONNECT over new address (either by ATS telling us to switch
171 * addresses or from RECONNECT_ATS); if this fails, we need to tell
172 * the rest of the system about a disconnect.
174 GNUNET_TRANSPORT_PS_RECONNECT_SENT,
177 * We have some primary connection, but ATS suggested we switch
178 * to some alternative; we're now checking the alternative against
181 GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_BLACKLIST,
184 * We have some primary connection, but ATS suggested we switch
185 * to some alternative; we now sent a CONNECT message for the
186 * alternative session to the other peer and waiting for a
187 * CONNECT_ACK to make this our primary connection.
189 GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT,
192 * Disconnect in progress (we're sending the DISCONNECT message to the
193 * other peer; after that is finished, the state will be cleaned up).
195 GNUNET_TRANSPORT_PS_DISCONNECT,
198 * We're finished with the disconnect; and are cleaning up the state
199 * now! We put the struct into this state when we are really in the
200 * task that calls 'free' on it and are about to remove the record
201 * from the map. We should never find a 'struct NeighbourMapEntry'
202 * in this state in the map. Accessing a 'struct NeighbourMapEntry'
203 * in this state virtually always means using memory that has been
204 * freed (the exception being the cleanup code in #free_neighbour()).
206 GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED
211 * Current state of a validation process
213 enum GNUNET_TRANSPORT_ValidationState
218 * Used for final callback indicating operation done
220 GNUNET_TRANSPORT_VS_NONE,
223 * Fresh validation entry
225 * Entry was just created, no validation process was executed
227 GNUNET_TRANSPORT_VS_NEW,
230 * Updated validation entry
232 * This is an update for an existing validation entry
234 GNUNET_TRANSPORT_VS_UPDATE,
237 * Timeout for validation entry
239 * A timeout occured during the validation process
241 GNUNET_TRANSPORT_VS_TIMEOUT,
244 * Validation entry is removed
246 * The validation entry is getting removed due to a failed validation
248 GNUNET_TRANSPORT_VS_REMOVE
253 * Function called by the transport for each received message.
256 * @param peer (claimed) identity of the other peer
257 * @param message the message
258 * @param ats performance data
259 * @param ats_count number of entries in @a ats
262 (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls,
263 const struct GNUNET_PeerIdentity *peer,
264 const struct GNUNET_MessageHeader *message);
268 * Opaque handle to the service.
270 struct GNUNET_TRANSPORT_Handle;
274 * Function called to notify transport users that another
275 * peer connected to us.
278 * @param peer the peer that connected
279 * @param ats performance data
280 * @param ats_count number of entries in @a ats (excluding 0-termination)
283 (*GNUNET_TRANSPORT_NotifyConnect) (void *cls,
284 const struct GNUNET_PeerIdentity *peer);
287 * Function called to notify transport users that another
288 * peer disconnected from us.
291 * @param peer the peer that disconnected
294 (*GNUNET_TRANSPORT_NotifyDisconnect) (void *cls,
295 const struct GNUNET_PeerIdentity *peer);
299 * Function to call with result of the try connect request.
303 * @param result #GNUNET_OK if message was transmitted to transport service
304 * #GNUNET_SYSERR if message was not transmitted to transport service
307 (*GNUNET_TRANSPORT_TryConnectCallback) (void *cls,
312 * Function to call with a textual representation of an address.
313 * This function will be called several times with different possible
314 * textual representations, and a last time with NULL to signal the end
318 * @param address NULL on error or end of iteration,
319 * otherwise 0-terminated printable UTF-8 string
322 (*GNUNET_TRANSPORT_AddressToStringCallback) (void *cls,
323 const char *address);
327 * Function to call with information about a peer
329 * If one_shot was set to #GNUNET_YES to iterate over all peers once,
330 * a final call with NULL for peer and address will follow when done.
331 * In this case state and timeout do not contain valid values.
333 * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called from
334 * within this function!
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, NULL for disconnect notification in monitor mode
341 * @param state current state this peer is in
342 * @param state_timeout timeout for the current state of the peer
345 (*GNUNET_TRANSPORT_PeerIterateCallback) (void *cls,
346 const struct GNUNET_PeerIdentity *peer,
347 const struct GNUNET_HELLO_Address *address,
348 enum GNUNET_TRANSPORT_PeerState state,
349 struct GNUNET_TIME_Absolute state_timeout);
353 * Function to call with validation information about a peer
355 * This function is called by the transport validation monitoring api to
356 * indicate a change to a validation entry. The information included represent
357 * the current state of the validation entry,
359 * If the monitoring was called with one_shot=GNUNET_YES, a final callback
360 * with peer==NULL and address==NULL is executed.
363 * @param peer peer this update is about,
364 * NULL if this is the final last callback for a iteration operation
365 * @param address address,
366 * NULL for disconnect notification in monitor mode
367 * @param last_validation when was this address last validated
368 * @param valid_until when does this address expire
369 * @param next_validation time of the next validation operation
370 * @param state state in the validation state machine
373 (*GNUNET_TRANSPORT_ValidationIterateCallback) (void *cls,
374 const struct GNUNET_PeerIdentity *peer,
375 const struct GNUNET_HELLO_Address *address,
376 struct GNUNET_TIME_Absolute last_validation,
377 struct GNUNET_TIME_Absolute valid_until,
378 struct GNUNET_TIME_Absolute next_validation,
379 enum GNUNET_TRANSPORT_ValidationState state);
383 * Connect to the transport service. Note that the connection may
384 * complete (or fail) asynchronously.
386 * @param cfg configuration to use
387 * @param self our own identity (API should check that it matches
388 * the identity found by transport), or NULL (no check)
389 * @param cls closure for the callbacks
390 * @param rec receive function to call, or NULL
391 * @param nc function to call on connect events, or NULL
392 * @param nd function to call on disconnect events, or NULL
393 * @return NULL on error
395 struct GNUNET_TRANSPORT_Handle *
396 GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
397 const struct GNUNET_PeerIdentity *self,
399 GNUNET_TRANSPORT_ReceiveCallback rec,
400 GNUNET_TRANSPORT_NotifyConnect nc,
401 GNUNET_TRANSPORT_NotifyDisconnect nd);
405 * Function called if we have "excess" bandwidth to a peer.
406 * The notification will happen the first time we have excess
407 * bandwidth, and then only again after the client has performed
408 * some transmission to the peer.
410 * Excess bandwidth is defined as being allowed (by ATS) to send
411 * more data, and us reaching the limit of the capacity build-up
412 * (which, if we go past it, means we don't use available bandwidth).
413 * See also the "max carry" in `struct GNUNET_BANDWIDTH_Tracker`.
415 * @param cls the closure
416 * @param peer peer that we have excess bandwidth to
419 (*GNUNET_TRANSPORT_NotifyExcessBandwidth)(void *cls,
420 const struct GNUNET_PeerIdentity *neighbour);
424 * Connect to the transport service. Note that the connection may
425 * complete (or fail) asynchronously.
427 * @param cfg configuration to use
428 * @param self our own identity (API should check that it matches
429 * the identity found by transport), or NULL (no check)
430 * @param cls closure for the callbacks
431 * @param rec receive function to call, or NULL
432 * @param nc function to call on connect events, or NULL
433 * @param nd function to call on disconnect events, or NULL
434 * @param neb function to call if we have excess bandwidth to a peer
435 * @return NULL on error
437 struct GNUNET_TRANSPORT_Handle *
438 GNUNET_TRANSPORT_connect2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
439 const struct GNUNET_PeerIdentity *self,
441 GNUNET_TRANSPORT_ReceiveCallback rec,
442 GNUNET_TRANSPORT_NotifyConnect nc,
443 GNUNET_TRANSPORT_NotifyDisconnect nd,
444 GNUNET_TRANSPORT_NotifyExcessBandwidth neb);
448 * Disconnect from the transport service.
450 * @param handle handle returned from connect
453 GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle);
457 * Opaque handle for a transmission-ready request.
459 struct GNUNET_TRANSPORT_TryConnectHandle;
463 * Ask the transport service to establish a connection to
466 * @param handle connection to transport service
467 * @param target who we should try to connect to
468 * @param cb callback to be called when request was transmitted to transport
470 * @param cb_cls closure for the callback @a cb
471 * @return a `struct GNUNET_TRANSPORT_TryConnectHandle` handle or
472 * NULL on failure (@a cb will not be called)
474 struct GNUNET_TRANSPORT_TryConnectHandle *
475 GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle,
476 const struct GNUNET_PeerIdentity *target,
477 GNUNET_TRANSPORT_TryConnectCallback cb,
482 * Cancel the request to transport to try a connect
483 * Callback will not be called
485 * @param tch GNUNET_TRANSPORT_TryConnectHandle handle to cancel
488 GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *tch);
492 * Opaque handle for a transmission-ready request.
494 struct GNUNET_TRANSPORT_TransmitHandle;
498 * Function called to notify a client about the connection begin ready
499 * to queue more data. @a buf will be NULL and @a size zero if the
500 * connection was closed for writing in the meantime.
503 * @param size number of bytes available in @a buf
504 * @param buf where the callee should write the message
505 * @return number of bytes written to @a buf
508 (*GNUNET_TRANSPORT_TransmitReadyNotify) (void *cls,
514 * Check if we could queue a message of the given size for
515 * transmission. The transport service will take both its internal
516 * buffers and bandwidth limits imposed by the other peer into
517 * consideration when answering this query.
519 * @param handle connection to transport service
520 * @param target who should receive the message
521 * @param size how big is the message we want to transmit?
522 * @param timeout after how long should we give up (and call
523 * notify with buf NULL and size 0)?
524 * @param notify function to call when we are ready to
525 * send such a message
526 * @param notify_cls closure for @a notify
527 * @return NULL if someone else is already waiting to be notified
528 * non-NULL if the notify callback was queued (can be used to cancel
529 * using GNUNET_TRANSPORT_notify_transmit_ready_cancel)
531 struct GNUNET_TRANSPORT_TransmitHandle *
532 GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *handle,
533 const struct GNUNET_PeerIdentity *target,
535 struct GNUNET_TIME_Relative timeout,
536 GNUNET_TRANSPORT_TransmitReadyNotify notify,
541 * Cancel the specified transmission-ready notification.
543 * @param th handle of the transmission notification request to cancel
546 GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct GNUNET_TRANSPORT_TransmitHandle *th);
550 * Function called whenever there is an update to the
551 * HELLO of this peer.
554 * @param hello our updated HELLO
557 (*GNUNET_TRANSPORT_HelloUpdateCallback) (void *cls,
558 const struct GNUNET_MessageHeader *hello);
562 * Handle to cancel a #GNUNET_TRANSPORT_get_hello() operation.
564 struct GNUNET_TRANSPORT_GetHelloHandle;
568 * Checks if a given peer is connected to us
570 * @param handle connection to transport service
571 * @param peer the peer to check
572 * @return #GNUNET_YES (connected) or #GNUNET_NO (disconnected)
575 GNUNET_TRANSPORT_check_peer_connected (struct GNUNET_TRANSPORT_Handle *handle,
576 const struct GNUNET_PeerIdentity *peer);
580 * Set transport metrics for a peer and a direction
582 * @param handle transport handle
583 * @param peer the peer to set the metric for
584 * @param inbound set inbound direction (#GNUNET_YES or #GNUNET_NO)
585 * @param outbound set outbound direction (#GNUNET_YES or #GNUNET_NO)
586 * @param ats the metric as ATS information
587 * @param ats_count the number of metrics
589 * Supported ATS values:
590 * #GNUNET_ATS_QUALITY_NET_DELAY (value in ms)
591 * #GNUNET_ATS_QUALITY_NET_DISTANCE (value in count(hops))
594 * To enforce a delay of 10 ms for peer p1 in sending direction use:
596 * struct GNUNET_ATS_Information ats;
597 * ats.type = ntohl (GNUNET_ATS_QUALITY_NET_DELAY);
598 * ats.value = ntohl (10);
599 * GNUNET_TRANSPORT_set_traffic_metric (th, p1, TM_SEND, &ats, 1);
602 * Delay restrictions in receiving direction will be enforced with
606 GNUNET_TRANSPORT_set_traffic_metric (struct GNUNET_TRANSPORT_Handle *handle,
607 const struct GNUNET_PeerIdentity *peer,
610 const struct GNUNET_ATS_Information *ats,
615 * Obtain updates on changes to the HELLO message for this peer. The callback
616 * given in this function is never called synchronously.
618 * @param handle connection to transport service
619 * @param rec function to call with the HELLO
620 * @param rec_cls closure for @a rec
621 * @return handle to cancel the operation
623 struct GNUNET_TRANSPORT_GetHelloHandle *
624 GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
625 GNUNET_TRANSPORT_HelloUpdateCallback rec,
630 * Stop receiving updates about changes to our HELLO message.
632 * @param ghh handle to cancel
635 GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *ghh);
638 struct GNUNET_TRANSPORT_OfferHelloHandle;
641 * Offer the transport service the HELLO of another peer. Note that
642 * the transport service may just ignore this message if the HELLO is
643 * malformed or useless due to our local configuration.
645 * @param handle connection to transport service
646 * @param hello the hello message
647 * @param cont continuation to call when HELLO has been sent,
648 * tc reason #GNUNET_SCHEDULER_REASON_TIMEOUT for fail
649 * tc reasong #GNUNET_SCHEDULER_REASON_READ_READY for success
650 * @param cls closure for continuation
651 * @return a GNUNET_TRANSPORT_OfferHelloHandle handle or NULL on failure,
652 * in case of failure cont will not be called
655 struct GNUNET_TRANSPORT_OfferHelloHandle *
656 GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
657 const struct GNUNET_MessageHeader *hello,
658 GNUNET_SCHEDULER_Task cont, void *cls);
662 * Cancel the request to transport to offer the HELLO message
664 * @param ohh the `struct GNUNET_TRANSPORT_OfferHelloHandle` to cancel
667 GNUNET_TRANSPORT_offer_hello_cancel (struct GNUNET_TRANSPORT_OfferHelloHandle *ohh);
671 * Handle to cancel a pending address lookup.
673 struct GNUNET_TRANSPORT_AddressToStringContext;
677 * Convert a binary address into a human readable address.
679 * @param cfg configuration to use
680 * @param address address to convert (binary format)
681 * @param numeric should (IP) addresses be displayed in numeric form
682 * (otherwise do reverse DNS lookup)
683 * @param timeout how long is the lookup allowed to take at most
684 * @param aluc function to call with the results
685 * @param aluc_cls closure for @a aluc
686 * @return handle to cancel the operation, NULL on error
688 struct GNUNET_TRANSPORT_AddressToStringContext *
689 GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cfg,
690 const struct GNUNET_HELLO_Address *address,
692 struct GNUNET_TIME_Relative timeout,
693 GNUNET_TRANSPORT_AddressToStringCallback aluc,
698 * Cancel request for address conversion.
700 * @param pic the context handle
703 GNUNET_TRANSPORT_address_to_string_cancel (struct GNUNET_TRANSPORT_AddressToStringContext *pic);
707 * Convert a transport state to a human readable string.
709 * @param state the state
712 GNUNET_TRANSPORT_ps2s (enum GNUNET_TRANSPORT_PeerState state);
716 * Check if a state is defined as connected
718 * @param state the state value
719 * @return #GNUNET_YES or #GNUNET_NO
722 GNUNET_TRANSPORT_is_connected (enum GNUNET_TRANSPORT_PeerState state);
726 * Convert validation state to human-readable string.
728 * @param state the state value
729 * @return corresponding string
732 GNUNET_TRANSPORT_vs2s (enum GNUNET_TRANSPORT_ValidationState state);
734 struct GNUNET_TRANSPORT_PeerMonitoringContext;
737 * Return information about a specific peer or all peers currently known to
738 * transport service once or in monitoring mode. To obtain information about
739 * a specific peer, a peer identity can be passed. To obtain information about
740 * all peers currently known to transport service, NULL can be passed as peer
743 * For each peer, the callback is called with information about the address used
744 * to communicate with this peer, the state this peer is currently in and the
745 * the current timeout for this state.
747 * Upon completion, the 'GNUNET_TRANSPORT_PeerIterateCallback' is called one
748 * more time with 'NULL'. After this, the operation must no longer be
749 * explicitly canceled.
751 * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called in the
754 * @param cfg configuration to use
755 * @param peer a specific peer identity to obtain information for,
757 * @param one_shot #GNUNET_YES to return the current state and then end (with NULL+NULL),
758 * #GNUNET_NO to monitor peers continuously
759 * @param timeout how long is the lookup allowed to take at most
760 * @param peer_callback function to call with the results
761 * @param peer_callback_cls closure for @a peer_callback
763 struct GNUNET_TRANSPORT_PeerMonitoringContext *
764 GNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
765 const struct GNUNET_PeerIdentity *peer,
767 struct GNUNET_TIME_Relative timeout,
768 GNUNET_TRANSPORT_PeerIterateCallback peer_callback,
769 void *peer_callback_cls);
773 * Cancel request to monitor peers
775 * @param pic handle for the request to cancel
778 GNUNET_TRANSPORT_monitor_peers_cancel (struct GNUNET_TRANSPORT_PeerMonitoringContext *pic);
781 struct GNUNET_TRANSPORT_ValidationMonitoringContext;
784 * Return information about pending address validation operations for a specific
787 * @param cfg configuration to use
788 * @param peer a specific peer identity to obtain validation entries for,
790 * @param one_shot #GNUNET_YES to return all entries and then end (with NULL+NULL),
791 * #GNUNET_NO to monitor validation entries continuously
792 * @param timeout how long is the lookup allowed to take at most
793 * @param validation_callback function to call with the results
794 * @param validation_callback_cls closure for @a validation_callback
796 struct GNUNET_TRANSPORT_ValidationMonitoringContext *
797 GNUNET_TRANSPORT_monitor_validation_entries (const struct GNUNET_CONFIGURATION_Handle *cfg,
798 const struct GNUNET_PeerIdentity *peer,
800 struct GNUNET_TIME_Relative timeout,
801 GNUNET_TRANSPORT_ValidationIterateCallback validation_callback,
802 void *validation_callback_cls);
806 * Return information about all current pending validation operations
808 * @param vic handle for the request to cancel
811 GNUNET_TRANSPORT_monitor_validation_entries_cancel (struct GNUNET_TRANSPORT_ValidationMonitoringContext *vic);
815 * Handle for blacklisting peers.
817 struct GNUNET_TRANSPORT_Blacklist;
821 * Function that decides if a connection is acceptable or not.
824 * @param pid peer to approve or disapproave
825 * @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not
828 (*GNUNET_TRANSPORT_BlacklistCallback) (void *cls,
830 GNUNET_PeerIdentity * pid);
834 * Install a blacklist callback. The service will be queried for all
835 * existing connections as well as any fresh connections to check if
836 * they are permitted. If the blacklisting callback is unregistered,
837 * all hosts that were denied in the past will automatically be
838 * whitelisted again. Cancelling the blacklist handle is also the
839 * only way to re-enable connections from peers that were previously
842 * @param cfg configuration to use
843 * @param cb callback to invoke to check if connections are allowed
844 * @param cb_cls closure for @a cb
845 * @return NULL on error, otherwise handle for cancellation
847 struct GNUNET_TRANSPORT_Blacklist *
848 GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg,
849 GNUNET_TRANSPORT_BlacklistCallback cb,
854 * Abort the blacklist. Note that this function is the only way for
855 * removing a peer from the blacklist.
857 * @param br handle of the request that is to be cancelled
860 GNUNET_TRANSPORT_blacklist_cancel (struct GNUNET_TRANSPORT_Blacklist *br);
864 #if 0 /* keep Emacsens' auto-indent happy */
871 /* ifndef GNUNET_TRANSPORT_SERVICE_H */
873 /* end of gnunet_transport_service.h */