gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r17435 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r17435 - gnunet/src/transport
Date: Thu, 13 Oct 2011 15:06:01 +0200

Author: wachs
Date: 2011-10-13 15:06:01 +0200 (Thu, 13 Oct 2011)
New Revision: 17435

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/gnunet-service-transport_neighbours.c
   gnunet/src/transport/gnunet-service-transport_validation.c
   gnunet/src/transport/plugin_transport_http.c
   gnunet/src/transport/plugin_transport_tcp.c
   gnunet/src/transport/plugin_transport_udp.c
   gnunet/src/transport/plugin_transport_unix.c
   gnunet/src/transport/plugin_transport_wlan.c
Log:
compile


Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2011-10-13 11:59:13 UTC 
(rev 17434)
+++ gnunet/src/transport/gnunet-service-transport.c     2011-10-13 13:06:01 UTC 
(rev 17435)
@@ -246,7 +246,6 @@
       break;
     }
   }
-  GNUNET_assert ((ats_count > 0) && (ats != NULL));
   /*
      FIXME: this gives an address that might not have been validated to
      ATS for 'selection', which is probably not what we want; this 
@@ -254,9 +253,11 @@
      validation) as 'GNUNET_ATS_address_update' currently ignores
      the expiration given.
   */
-  GNUNET_ATS_address_update (GST_ats, peer, GNUNET_TIME_absolute_get (),       
 /* valid at least until right now... */
-                             plugin_name, session, sender_address,
-                             sender_address_len, ats, ats_count);
+  if ((ats_count > 0) && (ats != NULL))
+    GNUNET_ATS_address_update (GST_ats, peer,
+                               plugin_name, sender_address, sender_address_len,
+                               session,
+                               ats, ats_count);
   return ret;
 }
 
@@ -304,7 +305,7 @@
               "Session %X to peer `%s' ended \n",
               session, GNUNET_i2s (peer));
 #endif
-  GNUNET_ATS_session_destroyed(GST_ats, peer, session);
+  GNUNET_ATS_address_destroyed(GST_ats, peer, NULL, NULL, 0, session);
   GST_neighbours_session_terminated (peer, session);
 }
 
@@ -327,15 +328,32 @@
  */
 static void
 ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer,
-                            const char *plugin_name, struct Session *session,
+                            const char *plugin_name,
                             const void *plugin_addr, size_t plugin_addr_len,
+                            struct Session *session,
                             struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
                             struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
 {
   GST_neighbours_switch_to_address (peer, plugin_name, plugin_addr,
                                     plugin_addr_len, session, NULL, 0);
   GST_neighbours_set_incoming_quota (peer, bandwidth_in);
-  // FIXME: use 'bandwidth_out'!
+
+#if DEBUG_TRANSPORT
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending outbound quota of %u Bps for 
peer `%s' to all clients\n",
+              ntohl (bandwidth_out.value__), GNUNET_i2s (target));
+#endif
+  struct QuotaSetMessage msg;
+  msg.header.size = htons (sizeof (struct QuotaSetMessage));
+  msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA);
+  msg.quota = bandwidth_out;
+  msg.peer = (*peer);
+  GST_clients_broadcast ((struct GNUNET_MessageHeader *) &msg, GNUNET_NO);
+
+#if DEBUG_TRANSPORT
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting inbound quota of %u for peer 
`%s' to \n",
+              ntohl (bandwidth_in.value__), GNUNET_i2s (target));
+#endif
+  GST_neighbours_set_incoming_quota (peer, bandwidth_in);
 }
 
 
@@ -346,7 +364,7 @@
  * @param cls closure
  * @param peer the peer that connected
  * @param ats performance data
- * @param ats_count number of entries in ats (excluding 0-termination)
+ * @param ats_count number of entries in ats
  */
 static void
 neighbours_connect_notification (void *cls,
@@ -357,16 +375,13 @@
   char buf[sizeof (struct ConnectInfoMessage) +
            ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)];
   struct ConnectInfoMessage *connect_msg = (struct ConnectInfoMessage *) buf;
-  struct GNUNET_TRANSPORT_ATS_Information *atsm = &connect_msg->ats;
 
   connect_msg->header.size = htons (sizeof (buf));
   connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
   connect_msg->ats_count = htonl (ats_count);
   connect_msg->id = *peer;
-  memcpy (&connect_msg->ats, ats,
+  memcpy (&connect_msg->ats, &connect_msg->ats,
           ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information));
-  atsm[ats_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
-  atsm[ats_count].value = htonl (0);
   GST_clients_broadcast (&connect_msg->header, GNUNET_NO);
 }
 
@@ -405,7 +420,7 @@
   GST_validation_stop ();
   GST_plugins_unload ();
   GST_neighbours_stop ();
