gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r29605 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r29605 - gnunet/src/ats
Date: Thu, 26 Sep 2013 14:12:24 +0200

Author: wachs
Date: 2013-09-26 14:12:23 +0200 (Thu, 26 Sep 2013)
New Revision: 29605

Modified:
   gnunet/src/ats/gnunet-service-ats-solver_proportional.c
Log:
indentation


Modified: gnunet/src/ats/gnunet-service-ats-solver_proportional.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats-solver_proportional.c     2013-09-26 
12:08:14 UTC (rev 29604)
+++ gnunet/src/ats/gnunet-service-ats-solver_proportional.c     2013-09-26 
12:12:23 UTC (rev 29605)
@@ -1,22 +1,22 @@
 /*
-     This file is part of GNUnet.
-     (C) 2011 Christian Grothoff (and other contributing authors)
+ This file is part of GNUnet.
+ (C) 2011 Christian Grothoff (and other contributing authors)
 
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
 
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ General Public License for more details.
 
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-*/
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING.  If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
 
 /**
  * @file ats/gnunet-service-ats-solver_proportional.c
@@ -212,7 +212,6 @@
 #define DEFAULT_ABS_PREFERENCE 0.0
 #define MIN_UPDATE_INTERVAL GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 10)
 
-
 /**
  * A handle for the proportional solver
  */
@@ -273,7 +272,6 @@
    */
   int bulk_requests;
 
-
   /**
    * Total number of addresses for solver
    */
@@ -296,7 +294,6 @@
 
 };
 
-
 /**
  * Representation of a network
  */
@@ -348,7 +345,6 @@
   struct AddressWrapper *tail;
 };
 
-
 /**
  * Wrapper for addresses to store them in network's linked list
  */
@@ -370,8 +366,6 @@
   struct ATS_Address *addr;
 };
 
-
-
 /**
  *  Important solver functions
  *  ---------------------------
@@ -386,27 +380,24 @@
 static int
 is_bandwidth_available_in_network (struct Network *net)
 {
-       GNUNET_assert (NULL != net);
+  GNUNET_assert(NULL != net);
   unsigned int na = net->active_addresses + 1;
   uint32_t min_bw = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
-  if (((net->total_quota_in / na) > min_bw) &&
-      ((net->total_quota_out / na) > min_bw))
+  if (((net->total_quota_in / na) > min_bw)
+      && ((net->total_quota_out / na) > min_bw))
   {
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Enough bandwidth available for %u active addresses in network 
`%s'\n",
-         na,
-         net->desc);
+    LOG(GNUNET_ERROR_TYPE_DEBUG,
+        "Enough bandwidth available for %u active addresses in network `%s'\n",
+        na, net->desc);
 
     return GNUNET_YES;
   }
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Not enough bandwidth available for %u active addresses in network 
`%s'\n",
-         na,
-         net->desc);
+  LOG(GNUNET_ERROR_TYPE_DEBUG,
+      "Not enough bandwidth available for %u active addresses in network 
`%s'\n",
+      na, net->desc);
   return GNUNET_NO;
 }
 
-
 /**
  * Update bandwidth assigned to peers in this network
  *
@@ -417,8 +408,7 @@
  */
 static void
 distribute_bandwidth_in_network (struct GAS_PROPORTIONAL_Handle *s,
-                          struct Network *net,
-                          struct ATS_Address *address_except)
+    struct Network *net, struct ATS_Address *address_except)
 {
   unsigned long long remaining_quota_in = 0;
   unsigned long long quota_out_used = 0;
@@ -436,15 +426,16 @@
   unsigned long long assigned_quota_out = 0;
   struct AddressWrapper *cur;
 
-       if (GNUNET_YES == s->bulk_lock)
-       {
-               s->bulk_requests++;
-               return;
-       }
+  if (GNUNET_YES == s->bulk_lock)
+  {
+    s->bulk_requests++;
+    return;
+  }
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-              "Recalculate quota for network type `%s' for %u addresses 
(in/out): %llu/%llu \n",
-              net->desc, net->active_addresses, net->total_quota_in, 
net->total_quota_in);
+  LOG(GNUNET_ERROR_TYPE_DEBUG,
+      "Recalculate quota for network type `%s' for %u addresses (in/out): 
%llu/%llu \n",
+      net->desc, net->active_addresses, net->total_quota_in,
+      net->total_quota_in);
 
   if (net->active_addresses == 0)
     return; /* no addresses to update */
