From 7e7b70bcdbc067949bfd5249944b27ad57b3777c Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Tue, 19 Feb 2013 12:52:39 +0000 Subject: [PATCH] refactoring and renaming --- src/ats/Makefile.am | 3 +- src/ats/ats.conf.in | 17 +- src/ats/gnunet-service-ats_addresses_mlp.c | 213 ++++++++++----------- src/ats/gnunet-service-ats_addresses_mlp.h | 10 +- src/ats/test_ats_api_common.h | 2 +- src/ats/test_ats_mlp.c | 103 +--------- 6 files changed, 126 insertions(+), 222 deletions(-) diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am index 5ee5183e9..048f1e220 100644 --- a/src/ats/Makefile.am +++ b/src/ats/Makefile.am @@ -200,7 +200,8 @@ test_ats_mlp_SOURCES = \ test_ats_mlp_LDADD = \ $(GN_LIBGLPK) \ $(top_builddir)/src/util/libgnunetutil.la \ - $(top_builddir)/src/statistics/libgnunetstatistics.la + $(top_builddir)/src/statistics/libgnunetstatistics.la \ + $(top_builddir)/src/ats/libgnunetats.la #test_ats_mlp_averaging_SOURCES = \ # $(GN_MLP_SRC) test_ats_mlp_averaging.c test_ats_api_common.c diff --git a/src/ats/ats.conf.in b/src/ats/ats.conf.in index bdc064e2f..481c46ec4 100644 --- a/src/ats/ats.conf.in +++ b/src/ats/ats.conf.in @@ -32,16 +32,23 @@ WLAN_QUOTA_OUT = 1 MiB # MLP specific settings -# MAX_DURATION = 3 s -# MAX_ITERATIONS = 1024 - +ATS_MIN_INTERVAL = 15000 +ATS_EXEC_INTERVAL = 30000 +# MLP defaults +# MLP_MAX_DURATION = 3 s +# MLP_MAX_ITERATIONS = 1024 +# MLP_COEFFICIENT_D = 1.0 +# MLP_COEFFICIENT_U = 1.0 +# MLP_COEFFICIENT_R = 1.0 +# MLP_MIN_BANDWIDTH = 1024 +# MLP_MIN_CONNECTIONS = 4 +# MLP Debugging settings DUMP_MLP = NO DUMP_SOLUTION = NO DUMP_OVERWRITE = NO DUMP_MIN_PEERS = 0 DUMP_MIN_ADDRS = 0 DUMP_OVERWRITE = NO -ATS_MIN_INTERVAL = 15000 -ATS_EXEC_INTERVAL = 30000 + diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index 98a77ae18..50983cec1 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c @@ -1101,8 +1101,8 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int n_min; struct GNUNET_TIME_Relative i_exec; int c; - char * quota_out_str; - char * quota_in_str; + int c2; + int found; struct GNUNET_TIME_Relative max_duration; long long unsigned int max_iterations; @@ -1111,21 +1111,21 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, int res = glp_init_env(); switch (res) { case 0: - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GLPK: `%s'\n", + LOG (GNUNET_ERROR_TYPE_DEBUG, "GLPK: `%s'\n", "initialization successful"); break; case 1: - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GLPK: `%s'\n", + LOG (GNUNET_ERROR_TYPE_DEBUG, "GLPK: `%s'\n", "environment is already initialized"); break; case 2: - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not init GLPK: `%s'\n", + LOG (GNUNET_ERROR_TYPE_ERROR, "Could not init GLPK: `%s'\n", "initialization failed (insufficient memory)"); GNUNET_free(mlp); return NULL; break; case 3: - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not init GLPK: `%s'\n", + LOG (GNUNET_ERROR_TYPE_ERROR, "Could not init GLPK: `%s'\n", "initialization failed (unsupported programming model)"); GNUNET_free(mlp); return NULL; @@ -1136,54 +1136,57 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, /* Create initial MLP problem */ mlp->prob = glp_create_prob(); - GNUNET_assert (mlp->prob != NULL); + if (NULL == mlp->prob) + { + GNUNET_assert (mlp->prob != NULL); + } mlp->BIG_M = (double) BIG_M_VALUE; /* Get timeout for iterations */ - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time(cfg, "ats", "MAX_DURATION", &max_duration)) + if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time(cfg, "ats", "MLP_MAX_DURATION", &max_duration)) { max_duration = MLP_MAX_EXEC_DURATION; } /* Get maximum number of iterations */ - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_size(cfg, "ats", "MAX_ITERATIONS", &max_iterations)) + if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_size(cfg, "ats", "MLP_MAX_ITERATIONS", &max_iterations)) { max_iterations = MLP_MAX_ITERATIONS; } /* Get diversity coefficient from configuration */ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", - "COEFFICIENT_D", + "MLP_COEFFICIENT_D", &tmp)) D = (double) tmp / 100; else - D = 1.0; + D = DEFAULT_D; /* Get proportionality coefficient from configuration */ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", - "COEFFICIENT_R", + "MLP_COEFFICIENT_R", &tmp)) R = (double) tmp / 100; else - R = 1.0; + R = DEFAULT_R; /* Get utilization coefficient from configuration */ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", - "COEFFICIENT_U", + "MLP_COEFFICIENT_U", &tmp)) U = (double) tmp / 100; else - U = 1.0; + U = DEFAULT_U; /* Get quality metric coefficients from configuration */ - int i_delay = -1; - int i_distance = -1; + int i_delay = NaN; + int i_distance = NaN; int q[GNUNET_ATS_QualityPropertiesCount] = GNUNET_ATS_QualityProperties; for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++) { /* initialize quality coefficients with default value 1.0 */ - mlp->co_Q[c] = 1.0; + mlp->co_Q[c] = DEFAULT_QUALITY; mlp->q[c] = q[c]; if (q[c] == GNUNET_ATS_QUALITY_NET_DELAY) @@ -1192,24 +1195,24 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, i_distance = c; } - if ((i_delay != -1) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", - "COEFFICIENT_QUALITY_DELAY", + if ((i_delay != NaN) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", + "MLP_COEFFICIENT_QUALITY_DELAY", &tmp))) mlp->co_Q[i_delay] = (double) tmp / 100; else - mlp->co_Q[i_delay] = 1.0; + mlp->co_Q[i_delay] = DEFAULT_QUALITY; - if ((i_distance != -1) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", - "COEFFICIENT_QUALITY_DISTANCE", + if ((i_distance != NaN) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", + "MLP_COEFFICIENT_QUALITY_DISTANCE", &tmp))) mlp->co_Q[i_distance] = (double) tmp / 100; else - mlp->co_Q[i_distance] = 1.0; + mlp->co_Q[i_distance] = DEFAULT_QUALITY; /* Get minimum bandwidth per used address from configuration */ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", - "MIN_BANDWIDTH", + "MLP_MIN_BANDWIDTH", &tmp)) b_min = tmp; else @@ -1219,103 +1222,78 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, /* Get minimum number of connections from configuration */ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", - "MIN_CONNECTIONS", + "MLP_MIN_CONNECTIONS", &tmp)) n_min = tmp; else - n_min = 4; + n_min = DEFAULT_MIN_CONNECTIONS; /* Init network quotas */ int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType; for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) { - mlp->quota_index[c] = quotas[c]; - static char * entry_in = NULL; - static char * entry_out = NULL; - unsigned long long quota_in = 0; - unsigned long long quota_out = 0; - - switch (quotas[c]) { - case GNUNET_ATS_NET_UNSPECIFIED: - entry_out = "UNSPECIFIED_QUOTA_OUT"; - entry_in = "UNSPECIFIED_QUOTA_IN"; - break; - case GNUNET_ATS_NET_LOOPBACK: - entry_out = "LOOPBACK_QUOTA_OUT"; - entry_in = "LOOPBACK_QUOTA_IN"; - break; - case GNUNET_ATS_NET_LAN: - entry_out = "LAN_QUOTA_OUT"; - entry_in = "LAN_QUOTA_IN"; - break; - case GNUNET_ATS_NET_WAN: - entry_out = "WAN_QUOTA_OUT"; - entry_in = "WAN_QUOTA_IN"; - break; - case GNUNET_ATS_NET_WLAN: - entry_out = "WLAN_QUOTA_OUT"; - entry_in = "WLAN_QUOTA_IN"; - break; - default: - break; - } - - if ((entry_in == NULL) || (entry_out == NULL)) - continue; - - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, "a_out_str)) - { - if (0 == strcmp(quota_out_str, BIG_M_STRING) || - (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str, "a_out))) - quota_out = mlp->BIG_M; - - GNUNET_free (quota_out_str); - quota_out_str = NULL; - } - else if (GNUNET_ATS_NET_UNSPECIFIED == quotas[c]) - { - quota_out = mlp->BIG_M; - } - else - { - quota_out = mlp->BIG_M; - } - - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_in, "a_in_str)) - { - if (0 == strcmp(quota_in_str, BIG_M_STRING) || - (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, "a_in))) - quota_in = mlp->BIG_M; - - GNUNET_free (quota_in_str); - quota_in_str = NULL; - } - else if (GNUNET_ATS_NET_UNSPECIFIED == quotas[c]) - { - quota_in = mlp->BIG_M; - } - else - { - quota_in = mlp->BIG_M; - } - - /* Check if defined quota could make problem unsolvable */ - if (((n_min * b_min) > quota_out) && (GNUNET_ATS_NET_UNSPECIFIED != quotas[c])) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Inconsistent quota configuration value `%s': " - "outbound quota (%u Bps) too small for combination of minimum connections and minimum bandwidth per peer (%u * %u Bps = %u)\n", entry_out, quota_out, n_min, b_min, n_min * b_min); + found = GNUNET_NO; + for (c2 = 0; c2 < dest_length; c2++) + { + if (quotas[c] == network[c2]) + { + mlp->quota_index[c] = network[c2]; + mlp->quota_out[c] = out_dest[c2]; + mlp->quota_in[c] = in_dest[c2]; + found = GNUNET_YES; + LOG (GNUNET_ERROR_TYPE_DEBUG, "Quota for network `%s' (in/out) %llu/%llu\n", + GNUNET_ATS_print_network_type(mlp->quota_index[c]), + mlp->quota_out[c], + mlp->quota_in[c]); + break; + } + } + + /* Check if defined quota could make problem unsolvable */ + if ((n_min * b_min) > mlp->quota_out[c]) + { + 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->quota_index[c]), + mlp->quota_out[c], + (n_min * b_min)); + mlp->quota_out[c] = (n_min * b_min); + } + if ((n_min * b_min) > mlp->quota_in[c]) + { + 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->quota_index[c]), + mlp->quota_in[c], + (n_min * b_min)); + mlp->quota_in[c] = (n_min * b_min); + } - GAS_mlp_done(mlp); - mlp = NULL; - return NULL; - } + /* Check if bandwidth is too big to make problem solvable */ + if (mlp->BIG_M < mlp->quota_out[c]) + { + LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting outbound quota configuration for network `%s'from %llu to %.0f\n"), + GNUNET_ATS_print_network_type(mlp->quota_index[c]), + mlp->quota_out[c], + mlp->BIG_M); + mlp->quota_out[c] = mlp->BIG_M; + } + if (mlp->BIG_M < mlp->quota_in[c]) + { + LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inbound quota configuration for network `%s' from %llu to %.0f\n"), + GNUNET_ATS_print_network_type(mlp->quota_index[c]), + mlp->quota_in[c], + mlp->BIG_M); + mlp->quota_in[c] = mlp->BIG_M; + } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found `%s' quota %llu and `%s' quota %llu\n", - entry_out, quota_out, entry_in, quota_in); - GNUNET_STATISTICS_update ((struct GNUNET_STATISTICS_Handle *) stats, entry_out, quota_out, GNUNET_NO); - GNUNET_STATISTICS_update ((struct GNUNET_STATISTICS_Handle *) stats, entry_in, quota_in, GNUNET_NO); - mlp->quota_out[c] = quota_out; - mlp->quota_in[c] = quota_in; + if (GNUNET_NO == found) + { + mlp->quota_in[c] = ntohl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); + mlp->quota_out[c] = ntohl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); + LOG (GNUNET_ERROR_TYPE_INFO, _("Using default quota configuration for network `%s' (in/out) %llu/%llu\n"), + GNUNET_ATS_print_network_type(mlp->quota_index[c]), + mlp->quota_in[c], + mlp->quota_out[c]); + } } /* Get minimum number of connections from configuration */ @@ -1326,6 +1304,8 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, else mlp->exec_interval = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30); + + /* Assign options to handle */ mlp->stats = (struct GNUNET_STATISTICS_Handle *) stats; mlp->max_iterations = max_iterations; mlp->max_exec_duration = max_duration; @@ -1363,6 +1343,9 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, mlp->n_min = n_min; mlp->m_q = GNUNET_ATS_QualityPropertiesCount; mlp->semaphore = GNUNET_NO; + + LOG (GNUNET_ERROR_TYPE_DEBUG, "solver ready\n"); + return mlp; } @@ -1538,7 +1521,7 @@ update_quality (struct GAS_MLP_Handle *mlp, struct ATS_Address * address) void GAS_mlp_address_add (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address) { - + LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding address for peer `%s'\n", GNUNET_i2s(&address->peer)); } /** @@ -1572,6 +1555,8 @@ GAS_mlp_address_update (void *solver, struct MLP_information *mlpi; struct GAS_MLP_SolutionContext ctx; + LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating address for peer `%s'\n", GNUNET_i2s(&address->peer)); + GNUNET_STATISTICS_update (mlp->stats, "# MLP address updates", 1, GNUNET_NO); /* We add a new address */ @@ -1676,6 +1661,8 @@ GAS_mlp_address_delete (void *solver, int session_only) { struct GAS_MLP_Handle *mlp = solver; + + LOG (GNUNET_ERROR_TYPE_DEBUG, "Deleting address for peer `%s'\n", GNUNET_i2s(&address->peer)); GNUNET_STATISTICS_update (mlp->stats,"# LP address deletions", 1, GNUNET_NO); struct GAS_MLP_SolutionContext ctx; diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h index a49f585ed..f2ec79487 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.h +++ b/src/ats/gnunet-service-ats_addresses_mlp.h @@ -40,7 +40,15 @@ #define MLP_AVERAGING_QUEUE_LENGTH 3 #define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3) -#define MLP_MAX_ITERATIONS INT_MAX +#define MLP_MAX_ITERATIONS 1024 + +#define DEFAULT_D 1.0 +#define DEFAULT_R 1.0 +#define DEFAULT_U 1.0 +#define DEFAULT_QUALITY 1.0 +#define DEFAULT_MIN_CONNECTIONS 4 + +#define NaN -1 struct ATS_Peer { diff --git a/src/ats/test_ats_api_common.h b/src/ats/test_ats_api_common.h index 1f9bd10c1..223d0c038 100644 --- a/src/ats/test_ats_api_common.h +++ b/src/ats/test_ats_api_common.h @@ -29,7 +29,7 @@ #include "gnunet_ats_service.h" #include "gnunet-service-ats_addresses.h" -#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) +#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) #define PEERID0 "2AK99KD8RM9UA9LC3QKA0IQ5UBFC0FBB50EBGCFQT8448DGGACNAC4CJQDD1CPFS494O41U88DJD1FLIG8VA5CQR9IN4L96GP104MVO" #define PEERID1 "5ED7I0AR3MSTAL7FQN04S22E0EQ3CR9RLASCDLVMM1BNFPUPTCT46DLKNJ4DACASJ6U0DR5J8S3R2UJL49682JS7MOVRAB8P8A4PJH0" diff --git a/src/ats/test_ats_mlp.c b/src/ats/test_ats_mlp.c index b2cbb36b2..ed315bf90 100644 --- a/src/ats/test_ats_mlp.c +++ b/src/ats/test_ats_mlp.c @@ -134,6 +134,7 @@ static void end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { timeout_task = GNUNET_SCHEDULER_NO_TASK; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Test failed: timeout\n")); end_now (1); } @@ -205,108 +206,8 @@ check (void *cls, char *const *args, const char *cfgfile, /* Adding address */ GAS_mlp_address_add (mlp, addresses, address); + /* Retrieving preferred address for peer and wait for callback */ GAS_mlp_get_preferred_address (mlp, addresses, &p); - - -#if 0 - struct ATS_Address addr[10]; - struct ATS_Address *res[10]; - struct GAS_MLP_SolutionContext ctx; - int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType; - unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount]; - unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount]; - int quota_count; - - - - - - quota_count = load_quotas(cfg, quotas_in, quotas_out, GNUNET_ATS_NetworkTypeCount); - mlp = GAS_mlp_init (cfg, NULL, quotas, quotas_in, quotas_out, quota_count); - mlp->auto_solve = GNUNET_NO; - - struct GNUNET_PeerIdentity p[10]; - - /* Creating peer 1 */ - GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[0].hashPubKey); - /* Creating peer 2 */ - GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[1].hashPubKey); - - /* Creating peer 1 address 1 */ - addr[0].peer.hashPubKey = p[0].hashPubKey; - struct GNUNET_ATS_Information a1_ats[3]; - set_ats (&a1_ats[0], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); - set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 1); - set_ats (&a1_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); - create_address (&addr[0], "dummy", 3, &a1_ats[0]); - addr[0].atsp_network_type = GNUNET_ATS_NET_WAN; - - /* Creating peer 1 address 2 */ - addr[1].peer.hashPubKey = p[0].hashPubKey; - struct GNUNET_ATS_Information a2_ats[3]; - set_ats (&a2_ats[1], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); - set_ats (&a2_ats[0], GNUNET_ATS_QUALITY_NET_DELAY, 1); - set_ats (&a2_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); - create_address (&addr[1], "dummy2", 3, &a2_ats[0]); - addr[1].atsp_network_type = GNUNET_ATS_NET_LAN; - - /* Creating peer 2 address 1 */ - addr[2].peer.hashPubKey = p[1].hashPubKey; - struct GNUNET_ATS_Information a3_ats[3]; - set_ats (&a3_ats[1], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); - set_ats (&a3_ats[0], GNUNET_ATS_QUALITY_NET_DELAY, 1); - set_ats (&a3_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); - create_address (&addr[2], "dummy3", 3, &a3_ats[0]); - addr[2].atsp_network_type = GNUNET_ATS_NET_LAN; - - GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[0], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); - - /* Add peer 1 address 1 */ - GAS_mlp_address_update (mlp, addresses, &addr[0]); - - GNUNET_assert (mlp != NULL); - GNUNET_assert (mlp->addr_in_problem == 1); - - /* Update an peer 1 address 1 */ - set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 1); - GAS_mlp_address_update (mlp, addresses, &addr[0]); - GNUNET_assert (mlp->addr_in_problem == 1); - - /* Add peer 1 address 2 */ - GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[1], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); - GAS_mlp_address_update (mlp, addresses, &addr[1]); - GNUNET_assert (mlp->addr_in_problem == 2); - - /* Add peer 2 address 1 */ - GNUNET_CONTAINER_multihashmap_put(addresses, &addr[2].peer.hashPubKey, &addr[2], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); - GAS_mlp_address_update (mlp, addresses, &addr[2]); - GNUNET_assert (mlp->addr_in_problem == 3); - - GNUNET_assert (GNUNET_OK == GAS_mlp_solve_problem(mlp, &ctx)); - GNUNET_assert (GNUNET_OK == ctx.lp_result); - GNUNET_assert (GNUNET_OK == ctx.mlp_result); - - res[0] = GAS_mlp_get_preferred_address(mlp, addresses, &p[0]); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Preferred address `%s' outbound bandwidth: %u Bps\n",res[0]->plugin, res[0]->assigned_bw_out); - res[1] = GAS_mlp_get_preferred_address(mlp, addresses, &p[1]); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Preferred address `%s' outbound bandwidth: %u Bps\n",res[1]->plugin, res[1]->assigned_bw_out); - - /* Delete an address */ - GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[0].peer.hashPubKey, &addr[0]); - GAS_mlp_address_delete (mlp, addresses, &addr[0]); - GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[1].peer.hashPubKey, &addr[1]); - GAS_mlp_address_delete (mlp, addresses, &addr[1]); - GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[2].peer.hashPubKey, &addr[2]); - GAS_mlp_address_delete (mlp, addresses, &addr[2]); - - GNUNET_assert (mlp->addr_in_problem == 0); - - GNUNET_free (addr[0].plugin); - GNUNET_free (addr[1].plugin); -#endif - - ret = 0; - return; } -- 2.25.1