REST: nothing triggers rest
[oweals/gnunet.git] / src / ats / plugin_ats_mlp.c
index e6a790377736e1633ee1bb85fbdaa11a8b6b53b3..0f3a727a74a482275d050c774650e0ca1d49a79e 100644 (file)
@@ -2,20 +2,20 @@
      This file is part of GNUnet.
      Copyright (C) 2011-2014 GNUnet e.V.
 
-     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 Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     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.
+     Affero General Public License for more details.
+    
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-     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., 51 Franklin Street, Fifth Floor,
-     Boston, MA 02110-1301, USA.
+     SPDX-License-Identifier: AGPL3.0-or-later
 */
 
 /**
@@ -150,7 +150,7 @@ struct MLP_Problem
   /* Row indices quality metrics  */
   int r_q[RQ_QUALITY_METRIC_COUNT];
   /* Row indices ATS network quotas */
-  int r_quota[GNUNET_ATS_NetworkTypeCount];
+  int r_quota[GNUNET_NT_COUNT];
 
   /* Column index Diversity (D) column */
   int c_d;
@@ -213,12 +213,12 @@ struct MLP_Variables
 
   /* Quotas */
   /* Array mapping array index to ATS network */
-  int quota_index[GNUNET_ATS_NetworkTypeCount];
+  int quota_index[GNUNET_NT_COUNT];
   /* Outbound quotas */
-  unsigned long long quota_out[GNUNET_ATS_NetworkTypeCount];
+  unsigned long long quota_out[GNUNET_NT_COUNT];
   /* Inbound quotas */
 
-  unsigned long long quota_in[GNUNET_ATS_NetworkTypeCount];
+  unsigned long long quota_in[GNUNET_NT_COUNT];
 
   /* ATS ressource costs
    * array with GNUNET_ATS_QualityPropertiesCount elements
@@ -603,7 +603,7 @@ mlp_delete_problem (struct GAS_MLP_Handle *mlp)
   mlp->p.r_c9 = MLP_UNDEFINED;
   for (c = 0; c < RQ_QUALITY_METRIC_COUNT ; c ++)
     mlp->p.r_q[c] = MLP_UNDEFINED;
-  for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c ++)
+  for (c = 0; c < GNUNET_NT_COUNT; c ++)
     mlp->p.r_quota[c] = MLP_UNDEFINED;
   mlp->p.ci = MLP_UNDEFINED;
 
@@ -971,20 +971,20 @@ mlp_create_problem_add_address_information (void *cls,
   }
 
   addr_net = address->properties.scope;
-  for (addr_net_index = 0; addr_net_index < GNUNET_ATS_NetworkTypeCount; addr_net_index++)
+  for (addr_net_index = 0; addr_net_index < GNUNET_NT_COUNT; addr_net_index++)
   {
     if (mlp->pv.quota_index[addr_net_index] == addr_net)
       break;
   }
 
-  if (addr_net_index >= GNUNET_ATS_NetworkTypeCount)
+  if (addr_net_index >= GNUNET_NT_COUNT)
   {
     GNUNET_break (0);
     return GNUNET_OK;
   }
 
   max_quota = 0;
-  for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
+  for (c = 0; c < GNUNET_NT_COUNT; c++)
   {
     if (mlp->pv.quota_out[c] > max_quota)
       max_quota = mlp->pv.quota_out[c];
@@ -1133,11 +1133,11 @@ mlp_create_problem_add_invariant_rows (struct GAS_MLP_Handle *mlp, struct MLP_Pr
   p->r_c4 = mlp_create_problem_create_constraint (p, "c4", GLP_LO, (mlp->pv.n_min > p->num_peers) ? p->num_peers : mlp->pv.n_min, 0.0);
 
   /* Rows for c 10) Enforce network quotas */
-  for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
+  for (c = 0; c < GNUNET_NT_COUNT; c++)
   {
     char * text;
     GNUNET_asprintf(&text, "c10_quota_ats_%s",
-        GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]));
+        GNUNET_NT_to_string(mlp->pv.quota_index[c]));
     p->r_quota[c] = mlp_create_problem_create_constraint (p, text, GLP_DB, 0.0, mlp->pv.quota_out[c]);
     GNUNET_free (text);
   }
@@ -1401,7 +1401,7 @@ mlp_propagate_results (void *cls,
       mlpi->b_in = mlp_bw_in;
       address->assigned_bw_out = mlp_bw_out;
       mlpi->b_out = mlp_bw_out;
-      if ((NULL == mlp->exclude_peer) || (0 != memcmp (&address->peer, mlp->exclude_peer, sizeof (address->peer))))
+      if ((NULL == mlp->exclude_peer) || (0 != GNUNET_memcmp (&address->peer, mlp->exclude_peer)))
         mlp->env->bandwidth_changed_cb (mlp->env->cls, address);
       return GNUNET_OK;
     }