-  GNUNET_ATS_shutdown (GST_ats);
+  GNUNET_ATS_scheduling_done (GST_ats);
   GST_ats = NULL;
   GST_clients_stop ();
   GST_blacklist_stop ();
@@ -484,7 +499,7 @@
   GST_plugins_load (&plugin_env_receive_callback,
                     &plugin_env_address_change_notification,
                     &plugin_env_session_end);
-  GST_ats = GNUNET_ATS_init (GST_cfg, &ats_request_address_change, NULL);
+  GST_ats = GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, 
NULL);
   GST_neighbours_start (NULL, &neighbours_connect_notification,
                         &neighbours_disconnect_notification);
   GST_clients_start (server);

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c  2011-10-13 
11:59:13 UTC (rev 17434)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c  2011-10-13 
13:06:01 UTC (rev 17435)
@@ -191,12 +191,6 @@
   struct MessageQueue *messages_tail;
 
   /**
-   * Context for address suggestion.
-   * NULL after we are connected.
-   */
-  struct GNUNET_ATS_SuggestionContext *asc;
-
-  /**
    * Performance data for the peer.
    */
   struct GNUNET_TRANSPORT_ATS_Information *ats;
@@ -505,11 +499,6 @@
     GNUNET_SCHEDULER_cancel (n->transmission_task);
     n->transmission_task = GNUNET_SCHEDULER_NO_TASK;
   }
-  if (NULL != n->asc)
-  {
-    GNUNET_ATS_suggest_address_cancel (n->asc);
-    n->asc = NULL;
-  }
   GNUNET_array_grow (n->ats, n->ats_count, 0);
   if (NULL != n->plugin_name)
   {
@@ -649,6 +638,7 @@
 {
   struct NeighbourMapEntry *n;
   struct SessionConnectMessage connect_msg;
+  int was_connected;
 
   GNUNET_assert (neighbours != NULL);
 
@@ -660,6 +650,8 @@
     // GNUNET_break (0);
     return;
   }
+  was_connected = n->is_connected;
+  n->is_connected = GNUNET_YES;
 
 #if DEBUG_TRANSPORT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -693,76 +685,18 @@
       GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
   GST_neighbours_send (peer, &connect_msg, sizeof (connect_msg),
                        GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL);
-}
 
-
-/**
- * Try to connect to the target peer using the given address
- *
- * @param cls the 'struct NeighbourMapEntry' of the target
- * @param target identity of the target peer
- * @param plugin_name name of the plugin
- * @param plugin_address binary address
- * @param plugin_address_len length of address
- * @param session session to use
- * @param bandwidth_out available outbound bandwidth
- * @param bandwidth_in available inbound bandwidth
- * @param ats performance data for the address (as far as known)
- * @param ats_count number of performance records in 'ats'
- */
-static void
-try_connect_using_address (void *cls, const struct GNUNET_PeerIdentity *target,
-                           const char *plugin_name, const void *plugin_address,
-                           size_t plugin_address_len, struct Session *session,
-                           struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
-                           struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
-                           const struct GNUNET_TRANSPORT_ATS_Information *ats,
-                           uint32_t ats_count)
-{
-  struct NeighbourMapEntry *n = cls;
-  int was_connected;
-
-  n->asc = NULL;
-  was_connected = n->is_connected;
-  n->is_connected = GNUNET_YES;
-
-  GST_neighbours_switch_to_address (target, plugin_name, plugin_address,
-                                    plugin_address_len, session, ats,
-                                    ats_count);
+  n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task,
+                                                n);
   if (GNUNET_YES == was_connected)
     return;
-  n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task,
-                                               n);
-
-  /* ATS told us inbound quota for this peer */
-#if DEBUG_TRANSPORT
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting inbound quota of %u for peer 
`%s' to \n",
-              ntohl (bandwidth_in.value__), GNUNET_i2s (target));
-#endif
-  GST_neighbours_set_incoming_quota (&n->id, bandwidth_in);
-
   /* First tell clients about connected neighbours...*/
   neighbours_connected++;
   GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
                             GNUNET_NO);
-  connect_notify_cb (callback_cls, target, n->ats, n->ats_count);
-
-  /* ... then send outbound quota for this peer to all clients */
-#if DEBUG_TRANSPORT
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending outbound quota of %u Bps for 
peer `%s' to all clients\n",
-              ntohl (bandwidth_out.value__), GNUNET_i2s (target));
-#endif
-
-  struct QuotaSetMessage msg;
-  msg.header.size = htons (sizeof (struct QuotaSetMessage));
-  msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA);
-  msg.quota = bandwidth_out;
-  msg.peer = (*target);
-  GST_clients_broadcast ((struct GNUNET_MessageHeader *) &msg, GNUNET_NO);
-
+  connect_notify_cb (callback_cls, peer, n->ats, n->ats_count);
 }
 
