+ GNUNET_free (quota_wan_in_str);
+ quota_wan_in_str = NULL;
+ }
+ else
+ ah->wan_quota_in = (UINT32_MAX) /10;
+
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_OUT", "a_wan_out_str))
+ {
+ if (0 == strcmp(quota_wan_out_str, "unlimited") ||
+ (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_wan_out_str, &ah->wan_quota_out)))
+ ah->wan_quota_out = (UINT32_MAX) /10;
+
+ GNUNET_free (quota_wan_out_str);
+ quota_wan_out_str = NULL;
+ }
+ else
+ ah->wan_quota_out = (UINT32_MAX) /10;
+
+ /* Initialize the addresses database */
+ ah->addresses = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
+ GNUNET_assert (NULL != ah->addresses);
+
+ /* Figure out configured solution method */
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, "ats", "MODE", &mode_str))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "No ressource assignment method configured, using simplistic approch\n");
+ ah->ats_mode = MODE_SIMPLISTIC;
+ }
+ else
+ {
+ for (c = 0; c < strlen (mode_str); c++)
+ mode_str[c] = toupper (mode_str[c]);
+ if (0 == strcmp (mode_str, "SIMPLISTIC"))
+ {
+ ah->ats_mode = MODE_SIMPLISTIC;
+ }
+ else if (0 == strcmp (mode_str, "MLP"))
+ {
+ ah->ats_mode = MODE_MLP;
+#if !HAVE_LIBGLPK
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Assignment method `%s' configured, but GLPK is not availabe, please install \n", mode_str);
+ ah->ats_mode = MODE_SIMPLISTIC;
+#endif
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid ressource assignment method `%s' configured, using simplistic approch\n", mode_str);
+ ah->ats_mode = MODE_SIMPLISTIC;
+ }
+ GNUNET_free (mode_str);
+ }
+ /* Start configured solution method */
+ switch (ah->ats_mode)
+ {
+ case MODE_MLP:
+ /* Init the MLP solver with default values */
+#if HAVE_LIBGLPK
+ ah->ats_mode = MODE_MLP;
+ ah->s_init = &GAS_mlp_init;
+ ah->s_update = &GAS_mlp_address_update;
+ ah->s_get = &GAS_mlp_get_preferred_address;
+ ah->s_pref = &GAS_mlp_address_change_preference;
+ ah->s_del = &GAS_mlp_address_delete;
+ ah->s_done = &GAS_mlp_done;
+#else
+ GNUNET_free (ah);
+ return NULL;
+#endif
+ break;
+ case MODE_SIMPLISTIC:
+ /* Init the simplistic solver with default values */
+ ah->ats_mode = MODE_SIMPLISTIC;
+ ah->s_init = &GAS_simplistic_init;
+ ah->s_update = &GAS_simplistic_address_update;
+ ah->s_get = &GAS_simplistic_get_preferred_address;
+ ah->s_pref = &GAS_simplistic_address_change_preference;
+ ah->s_del = &GAS_simplistic_address_delete;
+ ah->s_done = &GAS_simplistic_done;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS started in %s mode\n", "SIMPLISTIC");
+ break;
+ default:
+ return NULL;
+ break;
+ }
+
+ GNUNET_assert (NULL != ah->s_init);
+ GNUNET_assert (NULL != ah->s_update);
+ GNUNET_assert (NULL != ah->s_get);
+ GNUNET_assert (NULL != ah->s_pref);
+ GNUNET_assert (NULL != ah->s_del);
+ GNUNET_assert (NULL != ah->s_done);
+
+ ah->solver = ah->s_init (cfg, stats);
+ if (NULL == ah->solver)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize MLP solver!\n");
+ GNUNET_free (ah);
+ return NULL;
+ }
+
+ /* up and running */
+ ah->running = GNUNET_YES;
+ return ah;