@@ -456,125 +447,121 @@
 
   if ((net->active_addresses * min_bw) > net->total_quota_in)
   {
-    GNUNET_break (0);
+    GNUNET_break(0);
     return;
   }
   if ((net->active_addresses * min_bw) > net->total_quota_out)
   {
-    GNUNET_break (0);
+    GNUNET_break(0);
     return;
   }
 
   remaining_quota_in = net->total_quota_in - (net->active_addresses * min_bw);
   remaining_quota_out = net->total_quota_out - (net->active_addresses * 
min_bw);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Remaining bandwidth : (in/out): %llu/%llu \n",
-              remaining_quota_in, remaining_quota_out);
+  LOG(GNUNET_ERROR_TYPE_DEBUG, "Remaining bandwidth : (in/out): %llu/%llu \n",
+      remaining_quota_in, remaining_quota_out);
   total_prefs = 0.0;
   for (cur = net->head; NULL != cur; cur = cur->next)
   {
-      if (GNUNET_YES == cur->addr->active)
+    if (GNUNET_YES == cur->addr->active)
+    {
+      GNUNET_assert(
+          NULL != (t = s->get_preferences (s->get_preferences_cls, 
&cur->addr->peer)));
+
+      peer_prefs = 0.0;
+      for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
       {
-        GNUNET_assert (NULL != (t = s->get_preferences 
(s->get_preferences_cls, &cur->addr->peer)));
-
-                               peer_prefs = 0.0;
-                               for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
-                               {
-                                       if (c != GNUNET_ATS_PREFERENCE_END)
-                                       {
-                                               //fprintf (stderr, "VALUE[%u] 
%s %.3f \n", c, GNUNET_i2s (&cur->addr->peer), t[c]);
-                                               peer_prefs += t[c];
-                                       }
-                               }
-                               total_prefs += (peer_prefs / 
(GNUNET_ATS_PreferenceCount -1));
+        if (c != GNUNET_ATS_PREFERENCE_END)
+        {
+          //fprintf (stderr, "VALUE[%u] %s %.3f \n", c, GNUNET_i2s 
(&cur->addr->peer), t[c]);
+          peer_prefs += t[c];
+        }
       }
+      total_prefs += (peer_prefs / (GNUNET_ATS_PreferenceCount - 1));
+    }
   }
   for (cur = net->head; NULL != cur; cur = cur->next)
   {
-     if (GNUNET_YES == cur->addr->active)
-     {
-       cur_pref = 0.0;
-       GNUNET_assert (NULL != (t = s->get_preferences (s->get_preferences_cls, 
&cur->addr->peer)));
+    if (GNUNET_YES == cur->addr->active)
+    {
+      cur_pref = 0.0;
+      GNUNET_assert(
+          NULL != (t = s->get_preferences (s->get_preferences_cls, 
&cur->addr->peer)));
 
-                        for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
-                        {
-                                if (c != GNUNET_ATS_PREFERENCE_END)
-                                        cur_pref += t[c];
-                        }
-                        cur_pref /= 2;
+      for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
+      {
+        if (c != GNUNET_ATS_PREFERENCE_END)
+          cur_pref += t[c];
+      }
+      cur_pref /= 2;
 
-       assigned_quota_in = min_bw + ((cur_pref / total_prefs) * 
remaining_quota_in);
-       assigned_quota_out = min_bw + ((cur_pref / total_prefs) * 
remaining_quota_out);
+      assigned_quota_in = min_bw
+          + ((cur_pref / total_prefs) * remaining_quota_in);
+      assigned_quota_out = min_bw
+          + ((cur_pref / total_prefs) * remaining_quota_out);
 
-       LOG (GNUNET_ERROR_TYPE_DEBUG,
-                   "New quota for peer `%s' with preference (cur/total) 
%.3f/%.3f (in/out): %llu / %llu\n",
-                   GNUNET_i2s (&cur->addr->peer),
-                   cur_pref, total_prefs,
-                   assigned_quota_in, assigned_quota_out);
-     }
-     else
-     {
-       assigned_quota_in = 0;
-       assigned_quota_out = 0;
-     }
+      LOG(GNUNET_ERROR_TYPE_DEBUG,
+          "New quota for peer `%s' with preference (cur/total) %.3f/%.3f 
(in/out): %llu / %llu\n",
+          GNUNET_i2s (&cur->addr->peer), cur_pref, total_prefs,
+          assigned_quota_in, assigned_quota_out);
+    }
+    else
+    {
+      assigned_quota_in = 0;
+      assigned_quota_out = 0;
+    }
 
-     quota_in_used += assigned_quota_in;
-     quota_out_used += assigned_quota_out;
-     /* Prevent overflow due to rounding errors */
-     if (assigned_quota_in > UINT32_MAX)
-       assigned_quota_in = UINT32_MAX;
-     if (assigned_quota_out > UINT32_MAX)
-       assigned_quota_out = UINT32_MAX;
+    quota_in_used += assigned_quota_in;
+    quota_out_used += assigned_quota_out;
+    /* Prevent overflow due to rounding errors */
+    if (assigned_quota_in > UINT32_MAX)
+      assigned_quota_in = UINT32_MAX;
+    if (assigned_quota_out > UINT32_MAX)
+      assigned_quota_out = UINT32_MAX;
 
-     /* Compare to current bandwidth assigned */
-     if ((assigned_quota_in != ntohl(cur->addr->assigned_bw_in.value__)) ||
-         (assigned_quota_out != ntohl(cur->addr->assigned_bw_out.value__)))
-     {
-       cur->addr->assigned_bw_in.value__ = htonl (assigned_quota_in);
-       cur->addr->assigned_bw_out.value__ = htonl (assigned_quota_out);
-       /* Notify on change */
-       if ((GNUNET_YES == cur->addr->active) && (cur->addr != address_except))
-         s->bw_changed (s->bw_changed_cls, cur->addr);
-     }
+    /* Compare to current bandwidth assigned */
+    if ((assigned_quota_in != ntohl (cur->addr->assigned_bw_in.value__))
+        || (assigned_quota_out != ntohl (cur->addr->assigned_bw_out.value__)))
+    {
+      cur->addr->assigned_bw_in.value__ = htonl (assigned_quota_in);
+      cur->addr->assigned_bw_out.value__ = htonl (assigned_quota_out);
+      /* Notify on change */
+      if ((GNUNET_YES == cur->addr->active) && (cur->addr != address_except))
+        s->bw_changed (s->bw_changed_cls, cur->addr);
+    }
 
   }
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-    "Total bandwidth assigned is (in/out): %llu /%llu\n",
-    quota_in_used,
-    quota_out_used);
+  LOG(GNUNET_ERROR_TYPE_DEBUG,
+      "Total bandwidth assigned is (in/out): %llu /%llu\n", quota_in_used,
+      quota_out_used);
   if (quota_out_used > net->total_quota_out + 1) /* +1 is required due to 
rounding errors */
   {
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-      "Total outbound bandwidth assigned is larger than allowed (used/allowed) 
for %u active addresses: %llu / %llu\n",
-      net->active_addresses,
-      quota_out_used,
-      net->total_quota_out);
+    LOG(GNUNET_ERROR_TYPE_ERROR,
+        "Total outbound bandwidth assigned is larger than allowed 
(used/allowed) for %u active addresses: %llu / %llu\n",
+        net->active_addresses, quota_out_used, net->total_quota_out);
   }
   if (quota_in_used > net->total_quota_in + 1) /* +1 is required due to 
rounding errors */
   {
-      LOG (GNUNET_ERROR_TYPE_ERROR,
+    LOG(GNUNET_ERROR_TYPE_ERROR,
         "Total inbound bandwidth assigned is larger than allowed 
(used/allowed) for %u active addresses: %llu / %llu\n",
-        net->active_addresses,
-        quota_in_used,
-        net->total_quota_in);
+        net->active_addresses, quota_in_used, net->total_quota_in);
   }
 }
 
-
 struct FindBestAddressCtx
 {
   struct GAS_PROPORTIONAL_Handle *s;
   struct ATS_Address *best;
 };
 
-
 static int
 find_property_index (uint32_t type)
 {
   int existing_types[] = GNUNET_ATS_QualityProperties;
   int c;
   for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++)
-          if (existing_types[c] == type)
-                  return c;
+    if (existing_types[c] == type)
+      return c;
   return GNUNET_SYSERR;
 }
 
@@ -589,7 +576,8 @@
  * @return GNUNET_OK (continue to iterate)
  */
 static int
