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 * Function called by the transport for each received message.
51 * @param peer (claimed) identity of the other peer
52 * @param message the message
55 (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls,
56 const struct GNUNET_PeerIdentity *peer,
57 const struct GNUNET_MessageHeader *message);
61 * Opaque handle to the service.
63 struct GNUNET_TRANSPORT_Handle;
67 * Function called to notify transport users that another
68 * peer connected to us.
71 * @param peer the peer that connected
74 (*GNUNET_TRANSPORT_NotifyConnect) (void *cls,
75 const struct GNUNET_PeerIdentity *peer);
78 * Function called to notify transport users that another
79 * peer disconnected from us.
82 * @param peer the peer that disconnected
85 (*GNUNET_TRANSPORT_NotifyDisconnect) (void *cls,
86 const struct GNUNET_PeerIdentity *peer);
90 * Connect to the transport service. Note that the connection may
91 * complete (or fail) asynchronously.
93 * @param cfg configuration to use
94 * @param self our own identity (API should check that it matches
95 * the identity found by transport), or NULL (no check)
96 * @param cls closure for the callbacks
97 * @param rec receive function to call, or NULL
98 * @param nc function to call on connect events, or NULL
99 * @param nd function to call on disconnect events, or NULL
100 * @return NULL on error
102 struct GNUNET_TRANSPORT_Handle *
103 GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
104 const struct GNUNET_PeerIdentity *self,
106 GNUNET_TRANSPORT_ReceiveCallback rec,
107 GNUNET_TRANSPORT_NotifyConnect nc,
108 GNUNET_TRANSPORT_NotifyDisconnect nd);
112 * Function called if we have "excess" bandwidth to a peer.
113 * The notification will happen the first time we have excess
114 * bandwidth, and then only again after the client has performed
115 * some transmission to the peer.
117 * Excess bandwidth is defined as being allowed (by ATS) to send
118 * more data, and us reaching the limit of the capacity build-up
119 * (which, if we go past it, means we don't use available bandwidth).
120 * See also the "max carry" in `struct GNUNET_BANDWIDTH_Tracker`.
122 * @param cls the closure
123 * @param neighbour peer that we have excess bandwidth to
126 (*GNUNET_TRANSPORT_NotifyExcessBandwidth)(void *cls,
127 const struct GNUNET_PeerIdentity *neighbour);
131 * Connect to the transport service. Note that the connection may
132 * complete (or fail) asynchronously.
134 * @param cfg configuration to use
135 * @param self our own identity (API should check that it matches
136 * the identity found by transport), or NULL (no check)
137 * @param cls closure for the callbacks
138 * @param rec receive function to call, or NULL
139 * @param nc function to call on connect events, or NULL
140 * @param nd function to call on disconnect events, or NULL
141 * @param neb function to call if we have excess bandwidth to a peer
142 * @return NULL on error
144 struct GNUNET_TRANSPORT_Handle *
145 GNUNET_TRANSPORT_connect2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
146 const struct GNUNET_PeerIdentity *self,
148 GNUNET_TRANSPORT_ReceiveCallback rec,
149 GNUNET_TRANSPORT_NotifyConnect nc,
150 GNUNET_TRANSPORT_NotifyDisconnect nd,
151 GNUNET_TRANSPORT_NotifyExcessBandwidth neb);
155 * Disconnect from the transport service.
157 * @param handle handle returned from connect
160 GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle);
163 /* ************************* Connections *********************** */
166 * Opaque handle for a transmission-ready request.
168 struct GNUNET_TRANSPORT_TryConnectHandle;
171 * Function to call with result of the try connect request.
174 * @param result #GNUNET_OK if message was transmitted to transport service
175 * #GNUNET_SYSERR if message was not transmitted to transport service
178 (*GNUNET_TRANSPORT_TryConnectCallback) (void *cls,
183 * Ask the transport service to establish a connection to
186 * @param handle connection to transport service
187 * @param target who we should try to connect to
188 * @param cb callback to be called when request was transmitted to transport
190 * @param cb_cls closure for the callback @a cb
191 * @return a `struct GNUNET_TRANSPORT_TryConnectHandle` handle or
192 * NULL on failure (@a cb will not be called)
194 struct GNUNET_TRANSPORT_TryConnectHandle *
195 GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle,
196 const struct GNUNET_PeerIdentity *target,
197 GNUNET_TRANSPORT_TryConnectCallback cb,
202 * Cancel the request to transport to try a connect
203 * Callback will not be called
205 * @param tch handle to cancel
208 GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *tch);
212 * Ask the transport service to disconnect from the given peer.
214 * @param handle connection to transport service
215 * @param target who we should try to disconnect from
216 * @param cb callback to be called when request was transmitted to transport
218 * @param cb_cls closure for the callback @a cb
219 * @return a `struct GNUNET_TRANSPORT_TryConnectHandle` handle or
220 * NULL on failure (@a cb will not be called)
222 struct GNUNET_TRANSPORT_TryConnectHandle *
223 GNUNET_TRANSPORT_try_disconnect (struct GNUNET_TRANSPORT_Handle *handle,
224 const struct GNUNET_PeerIdentity *target,
225 GNUNET_TRANSPORT_TryConnectCallback cb,
230 * Cancel the request to transport to disconnect.
231 * Callback will not be called anymore.
233 * @param tch handle for operation to cancel
236 GNUNET_TRANSPORT_try_disconnect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *tch);
239 /* ************************* Sending *************************** */
242 * Opaque handle for a transmission-ready request.
244 struct GNUNET_TRANSPORT_TransmitHandle;
248 * Function called to notify a client about the connection begin ready
249 * to queue more data. @a buf will be NULL and @a size zero if the
250 * connection was closed for writing in the meantime.
253 * @param size number of bytes available in @a buf
254 * @param buf where the callee should write the message
255 * @return number of bytes written to @a buf
258 (*GNUNET_TRANSPORT_TransmitReadyNotify) (void *cls,
264 * Check if we could queue a message of the given size for
265 * transmission. The transport service will take both its internal
266 * buffers and bandwidth limits imposed by the other peer into
267 * consideration when answering this query.
269 * @param handle connection to transport service
270 * @param target who should receive the message
271 * @param size how big is the message we want to transmit?
272 * @param timeout after how long should we give up (and call
273 * notify with buf NULL and size 0)?
274 * @param notify function to call when we are ready to
275 * send such a message
276 * @param notify_cls closure for @a notify
277 * @return NULL if someone else is already waiting to be notified
278 * non-NULL if the notify callback was queued (can be used to cancel
279 * using #GNUNET_TRANSPORT_notify_transmit_ready_cancel())
281 struct GNUNET_TRANSPORT_TransmitHandle *
282 GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *handle,
283 const struct GNUNET_PeerIdentity *target,
285 struct GNUNET_TIME_Relative timeout,
286 GNUNET_TRANSPORT_TransmitReadyNotify notify,
291 * Cancel the specified transmission-ready notification.
293 * @param th handle of the transmission notification request to cancel
296 GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct GNUNET_TRANSPORT_TransmitHandle *th);
301 * Checks if a given peer is connected to us
303 * @param handle connection to transport service
304 * @param peer the peer to check
305 * @return #GNUNET_YES (connected) or #GNUNET_NO (disconnected)
308 GNUNET_TRANSPORT_check_peer_connected (struct GNUNET_TRANSPORT_Handle *handle,
309 const struct GNUNET_PeerIdentity *peer);
313 /* *********************** Metric manipulation ***************** */
316 * Set transport metrics for a peer and a direction
318 * @param handle transport handle
319 * @param peer the peer to set the metric for
320 * @param inbound set inbound direction (#GNUNET_YES or #GNUNET_NO)
321 * @param outbound set outbound direction (#GNUNET_YES or #GNUNET_NO)
322 * @param ats the metric as ATS information
323 * @param ats_count the number of metrics
325 * Supported ATS values:
326 * #GNUNET_ATS_QUALITY_NET_DELAY (value in ms)
327 * #GNUNET_ATS_QUALITY_NET_DISTANCE (value in count(hops))
330 * To enforce a delay of 10 ms for peer p1 in sending direction use:
332 * struct GNUNET_ATS_Information ats;
333 * ats.type = ntohl (GNUNET_ATS_QUALITY_NET_DELAY);
334 * ats.value = ntohl (10);
335 * GNUNET_TRANSPORT_set_traffic_metric (th, p1, TM_SEND, &ats, 1);
338 * Delay restrictions in receiving direction will be enforced with
342 GNUNET_TRANSPORT_set_traffic_metric (struct GNUNET_TRANSPORT_Handle *handle,
343 const struct GNUNET_PeerIdentity *peer,
346 const struct GNUNET_ATS_Information *ats,
350 /* *************************** HELLO *************************** */
354 * Function called whenever there is an update to the
355 * HELLO of this peer.
358 * @param hello our updated HELLO
361 (*GNUNET_TRANSPORT_HelloUpdateCallback) (void *cls,
362 const struct GNUNET_MessageHeader *hello);
366 * Handle to cancel a #GNUNET_TRANSPORT_get_hello() operation.
368 struct GNUNET_TRANSPORT_GetHelloHandle;
372 * Obtain updates on changes to the HELLO message for this peer. The callback
373 * given in this function is never called synchronously.
375 * @param handle connection to transport service
376 * @param rec function to call with the HELLO
377 * @param rec_cls closure for @a rec
378 * @return handle to cancel the operation
380 struct GNUNET_TRANSPORT_GetHelloHandle *
381 GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
382 GNUNET_TRANSPORT_HelloUpdateCallback rec,
387 * Stop receiving updates about changes to our HELLO message.
389 * @param ghh handle to cancel
392 GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *ghh);
396 * Handle for a #GNUNET_TRANSPORT_offer_hello operation
398 struct GNUNET_TRANSPORT_OfferHelloHandle;
401 * Offer the transport service the HELLO of another peer. Note that
402 * the transport service may just ignore this message if the HELLO is
403 * malformed or useless due to our local configuration.
405 * @param handle connection to transport service
406 * @param hello the hello message
407 * @param cont continuation to call when HELLO has been sent,
408 * tc reason #GNUNET_SCHEDULER_REASON_TIMEOUT for fail
409 * tc reasong #GNUNET_SCHEDULER_REASON_READ_READY for success
410 * @param cls closure for continuation
411 * @return a GNUNET_TRANSPORT_OfferHelloHandle handle or NULL on failure,
412 * in case of failure cont will not be called
415 struct GNUNET_TRANSPORT_OfferHelloHandle *
416 GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
417 const struct GNUNET_MessageHeader *hello,
418 GNUNET_SCHEDULER_Task cont, void *cls);
422 * Cancel the request to transport to offer the HELLO message
424 * @param ohh the `struct GNUNET_TRANSPORT_OfferHelloHandle` to cancel
427 GNUNET_TRANSPORT_offer_hello_cancel (struct GNUNET_TRANSPORT_OfferHelloHandle *ohh);
430 /* *********************** Address to String ******************* */
433 * Handle to cancel a pending address lookup.
435 struct GNUNET_TRANSPORT_AddressToStringContext;
439 * Function to call with a textual representation of an address. This
440 * function will be called several times with different possible
441 * textual representations, and a last time with @a address being NULL
442 * to signal the end of the iteration. Note that @a address NULL
443 * always is the last call, regardless of the value in @a res.
446 * @param address NULL on end of iteration,
447 * otherwise 0-terminated printable UTF-8 string,
448 * in particular an empty string if @a res is #GNUNET_NO
449 * @param res result of the address to string conversion:
450 * if #GNUNET_OK: conversion successful
451 * if #GNUNET_NO: address was invalid (or not supported)
452 * if #GNUNET_SYSERR: communication error (IPC error)
455 (*GNUNET_TRANSPORT_AddressToStringCallback) (void *cls,
461 * Convert a binary address into a human readable address.
463 * @param cfg configuration to use
464 * @param address address to convert (binary format)
465 * @param numeric should (IP) addresses be displayed in numeric form
466 * (otherwise do reverse DNS lookup)
467 * @param timeout how long is the lookup allowed to take at most
468 * @param aluc function to call with the results
469 * @param aluc_cls closure for @a aluc
470 * @return handle to cancel the operation, NULL on error
472 struct GNUNET_TRANSPORT_AddressToStringContext *
473 GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cfg,
474 const struct GNUNET_HELLO_Address *address,
476 struct GNUNET_TIME_Relative timeout,
477 GNUNET_TRANSPORT_AddressToStringCallback aluc,
482 * Cancel request for address conversion.
484 * @param pic the context handle
487 GNUNET_TRANSPORT_address_to_string_cancel (struct GNUNET_TRANSPORT_AddressToStringContext *pic);
490 /* *********************** Monitoring ************************** */
494 * Possible state of a neighbour. Initially, we are #GNUNET_TRANSPORT_PS_NOT_CONNECTED.
496 * Then, there are two main paths. If we receive a SYN message, we give
497 * the inbound address to ATS. After the check we ask ATS for a suggestion
498 * (#GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS). If ATS makes a suggestion, we
499 * send our SYN_ACK and go to #GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK.
500 * If we receive a ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED
501 * (and notify everyone about the new connection). If the operation times out,
502 * we go to #GNUNET_TRANSPORT_PS_DISCONNECT.
504 * The other case is where we transmit a SYN message first. We
505 * start with #GNUNET_TRANSPORT_PS_INIT_ATS. If we get an address, we send
506 * the SYN message and go to state #GNUNET_TRANSPORT_PS_CONNECT_SENT.
507 * Once we receive a SYN_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED
508 * (and notify everyone about the new connection and send
509 * back a ACK). If the operation times out, we go to
510 * #GNUNET_TRANSPORT_PS_DISCONNECT.
512 * If the session is in trouble (i.e. transport-level disconnect or
513 * timeout), we go to #GNUNET_TRANSPORT_PS_RECONNECT_ATS where we ask ATS for a new
514 * address (we don't notify anyone about the disconnect yet). Once we
515 * have a new address, we enter #GNUNET_TRANSPORT_PS_RECONNECT_SENT and send a
516 * SYN message. If we receive a
517 * SYN_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED and nobody noticed that we had
518 * trouble; we also send a ACK at this time just in case. If
519 * the operation times out, we go to #GNUNET_TRANSPORT_PS_DISCONNECT (and notify everyone
520 * about the lost connection).
522 * If ATS decides to switch addresses while we have a normal
523 * connection, we go to #GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT
524 * and send a SESSION_CONNECT. If we get a ACK back, we switch the
525 * primary connection to the suggested alternative from ATS, go back
526 * to #GNUNET_TRANSPORT_PS_CONNECTED and send a ACK to the other peer just to be
527 * sure. If the operation times out
528 * we go to #GNUNET_TRANSPORT_PS_CONNECTED (and notify ATS that the given alternative
529 * address is "invalid").
531 * Once a session is in #GNUNET_TRANSPORT_PS_DISCONNECT, it is cleaned up and then goes
532 * to (#GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED). If we receive an explicit disconnect
533 * request, we can go from any state to #GNUNET_TRANSPORT_PS_DISCONNECT, possibly after
534 * generating disconnect notifications.
536 * Note that it is quite possible that while we are in any of these
537 * states, we could receive a 'SYN' request from the other peer.
538 * We then enter a 'weird' state where we pursue our own primary state
539 * machine (as described above), but with the 'send_connect_ack' flag
540 * set to 1. If our state machine allows us to send a 'SYN_ACK'
541 * (because we have an acceptable address), we send the 'SYN_ACK'
542 * and set the 'send_connect_ack' to 2. If we then receive a
543 * 'ACK', we go to #GNUNET_TRANSPORT_PS_CONNECTED (and reset 'send_connect_ack'
547 enum GNUNET_TRANSPORT_PeerState
550 * Fresh peer or completely disconnected
552 GNUNET_TRANSPORT_PS_NOT_CONNECTED = 0,
555 * Asked to initiate connection, trying to get address from ATS
557 GNUNET_TRANSPORT_PS_INIT_ATS,
560 * Sent SYN message to other peer, waiting for SYN_ACK
562 GNUNET_TRANSPORT_PS_SYN_SENT,
565 * Received a SYN, asking ATS about address suggestions.
567 GNUNET_TRANSPORT_PS_SYN_RECV_ATS,
570 * SYN request from other peer was SYN_ACK'ed, waiting for ACK.
572 GNUNET_TRANSPORT_PS_SYN_RECV_ACK,
575 * Got our SYN_ACK/ACK, connection is up.
577 GNUNET_TRANSPORT_PS_CONNECTED,
580 * Connection got into trouble, rest of the system still believes
581 * it to be up, but we're getting a new address from ATS.
583 GNUNET_TRANSPORT_PS_RECONNECT_ATS,
586 * Sent SYN over new address (either by ATS telling us to switch
587 * addresses or from RECONNECT_ATS); if this fails, we need to tell
588 * the rest of the system about a disconnect.
590 GNUNET_TRANSPORT_PS_RECONNECT_SENT,
593 * We have some primary connection, but ATS suggested we switch
594 * to some alternative; we now sent a SYN message for the
595 * alternative session to the other peer and waiting for a
596 * SYN_ACK to make this our primary connection.
598 GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT,
601 * Disconnect in progress (we're sending the DISCONNECT message to the
602 * other peer; after that is finished, the state will be cleaned up).
604 GNUNET_TRANSPORT_PS_DISCONNECT,
607 * We're finished with the disconnect; and are cleaning up the state
608 * now! We put the struct into this state when we are really in the
609 * task that calls 'free' on it and are about to remove the record
610 * from the map. We should never find a 'struct NeighbourMapEntry'
611 * in this state in the map. Accessing a 'struct NeighbourMapEntry'
612 * in this state virtually always means using memory that has been
613 * freed (the exception being the cleanup code in #free_neighbour()).
615 GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED
620 * Convert a transport state to a human readable string.
622 * @param state the state
625 GNUNET_TRANSPORT_ps2s (enum GNUNET_TRANSPORT_PeerState state);
629 * Check if a state is defined as connected
631 * @param state the state value
632 * @return #GNUNET_YES or #GNUNET_NO
635 GNUNET_TRANSPORT_is_connected (enum GNUNET_TRANSPORT_PeerState state);
639 * Handle for a #GNUNET_TRANSPORT_monitor_peers operation.
641 struct GNUNET_TRANSPORT_PeerMonitoringContext;
645 * Function to call with information about a peer
647 * If one_shot was set to #GNUNET_YES to iterate over all peers once,
648 * a final call with NULL for peer and address will follow when done.
649 * In this case state and timeout do not contain valid values.
651 * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called from
652 * within this function!
656 * @param peer peer this update is about,
657 * NULL if this is the final last callback for a iteration operation
658 * @param address address, NULL for disconnect notification in monitor mode
659 * @param state current state this peer is in
660 * @param state_timeout timeout for the current state of the peer
663 (*GNUNET_TRANSPORT_PeerIterateCallback) (void *cls,
664 const struct GNUNET_PeerIdentity *peer,
665 const struct GNUNET_HELLO_Address *address,
666 enum GNUNET_TRANSPORT_PeerState state,
667 struct GNUNET_TIME_Absolute state_timeout);
671 * Return information about a specific peer or all peers currently known to
672 * transport service once or in monitoring mode. To obtain information about
673 * a specific peer, a peer identity can be passed. To obtain information about
674 * all peers currently known to transport service, NULL can be passed as peer
677 * For each peer, the callback is called with information about the address used
678 * to communicate with this peer, the state this peer is currently in and the
679 * the current timeout for this state.
681 * Upon completion, the 'GNUNET_TRANSPORT_PeerIterateCallback' is called one
682 * more time with 'NULL'. After this, the operation must no longer be
683 * explicitly canceled.
685 * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called in the
688 * @param cfg configuration to use
689 * @param peer a specific peer identity to obtain information for,
691 * @param one_shot #GNUNET_YES to return the current state and then end (with NULL+NULL),
692 * #GNUNET_NO to monitor peers continuously
693 * @param timeout how long is the lookup allowed to take at most
694 * @param peer_callback function to call with the results
695 * @param peer_callback_cls closure for @a peer_callback
697 struct GNUNET_TRANSPORT_PeerMonitoringContext *
698 GNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
699 const struct GNUNET_PeerIdentity *peer,
701 struct GNUNET_TIME_Relative timeout,
702 GNUNET_TRANSPORT_PeerIterateCallback peer_callback,
703 void *peer_callback_cls);
707 * Cancel request to monitor peers
709 * @param pic handle for the request to cancel
712 GNUNET_TRANSPORT_monitor_peers_cancel (struct GNUNET_TRANSPORT_PeerMonitoringContext *pic);
716 * Handle for a #GNUNET_TRANSPORT_monitor_validation_entries() operation.
718 struct GNUNET_TRANSPORT_ValidationMonitoringContext;
722 * Current state of a validation process.
724 * FIXME: what state is used to indicate that a validation
725 * was successful? If that is clarified/determined, "UGH" in
726 * ~gnunet-peerinfo-gtk.c:1103 should be resolved.
728 enum GNUNET_TRANSPORT_ValidationState
733 * Used for final callback indicating operation done
735 GNUNET_TRANSPORT_VS_NONE,
738 * Fresh validation entry
740 * Entry was just created, no validation process was executed
742 GNUNET_TRANSPORT_VS_NEW,
745 * Updated validation entry
747 * This is an update for an existing validation entry
749 GNUNET_TRANSPORT_VS_UPDATE,
752 * Timeout for validation entry
754 * A timeout occured during the validation process
756 GNUNET_TRANSPORT_VS_TIMEOUT,
759 * Validation entry is removed
761 * The validation entry is getting removed due to a failed validation
763 GNUNET_TRANSPORT_VS_REMOVE
768 * Function to call with validation information about a peer
770 * This function is called by the transport validation monitoring api to
771 * indicate a change to a validation entry. The information included represent
772 * the current state of the validation entry,
774 * If the monitoring was called with one_shot=GNUNET_YES, a final callback
775 * with peer==NULL and address==NULL is executed.
778 * @param peer peer this update is about,
779 * NULL if this is the final last callback for a iteration operation
780 * @param address address,
781 * NULL for disconnect notification in monitor mode
782 * @param last_validation when was this address last validated
783 * @param valid_until when does this address expire
784 * @param next_validation time of the next validation operation
785 * @param state state in the validation state machine
788 (*GNUNET_TRANSPORT_ValidationIterateCallback) (void *cls,
789 const struct GNUNET_PeerIdentity *peer,
790 const struct GNUNET_HELLO_Address *address,
791 struct GNUNET_TIME_Absolute last_validation,
792 struct GNUNET_TIME_Absolute valid_until,
793 struct GNUNET_TIME_Absolute next_validation,
794 enum GNUNET_TRANSPORT_ValidationState state);
798 * Convert validation state to human-readable string.
800 * @param state the state value
801 * @return corresponding string
804 GNUNET_TRANSPORT_vs2s (enum GNUNET_TRANSPORT_ValidationState state);
808 * Return information about pending address validation operations for a specific
811 * @param cfg configuration to use
812 * @param peer a specific peer identity to obtain validation entries for,
814 * @param one_shot #GNUNET_YES to return all entries and then end (with NULL+NULL),
815 * #GNUNET_NO to monitor validation entries continuously
816 * @param timeout how long is the lookup allowed to take at most
817 * @param validation_callback function to call with the results
818 * @param validation_callback_cls closure for @a validation_callback
820 struct GNUNET_TRANSPORT_ValidationMonitoringContext *
821 GNUNET_TRANSPORT_monitor_validation_entries (const struct GNUNET_CONFIGURATION_Handle *cfg,
822 const struct GNUNET_PeerIdentity *peer,
824 struct GNUNET_TIME_Relative timeout,
825 GNUNET_TRANSPORT_ValidationIterateCallback validation_callback,
826 void *validation_callback_cls);
830 * Return information about all current pending validation operations
832 * @param vic handle for the request to cancel
835 GNUNET_TRANSPORT_monitor_validation_entries_cancel (struct GNUNET_TRANSPORT_ValidationMonitoringContext *vic);
838 /* *********************** Blacklisting ************************ */
841 * Handle for blacklisting peers.
843 struct GNUNET_TRANSPORT_Blacklist;
847 * Function that decides if a connection is acceptable or not.
850 * @param pid peer to approve or disapproave
851 * @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not
854 (*GNUNET_TRANSPORT_BlacklistCallback) (void *cls,
855 const struct GNUNET_PeerIdentity *pid);
859 * Install a blacklist callback. The service will be queried for all
860 * existing connections as well as any fresh connections to check if
861 * they are permitted. If the blacklisting callback is unregistered,
862 * all hosts that were denied in the past will automatically be
863 * whitelisted again. Cancelling the blacklist handle is also the
864 * only way to re-enable connections from peers that were previously
867 * @param cfg configuration to use
868 * @param cb callback to invoke to check if connections are allowed
869 * @param cb_cls closure for @a cb
870 * @return NULL on error, otherwise handle for cancellation
872 struct GNUNET_TRANSPORT_Blacklist *
873 GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg,
874 GNUNET_TRANSPORT_BlacklistCallback cb,
879 * Abort the blacklist. Note that this function is the only way for
880 * removing a peer from the blacklist.
882 * @param br handle of the request that is to be cancelled
885 GNUNET_TRANSPORT_blacklist_cancel (struct GNUNET_TRANSPORT_Blacklist *br);
889 #if 0 /* keep Emacsens' auto-indent happy */
896 /* ifndef GNUNET_TRANSPORT_SERVICE_H */
898 /* end of gnunet_transport_service.h */