From 197c25b64e8cf36d25914dccc45247cb7e70f4b3 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Mon, 6 Dec 2010 17:43:49 +0000 Subject: [PATCH] - modified transport plugin interface to support ATS - modified transport plugins to support ATS --- src/include/gnunet_transport_plugin.h | 3 ++- src/transport/gnunet-service-transport.c | 18 +++++++++++++++--- src/transport/plugin_transport_http.c | 21 +++++++++++++++++++-- src/transport/plugin_transport_tcp.c | 10 +++++++++- src/transport/plugin_transport_udp.c | 9 ++++++++- src/transport/plugin_transport_wlan.c | 9 ++++++++- src/transport/test_plugin_transport_http.c | 14 +++++++------- src/transport/test_plugin_transport_https.c | 14 +++++++------- 8 files changed, 75 insertions(+), 23 deletions(-) diff --git a/src/include/gnunet_transport_plugin.h b/src/include/gnunet_transport_plugin.h index 31138e8f5..79103172f 100644 --- a/src/include/gnunet_transport_plugin.h +++ b/src/include/gnunet_transport_plugin.h @@ -111,7 +111,8 @@ typedef struct GNUNET_TIME_Relative (*GNUNET_TRANSPORT_PluginReceiveCallback) (v const struct GNUNET_MessageHeader * message, - uint32_t distance, + const struct GNUNET_TRANSPORT_ATS_Information *ats, + uint32_t ats_count, struct Session *session, const char *sender_address, uint16_t sender_address_len); diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index a6797aed5..e1f6793b2 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -4703,9 +4703,10 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message, static struct GNUNET_TIME_Relative plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, - uint32_t distance, - struct Session *session, - const char *sender_address, + const struct GNUNET_TRANSPORT_ATS_Information *ats, + uint32_t ats_count, + struct Session *session, + const char *sender_address, uint16_t sender_address_len) { struct TransportPlugin *plugin = cls; @@ -4716,6 +4717,8 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_TIME_Relative ret; if (is_blacklisted (peer, plugin)) return GNUNET_TIME_UNIT_FOREVER_REL; + uint32_t distance; + int c; n = find_neighbour (peer); if (n == NULL) @@ -4725,6 +4728,15 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, service_context = service_context->next; GNUNET_assert ((plugin->api->send == NULL) || (service_context != NULL)); peer_address = NULL; + distance = 1; + for (c=0; csize), GNUNET_i2s(&(ps->peercontext)->identity),http_plugin_address_to_string(NULL,ps->addr,ps->addrlen)); #endif + struct GNUNET_TRANSPORT_ATS_Information distance[2]; + distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); + distance[0].value = htonl (1); + distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); + distance[1].value = htonl (0); + delay = pc->plugin->env->receive (ps->peercontext->plugin->env->cls, &pc->identity, - message, 1, ps, + message, + (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, + 2, + ps, NULL, 0); pc->delay = delay; @@ -1576,9 +1585,17 @@ static void curl_receive_mst_cb (void *cls, ntohs(message->size), GNUNET_i2s(&(pc->identity)),http_plugin_address_to_string(NULL,ps->addr,ps->addrlen)); #endif + struct GNUNET_TRANSPORT_ATS_Information distance[2]; + distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); + distance[0].value = htonl (1); + distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); + distance[1].value = htonl (0); + delay = pc->plugin->env->receive (pc->plugin->env->cls, &pc->identity, - message, 1, ps, + message, + (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, 2, + ps, ps->addr, ps->addrlen); diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 627cb6b9b..df442c71f 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -2020,6 +2020,7 @@ delayed_done (void *cls, session->receive_delay_task = GNUNET_SCHEDULER_NO_TASK; delay = session->plugin->env->receive (session->plugin->env->cls, &session->target, + NULL, NULL, 0, session, NULL, 0); @@ -2076,7 +2077,14 @@ handle_tcp_data (void *cls, gettext_noop ("# bytes received via TCP"), ntohs (message->size), GNUNET_NO); - delay = plugin->env->receive (plugin->env->cls, &session->target, message, 1, + struct GNUNET_TRANSPORT_ATS_Information distance[2]; + distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); + distance[0].value = htonl (1); + distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); + distance[1].value = htonl (0); + delay = plugin->env->receive (plugin->env->cls, &session->target, message, + (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, + 2, session, (GNUNET_YES == session->inbound) ? NULL : session->connect_addr, (GNUNET_YES == session->inbound) ? 0 : session->connect_alen); diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 4bf66f206..169e161e2 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -1474,7 +1474,14 @@ udp_demultiplexer(struct Plugin *plugin, struct GNUNET_PeerIdentity *sender, "Sending message type %d to transport!\n", ntohs(currhdr->type)); #endif - plugin->env->receive (plugin->env->cls, sender, currhdr, UDP_DIRECT_DISTANCE, + struct GNUNET_TRANSPORT_ATS_Information distance[2]; + distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); + distance[0].value = htonl (UDP_DIRECT_DISTANCE); + distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); + distance[1].value = htonl (0); + + plugin->env->receive (plugin->env->cls, sender, currhdr, + (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, 2, NULL, sender_addr, fromlen); } diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index de868a427..98caaa4f1 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c @@ -1750,8 +1750,15 @@ wlan_process_helper (void *cls, } } //"receive" the message + struct GNUNET_TRANSPORT_ATS_Information distance[2]; + distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); + distance[0].value = htonl (1); + distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); + distance[1].value = htonl (0); + plugin->env->receive(plugin, &session->target, - temp_hdr, 1, session, session->addr, sizeof(session->addr)); + temp_hdr, (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, 2, + session, session->addr, sizeof(session->addr)); } else if (ntohs(hdr->type) == GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT) diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index 6b6463f1a..3c127a950 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c @@ -505,13 +505,13 @@ static void run_connection_tests( int phase , void * cls); * Recieves messages from plugin, in real world transport */ static struct GNUNET_TIME_Relative -receive (void *cls, - const struct GNUNET_PeerIdentity * peer, - const struct GNUNET_MessageHeader * message, - uint32_t distance, - struct Session *session, - const char *sender_address, - uint16_t sender_address_len) +receive (void *cls, const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_MessageHeader *message, + const struct GNUNET_TRANSPORT_ATS_Information *ats, + uint32_t ats_count, + struct Session *session, + const char *sender_address, + uint16_t sender_address_len) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", GNUNET_i2s(peer), ntohs(message->type), ntohs(message->size),session); diff --git a/src/transport/test_plugin_transport_https.c b/src/transport/test_plugin_transport_https.c index beda4c749..61aea1fa7 100644 --- a/src/transport/test_plugin_transport_https.c +++ b/src/transport/test_plugin_transport_https.c @@ -528,13 +528,13 @@ static void run_connection_tests( int phase , void * cls); * Recieves messages from plugin, in real world transport */ static struct GNUNET_TIME_Relative -receive (void *cls, - const struct GNUNET_PeerIdentity * peer, - const struct GNUNET_MessageHeader * message, - uint32_t distance, - struct Session *session, - const char *sender_address, - uint16_t sender_address_len) +receive (void *cls, const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_MessageHeader *message, + const struct GNUNET_TRANSPORT_ATS_Information *ats, + uint32_t ats_count, + struct Session *session, + const char *sender_address, + uint16_t sender_address_len) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", GNUNET_i2s(peer), ntohs(message->type), ntohs(message->size),session); -- 2.25.1