-find_best_address_it (void *cls, const struct GNUNET_HashCode * key, void 
*value)
+find_best_address_it (void *cls, const struct GNUNET_HashCode * key,
+    void *value)
 {
   struct FindBestAddressCtx *fba_ctx = (struct FindBestAddressCtx *) cls;
   struct ATS_Address *current = (struct ATS_Address *) value;
@@ -599,31 +587,29 @@
   const double *norm_prop_prev;
   int index;
 
-  now = GNUNET_TIME_absolute_get();
+  now = GNUNET_TIME_absolute_get ();
 
-  if (current->blocked_until.abs_value_us == GNUNET_TIME_absolute_max (now, 
current->blocked_until).abs_value_us)
+  if (current->blocked_until.abs_value_us
+      == GNUNET_TIME_absolute_max (now, current->blocked_until).abs_value_us)
   {
     /* This address is blocked for suggestion */
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Address %p blocked for suggestion for %s \n",
-        current,
-        GNUNET_STRINGS_relative_time_to_string 
(GNUNET_TIME_absolute_get_difference (now, current->blocked_until),
-                                                GNUNET_YES));
+    LOG(GNUNET_ERROR_TYPE_DEBUG, "Address %p blocked for suggestion for %s \n",
+        current,
+        GNUNET_STRINGS_relative_time_to_string 
(GNUNET_TIME_absolute_get_difference (now, current->blocked_until), 
GNUNET_YES));
     return GNUNET_OK;
   }
   if (GNUNET_NO == is_bandwidth_available_in_network (net))
     return GNUNET_OK; /* There's no bandwidth available in this network */
   if (NULL != fba_ctx->best)
   {
-       GNUNET_assert (NULL != fba_ctx->best->plugin);
-       GNUNET_assert (NULL != current->plugin);
+    GNUNET_assert(NULL != fba_ctx->best->plugin);
+    GNUNET_assert(NULL != current->plugin);
     if (0 == strcmp (fba_ctx->best->plugin, current->plugin))
     {
-      if ((0 != fba_ctx->best->addr_len) &&
-          (0 == current->addr_len))
+      if ((0 != fba_ctx->best->addr_len) && (0 == current->addr_len))
       {
         /* saved address was an outbound address, but we have an inbound 
address */
-       fba_ctx->best = current;
+        fba_ctx->best = current;
         return GNUNET_OK;
       }
       if (0 == fba_ctx->best->addr_len)
@@ -635,30 +621,30 @@
   }
   if (NULL == fba_ctx->best)
   {
-       fba_ctx->best = current;
+    fba_ctx->best = current;
     return GNUNET_OK;
   }
-  if ((ntohl (fba_ctx->best->assigned_bw_in.value__) == 0) &&
-      (ntohl (current->assigned_bw_in.value__) > 0))
+  if ((ntohl (fba_ctx->best->assigned_bw_in.value__) == 0)
+      && (ntohl (current->assigned_bw_in.value__) > 0))
   {
     /* stick to existing connection */
-       fba_ctx->best = current;
+    fba_ctx->best = current;
     return GNUNET_OK;
   }
 
   norm_prop_cur = fba_ctx->s->get_properties (fba_ctx->s->get_properties_cls,
-               (const struct ATS_Address *) current);
+      (const struct ATS_Address *) current);
   norm_prop_prev = fba_ctx->s->get_properties (fba_ctx->s->get_properties_cls,
-               (const struct ATS_Address *) fba_ctx->best);
-/*
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s previous %.2f current %.2f\n",
-               "DISTANCE", norm_prop_cur[1], norm_prop_cur[1]);
-*/
+      (const struct ATS_Address *) fba_ctx->best);
+  /*
+   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s previous %.2f current %.2f\n",
+   "DISTANCE", norm_prop_cur[1], norm_prop_cur[1]);
+   */
   index = find_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE);
   if (GNUNET_SYSERR == index)
   {
-       GNUNET_break (0);
-       return GNUNET_OK;
+    GNUNET_break(0);
+    return GNUNET_OK;
   }
   if (norm_prop_cur[index] < norm_prop_prev[index])
   {
@@ -666,20 +652,20 @@
     fba_ctx->best = current;
     return GNUNET_OK;
   }
-/*
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s previous %.2f current %.2f\n",
-               "DELAY", norm_prop_cur[1], norm_prop_cur[1]);
- */
+  /*
+   GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s previous %.2f current %.2f\n",
+   "DELAY", norm_prop_cur[1], norm_prop_cur[1]);
+   */
   index = find_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
   if (GNUNET_SYSERR == index)
   {
-       GNUNET_break (0);
-       return GNUNET_OK;
+    GNUNET_break(0);
+    return GNUNET_OK;
   }
   if (norm_prop_cur[index] < norm_prop_prev[index])
   {
     /* user shorter delay */
-       fba_ctx->best = current;
+    fba_ctx->best = current;
     return GNUNET_OK;
   }
 
@@ -702,10 +688,9 @@
 {
   int i;
   for (i = 0; i < s->networks; i++)
-          distribute_bandwidth_in_network (s, &s->network_entries[i], NULL);
+    distribute_bandwidth_in_network (s, &s->network_entries[i], NULL );
 }
 
-
 /**
  * Lookup network struct by type
  *
@@ -717,16 +702,15 @@
 get_network (struct GAS_PROPORTIONAL_Handle *s, uint32_t type)
 {
   int c;
-  for (c = 0 ; c < s->networks; c++)
+  for (c = 0; c < s->networks; c++)
   {
-      if (s->network_entries[c].type == type)
-        return &s->network_entries[c];
+    if (s->network_entries[c].type == type)
+      return &s->network_entries[c];
 
   }
-  return NULL;
+  return NULL ;
 }
 
-
 /**
  * Hashmap Iterator to find current active address for peer
  *
@@ -736,27 +720,28 @@
  * @return GNUNET_NO on double active address else GNUNET_YES;
  */
 static int
-get_active_address_it (void *cls, const struct GNUNET_HashCode * key, void 
*value)
+get_active_address_it (void *cls, const struct GNUNET_HashCode * key,
+    void *value)
 {
-       struct ATS_Address **dest = cls;
+  struct ATS_Address **dest = cls;
   struct ATS_Address *aa = (struct ATS_Address *) value;
 
   if (GNUNET_YES == aa->active)
   {
 
-      if (NULL != (*dest))
-      {
-          /* should never happen */
-          LOG (GNUNET_ERROR_TYPE_ERROR, "Multiple active addresses for peer 
`%s'\n", GNUNET_i2s (&aa->peer));
-          GNUNET_break (0);
-          return GNUNET_NO;
-      }
-      (*dest) = aa;
+    if (NULL != (*dest))
+    {
+      /* should never happen */
+      LOG(GNUNET_ERROR_TYPE_ERROR, "Multiple active addresses for peer `%s'\n",
+          GNUNET_i2s (&aa->peer));
+      GNUNET_break(0);
+      return GNUNET_NO;
+    }
+    (*dest) = aa;
   }
   return GNUNET_OK;
 }
 
-
 /**
  * Find current active address for peer
  *
@@ -767,70 +752,64 @@
  */
 static struct ATS_Address *
 get_active_address (void *solver,
-                     struct GNUNET_CONTAINER_MultiHashMap * addresses,
-                     const struct GNUNET_PeerIdentity *peer)
+    struct GNUNET_CONTAINER_MultiHashMap * addresses,
+    const struct GNUNET_PeerIdentity *peer)
 {
   struct ATS_Address * dest = NULL;
 
-  GNUNET_CONTAINER_multihashmap_get_multiple(addresses,
-       &peer->hashPubKey,
-       &get_active_address_it, &dest);
+  GNUNET_CONTAINER_multihashmap_get_multiple (addresses, &peer->hashPubKey,
+      &get_active_address_it, &dest);
   return dest;
 }
 
-
-
 static void
-addresse_increment (struct GAS_PROPORTIONAL_Handle *s,
-                                struct Network *net,
-                                int total,
-                                int active)
+addresse_increment (struct GAS_PROPORTIONAL_Handle *s, struct Network *net,
+    int total, int active)
 {
   if (GNUNET_YES == total)
   {
-      s->total_addresses ++;
-      net->total_addresses ++;
-      GNUNET_STATISTICS_update (s->stats, "# ATS addresses total", 1, 
GNUNET_NO);
-      GNUNET_STATISTICS_update (s->stats, net->stat_total, 1, GNUNET_NO);
+    s->total_addresses++;
+    net->total_addresses++;
+    GNUNET_STATISTICS_update (s->stats, "# ATS addresses total", 1, GNUNET_NO);
+    GNUNET_STATISTICS_update (s->stats, net->stat_total, 1, GNUNET_NO);
   }
   if (GNUNET_YES == active)
   {
-    net->active_addresses ++;
-    s->active_addresses ++;
-    GNUNET_STATISTICS_update (s->stats, "# ATS active addresses total", 1, 
GNUNET_NO);
+    net->active_addresses++;
+    s->active_addresses++;
+    GNUNET_STATISTICS_update (s->stats, "# ATS active addresses total", 1,
+        GNUNET_NO);
     GNUNET_STATISTICS_update (s->stats, net->stat_active, 1, GNUNET_NO);
   }
 
 }
 
