- modified transport plugin interface to support ATS
authorMatthias Wachs <wachs@net.in.tum.de>
Mon, 6 Dec 2010 17:43:49 +0000 (17:43 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Mon, 6 Dec 2010 17:43:49 +0000 (17:43 +0000)
- modified transport plugins to support ATS

src/include/gnunet_transport_plugin.h
src/transport/gnunet-service-transport.c
src/transport/plugin_transport_http.c
src/transport/plugin_transport_tcp.c
src/transport/plugin_transport_udp.c
src/transport/plugin_transport_wlan.c
src/transport/test_plugin_transport_http.c
src/transport/test_plugin_transport_https.c

index 31138e8f5711e926420adc0b487021f4d03084f8..79103172f17f375f97681f892797d1bd70b34e3c 100644 (file)
@@ -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);
index a6797aed5b29567e580b78486736a4915a5155ea..e1f6793b23f5cb20515e8776d4b240041a7a7981 100644 (file)
@@ -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; c<ats_count; c++)
+  {
+         if (ntohl(ats[c].type) == GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE)
+         {
+                 distance = ntohl(ats[c].value);
+         }
+  }
+
   if (message != NULL)
     {
       if ( (session != NULL) ||
index d94740654a39e4e77eccc058463d102b48dadc0a..a39893a8643c58ab215b6034ba336a43d99384e4 100644 (file)
@@ -873,9 +873,18 @@ static void mhd_write_mst_cb (void *cls,
               ntohs(message->size),
              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);
 
index 627cb6b9b4da69a5271d52ad2d88981fcd5aa9f3..df442c71f2e68aa9fceec954d2a09cd358344918 100644 (file)
@@ -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);
index 4bf66f206d3ddf6daff5e35ba67677dc3efd2eda..169e161e2fb93ece84d425995575db1bcb4a4b8d 100644 (file)
@@ -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);
   }
 
index de868a427597234a49665b5ba71aacf932641e6d..98caaa4f1bf5c5ab99ebf32fcbf83d06bcfe3f37 100644 (file)
@@ -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)
index 6b6463f1a1ef92d91971935af2a6b3ffb7b03408..3c127a9505102d71c3ce5a1611f06125eea4aedd 100644 (file)
@@ -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);
 
index beda4c749b42d790cdb0e57fde1565499f7e739e..61aea1fa717c38698700b51ca59e8120976d8aa8 100644 (file)
@@ -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);