-
 /**
  * Try to create a connection to the given target (eventually).
  *
@@ -795,9 +729,6 @@
 #endif
     n = GNUNET_malloc (sizeof (struct NeighbourMapEntry));
     n->id = *target;
-    GNUNET_array_grow (n->ats, n->ats_count, 1);
-    n->ats[0].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);;
-    n->ats[0].value = htonl (0);
     GNUNET_BANDWIDTH_tracker_init (&n->in_tracker,
                                    GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
                                    MAX_BANDWIDTH_CARRY_S);
@@ -809,16 +740,12 @@
                                                       &n->id.hashPubKey, n,
                                                       
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
   }
-  if (n->asc != NULL)
-    return;                     /* already trying */
 #if DEBUG_TRANSPORT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Asking ATS for suggested address to connect to peer `%s'\n",
               GNUNET_i2s (target));
 #endif
-  n->asc =
-      GNUNET_ATS_suggest_address (GST_ats, target, &try_connect_using_address,
-                                  n);
+   GNUNET_ATS_suggest_address (GST_ats, target);
 }
 
 
@@ -891,8 +818,7 @@
     //GNUNET_break (0);
     return;
   }
-  n->asc =
-      GNUNET_ATS_suggest_address (GST_ats, peer, &try_connect_using_address, 
n);
+  GNUNET_ATS_suggest_address (GST_ats, peer);
 }
 
 

Modified: gnunet/src/transport/gnunet-service-transport_validation.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_validation.c  2011-10-13 
11:59:13 UTC (rev 17434)
+++ gnunet/src/transport/gnunet-service-transport_validation.c  2011-10-13 
13:06:01 UTC (rev 17435)
@@ -394,7 +394,6 @@
   struct ValidationEntry *ve;
   struct GNUNET_PeerIdentity pid;
   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
-  struct GNUNET_TRANSPORT_ATS_Information ats;
 
   if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0)
     return GNUNET_OK;           /* expired */
@@ -406,10 +405,8 @@
   }
   ve = find_validation_entry (&public_key, &pid, tname, addr, addrlen);
   ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration);
-  ats.type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
-  ats.value = htonl (0);
-  GNUNET_ATS_address_update (GST_ats, &pid, ve->valid_until, tname, NULL, addr,
-                             addrlen, &ats, 1);
+  GNUNET_ATS_address_update (GST_ats, &pid, tname, addr,
+                             addrlen, NULL, NULL, 0);
   return GNUNET_OK;
 }
 
@@ -978,15 +975,13 @@
   /* validity achieved, remember it! */
   ve->valid_until = GNUNET_TIME_relative_to_absolute 
(HELLO_ADDRESS_EXPIRATION);
   {
-    struct GNUNET_TRANSPORT_ATS_Information ats[2];
+    struct GNUNET_TRANSPORT_ATS_Information ats;
 
-    ats[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY);
-    ats[0].value = htonl ((uint32_t) GNUNET_TIME_absolute_get_duration 
(ve->send_time).rel_value);
-    ats[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
-    ats[1].value = htonl (0);
-    GNUNET_ATS_address_update (GST_ats, &ve->pid, ve->valid_until, 
-                              ve->transport_name, NULL, ve->addr, ve->addrlen, 
-                              ats, 2);
+    ats.type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY);
+    ats.value = htonl ((uint32_t) GNUNET_TIME_absolute_get_duration 
(ve->send_time).rel_value);
+    GNUNET_ATS_address_update (GST_ats, &ve->pid,
+                              ve->transport_name,ve->addr, ve->addrlen, NULL,
+                              &ats, 1);
   }
   
   /* build HELLO to store in PEERINFO */

Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c        2011-10-13 11:59:13 UTC 
(rev 17434)
+++ gnunet/src/transport/plugin_transport_http.c        2011-10-13 13:06:01 UTC 
(rev 17435)
@@ -257,15 +257,13 @@
 {
   struct Session *s = cls;
   struct Plugin *plugin = s->plugin;
-  struct GNUNET_TRANSPORT_ATS_Information distance[2];
+  struct GNUNET_TRANSPORT_ATS_Information distance;
   struct GNUNET_TIME_Relative delay;
 
-  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);
+  distance.type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
+  distance.value = htonl (1);
 
-  delay = plugin->env->receive (plugin->env->cls, &s->target, message, (const 
struct GNUNET_TRANSPORT_ATS_Information*) &distance, 2, s, s->addr, s->addrlen);
+  delay = plugin->env->receive (plugin->env->cls, &s->target, message, (const 
struct GNUNET_TRANSPORT_ATS_Information*) &distance, 1, s, s->addr, s->addrlen);
   return delay;
 }
 

Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2011-10-13 11:59:13 UTC (rev 
17434)
+++ gnunet/src/transport/plugin_transport_tcp.c 2011-10-13 13:06:01 UTC (rev 
17435)
@@ -1663,13 +1663,10 @@
   struct GNUNET_TIME_Relative delay;
   struct GNUNET_TRANSPORT_ATS_Information ats;
 