-
 static int
-addresse_decrement (struct GAS_PROPORTIONAL_Handle *s,
-                    struct Network *net,
-                    int total,
-                    int active)
+addresse_decrement (struct GAS_PROPORTIONAL_Handle *s, struct Network *net,
+    int total, int active)
 {
   int res = GNUNET_OK;
   if (GNUNET_YES == total)
   {
     if (s->total_addresses < 1)
     {
-      GNUNET_break (0);
+      GNUNET_break(0);
       res = GNUNET_SYSERR;
     }
     else
     {
-      s->total_addresses --;
-      GNUNET_STATISTICS_update (s->stats, "# ATS addresses total", -1, 
GNUNET_NO);
+      s->total_addresses--;
+      GNUNET_STATISTICS_update (s->stats, "# ATS addresses total", -1,
+          GNUNET_NO);
     }
     if (net->total_addresses < 1)
     {
-      GNUNET_break (0);
+      GNUNET_break(0);
       res = GNUNET_SYSERR;
     }
     else
     {
-      net->total_addresses --;
+      net->total_addresses--;
       GNUNET_STATISTICS_update (s->stats, net->stat_total, -1, GNUNET_NO);
     }
   }
@@ -839,29 +818,29 @@
   {
     if (net->active_addresses < 1)
     {
-      GNUNET_break (0);
+      GNUNET_break(0);
       res = GNUNET_SYSERR;
     }
     else
     {
-      net->active_addresses --;
+      net->active_addresses--;
       GNUNET_STATISTICS_update (s->stats, net->stat_active, -1, GNUNET_NO);
     }
     if (s->active_addresses < 1)
     {
-      GNUNET_break (0);
+      GNUNET_break(0);
       res = GNUNET_SYSERR;
     }
     else
     {
-      s->active_addresses --;
-      GNUNET_STATISTICS_update (s->stats, "# ATS addresses total", -1, 
GNUNET_NO);
+      s->active_addresses--;
+      GNUNET_STATISTICS_update (s->stats, "# ATS addresses total", -1,
+          GNUNET_NO);
     }
   }
   return res;
 }
 
-
 /**
  *  Solver API functions
  *  ---------------------------
@@ -877,18 +856,16 @@
  */
 void
 GAS_proportional_address_change_preference (void *solver,
-                                                                               
        const struct GNUNET_PeerIdentity *peer,
-                                                                               
        enum GNUNET_ATS_PreferenceKind kind,
-                                                                               
        double pref_rel)
+    const struct GNUNET_PeerIdentity *peer, enum GNUNET_ATS_PreferenceKind 
kind,
+    double pref_rel)
 {
   struct GAS_PROPORTIONAL_Handle *s = solver;
-  GNUNET_assert (NULL != solver);
-  GNUNET_assert (NULL != peer);
+  GNUNET_assert(NULL != solver);
+  GNUNET_assert(NULL != peer);
 
-       distribute_bandwidth_in_all_networks (s);
+  distribute_bandwidth_in_all_networks (s);
 }
 
-
 /**
  * Get application feedback for a peer
  *
@@ -900,22 +877,19 @@
  * @param score the score
  */
 void
-GAS_proportional_address_preference_feedback (void *solver,
-                                                                               
        void *application,
-                                                                               
        const struct GNUNET_PeerIdentity *peer,
-                                                                               
        const struct GNUNET_TIME_Relative scope,
-                                                                               
        enum GNUNET_ATS_PreferenceKind kind,
-                                                                               
        double score)
+GAS_proportional_address_preference_feedback (void *solver, void *application,
+    const struct GNUNET_PeerIdentity *peer,
+    const struct GNUNET_TIME_Relative scope,
+    enum GNUNET_ATS_PreferenceKind kind, double score)
 {
   struct GAS_PROPORTIONAL_Handle *s = solver;
-  GNUNET_assert (NULL != solver);
-  GNUNET_assert (NULL != peer);
+  GNUNET_assert(NULL != solver);
+  GNUNET_assert(NULL != peer);
 
-  GNUNET_assert (NULL != s);
-  GNUNET_break (0);
+  GNUNET_assert(NULL != s);
+  GNUNET_break(0);
 }
 
