[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32154 - in gnunet/src: include transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32154 - in gnunet/src: include transport |
Date: |
Sun, 2 Feb 2014 18:51:46 +0100 |
Author: grothoff
Date: 2014-02-02 18:51:46 +0100 (Sun, 02 Feb 2014)
New Revision: 32154
Modified:
gnunet/src/include/gnunet_bandwidth_lib.h
gnunet/src/include/gnunet_transport_service.h
gnunet/src/transport/transport_api.c
Log:
add API for #3296
Modified: gnunet/src/include/gnunet_bandwidth_lib.h
===================================================================
--- gnunet/src/include/gnunet_bandwidth_lib.h 2014-02-02 17:38:22 UTC (rev
32153)
+++ gnunet/src/include/gnunet_bandwidth_lib.h 2014-02-02 17:51:46 UTC (rev
32154)
@@ -59,8 +59,8 @@
*
* @param cls a closure to pass
*/
-void
-typedef (*GNUNET_BANDWIDTH_tracker_update_cb) (void *cls);
+typedef void
+(*GNUNET_BANDWIDTH_tracker_update_cb) (void *cls);
/**
@@ -72,8 +72,15 @@
*/
struct GNUNET_BANDWIDTH_Tracker
{
+ /**
+ * Closure for @e update_cb.
+ */
void *update_cb_cls;
+ /**
+ * Function we call if the tracker's bandwidth is increased and a
+ * previously returned timeout might now expire earlier.
+ */
GNUNET_BANDWIDTH_tracker_update_cb update_cb;
/**
Modified: gnunet/src/include/gnunet_transport_service.h
===================================================================
--- gnunet/src/include/gnunet_transport_service.h 2014-02-02 17:38:22 UTC
(rev 32153)
+++ gnunet/src/include/gnunet_transport_service.h 2014-02-02 17:51:46 UTC
(rev 32154)
@@ -366,7 +366,6 @@
* NULL for disconnect notification in monitor mode
* @param valid_until when does this address expire
* @param next_validation time of the next validation operation
- *
*/
typedef void
(*GNUNET_TRANSPORT_ValidationIterateCallback) (void *cls,
@@ -401,6 +400,49 @@
/**
+ * Function called if we have "excess" bandwidth to a peer.
+ * The notification will happen the first time we have excess
+ * bandwidth, and then only again after the client has performed
+ * some transmission to the peer.
+ *
+ * Excess bandwidth is defined as being allowed (by ATS) to send
+ * more data, and us reaching the limit of the capacity build-up
+ * (which, if we go past it, means we don't use available bandwidth).
+ * See also the "max carry" in `struct GNUNET_BANDWIDTH_Tracker`.
+ *
+ * @param cls the closure
+ * @param peer peer that we have excess bandwidth to
+ */
+typedef void
+(*GNUNET_TRANSPORT_NotifyExcessBandwidth)(void *cls,
+ const struct GNUNET_PeerIdentity
*neighbour);
+
+
+/**
+ * Connect to the transport service. Note that the connection may
+ * complete (or fail) asynchronously.
+ *
+ * @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, or NULL
+ * @param nc function to call on connect events, or NULL
+ * @param nd function to call on disconnect events, or NULL
+ * @param neb function to call if we have excess bandwidth to a peer
+ * @return NULL on error
+ */
+struct GNUNET_TRANSPORT_Handle *
+GNUNET_TRANSPORT_connect2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const struct GNUNET_PeerIdentity *self,
+ void *cls,
+ GNUNET_TRANSPORT_ReceiveCallback rec,
+ GNUNET_TRANSPORT_NotifyConnect nc,
+ GNUNET_TRANSPORT_NotifyDisconnect nd,
+ GNUNET_TRANSPORT_NotifyExcessBandwidth neb);
+
+
+/**
* Disconnect from the transport service.
*
* @param handle handle returned from connect
Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c 2014-02-02 17:38:22 UTC (rev
32153)
+++ gnunet/src/transport/transport_api.c 2014-02-02 17:51:46 UTC (rev
32154)
@@ -268,6 +268,11 @@
GNUNET_TRANSPORT_NotifyDisconnect nd_cb;
/**
+ * function to call on excess bandwidth events
+ */
+ GNUNET_TRANSPORT_NotifyExcessBandwidth neb_cb;
+
+ /**
* Head of DLL of control messages.
*/
struct GNUNET_TRANSPORT_TransmitHandle *control_head;
@@ -1505,6 +1510,7 @@
* @param rec receive function to call
* @param nc function to call on connect events
* @param nd function to call on disconnect events
+ * @return NULL on error
*/
struct GNUNET_TRANSPORT_Handle *
GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
@@ -1513,6 +1519,33 @@
GNUNET_TRANSPORT_NotifyConnect nc,
GNUNET_TRANSPORT_NotifyDisconnect nd)
{
+ return GNUNET_TRANSPORT_connect2 (cfg, self, cls,
+ rec, nc, nd, NULL);
+}
+
+
+/**
+ * Connect to the transport service. Note that the connection may
+ * complete (or fail) asynchronously.
+ *
+ * @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 nd function to call on disconnect events
+ * @param neb function to call if we have excess bandwidth to a peer
+ * @return NULL on error
+ */
+struct GNUNET_TRANSPORT_Handle *
+GNUNET_TRANSPORT_connect2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const struct GNUNET_PeerIdentity *self, void *cls,
+ GNUNET_TRANSPORT_ReceiveCallback rec,
+ GNUNET_TRANSPORT_NotifyConnect nc,
+ GNUNET_TRANSPORT_NotifyDisconnect nd,
+ GNUNET_TRANSPORT_NotifyExcessBandwidth neb)
+{
struct GNUNET_TRANSPORT_Handle *ret;
ret = GNUNET_new (struct GNUNET_TRANSPORT_Handle);
@@ -1526,6 +1559,7 @@
ret->rec = rec;
ret->nc_cb = nc;
ret->nd_cb = nd;
+ ret->neb_cb = neb;
ret->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Connecting to transport service.\n");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32154 - in gnunet/src: include transport,
gnunet <=