/*
This file is part of GNUnet.
- Copyright (C) 2011-2014 Christian Grothoff (and other contributing authors)
+ 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., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
/* 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;
/* 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
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;
double *val_array;
int *ind_array;
- GNUNET_assert (NULL != p);
GNUNET_assert (NULL != p->prob);
/* Get number of columns and prepare data structure */
}
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];
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);
}
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;
}
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;
}
struct GNUNET_TIME_Relative dur_mlp;
GNUNET_assert(NULL != solver);
+ dur_lp = GNUNET_TIME_UNIT_ZERO;
if (GNUNET_YES == mlp->stat_bulk_lock)
{
{
LOG(GNUNET_ERROR_TYPE_DEBUG, "Problem size changed, rebuilding\n");
notify(mlp, GAS_OP_SOLVE_SETUP_START, GAS_STAT_SUCCESS, GAS_INFO_FULL);
- mlp_delete_problem(mlp);
- if (GNUNET_SYSERR == mlp_create_problem(mlp))
+ mlp_delete_problem (mlp);
+ if (GNUNET_SYSERR == mlp_create_problem (mlp))
{
notify(mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_FAIL, GAS_INFO_FULL);
return GNUNET_SYSERR;
{
struct GAS_MLP_Handle *mlp = solver;
- if (GNUNET_ATS_NetworkTypeCount <= network)
+ if (GNUNET_NT_COUNT <= network)
{
GNUNET_break (0);
return;
struct MLP_information *mlpi = address->solver_information;
struct GAS_MLP_Handle *mlp = solver;
+ if (NULL == mlp->p.prob)
+ return; /* There is no MLP problem to update yet */
+
if (NULL == mlpi)
{
LOG (GNUNET_ERROR_TYPE_INFO,
*/
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,
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];
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 */
{
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);
{
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);
{
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 ;
{
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 ;