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 CONNECT 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 CONNECT_ACK and go to #GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK.
500 * If we receive a SESSION_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 CONNECT message first. We
505 * start with #GNUNET_TRANSPORT_PS_INIT_ATS. If we get an address, we send
506 * the CONNECT message and go to state #GNUNET_TRANSPORT_PS_CONNECT_SENT.
507 * Once we receive a CONNECT_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED
508 * (and notify everyone about the new connection and send
509 * back a SESSION_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 * CONNECT message. If we receive a
517 * CONNECT_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED and nobody noticed that we had
518 * trouble; we also send a SESSION_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_CONNECT_SENT
524 * and send a SESSION_CONNECT. If we get a SESSION_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 SESSION_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 'CONNECT' 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 'CONNECT_ACK'
541 * (because we have an acceptable address), we send the 'CONNECT_ACK'
542 * and set the 'send_connect_ack' to 2. If we then receive a
543 * 'SESSION_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 CONNECT message to other peer, waiting for CONNECT_ACK
562 GNUNET_TRANSPORT_PS_CONNECT_SENT,
565 * Received a CONNECT, asking ATS about address suggestions.
567 GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS,
570 * CONNECT request from other peer was CONNECT_ACK'ed, waiting for
573 GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK,
576 * Got our CONNECT_ACK/SESSION_ACK, connection is up.
578 GNUNET_TRANSPORT_PS_CONNECTED,
581 * Connection got into trouble, rest of the system still believes
582 * it to be up, but we're getting a new address from ATS.
584 GNUNET_TRANSPORT_PS_RECONNECT_ATS,
587 * Sent CONNECT over new address (either by ATS telling us to switch
588 * addresses or from RECONNECT_ATS); if this fails, we need to tell
589 * the rest of the system about a disconnect.
591 GNUNET_TRANSPORT_PS_RECONNECT_SENT,
594 * We have some primary connection, but ATS suggested we switch
595 * to some alternative; we now sent a CONNECT message for the
596 * alternative session to the other peer and waiting for a
597 * CONNECT_ACK to make this our primary connection.
599 GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT,
602 * Disconnect in progress (we're sending the DISCONNECT message to the
603 * other peer; after that is finished, the state will be cleaned up).
605 GNUNET_TRANSPORT_PS_DISCONNECT,
608 * We're finished with the disconnect; and are cleaning up the state
609 * now! We put the struct into this state when we are really in the
610 * task that calls 'free' on it and are about to remove the record
611 * from the map. We should never find a 'struct NeighbourMapEntry'
612 * in this state in the map. Accessing a 'struct NeighbourMapEntry'
613 * in this state virtually always means using memory that has been
614 * freed (the exception being the cleanup code in #free_neighbour()).
616 GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED
621 * Convert a transport state to a human readable string.
623 * @param state the state
626 GNUNET_TRANSPORT_ps2s (enum GNUNET_TRANSPORT_PeerState state);
630 * Check if a state is defined as connected
632 * @param state the state value
633 * @return #GNUNET_YES or #GNUNET_NO
636 GNUNET_TRANSPORT_is_connected (enum GNUNET_TRANSPORT_PeerState state);
640 * Handle for a #GNUNET_TRANSPORT_monitor_peers operation.
642 struct GNUNET_TRANSPORT_PeerMonitoringContext;
646 * Function to call with information about a peer
648 * If one_shot was set to #GNUNET_YES to iterate over all peers once,
649 * a final call with NULL for peer and address will follow when done.
650 * In this case state and timeout do not contain valid values.
652 * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called from
653 * within this function!
657 * @param peer peer this update is about,
658 * NULL if this is the final last callback for a iteration operation
659 * @param address address, NULL for disconnect notification in monitor mode
660 * @param state current state this peer is in
661 * @param state_timeout timeout for the current state of the peer
664 (*GNUNET_TRANSPORT_PeerIterateCallback) (void *cls,
665 const struct GNUNET_PeerIdentity *peer,
666 const struct GNUNET_HELLO_Address *address,
667 enum GNUNET_TRANSPORT_PeerState state,
668 struct GNUNET_TIME_Absolute state_timeout);
672 * Return information about a specific peer or all peers currently known to
673 * transport service once or in monitoring mode. To obtain information about
674 * a specific peer, a peer identity can be passed. To obtain information about
675 * all peers currently known to transport service, NULL can be passed as peer
678 * For each peer, the callback is called with information about the address used
679 * to communicate with this peer, the state this peer is currently in and the
680 * the current timeout for this state.
682 * Upon completion, the 'GNUNET_TRANSPORT_PeerIterateCallback' is called one
683 * more time with 'NULL'. After this, the operation must no longer be
684 * explicitly canceled.
686 * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called in the
689 * @param cfg configuration to use
690 * @param peer a specific peer identity to obtain information for,
692 * @param one_shot #GNUNET_YES to return the current state and then end (with NULL+NULL),
693 * #GNUNET_NO to monitor peers continuously
694 * @param timeout how long is the lookup allowed to take at most
695 * @param peer_callback function to call with the results
696 * @param peer_callback_cls closure for @a peer_callback
698 struct GNUNET_TRANSPORT_PeerMonitoringContext *
699 GNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
700 const struct GNUNET_PeerIdentity *peer,
702 struct GNUNET_TIME_Relative timeout,
703 GNUNET_TRANSPORT_PeerIterateCallback peer_callback,
704 void *peer_callback_cls);
708 * Cancel request to monitor peers
710 * @param pic handle for the request to cancel
713 GNUNET_TRANSPORT_monitor_peers_cancel (struct GNUNET_TRANSPORT_PeerMonitoringContext *pic);
717 * Handle for a #GNUNET_TRANSPORT_monitor_validation_entries() operation.
719 struct GNUNET_TRANSPORT_ValidationMonitoringContext;
723 * Current state of a validation process.
725 * FIXME: what state is used to indicate that a validation
726 * was successful? If that is clarified/determined, "UGH" in
727 * ~gnunet-peerinfo-gtk.c:1103 should be resolved.
729 enum GNUNET_TRANSPORT_ValidationState
734 * Used for final callback indicating operation done
736 GNUNET_TRANSPORT_VS_NONE,
739 * Fresh validation entry
741 * Entry was just created, no validation process was executed
743 GNUNET_TRANSPORT_VS_NEW,
746 * Updated validation entry
748 * This is an update for an existing validation entry
750 GNUNET_TRANSPORT_VS_UPDATE,
753 * Timeout for validation entry
755 * A timeout occured during the validation process
757 GNUNET_TRANSPORT_VS_TIMEOUT,
760 * Validation entry is removed
762 * The validation entry is getting removed due to a failed validation
764 GNUNET_TRANSPORT_VS_REMOVE
769 * Function to call with validation information about a peer
771 * This function is called by the transport validation monitoring api to
772 * indicate a change to a validation entry. The information included represent
773 * the current state of the validation entry,
775 * If the monitoring was called with one_shot=GNUNET_YES, a final callback
776 * with peer==NULL and address==NULL is executed.
779 * @param peer peer this update is about,
780 * NULL if this is the final last callback for a iteration operation
781 * @param address address,
782 * NULL for disconnect notification in monitor mode
783 * @param last_validation when was this address last validated
784 * @param valid_until when does this address expire
785 * @param next_validation time of the next validation operation
786 * @param state state in the validation state machine
789 (*GNUNET_TRANSPORT_ValidationIterateCallback) (void *cls,
790 const struct GNUNET_PeerIdentity *peer,
791 const struct GNUNET_HELLO_Address *address,
792 struct GNUNET_TIME_Absolute last_validation,
793 struct GNUNET_TIME_Absolute valid_until,
794 struct GNUNET_TIME_Absolute next_validation,
795 enum GNUNET_TRANSPORT_ValidationState state);
799 * Convert validation state to human-readable string.
801 * @param state the state value
802 * @return corresponding string
805 GNUNET_TRANSPORT_vs2s (enum GNUNET_TRANSPORT_ValidationState state);
809 * Return information about pending address validation operations for a specific
812 * @param cfg configuration to use
813 * @param peer a specific peer identity to obtain validation entries for,
815 * @param one_shot #GNUNET_YES to return all entries and then end (with NULL+NULL),
816 * #GNUNET_NO to monitor validation entries continuously
817 * @param timeout how long is the lookup allowed to take at most
818 * @param validation_callback function to call with the results
819 * @param validation_callback_cls closure for @a validation_callback
821 struct GNUNET_TRANSPORT_ValidationMonitoringContext *
822 GNUNET_TRANSPORT_monitor_validation_entries (const struct GNUNET_CONFIGURATION_Handle *cfg,
823 const struct GNUNET_PeerIdentity *peer,
825 struct GNUNET_TIME_Relative timeout,
826 GNUNET_TRANSPORT_ValidationIterateCallback validation_callback,
827 void *validation_callback_cls);
831 * Return information about all current pending validation operations
833 * @param vic handle for the request to cancel
836 GNUNET_TRANSPORT_monitor_validation_entries_cancel (struct GNUNET_TRANSPORT_ValidationMonitoringContext *vic);
839 /* *********************** Blacklisting ************************ */
842 * Handle for blacklisting peers.
844 struct GNUNET_TRANSPORT_Blacklist;
848 * Function that decides if a connection is acceptable or not.
851 * @param pid peer to approve or disapproave
852 * @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not
855 (*GNUNET_TRANSPORT_BlacklistCallback) (void *cls,
856 const struct GNUNET_PeerIdentity *pid);
860 * Install a blacklist callback. The service will be queried for all
861 * existing connections as well as any fresh connections to check if
862 * they are permitted. If the blacklisting callback is unregistered,
863 * all hosts that were denied in the past will automatically be
864 * whitelisted again. Cancelling the blacklist handle is also the
865 * only way to re-enable connections from peers that were previously
868 * @param cfg configuration to use
869 * @param cb callback to invoke to check if connections are allowed
870 * @param cb_cls closure for @a cb
871 * @return NULL on error, otherwise handle for cancellation
873 struct GNUNET_TRANSPORT_Blacklist *
874 GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg,
875 GNUNET_TRANSPORT_BlacklistCallback cb,
880 * Abort the blacklist. Note that this function is the only way for
881 * removing a peer from the blacklist.
883 * @param br handle of the request that is to be cancelled
886 GNUNET_TRANSPORT_blacklist_cancel (struct GNUNET_TRANSPORT_Blacklist *br);
890 #if 0 /* keep Emacsens' auto-indent happy */
897 /* ifndef GNUNET_TRANSPORT_SERVICE_H */
899 /* end of gnunet_transport_service.h */