aboutsummaryrefslogtreecommitdiff
path: root/src/ats/gnunet-service-ats_plugins.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-07 12:52:52 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-07 12:52:52 +0000
commit3fa5361da7754b5080ae52963c99eb9dc848221f (patch)
tree3597b83da98cc03e294340d314fe3b7fafe4a39e /src/ats/gnunet-service-ats_plugins.c
parentfd0e0fcaa261ceb79897263fd037328d61e46a98 (diff)
downloadgnunet-3fa5361da7754b5080ae52963c99eb9dc848221f.tar.gz
gnunet-3fa5361da7754b5080ae52963c99eb9dc848221f.zip
simplify logic: just use string directly for the plugin name
Diffstat (limited to 'src/ats/gnunet-service-ats_plugins.c')
-rw-r--r--src/ats/gnunet-service-ats_plugins.c62
1 files changed, 7 insertions, 55 deletions
diff --git a/src/ats/gnunet-service-ats_plugins.c b/src/ats/gnunet-service-ats_plugins.c
index 8cc6af46f..53f12ec10 100644
--- a/src/ats/gnunet-service-ats_plugins.c
+++ b/src/ats/gnunet-service-ats_plugins.c
@@ -35,11 +35,6 @@
35 35
36 36
37/** 37/**
38 * Configured ATS solver
39 */
40static int ats_mode;
41
42/**
43 * Solver handle. 38 * Solver handle.
44 */ 39 */
45static struct GNUNET_ATS_SolverFunctions *sf; 40static struct GNUNET_ATS_SolverFunctions *sf;
@@ -416,45 +411,16 @@ GAS_plugins_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
416 unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount]; 411 unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount];
417 unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount]; 412 unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount];
418 char *mode_str; 413 char *mode_str;
419 char *plugin_short; 414 unsigned int c;
420 int c;
421 415
422 /* Figure out configured solution method */ 416 /* Figure out configured solution method */
423 if (GNUNET_SYSERR == 417 if (GNUNET_SYSERR ==
424 GNUNET_CONFIGURATION_get_value_string (cfg, "ats", "MODE", &mode_str)) 418 GNUNET_CONFIGURATION_get_value_string (cfg, "ats", "MODE", &mode_str))
425 { 419 {
426 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 420 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
427 "No resource assignment method configured, using proportional approach\n"); 421 "No resource assignment method configured, using proportional approach\n");
428 ats_mode = MODE_PROPORTIONAL; 422 mode_str = GNUNET_strdup ("proportional");
429 }
430 else
431 {
432 for (c = 0; c < strlen (mode_str); c++)
433 mode_str[c] = toupper (mode_str[c]);
434 if (0 == strcmp (mode_str, "PROPORTIONAL"))
435 ats_mode = MODE_PROPORTIONAL;
436 else if (0 == strcmp (mode_str, "MLP"))
437 {
438 ats_mode = MODE_MLP;
439#if !HAVE_LIBGLPK
440 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
441 "Assignment method `%s' configured, but GLPK is not available, please install \n",
442 mode_str);
443 ats_mode = MODE_PROPORTIONAL;
444#endif
445 }
446 else if (0 == strcmp (mode_str, "RIL"))
447 ats_mode = MODE_RIL;
448 else
449 {
450 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
451 "Invalid resource assignment method `%s' configured, using proportional approach\n",
452 mode_str);
453 ats_mode = MODE_PROPORTIONAL;
454 }
455 GNUNET_free(mode_str);
456 } 423 }
457
458 load_quotas (cfg, 424 load_quotas (cfg,
459 quotas_out, 425 quotas_out,
460 quotas_in, 426 quotas_in,
@@ -474,27 +440,13 @@ GAS_plugins_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
474 env.in_quota[c] = quotas_in[c]; 440 env.in_quota[c] = quotas_in[c];
475 } 441 }
476 442
477 switch (ats_mode) {
478 case MODE_PROPORTIONAL:
479 plugin_short = "proportional";
480 break;
481 case MODE_MLP:
482 plugin_short = "mlp";
483 break;
484 case MODE_RIL:
485 plugin_short = "ril";
486 break;
487 default:
488 plugin_short = NULL;
489 break;
490 }
491 GNUNET_asprintf (&plugin, 443 GNUNET_asprintf (&plugin,
492 "libgnunet_plugin_ats_%s", 444 "libgnunet_plugin_ats_%s",
493 plugin_short); 445 mode_str);
494 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 446 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
495 "Initializing solver `%s '`%s'\n", 447 "Initializing solver `%s'\n",
496 plugin_short, 448 mode_str);
497 plugin); 449 GNUNET_free (mode_str);
498 if (NULL == (sf = GNUNET_PLUGIN_load (plugin, &env))) 450 if (NULL == (sf = GNUNET_PLUGIN_load (plugin, &env)))
499 { 451 {
500 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 452 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,