GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
#endif
#endif
+#include "gnunet_bandwidth_lib.h"
#include "gnunet_configuration_lib.h"
#include "gnunet_crypto_lib.h"
-#include "gnunet_network_lib.h"
+#include "gnunet_connection_lib.h"
#include "gnunet_scheduler_lib.h"
#include "gnunet_time_lib.h"
* Function called by the transport for each received message.
*
* @param cls closure
- * @param latency estimated latency for communicating with the
- * given peer
* @param peer (claimed) identity of the other peer
* @param message the message
+ * @param latency estimated latency for communicating with the
+ * given peer (round-trip)
+ * @param distance in overlay hops, as given by transport plugin
*/
typedef void (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls,
- struct GNUNET_TIME_Relative
- latency,
const struct
GNUNET_PeerIdentity * peer,
const struct
GNUNET_MessageHeader *
- message);
+ message,
+ struct GNUNET_TIME_Relative
+ latency,
+ uint32_t distance);
/**
*
* @param cls closure
* @param peer the peer that connected
- * @param latency current latency of the connection
+ * @param latency estimated latency for communicating with the
+ * given peer (round-trip)
+ * @param distance in overlay hops, as given by transport plugin
*/
typedef void
(*GNUNET_TRANSPORT_NotifyConnect) (void *cls,
const struct GNUNET_PeerIdentity * peer,
- struct GNUNET_TIME_Relative latency);
+ struct GNUNET_TIME_Relative latency,
+ uint32_t distance);
/**
* Function called to notify transport users that another
peer);
+/**
+ * Function to call with a human-readable format of an address
+ *
+ * @param cls closure
+ * @param address NULL on error, otherwise 0-terminated printable UTF-8 string
+ */
+typedef void
+(*GNUNET_TRANSPORT_AddressLookUpCallback) (void *cls,
+ const char *address);
+
+
/**
* Connect to the transport service. Note that the connection may
* complete (or fail) asynchronously.
*
* @param sched scheduler to use
* @param cfg configuration to use
+ * @param self our own identity (API should check that it matches
+ * the identity found by transport), or NULL (no check)
* @param cls closure for the callbacks
* @param rec receive function to call
* @param nc function to call on connect events
- * @param dc function to call on disconnect events
+ * @param nd function to call on disconnect events
+ * @return NULL on error
*/
struct GNUNET_TRANSPORT_Handle *GNUNET_TRANSPORT_connect (struct
GNUNET_SCHEDULER_Handle
*sched,
- struct
+ const struct
GNUNET_CONFIGURATION_Handle
- *cfg, void *cls,
+ *cfg,
+ const struct GNUNET_PeerIdentity *self,
+ void *cls,
GNUNET_TRANSPORT_ReceiveCallback
rec,
GNUNET_TRANSPORT_NotifyConnect
/**
* Disconnect from the transport service.
+ *
+ * @param handle handle returned from connect
*/
void GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle);
*
* @param handle connection to transport service
* @param target who's bandwidth quota is being changed
- * @param quota_in incoming bandwidth quota in bytes per ms; 0 can
- * be used to force all traffic to be discarded
- * @param quota_out outgoing bandwidth quota in bytes per ms; 0 can
- * be used to force all traffic to be discarded
+ * @param quota_in incoming bandwidth quota
+ * @param quota_out outgoing bandwidth quota
* @param timeout how long to wait until signaling failure if
* we can not communicate the quota change
* @param cont continuation to call when done, will be called
void
GNUNET_TRANSPORT_set_quota (struct GNUNET_TRANSPORT_Handle *handle,
const struct GNUNET_PeerIdentity *target,
- uint32_t quota_in,
- uint32_t quota_out,
+ struct GNUNET_BANDWIDTH_Value32NBO quota_in,
+ struct GNUNET_BANDWIDTH_Value32NBO quota_out,
struct GNUNET_TIME_Relative timeout,
GNUNET_SCHEDULER_Task cont, void *cont_cls);
/**
* Check if we could queue a message of the given size for
- * transmission. The transport service will take both its
- * internal buffers and bandwidth limits imposed by the
- * other peer into consideration when answering this query.
+ * transmission. The transport service will take both its internal
+ * buffers and bandwidth limits imposed by the other peer into
+ * consideration when answering this query.
*
* @param handle connection to transport service
* @param target who should receive the message
*handle,
const struct GNUNET_PeerIdentity
*target, size_t size,
- unsigned int priority,
+ uint32_t priority,
struct GNUNET_TIME_Relative
timeout,
- GNUNET_NETWORK_TransmitReadyNotify
+ GNUNET_CONNECTION_TransmitReadyNotify
notify, void *notify_cls);
/**
- * Cancel the specified transmission-ready
- * notification.
+ * Cancel the specified transmission-ready notification.
+ *
+ * @param h handle of the transmission notification request to cancel
*/
void
GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct
*h);
+
+/**
+ * Function called whenever there is an update to the
+ * HELLO of this peer.
+ *
+ * @param cls closure
+ * @param hello our updated HELLO
+ */
+typedef void (*GNUNET_TRANSPORT_HelloUpdateCallback)(void *cls,
+ const struct GNUNET_MessageHeader *hello);
+
+
/**
- * Obtain the HELLO message for this peer.
+ * Obtain updates on changes to the HELLO message for this peer.
*
* @param handle connection to transport service
- * @param timeout how long to wait for the HELLO
- * @param rec function to call with the HELLO, sender will be our peer
- * identity; message and sender will be NULL on timeout
- * (handshake with transport service pending/failed).
- * cost estimate will be 0.
+ * @param rec function to call with the HELLO
* @param rec_cls closure for rec
*/
void
GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
- struct GNUNET_TIME_Relative timeout,
- GNUNET_TRANSPORT_ReceiveCallback rec,
+ GNUNET_TRANSPORT_HelloUpdateCallback rec,
void *rec_cls);
+/**
+ * Stop receiving updates about changes to our HELLO message.
+ *
+ * @param handle connection to transport service
+ * @param rec function previously registered to be called with the HELLOs
+ * @param rec_cls closure for rec
+ */
+void
+GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_Handle *handle,
+ GNUNET_TRANSPORT_HelloUpdateCallback rec,
+ void *rec_cls);
+
+
/**
* Offer the transport service the HELLO of another peer. Note that
* the transport service may just ignore this message if the HELLO is
- * malformed or useless due to our local configuration.
+ * malformed or useless due to our local configuration. If the HELLO
+ * is working, we should add it to PEERINFO.
*
* @param handle connection to transport service
* @param hello the hello message
const struct GNUNET_MessageHeader *hello);
+/**
+ * Convert a binary address into a human readable address.
+ *
+ * @param sched scheduler to use
+ * @param cfg configuration to use
+ * @param address address to convert (binary format)
+ * @param addressLen number of bytes in address
+ * @param numeric should (IP) addresses be displayed in numeric form
+ * (otherwise do reverse DNS lookup)
+ * @param nameTrans name of the transport to which the address belongs
+ * @param timeout how long is the lookup allowed to take at most
+ * @param aluc function to call with the results
+ * @param aluc_cls closure for aluc
+ */
+void
+GNUNET_TRANSPORT_address_lookup (struct GNUNET_SCHEDULER_Handle *sched,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char * address,
+ size_t addressLen,
+ int numeric,
+ const char * nameTrans,
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_TRANSPORT_AddressLookUpCallback aluc,
+ void *aluc_cls);
+
+
+
+/**
+ * Handle for blacklisting peers.
+ */
+struct GNUNET_TRANSPORT_Blacklist;
+
+
+/**
+ * Function that decides if a connection is acceptable or not.
+ *
+ * @param cls closure
+ * @param pid peer to approve or disapproave
+ * @return GNUNET_OK if the connection is allowed
+ */
+typedef int (*GNUNET_TRANSPORT_BlacklistCallback)(void *cls,
+ const struct GNUNET_PeerIdentity *pid);
+
+
+/**
+ * Install a blacklist callback. The service will be queried for all
+ * existing connections as well as any fresh connections to check if
+ * they are permitted. If the blacklisting callback is unregistered,
+ * all hosts that were denied in the past will automatically be
+ * whitelisted again. Cancelling the blacklist handle is also the
+ * only way to re-enable connections from peers that were previously
+ * blacklisted.
+ *
+ * @param sched scheduler to use
+ * @param cfg configuration to use
+ * @param cb callback to invoke to check if connections are allowed
+ * @param cb_cls closure for cb
+ * @return NULL on error, otherwise handle for cancellation
+ */
+struct GNUNET_TRANSPORT_Blacklist *
+GNUNET_TRANSPORT_blacklist (struct GNUNET_SCHEDULER_Handle *sched,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ GNUNET_TRANSPORT_BlacklistCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Abort the blacklist. Note that this function is the only way for
+ * removing a peer from the blacklist.
+ *
+ * @param br handle of the request that is to be cancelled
+ */
+void
+GNUNET_TRANSPORT_blacklist_cancel (struct GNUNET_TRANSPORT_Blacklist *br);
+
+
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif