gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r22524 - gnunet/src/transport
Date: Fri, 6 Jul 2012 15:24:20 +0200

Author: wachs
Date: 2012-07-06 15:24:20 +0200 (Fri, 06 Jul 2012)
New Revision: 22524

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/gnunet-service-transport_blacklist.c
   gnunet/src/transport/gnunet-service-transport_clients.c
   gnunet/src/transport/gnunet-service-transport_neighbours.c
   gnunet/src/transport/gnunet-service-transport_neighbours.h
   gnunet/src/transport/transport.h
   gnunet/src/transport/transport_api.c
Log:
- implementation for mantis 0002485


Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2012-07-06 12:57:14 UTC 
(rev 22523)
+++ gnunet/src/transport/gnunet-service-transport.c     2012-07-06 13:24:20 UTC 
(rev 22524)
@@ -90,12 +90,16 @@
  * @param ats performance information (unused)
  * @param ats_count number of records in ats (unused)
  * @param address the address
+ * @param bandwidth_in inbound quota in NBO
+ * @param bandwidth_out outbound quota in NBO
  */
 static void
 transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target,
                     const struct GNUNET_ATS_Information *ats,
                     uint32_t ats_count,
-                    const struct GNUNET_HELLO_Address *address)
+                    const struct GNUNET_HELLO_Address *address,
+                    struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+                    struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
 {
   const struct GNUNET_MessageHeader *hello = cls;
 
@@ -451,7 +455,9 @@
 neighbours_connect_notification (void *cls,
                                  const struct GNUNET_PeerIdentity *peer,
                                  const struct GNUNET_ATS_Information *ats,
-                                 uint32_t ats_count)
+                                 uint32_t ats_count,
+                                 struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_in,
+                                 struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_out)
 {
   size_t len =
       sizeof (struct ConnectInfoMessage) +
@@ -469,6 +475,8 @@
   connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
   connect_msg->ats_count = htonl (ats_count);
   connect_msg->id = *peer;
+  connect_msg->quota_in = bandwidth_in;
+  connect_msg->quota_out = bandwidth_out;
   ap = (struct GNUNET_ATS_Information *) &connect_msg[1];
   memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
   GST_clients_broadcast (&connect_msg->header, GNUNET_NO);

Modified: gnunet/src/transport/gnunet-service-transport_blacklist.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_blacklist.c   2012-07-06 
12:57:14 UTC (rev 22523)
+++ gnunet/src/transport/gnunet-service-transport_blacklist.c   2012-07-06 
13:24:20 UTC (rev 22524)
@@ -543,12 +543,16 @@
  * @param ats performance data
  * @param ats_count number of entries in ats (excluding 0-termination)
  * @param address the address
+ * @param bandwidth_in inbound quota in NBO
+ * @param bandwidth_out outbound quota in NBO
  */
 static void
 test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour,
                     const struct GNUNET_ATS_Information *ats,
                     uint32_t ats_count,
-                    const struct GNUNET_HELLO_Address *address)
+                    const struct GNUNET_HELLO_Address *address,
+                    struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+                    struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
 {
   struct TestConnectionContext *tcc = cls;
   struct GST_BlacklistCheck *bc;

Modified: gnunet/src/transport/gnunet-service-transport_clients.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.c     2012-07-06 
12:57:14 UTC (rev 22523)
+++ gnunet/src/transport/gnunet-service-transport_clients.c     2012-07-06 
13:24:20 UTC (rev 22524)
@@ -437,7 +437,9 @@
                                const struct GNUNET_PeerIdentity *peer,
                                const struct GNUNET_ATS_Information *ats,
                                uint32_t ats_count,
-                               const struct GNUNET_HELLO_Address *address)
+                               const struct GNUNET_HELLO_Address *address,
+                               struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+                               struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_out)
 {
   struct TransportClient *tc = cls;
   struct ConnectInfoMessage *cim;
@@ -453,6 +455,8 @@
   cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
   cim->ats_count = htonl (ats_count);
   cim->id = *peer;
+  cim->quota_in = bandwidth_in;
+  cim->quota_out = bandwidth_out;
   ap = (struct GNUNET_ATS_Information *) &cim[1];
   memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
   unicast (tc, &cim->header, GNUNET_NO);
@@ -832,11 +836,15 @@
  * @param ats performance data
  * @param ats_count number of entries in ats (excluding 0-termination)
  * @param address the address
+ * @param bandwidth_in inbound quota in NBO
+ * @param bandwidth_out outbound quota in NBO
  */
 static void
 output_address (void *cls, const struct GNUNET_PeerIdentity *peer,
                 const struct GNUNET_ATS_Information *ats, uint32_t ats_count,
-                const struct GNUNET_HELLO_Address *address)
+                const struct GNUNET_HELLO_Address *address,
+                struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+                struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
 {
   struct GNUNET_SERVER_TransmitContext *tc = cls;
   struct AddressIterateResponseMessage *msg;
@@ -900,7 +908,9 @@
     /* just return one neighbour */
     address = GST_neighbour_get_current_address (&msg->peer);
     if (address != NULL)
-      output_address (tc, &msg->peer, NULL, 0, address);
+      output_address (tc, &msg->peer, NULL, 0, address,
+                      GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
+                      GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT);
   }
   if (GNUNET_YES != ntohl (msg->one_shot))
     setup_monitoring_client (client, &msg->peer);

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c  2012-07-06 
12:57:14 UTC (rev 22523)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c  2012-07-06 
13:24:20 UTC (rev 22524)
@@ -595,7 +595,7 @@
 /**
  * Function to call when we connected to a neighbour.
  */
-static GNUNET_TRANSPORT_NotifyConnect connect_notify_cb;
+static NotifyConnect connect_notify_cb;
 
 /**
  * Function to call when we disconnected from a neighbour.
@@ -2170,11 +2170,14 @@
   }
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "ATS tells us to switch to address '%s' session %p for peer `%s' 
in state %s\n",
+              "ATS tells us to switch to address '%s' session %p for "
+              "peer `%s' in state %s (quota in/out %u %u )\n",
               (address->address_length != 0) ? GST_plugins_a2s (address): 
"<inbound>",
               session,
               GNUNET_i2s (peer),
-              print_state (n->state));
+              print_state (n->state),
+              ntohl (bandwidth_in.value__),
+              ntohl (bandwidth_out.value__));
 
   if (NULL == session)
   {
@@ -2634,7 +2637,9 @@
                           gettext_noop ("# peers connected"), 
                           ++neighbours_connected,
                           GNUNET_NO);
-    connect_notify_cb (callback_cls, &n->id, ats, ats_count);
+    connect_notify_cb (callback_cls, &n->id, ats, ats_count,
+                       n->primary_address.bandwidth_in,
+                       n->primary_address.bandwidth_out);
     /* Tell ATS that the outbound session we created to send CONNECT was 
successfull */
     GNUNET_ATS_address_add (GST_ats,
                             n->primary_address.address,
@@ -2894,7 +2899,9 @@
                         gettext_noop ("# peers connected"), 
                         ++neighbours_connected,
                         GNUNET_NO);
-  connect_notify_cb (callback_cls, &n->id, ats, ats_count);
+  connect_notify_cb (callback_cls, &n->id, ats, ats_count,
+                     n->primary_address.bandwidth_in,
+                     n->primary_address.bandwidth_out);
   GNUNET_ATS_address_add(GST_ats,
                          n->primary_address.address,
                          n->primary_address.session,
@@ -3062,7 +3069,25 @@
   struct NeighbourMapEntry *n = value;
 
   if (GNUNET_YES == test_connected (n))
-    ic->cb (ic->cb_cls, &n->id, NULL, 0, n->primary_address.address);
+  {
+    struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
+    struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
+
+    if (NULL != n->primary_address.address)
+    {
+      bandwidth_in = n->primary_address.bandwidth_in;
+      bandwidth_out = n->primary_address.bandwidth_out;
+    }
+    else
+    {
+      bandwidth_in = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT;
+      bandwidth_out = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT;
+    }
+
+    ic->cb (ic->cb_cls, &n->id, NULL, 0,
+            n->primary_address.address,
+            bandwidth_in, bandwidth_out);
+  }
   return GNUNET_OK;
 }
 
@@ -3180,7 +3205,7 @@
  */
 void
 GST_neighbours_start (void *cls,
-                      GNUNET_TRANSPORT_NotifyConnect connect_cb,
+    NotifyConnect connect_cb,
                       GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb,
                       GNUNET_TRANSPORT_PeerIterateCallback peer_address_cb)
 {

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.h  2012-07-06 
12:57:14 UTC (rev 22523)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.h  2012-07-06 
13:24:20 UTC (rev 22524)
@@ -29,6 +29,7 @@
 #include "gnunet_statistics_service.h"
 #include "gnunet_transport_service.h"
 #include "gnunet_transport_plugin.h"
+#include "transport.h"
 #include "gnunet_util_lib.h"
 
 // TODO:
@@ -46,7 +47,7 @@
  */
 void
 GST_neighbours_start (void *cls,
-                      GNUNET_TRANSPORT_NotifyConnect connect_cb,
+                      NotifyConnect connect_cb,
                       GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb,
                       GNUNET_TRANSPORT_PeerIterateCallback peer_address_cb);
 
@@ -170,6 +171,8 @@
  * @param ats performance data
  * @param ats_count number of entries in ats (including 0-termination)
  * @param address the address (or NULL)
+ * @param bandwidth_in inbound quota in NBO
+ * @param bandwidth_out outbound quota in NBO
  */
 typedef void (*GST_NeighbourIterator) (void *cls,
                                        const struct GNUNET_PeerIdentity *
@@ -177,7 +180,9 @@
                                        const struct GNUNET_ATS_Information *
                                        ats, uint32_t ats_count,
                                        const struct GNUNET_HELLO_Address *
-                                       address);
+                                       address,
+                                       struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_in,
+                                       struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_out);
 
 
 /**

Modified: gnunet/src/transport/transport.h
===================================================================
--- gnunet/src/transport/transport.h    2012-07-06 12:57:14 UTC (rev 22523)
+++ gnunet/src/transport/transport.h    2012-07-06 13:24:20 UTC (rev 22524)
@@ -56,6 +56,26 @@
  */
 #define CONNECTED_LATENCY_EVALUATION_MAX_DELAY GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_MINUTES, 1)
 
+/**
+ * Similiar to GNUNET_TRANSPORT_NotifyDisconnect but in and out quotas are
+ * included here. These values are not required outside transport_api
+ *
+ * @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 bandwidth_in inbound bandwidth in NBO
+ * @param bandwidth_out outbound bandwidth in NBO
+ *
+ */
+
+typedef void (*NotifyConnect) (void *cls,
+                              const struct GNUNET_PeerIdentity *peer,
+                              const struct GNUNET_ATS_Information *ats,
+                              uint32_t ats_count,
+                              struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+                              struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_out);
+
 GNUNET_NETWORK_STRUCT_BEGIN
 
 /**
@@ -109,6 +129,16 @@
    * Identity of the new neighbour.
    */
   struct GNUNET_PeerIdentity id;
+
+  /**
+   * Current inbound quota for this peer
+   */
+  struct GNUNET_BANDWIDTH_Value32NBO quota_in;
+
+  /**
+   * Current outbound quota for this peer
+   */
+  struct GNUNET_BANDWIDTH_Value32NBO quota_out;
 };
 
 

Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c        2012-07-06 12:57:14 UTC (rev 
22523)
+++ gnunet/src/transport/transport_api.c        2012-07-06 13:24:20 UTC (rev 
22524)
@@ -477,6 +477,7 @@
       break;
     }
     n = neighbour_add (h, &cim->id);
+    GNUNET_BANDWIDTH_tracker_update_quota (&n->out_tracker, cim->quota_out);
     if (h->nc_cb != NULL)
       h->nc_cb (h->cls, &n->id, ats, ats_count);
     break;




reply via email to

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