diff options
Diffstat (limited to 'src/transport/test_transport_ats.c')
-rw-r--r-- | src/transport/test_transport_ats.c | 137 |
1 files changed, 68 insertions, 69 deletions
diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c index bf7bc0fe5a..d9e4b23d51 100644 --- a/src/transport/test_transport_ats.c +++ b/src/transport/test_transport_ats.c @@ -28,18 +28,17 @@ #define VERBOSE GNUNET_YES -static struct ATS_Handle * ats; +static struct ATS_Handle *ats; -static struct GNUNET_CONFIGURATION_Handle * cfg; +static struct GNUNET_CONFIGURATION_Handle *cfg; static struct TransportConfiguration *tc; -static void +static void ats_result_cb () { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ATS Result callback\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS Result callback\n"); } struct TransportConfiguration @@ -47,35 +46,35 @@ struct TransportConfiguration int peers; int mechanisms; - struct ATS_peer * p_head; - struct ATS_peer * p_tail; + struct ATS_peer *p_head; + struct ATS_peer *p_tail; - struct ATS_mechanism * m_head; - struct ATS_mechanism * m_tail; + struct ATS_mechanism *m_head; + struct ATS_mechanism *m_tail; }; -static void -create_ats_information (struct ATS_peer **p, int * c_p, - struct ATS_mechanism ** m, int * c_m) -{ - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ATS needs addresses\n"); +static void +create_ats_information (struct ATS_peer **p, int *c_p, + struct ATS_mechanism **m, int *c_m) +{ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS needs addresses\n"); - (*p) = tc->p_head; - (*c_p) = tc->mechanisms; - (*m) = tc->m_head; - (*c_m) = tc->mechanisms; + (*p) = tc->p_head; + (*c_p) = tc->mechanisms; + (*m) = tc->m_head; + (*c_m) = tc->mechanisms; } -static -int run_ats () +static int +run_ats () { int ret = 0; + ats_calculate_bandwidth_distribution (ats); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Running ATS: %s \n", (ret==0)? "SUCCESSFUL": "FAILED"); + "Running ATS: %s \n", (ret == 0) ? "SUCCESSFUL" : "FAILED"); return ret; } @@ -84,96 +83,96 @@ static int init_ats () { int ret = 0; - ats = ats_init(1.0, 1.0, 1.0, 50000, 5, 10, ATS_MAX_EXEC_DURATION, - create_ats_information, - ats_result_cb); + + ats = ats_init (1.0, 1.0, 1.0, 50000, 5, 10, ATS_MAX_EXEC_DURATION, + create_ats_information, ats_result_cb); //GNUNET_assert (ats != NULL); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Initializing ATS: %s \n", (ret==0)? "SUCCESSFUL": "FAILED"); + "Initializing ATS: %s \n", (ret == 0) ? "SUCCESSFUL" : "FAILED"); return ret; } -static int +static int shutdown_ats () { int ret = 0; + ats_delete_problem (ats); ats_shutdown (ats); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Shutdown ATS: %s \n", (ret==0)? "SUCCESSFUL": "FAILED"); + "Shutdown ATS: %s \n", (ret == 0) ? "SUCCESSFUL" : "FAILED"); return ret; } /* To make compiler happy */ -void -dummy() +void +dummy () { - struct ATS_quality_metric * q = qm; + struct ATS_quality_metric *q = qm; + q = NULL; - struct ATS_ressource * r = ressources; + struct ATS_ressource *r = ressources; + r = NULL; - q++; + q++; r++; } -static void +static void iterate_peer_values (void *cls, - const char *section, - const char *option, - const char *value) + const char *section, const char *option, const char *value) { if (strcmp (option, "f") == 0) - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "\t %s %s\n", option, value); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\t %s %s\n", option, value); } static void iterate_mech_values (void *cls, - const char *section, - const char *option, - const char *value) + const char *section, const char *option, const char *value) { if (strcmp (option, "f") == 0) - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "\t %s %s\n", option, value); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\t %s %s\n", option, value); } -static void -iterate_sections (void *cls, - const char *section) +static void +iterate_sections (void *cls, const char *section) { - struct TransportConfiguration * tc = cls; + struct TransportConfiguration *tc = cls; + /* Peer definition */ - if (99 == strlen(section)) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Peer '%s`\n", section); - GNUNET_HashCode h; - int res =GNUNET_CRYPTO_hash_from_string(section, &h); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "HASH '%s` %i\n", GNUNET_h2s (&h), res); - GNUNET_CONFIGURATION_iterate_section_values(cfg, section, iterate_peer_values, NULL); - tc->peers++; - } - if (10 == strlen(section)) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Mechanism '%s`\n",section); - GNUNET_CONFIGURATION_iterate_section_values(cfg, section, iterate_mech_values, NULL); - tc->peers++; - } + if (99 == strlen (section)) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Peer '%s`\n", section); + GNUNET_HashCode h; + int res = GNUNET_CRYPTO_hash_from_string (section, &h); + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "HASH '%s` %i\n", GNUNET_h2s (&h), res); + GNUNET_CONFIGURATION_iterate_section_values (cfg, section, + iterate_peer_values, NULL); + tc->peers++; + } + if (10 == strlen (section)) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Mechanism '%s`\n", section); + GNUNET_CONFIGURATION_iterate_section_values (cfg, section, + iterate_mech_values, NULL); + tc->peers++; + } } -static struct TransportConfiguration * -load_transport_configuration (char * filename) +static struct TransportConfiguration * +load_transport_configuration (char *filename) { - struct TransportConfiguration * ret = GNUNET_malloc(sizeof (struct TransportConfiguration)); + struct TransportConfiguration *ret = + GNUNET_malloc (sizeof (struct TransportConfiguration)); - cfg = GNUNET_CONFIGURATION_create(); - GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_load(cfg, filename)); + cfg = GNUNET_CONFIGURATION_create (); + GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (cfg, filename)); GNUNET_CONFIGURATION_iterate_sections (cfg, iterate_sections, ret); GNUNET_CONFIGURATION_destroy (cfg); cfg = NULL; |