-
 /**
  * Get the preferred address for a specific peer
  *
@@ -924,7 +898,7 @@
  */
 const struct ATS_Address *
 GAS_proportional_get_preferred_address (void *solver,
-                               const struct GNUNET_PeerIdentity *peer)
+    const struct GNUNET_PeerIdentity *peer)
 {
   struct GAS_PROPORTIONAL_Handle *s = solver;
   struct Network *net_prev;
@@ -932,41 +906,44 @@
   struct ATS_Address *prev;
   struct FindBestAddressCtx fba_ctx;
 
-  GNUNET_assert (s != NULL);
-  GNUNET_assert (peer != NULL);
+  GNUNET_assert(s != NULL);
+  GNUNET_assert(peer != NULL);
 
   /* Add to list of pending requests */
-  if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (s->requests, 
&peer->hashPubKey))
-    GNUNET_CONTAINER_multihashmap_put (s->requests, &peer->hashPubKey,
-        NULL, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+  if (GNUNET_NO
+      == GNUNET_CONTAINER_multihashmap_contains (s->requests,
+          &peer->hashPubKey))
+    GNUNET_CONTAINER_multihashmap_put (s->requests, &peer->hashPubKey, NULL,
+        GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
 
   /* Get address with: stick to current address, lower distance, lower latency 
*/
   fba_ctx.s = s;
   fba_ctx.best = NULL;
 
   GNUNET_CONTAINER_multihashmap_get_multiple (s->addresses, &peer->hashPubKey,
-                                              &find_best_address_it, &fba_ctx);
+      &find_best_address_it, &fba_ctx);
   if (NULL == fba_ctx.best)
   {
-    LOG (GNUNET_ERROR_TYPE_INFO, "Cannot suggest address for peer `%s'\n", 
GNUNET_i2s (peer));
-    return NULL;
+    LOG(GNUNET_ERROR_TYPE_INFO, "Cannot suggest address for peer `%s'\n",
+        GNUNET_i2s (peer));
+    return NULL ;
   }
 
-  LOG (GNUNET_ERROR_TYPE_INFO, "Suggesting %s address %p for peer `%s'\n",
-      (GNUNET_NO == fba_ctx.best->active) ? "inactive" : "active",
-               fba_ctx.best, GNUNET_i2s (peer));
+  LOG(GNUNET_ERROR_TYPE_INFO, "Suggesting %s address %p for peer `%s'\n",
+      (GNUNET_NO == fba_ctx.best->active) ? "inactive" : "active", 
fba_ctx.best,
+      GNUNET_i2s (peer));
   net_cur = (struct Network *) fba_ctx.best->solver_information;
   if (NULL == fba_ctx.best)
   {
-    LOG (GNUNET_ERROR_TYPE_ERROR, "Trying to suggesting unknown address peer 
`%s'\n",
-        GNUNET_i2s (peer));
-    GNUNET_break (0);
-    return NULL;
+    LOG(GNUNET_ERROR_TYPE_ERROR,
+        "Trying to suggesting unknown address peer `%s'\n", GNUNET_i2s (peer));
+    GNUNET_break(0);
+    return NULL ;
   }
   if (GNUNET_YES == fba_ctx.best->active)
   {
-      /* This address was selected previously, so no need to update quotas */
-      return fba_ctx.best;
+    /* This address was selected previously, so no need to update quotas */
+    return fba_ctx.best;
   }
 
   /* This address was not active, so we have to:
@@ -975,31 +952,33 @@
    * - update quota for previous address network
    * - update quota for this address network
    */
-  prev = get_active_address (s, (struct GNUNET_CONTAINER_MultiHashMap *) 
s->addresses, peer);
+  prev = get_active_address (s,
+      (struct GNUNET_CONTAINER_MultiHashMap *) s->addresses, peer);
   if (NULL != prev)
   {
-      net_prev = (struct Network *) prev->solver_information;
-      prev->active = GNUNET_NO; /* No active any longer */
-      prev->assigned_bw_in = BANDWIDTH_ZERO; /* no bandwidth assigned */
-      prev->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */
-      if (GNUNET_SYSERR == addresse_decrement (s, net_prev, GNUNET_NO, 
GNUNET_YES))
-        GNUNET_break (0);
-      distribute_bandwidth_in_network (s, net_prev, NULL);
+    net_prev = (struct Network *) prev->solver_information;
+    prev->active = GNUNET_NO; /* No active any longer */
+    prev->assigned_bw_in = BANDWIDTH_ZERO; /* no bandwidth assigned */
+    prev->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */
+    if (GNUNET_SYSERR
+        == addresse_decrement (s, net_prev, GNUNET_NO, GNUNET_YES))
+      GNUNET_break(0);
+    distribute_bandwidth_in_network (s, net_prev, NULL );
   }
 
-  if (GNUNET_NO == (is_bandwidth_available_in_network 
(fba_ctx.best->solver_information)))
+  if (GNUNET_NO
+      == (is_bandwidth_available_in_network 
(fba_ctx.best->solver_information)))
   {
-    GNUNET_break (0); /* This should never happen*/
-    return NULL;
+    GNUNET_break(0); /* This should never happen*/
+    return NULL ;
   }
 
   fba_ctx.best->active = GNUNET_YES;
   addresse_increment (s, net_cur, GNUNET_NO, GNUNET_YES);
-  distribute_bandwidth_in_network (s, net_cur, NULL);
+  distribute_bandwidth_in_network (s, net_cur, NULL );
   return fba_ctx.best;
 }
 
-
 /**
  * Stop notifying about address and bandwidth changes for this peer
  *
@@ -1008,16 +987,20 @@
  */
 void
 GAS_proportional_stop_get_preferred_address (void *solver,
-                                     const struct GNUNET_PeerIdentity *peer)
+    const struct GNUNET_PeerIdentity *peer)
 {
   struct GAS_PROPORTIONAL_Handle *s = solver;
-       struct ATS_Address *cur;
-       struct Network *cur_net;
+  struct ATS_Address *cur;
+  struct Network *cur_net;
 
-  if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (s->requests, 
&peer->hashPubKey))
-    GNUNET_CONTAINER_multihashmap_remove (s->requests, &peer->hashPubKey, 
NULL);
+  if (GNUNET_YES
+      == GNUNET_CONTAINER_multihashmap_contains (s->requests,
+          &peer->hashPubKey))
+    GNUNET_CONTAINER_multihashmap_remove (s->requests, &peer->hashPubKey,
+        NULL );
 
-  cur = get_active_address (s, (struct GNUNET_CONTAINER_MultiHashMap *) 
s->addresses, peer);
+  cur = get_active_address (s,
+      (struct GNUNET_CONTAINER_MultiHashMap *) s->addresses, peer);
   if (NULL != cur)
   {
     /* Disabling current address */
@@ -1026,13 +1009,12 @@
     cur->assigned_bw_in = BANDWIDTH_ZERO; /* no bandwidth assigned */
     cur->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */
     if (GNUNET_SYSERR == addresse_decrement (s, cur_net, GNUNET_NO, 
GNUNET_YES))
-      GNUNET_break (0);
-    distribute_bandwidth_in_network (s, cur_net, NULL);
+      GNUNET_break(0);
+    distribute_bandwidth_in_network (s, cur_net, NULL );
   }
   return;
 }
 
-
 /**
  * Remove an address from the solver
  *
@@ -1041,9 +1023,8 @@
  * @param session_only delete only session not whole address
  */
 void
-GAS_proportional_address_delete (void *solver,
-                                                                               
                                 struct ATS_Address *address,
-                                                                               
                                 int session_only)
+GAS_proportional_address_delete (void *solver, struct ATS_Address *address,
+    int session_only)
 {
   struct GAS_PROPORTIONAL_Handle *s = solver;
   struct Network *net;
@@ -1061,54 +1042,54 @@
 
   if (GNUNET_NO == session_only)
   {
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "Deleting %s address %p for peer `%s' from 
network `%s' (total: %u/ active: %u)\n",
-        (GNUNET_NO == address->active) ? "inactive" : "active",
-        address, GNUNET_i2s (&address->peer),
-        net->desc, net->total_addresses, net->active_addresses);
+    LOG(GNUNET_ERROR_TYPE_DEBUG,
+        "Deleting %s address %p for peer `%s' from network `%s' (total: %u/ 
active: %u)\n",
+        (GNUNET_NO == address->active) ? "inactive" : "active", address,
+        GNUNET_i2s (&address->peer), net->desc, net->total_addresses,
+        net->active_addresses);
 
     /* Remove address */
     addresse_decrement (s, net, GNUNET_YES, GNUNET_NO);
     for (aw = net->head; NULL != aw; aw = aw->next)
     {
-        if (aw->addr == address)
-          break;
+      if (aw->addr == address)
+        break;
     }
-    if (NULL == aw )
+    if (NULL == aw)
     {
-        GNUNET_break (0);
-        return;
+      GNUNET_break(0);
+      return;
     }
-    GNUNET_CONTAINER_DLL_remove (net->head, net->tail, aw);
-    GNUNET_free (aw);
+    GNUNET_CONTAINER_DLL_remove(net->head, net->tail, aw);
+    GNUNET_free(aw);
   }
   else
   {
-      /* Remove session only: remove if active and update */
-      LOG (GNUNET_ERROR_TYPE_DEBUG, "Deleting %s session %p for peer `%s' from 
network `%s' (total: %u/ active: %u)\n",
-          (GNUNET_NO == address->active) ? "inactive" : "active",
-          address, GNUNET_i2s (&address->peer),
-          net->desc, net->total_addresses, net->active_addresses);
+    /* Remove session only: remove if active and update */
+    LOG(GNUNET_ERROR_TYPE_DEBUG,
+        "Deleting %s session %p for peer `%s' from network `%s' (total: %u/ 
active: %u)\n",
+        (GNUNET_NO == address->active) ? "inactive" : "active", address,
+        GNUNET_i2s (&address->peer), net->desc, net->total_addresses,
+        net->active_addresses);
   }
 
   if (GNUNET_YES == address->active)
   {
-      /* Address was active, remove from network and update quotas*/
-      address->active = GNUNET_NO;
-      address->assigned_bw_in = BANDWIDTH_ZERO;
-      address->assigned_bw_out = BANDWIDTH_ZERO;
+    /* Address was active, remove from network and update quotas*/
+    address->active = GNUNET_NO;
+    address->assigned_bw_in = BANDWIDTH_ZERO;
+    address->assigned_bw_out = BANDWIDTH_ZERO;
 
-      if (GNUNET_SYSERR == addresse_decrement (s, net, GNUNET_NO, GNUNET_YES))
-        GNUNET_break (0);
-      distribute_bandwidth_in_network (s, net, NULL);
+    if (GNUNET_SYSERR == addresse_decrement (s, net, GNUNET_NO, GNUNET_YES))
+      GNUNET_break(0);
+    distribute_bandwidth_in_network (s, net, NULL );
   }
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "After deleting address now total %u and 
active %u addresses in network `%s'\n",
-      net->total_addresses,
-      net->active_addresses,
-      net->desc);
+  LOG(GNUNET_ERROR_TYPE_DEBUG,
+      "After deleting address now total %u and active %u addresses in network 
`%s'\n",
+      net->total_addresses, net->active_addresses, net->desc);
 
 }
 
