aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-03-28 13:49:14 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-03-28 13:49:14 +0000
commitff71fa2f71ad29c1972efd0e57937459a0976389 (patch)
treeb3d6741a74d8f923277538e5a82a88449734ad50 /src
parent80a7c5fe311c13c34411440a98d6d0398c7d3fe6 (diff)
downloadgnunet-ff71fa2f71ad29c1972efd0e57937459a0976389.tar.gz
gnunet-ff71fa2f71ad29c1972efd0e57937459a0976389.zip
docu
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-service-transport.c2
-rw-r--r--src/transport/gnunet-service-transport_manipulation.c37
-rw-r--r--src/transport/gnunet-service-transport_manipulation.h40
3 files changed, 67 insertions, 12 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index c8d688407..be0371a6a 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -692,7 +692,7 @@ key_generation_cb (void *cls,
692 GST_blacklist_start (GST_server, GST_cfg, &GST_my_identity); 692 GST_blacklist_start (GST_server, GST_cfg, &GST_my_identity);
693 GST_ats = 693 GST_ats =
694 GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, NULL); 694 GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, NULL);
695 GST_manipulation_init (GST_cfg, &plugin_env_update_metrics); 695 GST_manipulation_init (GST_cfg);
696 GST_plugins_load (&GST_manipulation_recv, 696 GST_plugins_load (&GST_manipulation_recv,
697 &plugin_env_address_change_notification, 697 &plugin_env_address_change_notification,
698 &plugin_env_session_end, 698 &plugin_env_session_end,
diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c
index e8f64f6cf..145ffc078 100644
--- a/src/transport/gnunet-service-transport_manipulation.c
+++ b/src/transport/gnunet-service-transport_manipulation.c
@@ -52,8 +52,6 @@ struct GST_ManipulationHandle
52{ 52{
53 struct GNUNET_CONTAINER_MultiHashMap *peers; 53 struct GNUNET_CONTAINER_MultiHashMap *peers;
54 54
55 GNUNET_TRANSPORT_UpdateAddressMetrics metric_update_cb;
56
57 /** 55 /**
58 * General inbound delay 56 * General inbound delay
59 */ 57 */
@@ -290,6 +288,17 @@ send_delayed (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
290 GNUNET_free (dqe); 288 GNUNET_free (dqe);
291} 289}
292 290
291
292/**
293 * Adapter function between transport's send function and transport plugins
294 *
295 * @param target the peer the message to send to
296 * @param msg the message received
297 * @param msg_size message size
298 * @param timeout timeout
299 * @param cont the continuation to call after sending
300 * @param cont_cls cls for continuation
301 */
293void 302void
294GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg, 303GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg,
295 size_t msg_size, struct GNUNET_TIME_Relative timeout, 304 size_t msg_size, struct GNUNET_TIME_Relative timeout,
@@ -393,6 +402,19 @@ GST_manipulation_manipulate_metrics (const struct GNUNET_PeerIdentity *peer,
393 return ats_new; 402 return ats_new;
394} 403}
395 404
405
406/**
407 * Adapter function between transport plugins and transport receive function
408 * manipulation delays for next send.
409 *
410 * @param cls the closure for transport
411 * @param peer the peer the message was received from
412 * @param message the message received
413 * @param session the session the message was received on
414 * @param sender_address the sender address
415 * @param sender_address_len the length of the sender address
416 * @return manipulated delay for next receive
417 */
396struct GNUNET_TIME_Relative 418struct GNUNET_TIME_Relative
397GST_manipulation_recv (void *cls, 419GST_manipulation_recv (void *cls,
398 const struct GNUNET_PeerIdentity *peer, 420 const struct GNUNET_PeerIdentity *peer,
@@ -426,12 +448,15 @@ GST_manipulation_recv (void *cls,
426 return m_delay; 448 return m_delay;
427} 449}
428 450
451
452/**
453 * Initialize traffic manipulation
454 *
455 * @param GST_cfg configuration handle
456 */
429void 457void
430GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg, 458GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg)
431 GNUNET_TRANSPORT_UpdateAddressMetrics metric_update_cb)
432{ 459{
433 man_handle.metric_update_cb = metric_update_cb;
434
435 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg, 460 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg,
436 "transport", "MANIPULATE_DISTANCE_IN", &man_handle.distance_recv)) 461 "transport", "MANIPULATE_DISTANCE_IN", &man_handle.distance_recv))
437 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting inbound distance_in to %u\n", 462 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting inbound distance_in to %u\n",
diff --git a/src/transport/gnunet-service-transport_manipulation.h b/src/transport/gnunet-service-transport_manipulation.h
index e9bfeddb6..091062459 100644
--- a/src/transport/gnunet-service-transport_manipulation.h
+++ b/src/transport/gnunet-service-transport_manipulation.h
@@ -41,11 +41,34 @@ void
41GST_manipulation_set_metric (void *cls, struct GNUNET_SERVER_Client *client, 41GST_manipulation_set_metric (void *cls, struct GNUNET_SERVER_Client *client,
42 const struct GNUNET_MessageHeader *message); 42 const struct GNUNET_MessageHeader *message);
43 43
44/**
45 * Adapter function between transport's send function and transport plugins
46 *
47 * @param target the peer the message to send to
48 * @param msg the message received
49 * @param msg_size message size
50 * @param timeout timeout
51 * @param cont the continuation to call after sending
52 * @param cont_cls cls for continuation
53 */
44void 54void
45GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg, 55GST_manipulation_send (const struct GNUNET_PeerIdentity *target,
46 size_t msg_size, struct GNUNET_TIME_Relative timeout, 56 const void *msg, size_t msg_size,
47 GST_NeighbourSendContinuation cont, void *cont_cls); 57 struct GNUNET_TIME_Relative timeout,
58 GST_NeighbourSendContinuation cont, void *cont_cls);
48 59
60/**
61 * Adapter function between transport plugins and transport receive function
62 * manipulation delays for next send.
63 *
64 * @param cls the closure for transport
65 * @param peer the peer the message was received from
66 * @param message the message received
67 * @param session the session the message was received on
68 * @param sender_address the sender address
69 * @param sender_address_len the length of the sender address
70 * @return manipulated delay for next receive
71 */
49struct GNUNET_TIME_Relative 72struct GNUNET_TIME_Relative
50GST_manipulation_recv (void *cls, 73GST_manipulation_recv (void *cls,
51 const struct GNUNET_PeerIdentity *peer, 74 const struct GNUNET_PeerIdentity *peer,
@@ -71,10 +94,17 @@ GST_manipulation_manipulate_metrics (const struct GNUNET_PeerIdentity *peer,
71 const struct GNUNET_ATS_Information *ats, 94 const struct GNUNET_ATS_Information *ats,
72 uint32_t ats_count); 95 uint32_t ats_count);
73 96
97/**
98 * Initialize traffic manipulation
99 *
100 * @param GST_cfg configuration handle
101 */
74void 102void
75GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg, 103GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg);
76 GNUNET_TRANSPORT_UpdateAddressMetrics metric_update_cb);
77 104
105/**
106 * Stop traffic manipulation
107 */
78void 108void
79GST_manipulation_stop (); 109GST_manipulation_stop ();
80 110