summaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-01-30 14:16:20 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-01-30 14:16:20 +0000
commite34f367380ed951b51895e24d99a81a12899278c (patch)
treef69a83bde0e96cb3def8af1cefa4e7b5548e7bc2 /src/transport
parentff57ba65e29db50bd42e540ba95cb938a5ef8008 (diff)
extending bandwidth tracker api to support notifications
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c20
-rw-r--r--src/transport/plugin_transport_bluetooth.c2
-rw-r--r--src/transport/plugin_transport_udp.c2
-rw-r--r--src/transport/plugin_transport_wlan.c2
-rw-r--r--src/transport/transport_api.c18
5 files changed, 37 insertions, 7 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index b82bd8694..58cb0fbb3 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -1689,6 +1689,15 @@ send_session_connect_ack_message (const struct GNUNET_HELLO_Address *address,
}
+static void
+inbound_bw_tracker_update (void *cls)
+{
+ struct Neighbour *n = cls;
+
+ /* Quota was updated, tell plugins to update the time to receive next */
+
+}
+
/**
* Create a fresh entry in the neighbour map for the given peer
@@ -1712,7 +1721,7 @@ setup_neighbour (const struct GNUNET_PeerIdentity *peer)
n->util_payload_bytes_sent = 0;
n->util_total_bytes_recv = 0;
n->util_total_bytes_sent = 0;
- GNUNET_BANDWIDTH_tracker_init (&n->in_tracker,
+ GNUNET_BANDWIDTH_tracker_init (&n->in_tracker, &inbound_bw_tracker_update, n,
GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
MAX_BANDWIDTH_CARRY_S);
n->task = GNUNET_SCHEDULER_add_now (&master_task, n);
@@ -2535,6 +2544,7 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
{
struct NeighbourMapEntry *n;
+ struct GST_BlacklistCheck *blc;
struct GNUNET_TRANSPORT_PluginFunctions *papi;
struct BlacklistCheckSwitchContext *blc_ctx;
int c;
@@ -2601,8 +2611,11 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
}
GNUNET_CONTAINER_DLL_insert (pending_bc_head, pending_bc_tail, blc_ctx);
- blc_ctx->blc = GST_blacklist_test_allowed (peer, address->transport_name,
- &switch_address_bl_check_cont, blc_ctx);
+ if (NULL != (blc = GST_blacklist_test_allowed (peer, address->transport_name,
+ &switch_address_bl_check_cont, blc_ctx)))
+ {
+ blc_ctx->blc = blc;
+ }
}
@@ -3338,7 +3351,6 @@ GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target)
return test_connected (lookup_neighbour (target));
}
-
/**
* Change the incoming quota for the given peer.
*
diff --git a/src/transport/plugin_transport_bluetooth.c b/src/transport/plugin_transport_bluetooth.c
index 8d751f443..266276730 100644
--- a/src/transport/plugin_transport_bluetooth.c
+++ b/src/transport/plugin_transport_bluetooth.c
@@ -1943,7 +1943,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls)
0, GNUNET_NO);
GNUNET_STATISTICS_set (plugin->env->stats, _("# Bluetooth MAC endpoints allocated"),
0, 0);
- GNUNET_BANDWIDTH_tracker_init (&plugin->tracker,
+ GNUNET_BANDWIDTH_tracker_init (&plugin->tracker, NULL, NULL,
GNUNET_BANDWIDTH_value_init (100 * 1024 *
1024 / 8), 100);
plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index be3f3f8d9..a50aaa436 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -3007,7 +3007,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
p->defrag_ctxs = GNUNET_CONTAINER_heap_create (
GNUNET_CONTAINER_HEAP_ORDER_MIN);
p->mst = GNUNET_SERVER_mst_create (&process_inbound_tokenized_messages, p);
- GNUNET_BANDWIDTH_tracker_init (&p->tracker,
+ GNUNET_BANDWIDTH_tracker_init (&p->tracker, NULL, NULL,
GNUNET_BANDWIDTH_value_init ((uint32_t) udp_max_bps), 30);
plugin = p;
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index e3dd24fdb..36e09fdd7 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -1949,7 +1949,7 @@ libgnunet_plugin_transport_wlan_init (void *cls)
0, GNUNET_NO);
GNUNET_STATISTICS_set (plugin->env->stats, _("# WLAN MAC endpoints allocated"),
0, 0);
- GNUNET_BANDWIDTH_tracker_init (&plugin->tracker,
+ GNUNET_BANDWIDTH_tracker_init (&plugin->tracker, NULL, NULL,
GNUNET_BANDWIDTH_value_init (100 * 1024 *
1024 / 8), 100);
plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index 292aca5f0..ac7c55599 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -419,6 +419,23 @@ neighbour_find (struct GNUNET_TRANSPORT_Handle *h,
}
+
+static void
+outbound_bw_tracker_update (void *cls)
+{
+ struct Neighbour *n = cls;
+ struct GNUNET_TIME_Relative delay;
+ if (NULL == n->hn)
+ return;
+
+ delay = GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker,
+ n->th->notify_size + n->traffic_overhead);
+ GNUNET_CONTAINER_heap_update_cost (n->h->ready_heap,
+ n->hn, delay.rel_value_us);
+ schedule_transmission (n->h);
+}
+
+
/**
* Add neighbour to our list
*
@@ -439,6 +456,7 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h,
n->is_ready = GNUNET_YES;
n->traffic_overhead = 0;
GNUNET_BANDWIDTH_tracker_init (&n->out_tracker,
+ outbound_bw_tracker_update, n,
GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
MAX_BANDWIDTH_CARRY_S);
GNUNET_assert (GNUNET_OK ==