2 This file is part of GNUnet.
3 Copyright (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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, 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 0x00000002
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)
195 struct GNUNET_TRANSPORT_TryConnectHandle *
196 GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle,
197 const struct GNUNET_PeerIdentity *target,
198 GNUNET_TRANSPORT_TryConnectCallback cb,
203 * Cancel the request to transport to try a connect
204 * Callback will not be called
206 * @param tch handle to cancel
209 GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *tch);
212 /* ************************* Sending *************************** */
215 * Opaque handle for a transmission-ready request.
217 struct GNUNET_TRANSPORT_TransmitHandle;
221 * Function called to notify a client about the connection begin ready
222 * to queue more data. @a buf will be NULL and @a size zero if the
223 * connection was closed for writing in the meantime.
226 * @param size number of bytes available in @a buf
227 * @param buf where the callee should write the message
228 * @return number of bytes written to @a buf
231 (*GNUNET_TRANSPORT_TransmitReadyNotify) (void *cls,
237 * Check if we could queue a message of the given size for
238 * transmission. The transport service will take both its internal
239 * buffers and bandwidth limits imposed by the other peer into
240 * consideration when answering this query.
242 * @param handle connection to transport service
243 * @param target who should receive the message
244 * @param size how big is the message we want to transmit?
245 * @param timeout after how long should we give up (and call
246 * notify with buf NULL and size 0)?
247 * @param notify function to call when we are ready to
248 * send such a message
249 * @param notify_cls closure for @a notify
250 * @return NULL if someone else is already waiting to be notified
251 * non-NULL if the notify callback was queued (can be used to cancel
252 * using #GNUNET_TRANSPORT_notify_transmit_ready_cancel())
254 struct GNUNET_TRANSPORT_TransmitHandle *
255 GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *handle,
256 const struct GNUNET_PeerIdentity *target,
258 struct GNUNET_TIME_Relative timeout,
259 GNUNET_TRANSPORT_TransmitReadyNotify notify,
264 * Cancel the specified transmission-ready notification.
266 * @param th handle of the transmission notification request to cancel
269 GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct GNUNET_TRANSPORT_TransmitHandle *th);
273 * Checks if a given peer is connected to us
275 * @param handle connection to transport service
276 * @param peer the peer to check
277 * @return #GNUNET_YES (connected) or #GNUNET_NO (disconnected)
280 GNUNET_TRANSPORT_check_peer_connected (struct GNUNET_TRANSPORT_Handle *handle,
281 const struct GNUNET_PeerIdentity *peer);
285 /* *********************** Metric manipulation ***************** */
288 * Set transport metrics for a peer and a direction
290 * @param handle transport handle
291 * @param peer the peer to set the metric for
292 * @param prop the performance metrics to set
293 * @param delay_in inbound delay to introduce
294 * @param delay_out outbound delay to introduce
296 * Note: Delay restrictions in receiving direction will be enforced
297 * with one message delay.
300 GNUNET_TRANSPORT_set_traffic_metric (struct GNUNET_TRANSPORT_Handle *handle,
301 const struct GNUNET_PeerIdentity *peer,
302 const struct GNUNET_ATS_Properties *prop,
303 struct GNUNET_TIME_Relative delay_in,
304 struct GNUNET_TIME_Relative delay_out);
307 /* *************************** HELLO *************************** */
311 * Function called whenever there is an update to the
312 * HELLO of this peer.
315 * @param hello our updated HELLO
318 (*GNUNET_TRANSPORT_HelloUpdateCallback) (void *cls,
319 const struct GNUNET_MessageHeader *hello);
323 * Handle to cancel a #GNUNET_TRANSPORT_get_hello() operation.
325 struct GNUNET_TRANSPORT_GetHelloHandle;
329 * Obtain updates on changes to the HELLO message for this peer. The callback
330 * given in this function is never called synchronously.
332 * @param handle connection to transport service
333 * @param rec function to call with the HELLO
334 * @param rec_cls closure for @a rec
335 * @return handle to cancel the operation
337 struct GNUNET_TRANSPORT_GetHelloHandle *
338 GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
339 GNUNET_TRANSPORT_HelloUpdateCallback rec,
344 * Stop receiving updates about changes to our HELLO message.
346 * @param ghh handle to cancel
349 GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *ghh);
353 * Handle for a #GNUNET_TRANSPORT_offer_hello operation
355 struct GNUNET_TRANSPORT_OfferHelloHandle;
359 * Offer the transport service the HELLO of another peer. Note that
360 * the transport service may just ignore this message if the HELLO is
361 * malformed or useless due to our local configuration.
363 * @param handle connection to transport service
364 * @param hello the hello message
365 * @param cont continuation to call when HELLO has been sent,
366 * tc reason #GNUNET_SCHEDULER_REASON_TIMEOUT for fail
367 * tc reasong #GNUNET_SCHEDULER_REASON_READ_READY for success
368 * @param cont_cls closure for @a cont
369 * @return a GNUNET_TRANSPORT_OfferHelloHandle handle or NULL on failure,
370 * in case of failure @a cont will not be called
373 struct GNUNET_TRANSPORT_OfferHelloHandle *
374 GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
375 const struct GNUNET_MessageHeader *hello,
376 GNUNET_SCHEDULER_TaskCallback cont,
381 * Cancel the request to transport to offer the HELLO message
383 * @param ohh the `struct GNUNET_TRANSPORT_OfferHelloHandle` to cancel
386 GNUNET_TRANSPORT_offer_hello_cancel (struct GNUNET_TRANSPORT_OfferHelloHandle *ohh);
389 /* *********************** Address to String ******************* */
392 * Handle to cancel a pending address lookup.
394 struct GNUNET_TRANSPORT_AddressToStringContext;
398 * Function to call with a textual representation of an address. This
399 * function will be called several times with different possible
400 * textual representations, and a last time with @a address being NULL
401 * to signal the end of the iteration. Note that @a address NULL
402 * always is the last call, regardless of the value in @a res.
405 * @param address NULL on end of iteration,
406 * otherwise 0-terminated printable UTF-8 string,
407 * in particular an empty string if @a res is #GNUNET_NO
408 * @param res result of the address to string conversion:
409 * if #GNUNET_OK: conversion successful
410 * if #GNUNET_NO: address was invalid (or not supported)
411 * if #GNUNET_SYSERR: communication error (IPC error)
414 (*GNUNET_TRANSPORT_AddressToStringCallback) (void *cls,
420 * Convert a binary address into a human readable address.
422 * @param cfg configuration to use
423 * @param address address to convert (binary format)
424 * @param numeric should (IP) addresses be displayed in numeric form
425 * (otherwise do reverse DNS lookup)
426 * @param timeout how long is the lookup allowed to take at most
427 * @param aluc function to call with the results
428 * @param aluc_cls closure for @a aluc
429 * @return handle to cancel the operation, NULL on error
431 struct GNUNET_TRANSPORT_AddressToStringContext *
432 GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cfg,
433 const struct GNUNET_HELLO_Address *address,
435 struct GNUNET_TIME_Relative timeout,
436 GNUNET_TRANSPORT_AddressToStringCallback aluc,
441 * Cancel request for address conversion.
443 * @param pic the context handle
446 GNUNET_TRANSPORT_address_to_string_cancel (struct GNUNET_TRANSPORT_AddressToStringContext *pic);
449 /* *********************** Monitoring ************************** */
453 * Possible state of a neighbour. Initially, we are #GNUNET_TRANSPORT_PS_NOT_CONNECTED.
455 * Then, there are two main paths. If we receive a SYN message, we give
456 * the inbound address to ATS. After the check we ask ATS for a suggestion
457 * (#GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS). If ATS makes a suggestion, we
458 * send our SYN_ACK and go to #GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK.
459 * If we receive a ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED
460 * (and notify everyone about the new connection). If the operation times out,
461 * we go to #GNUNET_TRANSPORT_PS_DISCONNECT.
463 * The other case is where we transmit a SYN message first. We
464 * start with #GNUNET_TRANSPORT_PS_INIT_ATS. If we get an address, we send
465 * the SYN message and go to state #GNUNET_TRANSPORT_PS_CONNECT_SENT.
466 * Once we receive a SYN_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED
467 * (and notify everyone about the new connection and send
468 * back a ACK). If the operation times out, we go to
469 * #GNUNET_TRANSPORT_PS_DISCONNECT.
471 * If the session is in trouble (i.e. transport-level disconnect or
472 * timeout), we go to #GNUNET_TRANSPORT_PS_RECONNECT_ATS where we ask ATS for a new
473 * address (we don't notify anyone about the disconnect yet). Once we
474 * have a new address, we enter #GNUNET_TRANSPORT_PS_RECONNECT_SENT and send a
475 * SYN message. If we receive a
476 * SYN_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED and nobody noticed that we had
477 * trouble; we also send a ACK at this time just in case. If
478 * the operation times out, we go to #GNUNET_TRANSPORT_PS_DISCONNECT (and notify everyone
479 * about the lost connection).
481 * If ATS decides to switch addresses while we have a normal
482 * connection, we go to #GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT
483 * and send a SESSION_CONNECT. If we get a ACK back, we switch the
484 * primary connection to the suggested alternative from ATS, go back
485 * to #GNUNET_TRANSPORT_PS_CONNECTED and send a ACK to the other peer just to be
486 * sure. If the operation times out
487 * we go to #GNUNET_TRANSPORT_PS_CONNECTED (and notify ATS that the given alternative
488 * address is "invalid").
490 * Once a session is in #GNUNET_TRANSPORT_PS_DISCONNECT, it is cleaned up and then goes
491 * to (#GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED). If we receive an explicit disconnect
492 * request, we can go from any state to #GNUNET_TRANSPORT_PS_DISCONNECT, possibly after
493 * generating disconnect notifications.
495 * Note that it is quite possible that while we are in any of these
496 * states, we could receive a 'SYN' request from the other peer.
497 * We then enter a 'weird' state where we pursue our own primary state
498 * machine (as described above), but with the 'send_connect_ack' flag
499 * set to 1. If our state machine allows us to send a 'SYN_ACK'
500 * (because we have an acceptable address), we send the 'SYN_ACK'
501 * and set the 'send_connect_ack' to 2. If we then receive a
502 * 'ACK', we go to #GNUNET_TRANSPORT_PS_CONNECTED (and reset 'send_connect_ack'
506 enum GNUNET_TRANSPORT_PeerState
509 * Fresh peer or completely disconnected
511 GNUNET_TRANSPORT_PS_NOT_CONNECTED = 0,
514 * Asked to initiate connection, trying to get address from ATS
516 GNUNET_TRANSPORT_PS_INIT_ATS,
519 * Sent SYN message to other peer, waiting for SYN_ACK
521 GNUNET_TRANSPORT_PS_SYN_SENT,
524 * Received a SYN, asking ATS about address suggestions.
526 GNUNET_TRANSPORT_PS_SYN_RECV_ATS,
529 * SYN request from other peer was SYN_ACK'ed, waiting for ACK.
531 GNUNET_TRANSPORT_PS_SYN_RECV_ACK,
534 * Got our SYN_ACK/ACK, connection is up.
536 GNUNET_TRANSPORT_PS_CONNECTED,
539 * Connection got into trouble, rest of the system still believes
540 * it to be up, but we're getting a new address from ATS.
542 GNUNET_TRANSPORT_PS_RECONNECT_ATS,
545 * Sent SYN over new address (either by ATS telling us to switch
546 * addresses or from RECONNECT_ATS); if this fails, we need to tell
547 * the rest of the system about a disconnect.
549 GNUNET_TRANSPORT_PS_RECONNECT_SENT,
552 * We have some primary connection, but ATS suggested we switch
553 * to some alternative; we now sent a SYN message for the
554 * alternative session to the other peer and waiting for a
555 * SYN_ACK to make this our primary connection.
557 GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT,
560 * Disconnect in progress (we're sending the DISCONNECT message to the
561 * other peer; after that is finished, the state will be cleaned up).
563 GNUNET_TRANSPORT_PS_DISCONNECT,
566 * We're finished with the disconnect; and are cleaning up the state
567 * now! We put the struct into this state when we are really in the
568 * task that calls 'free' on it and are about to remove the record
569 * from the map. We should never find a 'struct NeighbourMapEntry'
570 * in this state in the map. Accessing a 'struct NeighbourMapEntry'
571 * in this state virtually always means using memory that has been
572 * freed (the exception being the cleanup code in #free_neighbour()).
574 GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED
579 * Convert a transport state to a human readable string.
581 * @param state the state
584 GNUNET_TRANSPORT_ps2s (enum GNUNET_TRANSPORT_PeerState state);
588 * Check if a state is defined as connected
590 * @param state the state value
591 * @return #GNUNET_YES or #GNUNET_NO
594 GNUNET_TRANSPORT_is_connected (enum GNUNET_TRANSPORT_PeerState state);
598 * Handle for a #GNUNET_TRANSPORT_monitor_peers operation.
600 struct GNUNET_TRANSPORT_PeerMonitoringContext;
604 * Function to call with information about a peer
606 * If one_shot was set to #GNUNET_YES to iterate over all peers once,
607 * a final call with NULL for peer and address will follow when done.
608 * In this case state and timeout do not contain valid values.
610 * The #GNUNET_TRANSPORT_monitor_peers_cancel() call MUST not be called from
611 * within this function!
615 * @param peer peer this update is about,
616 * NULL if this is the final last callback for a iteration operation
617 * @param address address, NULL if this is the final callback for iteration op
618 * @param state current state this peer is in
619 * @param state_timeout timeout for the current state of the peer
622 (*GNUNET_TRANSPORT_PeerIterateCallback) (void *cls,
623 const struct GNUNET_PeerIdentity *peer,
624 const struct GNUNET_HELLO_Address *address,
625 enum GNUNET_TRANSPORT_PeerState state,
626 struct GNUNET_TIME_Absolute state_timeout);
630 * Return information about a specific peer or all peers currently known to
631 * transport service once or in monitoring mode. To obtain information about
632 * a specific peer, a peer identity can be passed. To obtain information about
633 * all peers currently known to transport service, NULL can be passed as peer
636 * For each peer, the callback is called with information about the address used
637 * to communicate with this peer, the state this peer is currently in and the
638 * the current timeout for this state.
640 * Upon completion, the #GNUNET_TRANSPORT_PeerIterateCallback is called one
641 * more time with `NULL`. After this, the operation must no longer be
642 * explicitly canceled.
644 * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called in the
647 * @param cfg configuration to use
648 * @param peer a specific peer identity to obtain information for,
650 * @param one_shot #GNUNET_YES to return the current state and then end (with NULL+NULL),
651 * #GNUNET_NO to monitor peers continuously
652 * @param timeout how long is the lookup allowed to take at most
653 * @param peer_callback function to call with the results
654 * @param peer_callback_cls closure for @a peer_callback
656 struct GNUNET_TRANSPORT_PeerMonitoringContext *
657 GNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
658 const struct GNUNET_PeerIdentity *peer,
660 struct GNUNET_TIME_Relative timeout,
661 GNUNET_TRANSPORT_PeerIterateCallback peer_callback,
662 void *peer_callback_cls);
666 * Cancel request to monitor peers
668 * @param pic handle for the request to cancel
671 GNUNET_TRANSPORT_monitor_peers_cancel (struct GNUNET_TRANSPORT_PeerMonitoringContext *pic);
675 * Handle for a #GNUNET_TRANSPORT_monitor_validation_entries() operation.
677 struct GNUNET_TRANSPORT_ValidationMonitoringContext;
681 * Current state of a validation process.
683 * FIXME: what state is used to indicate that a validation
684 * was successful? If that is clarified/determined, "UGH" in
685 * ~gnunet-peerinfo-gtk.c:1103 should be resolved.
687 enum GNUNET_TRANSPORT_ValidationState
692 * Used for final callback indicating operation done
694 GNUNET_TRANSPORT_VS_NONE,
697 * Fresh validation entry
699 * Entry was just created, no validation process was executed
701 GNUNET_TRANSPORT_VS_NEW,
704 * Updated validation entry
706 * This is an update for an existing validation entry
708 GNUNET_TRANSPORT_VS_UPDATE,
711 * Timeout for validation entry
713 * A timeout occured during the validation process
715 GNUNET_TRANSPORT_VS_TIMEOUT,
718 * Validation entry is removed
720 * The validation entry is getting removed due to a failed validation
722 GNUNET_TRANSPORT_VS_REMOVE
727 * Function to call with validation information about a peer
729 * This function is called by the transport validation monitoring api to
730 * indicate a change to a validation entry. The information included represent
731 * the current state of the validation entry,
733 * If the monitoring was called with `one_shot==GNUNET_YES`, a final callback
734 * with `address==NULL` is executed.
737 * @param address address this update is about,
738 * NULL if this is the final last callback for a iteration operation
739 * @param last_validation when was this address last validated
740 * @param valid_until when does this address expire
741 * @param next_validation time of the next validation operation
742 * @param state state in the validation state machine
745 (*GNUNET_TRANSPORT_ValidationIterateCallback) (void *cls,
746 const struct GNUNET_HELLO_Address *address,
747 struct GNUNET_TIME_Absolute last_validation,
748 struct GNUNET_TIME_Absolute valid_until,
749 struct GNUNET_TIME_Absolute next_validation,
750 enum GNUNET_TRANSPORT_ValidationState state);
754 * Convert validation state to human-readable string.
756 * @param state the state value
757 * @return corresponding string
760 GNUNET_TRANSPORT_vs2s (enum GNUNET_TRANSPORT_ValidationState state);
764 * Return information about pending address validation operations for a specific
767 * @param cfg configuration to use
768 * @param peer a specific peer identity to obtain validation entries for,
770 * @param one_shot #GNUNET_YES to return all entries and then end (with NULL+NULL),
771 * #GNUNET_NO to monitor validation entries continuously
772 * @param timeout how long is the lookup allowed to take at most
773 * @param validation_callback function to call with the results
774 * @param validation_callback_cls closure for @a validation_callback
776 struct GNUNET_TRANSPORT_ValidationMonitoringContext *
777 GNUNET_TRANSPORT_monitor_validation_entries (const struct GNUNET_CONFIGURATION_Handle *cfg,
778 const struct GNUNET_PeerIdentity *peer,
780 struct GNUNET_TIME_Relative timeout,
781 GNUNET_TRANSPORT_ValidationIterateCallback validation_callback,
782 void *validation_callback_cls);
786 * Return information about all current pending validation operations
788 * @param vic handle for the request to cancel
791 GNUNET_TRANSPORT_monitor_validation_entries_cancel (struct GNUNET_TRANSPORT_ValidationMonitoringContext *vic);
794 /* *********************** Blacklisting ************************ */
797 * Handle for blacklisting peers.
799 struct GNUNET_TRANSPORT_Blacklist;
803 * Function that decides if a connection is acceptable or not.
806 * @param pid peer to approve or disapproave
807 * @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not
810 (*GNUNET_TRANSPORT_BlacklistCallback) (void *cls,
811 const struct GNUNET_PeerIdentity *pid);
815 * Install a blacklist callback. The service will be queried for all
816 * existing connections as well as any fresh connections to check if
817 * they are permitted. If the blacklisting callback is unregistered,
818 * all hosts that were denied in the past will automatically be
819 * whitelisted again. Cancelling the blacklist handle is also the
820 * only way to re-enable connections from peers that were previously
823 * @param cfg configuration to use
824 * @param cb callback to invoke to check if connections are allowed
825 * @param cb_cls closure for @a cb
826 * @return NULL on error, otherwise handle for cancellation
828 struct GNUNET_TRANSPORT_Blacklist *
829 GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg,
830 GNUNET_TRANSPORT_BlacklistCallback cb,
835 * Abort the blacklist. Note that this function is the only way for
836 * removing a peer from the blacklist.
838 * @param br handle of the request that is to be cancelled
841 GNUNET_TRANSPORT_blacklist_cancel (struct GNUNET_TRANSPORT_Blacklist *br);
845 * Handle for a plugin session state monitor.
847 struct GNUNET_TRANSPORT_PluginMonitor;
850 * Abstract representation of a plugin's session.
851 * Corresponds to the `struct GNUNET_ATS_Session` within the TRANSPORT service.
853 struct GNUNET_TRANSPORT_PluginSession;
857 * Possible states of a session in a plugin.
859 enum GNUNET_TRANSPORT_SessionState
863 * The session was created (first call for each session object).
865 GNUNET_TRANSPORT_SS_INIT,
868 * Initial session handshake is in progress.
870 GNUNET_TRANSPORT_SS_HANDSHAKE,
873 * Session is fully UP.
875 GNUNET_TRANSPORT_SS_UP,
878 * This is just an update about the session,
879 * the state did not change.
881 GNUNET_TRANSPORT_SS_UPDATE,
884 * Session is being torn down and about to disappear.
885 * Last call for each session object.
887 GNUNET_TRANSPORT_SS_DONE
893 * Information about a plugin's session.
895 struct GNUNET_TRANSPORT_SessionInfo
899 * New state of the session.
901 enum GNUNET_TRANSPORT_SessionState state;
904 * #GNUNET_YES if this is an inbound connection,
905 * #GNUNET_NO if this is an outbound connection,
906 * #GNUNET_SYSERR if connections of this plugin
907 * are so fundamentally bidirectional
908 * that they have no 'initiator'
913 * Number of messages pending transmission for this session.
915 uint32_t num_msg_pending;
918 * Number of bytes pending transmission for this session.
920 uint32_t num_bytes_pending;
923 * Until when does this plugin refuse to receive to manage
924 * staying within the inbound quota? ZERO if receive is
927 struct GNUNET_TIME_Absolute receive_delay;
930 * At what time will this session timeout (unless activity
933 struct GNUNET_TIME_Absolute session_timeout;
936 * Address used by the session. Can be NULL if none is available.
938 const struct GNUNET_HELLO_Address *address;
943 * Function called by the plugin with information about the
944 * current sessions managed by the plugin (for monitoring).
947 * @param session session handle this information is about,
948 * NULL to indicate that we are "in sync" (initial
949 * iteration complete)
950 * @param session_ctx storage location where the application
951 * can store data; will point to NULL on #GNUNET_TRANSPORT_SS_INIT,
952 * and must be reset to NULL on #GNUNET_TRANSPORT_SS_DONE
953 * @param info information about the state of the session,
954 * NULL if @a session is also NULL and we are
955 * merely signalling that the initial iteration is over;
956 * NULL with @a session being non-NULL if the monitor
957 * was being cancelled while sessions were active
960 (*GNUNET_TRANSPORT_SessionMonitorCallback) (void *cls,
961 struct GNUNET_TRANSPORT_PluginSession *session,
963 const struct GNUNET_TRANSPORT_SessionInfo *info);
967 * Install a plugin session state monitor callback. The callback
968 * will be notified whenever the session changes.
970 * @param cfg configuration to use
971 * @param cb callback to invoke on events
972 * @param cb_cls closure for @a cb
973 * @return NULL on error, otherwise handle for cancellation
975 struct GNUNET_TRANSPORT_PluginMonitor *
976 GNUNET_TRANSPORT_monitor_plugins (const struct GNUNET_CONFIGURATION_Handle *cfg,
977 GNUNET_TRANSPORT_SessionMonitorCallback cb,
982 * Cancel monitoring the plugin session state. The callback will be
983 * called once for each session that is up with the "info" argument
984 * being NULL (this is just to enable client-side cleanup).
986 * @param pm handle of the request that is to be cancelled
989 GNUNET_TRANSPORT_monitor_plugins_cancel (struct GNUNET_TRANSPORT_PluginMonitor *pm);
993 #if 0 /* keep Emacsens' auto-indent happy */
1000 /* ifndef GNUNET_TRANSPORT_SERVICE_H */
1002 /* end of gnunet_transport_service.h */