-  ats.type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
-  ats.value = htonl (0);
-
   session->receive_delay_task = GNUNET_SCHEDULER_NO_TASK;
   delay =
       session->plugin->env->receive (session->plugin->env->cls,
-                                     &session->target, NULL, &ats, 1, session,
+                                     &session->target, NULL, &ats, 0, session,
                                      NULL, 0);
   if (delay.rel_value == 0)
     GNUNET_SERVER_receive_done (session->client, GNUNET_OK);
@@ -1721,16 +1718,14 @@
   GNUNET_STATISTICS_update (plugin->env->stats,
                             gettext_noop ("# bytes received via TCP"),
                             ntohs (message->size), GNUNET_NO);
-  struct GNUNET_TRANSPORT_ATS_Information distance[2];
+  struct GNUNET_TRANSPORT_ATS_Information distance;
 
-  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);
+  distance.type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
+  distance.value = htonl (1);
   delay =
       plugin->env->receive (plugin->env->cls, &session->target, message,
                             (const struct GNUNET_TRANSPORT_ATS_Information *)
-                            &distance, 2, session,
+                            &distance, 1, session,
                             (GNUNET_YES ==
                              session->inbound) ? NULL : session->connect_addr,
                             (GNUNET_YES ==

Modified: gnunet/src/transport/plugin_transport_udp.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp.c 2011-10-13 11:59:13 UTC (rev 
17434)
+++ gnunet/src/transport/plugin_transport_udp.c 2011-10-13 13:06:01 UTC (rev 
17435)
@@ -759,17 +759,15 @@
 {
   struct Plugin *plugin = cls;
   struct SourceInformation *si = client;
-  struct GNUNET_TRANSPORT_ATS_Information distance[2];
+  struct GNUNET_TRANSPORT_ATS_Information distance;
 
   /* setup ATS */
-  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);
+  distance.type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
+  distance.value = htonl (1);
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
                    "Giving Session %X %s  to transport\n", si->session, 
GNUNET_i2s(&si->session->target));
-  plugin->env->receive (plugin->env->cls, &si->sender, hdr, distance, 2, 
si->session,
+  plugin->env->receive (plugin->env->cls, &si->sender, hdr, &distance, 1, 
si->session,
                         si->arg, si->args);
 }
 

Modified: gnunet/src/transport/plugin_transport_unix.c
===================================================================
--- gnunet/src/transport/plugin_transport_unix.c        2011-10-13 11:59:13 UTC 
(rev 17434)
+++ gnunet/src/transport/plugin_transport_unix.c        2011-10-13 13:06:01 UTC 
(rev 17435)
@@ -719,12 +719,10 @@
                     const struct GNUNET_MessageHeader *currhdr,
                     const struct sockaddr_un *un, size_t fromlen)
 {
-  struct GNUNET_TRANSPORT_ATS_Information distance[2];
+  struct GNUNET_TRANSPORT_ATS_Information distance;
 
-  distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
-  distance[0].value = htonl (UNIX_DIRECT_DISTANCE);
-  distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
-  distance[1].value = htonl (0);
+  distance.type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
+  distance.value = htonl (UNIX_DIRECT_DISTANCE);
 
   GNUNET_assert (fromlen >= sizeof (struct sockaddr_un));
 
@@ -734,7 +732,7 @@
 #endif
   plugin->env->receive (plugin->env->cls, sender, currhdr,
                         (const struct GNUNET_TRANSPORT_ATS_Information *)
-                        &distance, 2, NULL, un->sun_path,
+                        &distance, 1, NULL, un->sun_path,
                         strlen (un->sun_path) + 1);
 }
 

Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c        2011-10-13 11:59:13 UTC 
(rev 17434)
+++ gnunet/src/transport/plugin_transport_wlan.c        2011-10-13 13:06:01 UTC 
(rev 17435)
@@ -2334,12 +2334,10 @@
   struct Session *session = (struct Session *) client;
   struct Plugin *plugin = (struct Plugin *) cls;
 
-  struct GNUNET_TRANSPORT_ATS_Information distance[2];
+  struct GNUNET_TRANSPORT_ATS_Information distance;
 
-  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);
+  distance.type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
+  distance.value = htonl (1);
 
 #if DEBUG_wlan
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
@@ -2352,7 +2350,7 @@
 
   plugin->env->receive (plugin->env->cls, &(session->target), hdr,
                         (const struct GNUNET_TRANSPORT_ATS_Information *)
-                        &distance, 2, session,
+                        &distance, 1, session,
                         (const char *) &session->mac->addr,
                         sizeof (session->mac->addr));
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]