-
 /**
  * Start a bulk operation
  *
@@ -1117,11 +1098,11 @@
 void
 GAS_proportional_bulk_start (void *solver)
 {
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Locking solver for bulk operation ...\n");
+  LOG(GNUNET_ERROR_TYPE_DEBUG, "Locking solver for bulk operation ...\n");
   struct GAS_PROPORTIONAL_Handle *s = (struct GAS_PROPORTIONAL_Handle *) 
solver;
 
-  GNUNET_assert (NULL != solver);
-  s->bulk_lock ++;
+  GNUNET_assert(NULL != solver);
+  s->bulk_lock++;
 }
 
 /**
@@ -1130,26 +1111,25 @@
 void
 GAS_proportional_bulk_stop (void *solver)
 {
-       LOG (GNUNET_ERROR_TYPE_DEBUG, "Unlocking solver from bulk operation 
...\n");
+  LOG(GNUNET_ERROR_TYPE_DEBUG, "Unlocking solver from bulk operation ...\n");
 
   struct GAS_PROPORTIONAL_Handle *s = (struct GAS_PROPORTIONAL_Handle *) 
solver;
-  GNUNET_assert (NULL != solver);
+  GNUNET_assert(NULL != solver);
 
   if (s->bulk_lock < 1)
   {
-       GNUNET_break (0);
-       return;
+    GNUNET_break(0);
+    return;
   }
-  s->bulk_lock --;
+  s->bulk_lock--;
   if ((0 == s->bulk_lock) && (0 < s->bulk_requests))
   {
-       LOG (GNUNET_ERROR_TYPE_DEBUG, "No lock pending, recalculating\n");
-       distribute_bandwidth_in_all_networks (s);
-       s->bulk_requests = 0;
+    LOG(GNUNET_ERROR_TYPE_DEBUG, "No lock pending, recalculating\n");
+    distribute_bandwidth_in_all_networks (s);
+    s->bulk_requests = 0;
   }
 }
 
-
 /**
  * Add a new single address to a network
  *
@@ -1158,11 +1138,9 @@
  * @param network network type of this address
  */
 void
-GAS_proportional_address_add (void *solver,
-                                                                               
                                        struct ATS_Address *address,
-                                                                               
                                        uint32_t network);
+GAS_proportional_address_add (void *solver, struct ATS_Address *address,
+    uint32_t network);
 
-
 /**
  * Transport properties for this address have changed
  *
@@ -1174,46 +1152,42 @@
  */
 void
 GAS_proportional_address_property_changed (void *solver,
-                                          struct ATS_Address *address,
-                                          uint32_t type,
-                                          uint32_t abs_value,
-                                          double rel_value)
+    struct ATS_Address *address, uint32_t type, uint32_t abs_value,
+    double rel_value)
 {
-       struct GAS_PROPORTIONAL_Handle *s;
-       struct Network *n;
+  struct GAS_PROPORTIONAL_Handle *s;
+  struct Network *n;
 
-       GNUNET_assert (NULL != solver);
-       GNUNET_assert (NULL != address);
+  GNUNET_assert(NULL != solver);
+  GNUNET_assert(NULL != address);
 
-       s = (struct GAS_PROPORTIONAL_Handle *) solver;
-       n = (struct Network *) address->solver_information;
+  s = (struct GAS_PROPORTIONAL_Handle *) solver;
+  n = (struct Network *) address->solver_information;
 
-       if (NULL == n)
-       {
-               GNUNET_break (0);
-               return;
-       }
+  if (NULL == n)
+  {
+    GNUNET_break(0);
+    return;
+  }
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-              "Property `%s' for peer `%s' address %p changed to %.2f \n",
-              GNUNET_ATS_print_property_type (type),
-              GNUNET_i2s (&address->peer),
-              address, rel_value);
+  LOG(GNUNET_ERROR_TYPE_DEBUG,
+      "Property `%s' for peer `%s' address %p changed to %.2f \n",
+      GNUNET_ATS_print_property_type (type), GNUNET_i2s (&address->peer),
+      address, rel_value);
   switch (type)
   {
-       case GNUNET_ATS_UTILIZATION_UP:
-       case GNUNET_ATS_UTILIZATION_DOWN:
-       case GNUNET_ATS_QUALITY_NET_DELAY:
-       case GNUNET_ATS_QUALITY_NET_DISTANCE:
-       case GNUNET_ATS_COST_WAN:
-       case GNUNET_ATS_COST_LAN:
-       case GNUNET_ATS_COST_WLAN:
+  case GNUNET_ATS_UTILIZATION_UP:
+  case GNUNET_ATS_UTILIZATION_DOWN:
+  case GNUNET_ATS_QUALITY_NET_DELAY:
+  case GNUNET_ATS_QUALITY_NET_DISTANCE:
+  case GNUNET_ATS_COST_WAN:
+  case GNUNET_ATS_COST_LAN:
+  case GNUNET_ATS_COST_WLAN:
     distribute_bandwidth_in_network (s, n, GNUNET_NO);
-       break;
+    break;
   }
 }
 
-
 /**
  * Transport session for this address has changed
  *
@@ -1226,18 +1200,15 @@
  */
 void
 GAS_proportional_address_session_changed (void *solver,
-struct ATS_Address *address,
-uint32_t cur_session,
-uint32_t new_session)
+    struct ATS_Address *address, uint32_t cur_session, uint32_t new_session)
 {
-  if (cur_session!= new_session)
+  if (cur_session != new_session)
   {
-      LOG (GNUNET_ERROR_TYPE_DEBUG,
-                  "Session changed from %u to %u\n", cur_session, new_session);
+    LOG(GNUNET_ERROR_TYPE_DEBUG, "Session changed from %u to %u\n", 
cur_session,
+        new_session);
   }
 }
 
-
 /**
  * Usage for this address has changed
  *
@@ -1249,15 +1220,12 @@
  */
 void
 GAS_proportional_address_inuse_changed (void *solver,
-struct ATS_Address *address,
-int in_use)
+    struct ATS_Address *address, int in_use)
 {
-       LOG (GNUNET_ERROR_TYPE_DEBUG,
-                                                       "Usage changed to %s\n",
-                                                       (GNUNET_YES == in_use) 
? "USED" : "UNUSED");
+  LOG(GNUNET_ERROR_TYPE_DEBUG, "Usage changed to %s\n",
+      (GNUNET_YES == in_use) ? "USED" : "UNUSED");
 }
 