@@ -1417,7 +1417,7 @@ mlp_propagate_results (void *cls,
           mlpi->b_in = mlp_bw_in;
           address->assigned_bw_out = mlp_bw_out;
           mlpi->b_out = mlp_bw_out;
-          if ((NULL == mlp->exclude_peer) || (0 != memcmp (&address->peer, mlp->exclude_peer, sizeof (address->peer))))
+          if ((NULL == mlp->exclude_peer) || (0 != GNUNET_memcmp (&address->peer, mlp->exclude_peer)))
             mlp->env->bandwidth_changed_cb (mlp->env->cls, address);
           return GNUNET_OK;
       }
@@ -1556,6 +1556,7 @@ GAS_mlp_solve_problem (void *solver)
   struct GNUNET_TIME_Relative dur_mlp;
 
   GNUNET_assert(NULL != solver);
+  dur_lp = GNUNET_TIME_UNIT_ZERO; 
 
   if (GNUNET_YES == mlp->stat_bulk_lock)
     {
@@ -1854,7 +1855,7 @@ GAS_mlp_address_add (void *solver,
 {
   struct GAS_MLP_Handle *mlp = solver;
 
-  if (GNUNET_ATS_NetworkTypeCount <= network)
+  if (GNUNET_NT_COUNT <= network)
   {
     GNUNET_break (0);
     return;
@@ -2281,7 +2282,7 @@ GAS_mlp_address_change_preference (void *solver,
  */
 static void
 GAS_mlp_address_preference_feedback (void *solver,
-                                     struct GNUNET_SERVER_Client *application,
+                                     struct GNUNET_SERVICE_Client *application,
                                      const struct GNUNET_PeerIdentity *peer,
                                      const struct GNUNET_TIME_Relative scope,
                                      enum GNUNET_ATS_PreferenceKind kind,
@@ -2652,7 +2653,7 @@ libgnunet_plugin_ats_mlp_init (void *cls)
     n_min = MLP_DEFAULT_MIN_CONNECTIONS;
 
   /* Init network quotas */
-  for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
+  for (c = 0; c < GNUNET_NT_COUNT; c++)
   {
     mlp->pv.quota_index[c] = c;
     mlp->pv.quota_out[c] = env->out_quota[c];
@@ -2660,7 +2661,7 @@ libgnunet_plugin_ats_mlp_init (void *cls)
 
     LOG (GNUNET_ERROR_TYPE_INFO,
          "Quota for network `%s' (in/out) %llu/%llu\n",
-         GNUNET_ATS_print_network_type (c),
+         GNUNET_NT_to_string (c),
          mlp->pv.quota_out[c],
          mlp->pv.quota_in[c]);
     /* Check if defined quota could make problem unsolvable */
@@ -2668,7 +2669,7 @@ libgnunet_plugin_ats_mlp_init (void *cls)
     {
       LOG (GNUNET_ERROR_TYPE_INFO,
            _("Adjusting inconsistent outbound quota configuration for network `%s', is %llu must be at least %llu\n"),
-           GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
+           GNUNET_NT_to_string(mlp->pv.quota_index[c]),
            mlp->pv.quota_out[c],
            (n_min * b_min));
       mlp->pv.quota_out[c] = (n_min * b_min);
@@ -2677,7 +2678,7 @@ libgnunet_plugin_ats_mlp_init (void *cls)
     {
       LOG (GNUNET_ERROR_TYPE_INFO,
            _("Adjusting inconsistent inbound quota configuration for network `%s', is %llu must be at least %llu\n"),
-           GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
+           GNUNET_NT_to_string(mlp->pv.quota_index[c]),
            mlp->pv.quota_in[c],
            (n_min * b_min));
       mlp->pv.quota_in[c] = (n_min * b_min);
@@ -2687,7 +2688,7 @@ libgnunet_plugin_ats_mlp_init (void *cls)
     {
       LOG (GNUNET_ERROR_TYPE_INFO,
            _("Adjusting outbound quota configuration for network `%s'from %llu to %.0f\n"),
-           GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
+           GNUNET_NT_to_string(mlp->pv.quota_index[c]),
            mlp->pv.quota_out[c],
            mlp->pv.BIG_M);
       mlp->pv.quota_out[c] = mlp->pv.BIG_M ;
@@ -2696,7 +2697,7 @@ libgnunet_plugin_ats_mlp_init (void *cls)
     {
       LOG (GNUNET_ERROR_TYPE_INFO,
            _("Adjusting inbound quota configuration for network `%s' from %llu to %.0f\n"),
-           GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
+           GNUNET_NT_to_string(mlp->pv.quota_index[c]),
            mlp->pv.quota_in[c],
            mlp->pv.BIG_M);
       mlp->pv.quota_in[c] = mlp->pv.BIG_M ;