-
 /**
  * Network scope for this address has changed
  *
@@ -1270,9 +1238,7 @@
  */
 void
 GAS_proportional_address_change_network (void *solver,
-                                                                               
                                                           struct ATS_Address 
*address,
-                                                                               
                                                           uint32_t 
current_network,
-                                                                               
                                                           uint32_t new_network)
+    struct ATS_Address *address, uint32_t current_network, uint32_t 
new_network)
 {
   struct ATS_Address *new;
   struct GAS_PROPORTIONAL_Handle *s = (struct GAS_PROPORTIONAL_Handle *) 
solver;
@@ -1281,65 +1247,74 @@
 
   if (current_network == new_network)
   {
-       GNUNET_break (0);
-       return;
+    GNUNET_break(0);
+    return;
   }
 
-       /* Network changed */
-       LOG (GNUNET_ERROR_TYPE_DEBUG, "Network type changed, moving %s address 
from `%s' to `%s'\n",
-                       (GNUNET_YES == address->active) ? "active" : "inactive",
-                        GNUNET_ATS_print_network_type (current_network),
-                        GNUNET_ATS_print_network_type (new_network));
+  /* Network changed */
+  LOG(GNUNET_ERROR_TYPE_DEBUG,
+      "Network type changed, moving %s address from `%s' to `%s'\n",
+      (GNUNET_YES == address->active) ? "active" : "inactive",
+      GNUNET_ATS_print_network_type (current_network),
+      GNUNET_ATS_print_network_type (new_network));
 
   save_active = address->active;
 
   /* Disable and assign no bandwidth */
-       address->active = GNUNET_NO;
-       address->assigned_bw_in = BANDWIDTH_ZERO; /* no bandwidth assigned */
-       address->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */
+  address->active = GNUNET_NO;
+  address->assigned_bw_in = BANDWIDTH_ZERO; /* no bandwidth assigned */
+  address->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */
 
-       /* Remove from old network */
-       GAS_proportional_address_delete (solver, address, GNUNET_NO);
+  /* Remove from old network */
+  GAS_proportional_address_delete (solver, address, GNUNET_NO);
 
-       /* Set new network type */
-       if (NULL == (new_net = get_network (solver, new_network)))
-       {
-               /* Address changed to invalid network... */
-               LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid network type `%u' 
`%s': Disconnect!\n"),
-                               new_network, GNUNET_ATS_print_network_type 
(new_network));
+  /* Set new network type */
+  if (NULL == (new_net = get_network (solver, new_network)))
+  {
+    /* Address changed to invalid network... */
+    LOG(GNUNET_ERROR_TYPE_ERROR,
+        _("Invalid network type `%u' `%s': Disconnect!\n"), new_network,
+        GNUNET_ATS_print_network_type (new_network));
 
-               /* Find new address to suggest since no bandwidth in network*/
-               if (NULL == (new = (struct ATS_Address *) 
GAS_proportional_get_preferred_address (s, &address->peer)))
-               {
-                       /* No alternative address found, disconnect peer */
-                       s->bw_changed  (s->bw_changed_cls, address);
-               }
-               return;
-       }
+    /* Find new address to suggest since no bandwidth in network*/
+    if (NULL
+        == (new =
+            (struct ATS_Address *) GAS_proportional_get_preferred_address (s,
+                &address->peer)))
+    {
+      /* No alternative address found, disconnect peer */
+      s->bw_changed (s->bw_changed_cls, address);
+    }
+    return;
+  }
 
-       /* Add to new network and update*/
-       address->solver_information = new_net;
-       GAS_proportional_address_add (solver, address, new_network);
-       if (GNUNET_YES == save_active)
-       {
-               /* check if bandwidth available in new network */
-               if (GNUNET_YES == (is_bandwidth_available_in_network (new_net)))
-               {
-                               /* Assign bandwidth to updated address */
-                               address->active = GNUNET_YES;
-                               addresse_increment (s, new_net, GNUNET_NO, 
GNUNET_YES);
-                               distribute_bandwidth_in_network (solver, 
new_net, NULL);
-               }
-               else
-               {
-                       LOG (GNUNET_ERROR_TYPE_DEBUG, "Not enough bandwidth in 
new network, suggesting alternative address ..\n");
-                       /* Find new address to suggest since no bandwidth in 
network*/
-                       if (NULL == (new = (struct ATS_Address *) 
GAS_proportional_get_preferred_address (s, &address->peer)))
-                       {
-                               /* No alternative address found, disconnect 
peer */
-                               s->bw_changed  (s->bw_changed_cls, address);
-                       }
-               }
+  /* Add to new network and update*/
+  address->solver_information = new_net;
+  GAS_proportional_address_add (solver, address, new_network);
+  if (GNUNET_YES == save_active)
+  {
+    /* check if bandwidth available in new network */
+    if (GNUNET_YES == (is_bandwidth_available_in_network (new_net)))
+    {
+      /* Assign bandwidth to updated address */
+      address->active = GNUNET_YES;
+      addresse_increment (s, new_net, GNUNET_NO, GNUNET_YES);
+      distribute_bandwidth_in_network (solver, new_net, NULL );
+    }
+    else
+    {
+      LOG(GNUNET_ERROR_TYPE_DEBUG,
+          "Not enough bandwidth in new network, suggesting alternative address 
..\n");
+      /* Find new address to suggest since no bandwidth in network*/
+      if (NULL
+          == (new =
+              (struct ATS_Address *) GAS_proportional_get_preferred_address (s,
+                  &address->peer)))
+      {
+        /* No alternative address found, disconnect peer */
+        s->bw_changed (s->bw_changed_cls, address);
+      }
+    }
   }
 }
 
@@ -1351,40 +1326,41 @@
  * @param network network type of this address
  */
 void
-GAS_proportional_address_add (void *solver,
-                              struct ATS_Address *address,
-                              uint32_t network)
+GAS_proportional_address_add (void *solver, struct ATS_Address *address,
+    uint32_t network)
 {
   struct GAS_PROPORTIONAL_Handle *s = solver;
   struct Network *net = NULL;
   struct AddressWrapper *aw = NULL;
-  GNUNET_assert (NULL != s);
+  GNUNET_assert(NULL != s);
 
   net = get_network (s, network);
   if (NULL == net)
   {
-    GNUNET_break (0);
+    GNUNET_break(0);
     return;
   }
 
   aw = GNUNET_malloc (sizeof (struct AddressWrapper));
   aw->addr = address;
-  GNUNET_CONTAINER_DLL_insert (net->head, net->tail, aw);
+  GNUNET_CONTAINER_DLL_insert(net->head, net->tail, aw);
   addresse_increment (s, net, GNUNET_YES, GNUNET_NO);
   aw->addr->solver_information = net;
 
-  if ((GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains(s->requests, 
&address->peer.hashPubKey)) &&
-      (NULL == get_active_address (s,
-          (struct GNUNET_CONTAINER_MultiHashMap *) s->addresses, 
&address->peer)))
-      GAS_proportional_get_preferred_address (s, &address->peer);
+  if ((GNUNET_YES
+      == GNUNET_CONTAINER_multihashmap_contains (s->requests,
+          &address->peer.hashPubKey))
+      && (NULL
+          == get_active_address (s,
+              (struct GNUNET_CONTAINER_MultiHashMap *) s->addresses,
+              &address->peer)))
+    GAS_proportional_get_preferred_address (s, &address->peer);
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "After adding address now total %u and active 
%u addresses in network `%s'\n",
-      net->total_addresses,
-      net->active_addresses,
-      net->desc);
+  LOG(GNUNET_ERROR_TYPE_DEBUG,
+      "After adding address now total %u and active %u addresses in network 
`%s'\n",
+      net->total_addresses, net->active_addresses, net->desc);
 }
 
-
 /**
  * Init the proportional problem solver
  *
@@ -1416,30 +1392,26 @@
  */
 void *
 GAS_proportional_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                       const struct GNUNET_STATISTICS_Handle *stats,
-                       const struct GNUNET_CONTAINER_MultiHashMap *addresses,
-                       int *network,
-                       unsigned long long *out_quota,
-                       unsigned long long *in_quota,
-                       int dest_length,
-                       GAS_bandwidth_changed_cb bw_changed_cb,
-                       void *bw_changed_cb_cls,
-                       GAS_get_preferences get_preference,
-                       void *get_preference_cls,
-                       GAS_get_properties get_properties,
-                       void *get_properties_cls)
+    const struct GNUNET_STATISTICS_Handle *stats,
+    const struct GNUNET_CONTAINER_MultiHashMap *addresses, int *network,
+    unsigned long long *out_quota, unsigned long long *in_quota,
+    int dest_length, GAS_bandwidth_changed_cb bw_changed_cb,
+    void *bw_changed_cb_cls, GAS_get_preferences get_preference,
+    void *get_preference_cls, GAS_get_properties get_properties,
+    void *get_properties_cls)
 {
   int c;
-  struct GAS_PROPORTIONAL_Handle *s = GNUNET_malloc (sizeof (struct 
GAS_PROPORTIONAL_Handle));
+  struct GAS_PROPORTIONAL_Handle *s =
+      GNUNET_malloc (sizeof (struct GAS_PROPORTIONAL_Handle));
   struct Network * cur;
   char * net_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString;
 
-  GNUNET_assert (NULL != cfg);
-  GNUNET_assert (NULL != stats);
-  GNUNET_assert (NULL != network);
-  GNUNET_assert (NULL != bw_changed_cb);
-  GNUNET_assert (NULL != get_preference);
-  GNUNET_assert (NULL != get_properties);
+  GNUNET_assert(NULL != cfg);
+  GNUNET_assert(NULL != stats);
+  GNUNET_assert(NULL != network);
+  GNUNET_assert(NULL != bw_changed_cb);
+  GNUNET_assert(NULL != get_preference);
+  GNUNET_assert(NULL != get_properties);
 
   s->stats = (struct GNUNET_STATISTICS_Handle *) stats;
   s->bw_changed = bw_changed_cb;
@@ -1459,20 +1431,20 @@
 
   for (c = 0; c < dest_length; c++)
   {
-      cur = &s->network_entries[c];
-      cur->total_addresses = 0;
-      cur->active_addresses = 0;
-      cur->type = network[c];
-      cur->total_quota_in = in_quota[c];
-      cur->total_quota_out = out_quota[c];
-      cur->desc = net_str[c];
-      GNUNET_asprintf (&cur->stat_total, "# ATS addresses %s total", 
cur->desc);
-      GNUNET_asprintf (&cur->stat_active, "# ATS active addresses %s total", 
cur->desc);
+    cur = &s->network_entries[c];
+    cur->total_addresses = 0;
+    cur->active_addresses = 0;
+    cur->type = network[c];
+    cur->total_quota_in = in_quota[c];
+    cur->total_quota_out = out_quota[c];
+    cur->desc = net_str[c];
+    GNUNET_asprintf (&cur->stat_total, "# ATS addresses %s total", cur->desc);
+    GNUNET_asprintf (&cur->stat_active, "# ATS active addresses %s total",
+        cur->desc);
   }
   return s;
 }
 
-
 /**
  * Shutdown the proportional problem solver
  *
@@ -1485,58 +1457,53 @@
   struct AddressWrapper *cur;
   struct AddressWrapper *next;
   int c;
-  GNUNET_assert (s != NULL);
+  GNUNET_assert(s != NULL);
 
   for (c = 0; c < s->networks; c++)
   {
-      if (s->network_entries[c].total_addresses > 0)
-      {
-        LOG (GNUNET_ERROR_TYPE_ERROR,
-                    "Had %u addresses for network `%s' not deleted during 
shutdown\n",
-                    s->network_entries[c].total_addresses,
-                    s->network_entries[c].desc);
-        GNUNET_break (0);
-      }
+    if (s->network_entries[c].total_addresses > 0)
+    {
+      LOG(GNUNET_ERROR_TYPE_ERROR,
+          "Had %u addresses for network `%s' not deleted during shutdown\n",
+          s->network_entries[c].total_addresses, s->network_entries[c].desc);
+      GNUNET_break(0);
+    }
 
-      if (s->network_entries[c].active_addresses > 0)
-      {
-        LOG (GNUNET_ERROR_TYPE_ERROR,
-                    "Had %u active addresses for network `%s' not deleted 
during shutdown\n",
-                    s->network_entries[c].active_addresses,
-                    s->network_entries[c].desc);
-        GNUNET_break (0);
-      }
+    if (s->network_entries[c].active_addresses > 0)
+    {
+      LOG(GNUNET_ERROR_TYPE_ERROR,
+          "Had %u active addresses for network `%s' not deleted during 
shutdown\n",
+          s->network_entries[c].active_addresses, s->network_entries[c].desc);
+      GNUNET_break(0);
+    }
 
-      next = s->network_entries[c].head;
-      while (NULL != (cur = next))
-      {
-          next = cur->next;
-          GNUNET_CONTAINER_DLL_remove (s->network_entries[c].head,
-                                       s->network_entries[c].tail,
-                                       cur);
-          GNUNET_free (cur);
-      }
-      GNUNET_free (s->network_entries[c].stat_total);
-      GNUNET_free (s->network_entries[c].stat_active);
+    next = s->network_entries[c].head;
+    while (NULL != (cur = next))
+    {
+      next = cur->next;
+      GNUNET_CONTAINER_DLL_remove(s->network_entries[c].head,
+          s->network_entries[c].tail, cur);
+      GNUNET_free(cur);
+    }
+    GNUNET_free(s->network_entries[c].stat_total);
+    GNUNET_free(s->network_entries[c].stat_active);
   }
   if (s->total_addresses > 0)
   {
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-                "Had %u addresses not deleted during shutdown\n",
-                s->total_addresses);
-    GNUNET_break (0);
+    LOG(GNUNET_ERROR_TYPE_ERROR,
+        "Had %u addresses not deleted during shutdown\n", s->total_addresses);
+    GNUNET_break(0);
   }
   if (s->active_addresses > 0)
   {
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-                "Had %u active addresses not deleted during shutdown\n",
-                s->active_addresses);
-    GNUNET_break (0);
+    LOG(GNUNET_ERROR_TYPE_ERROR,
+        "Had %u active addresses not deleted during shutdown\n",
+        s->active_addresses);
+    GNUNET_break(0);
   }
-  GNUNET_free (s->network_entries);
+  GNUNET_free(s->network_entries);
   GNUNET_CONTAINER_multihashmap_destroy (s->requests);
-  GNUNET_free (s);
+  GNUNET_free(s);
 }
 
-
 /* end of gnunet-service-ats-solver_proportional.c */




reply via email to

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