diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-05 21:41:58 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-05 21:41:58 +0000 |
commit | b8d5c4c9220576e85b4eec4c7ffa0390ba887fb5 (patch) | |
tree | f93ff7c7d94c81f5182e1c4bc7fd829f4fc9a609 /src/ats/plugin_ats_ril.c | |
parent | d4cb0035c1248e050d906e9018d36a9f5d19eb73 (diff) | |
download | gnunet-b8d5c4c9220576e85b4eec4c7ffa0390ba887fb5.tar.gz gnunet-b8d5c4c9220576e85b4eec4c7ffa0390ba887fb5.zip |
first pass at cleaning up ATS plugin API
Diffstat (limited to 'src/ats/plugin_ats_ril.c')
-rw-r--r-- | src/ats/plugin_ats_ril.c | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/src/ats/plugin_ats_ril.c b/src/ats/plugin_ats_ril.c index 31bed2a27..662935583 100644 --- a/src/ats/plugin_ats_ril.c +++ b/src/ats/plugin_ats_ril.c | |||
@@ -392,12 +392,7 @@ struct GAS_RIL_Handle | |||
392 | /** | 392 | /** |
393 | * The solver-plugin environment of the solver-plugin API | 393 | * The solver-plugin environment of the solver-plugin API |
394 | */ | 394 | */ |
395 | struct GNUNET_ATS_PluginEnvironment *plugin_envi; | 395 | struct GNUNET_ATS_PluginEnvironment *env; |
396 | |||
397 | /** | ||
398 | * Statistics handle | ||
399 | */ | ||
400 | struct GNUNET_STATISTICS_Handle *stats; | ||
401 | 396 | ||
402 | /** | 397 | /** |
403 | * Number of performed steps | 398 | * Number of performed steps |
@@ -786,8 +781,8 @@ ril_inform (struct GAS_RIL_Handle *solver, | |||
786 | enum GAS_Solver_Operation op, | 781 | enum GAS_Solver_Operation op, |
787 | enum GAS_Solver_Status stat) | 782 | enum GAS_Solver_Status stat) |
788 | { | 783 | { |
789 | if (NULL != solver->plugin_envi->info_cb) | 784 | if (NULL != solver->env->info_cb) |
790 | solver->plugin_envi->info_cb (solver->plugin_envi->info_cb_cls, op, stat, GAS_INFO_NONE); | 785 | solver->env->info_cb (solver->env->cls, op, stat, GAS_INFO_NONE); |
791 | } | 786 | } |
792 | 787 | ||
793 | /** | 788 | /** |
@@ -974,8 +969,8 @@ agent_get_utility (struct RIL_Peer_Agent *agent) | |||
974 | double delay_norm; | 969 | double delay_norm; |
975 | double pref_match; | 970 | double pref_match; |
976 | 971 | ||
977 | preferences = agent->envi->plugin_envi->get_preferences (agent->envi->plugin_envi->get_preference_cls, | 972 | preferences = agent->envi->env->get_preferences (agent->envi->env->cls, |
978 | &agent->peer); | 973 | &agent->peer); |
979 | 974 | ||
980 | delay_atsi = (double) ril_get_atsi (agent->address_inuse, GNUNET_ATS_QUALITY_NET_DELAY); | 975 | delay_atsi = (double) ril_get_atsi (agent->address_inuse, GNUNET_ATS_QUALITY_NET_DELAY); |
981 | delay_norm = RIL_UTILITY_DELAY_MAX*exp(-delay_atsi*0.00001); | 976 | delay_norm = RIL_UTILITY_DELAY_MAX*exp(-delay_atsi*0.00001); |
@@ -1937,7 +1932,7 @@ ril_step (struct GAS_RIL_Handle *solver) | |||
1937 | for (cur = solver->agents_head; NULL != cur; cur = cur->next) | 1932 | for (cur = solver->agents_head; NULL != cur; cur = cur->next) |
1938 | { | 1933 | { |
1939 | if (cur->suggestion_issue) { | 1934 | if (cur->suggestion_issue) { |
1940 | solver->plugin_envi->bandwidth_changed_cb(solver->plugin_envi->bw_changed_cb_cls, cur->suggestion_address); | 1935 | solver->env->bandwidth_changed_cb(solver->env->cls, cur->suggestion_address); |
1941 | cur->suggestion_issue = GNUNET_NO; | 1936 | cur->suggestion_issue = GNUNET_NO; |
1942 | } | 1937 | } |
1943 | } | 1938 | } |
@@ -2397,16 +2392,19 @@ GAS_ril_address_property_changed (void *solver, | |||
2397 | */ | 2392 | */ |
2398 | static void | 2393 | static void |
2399 | GAS_ril_address_preference_feedback (void *solver, | 2394 | GAS_ril_address_preference_feedback (void *solver, |
2400 | void *application, | 2395 | struct GNUNET_SERVER_Client *application, |
2401 | const struct GNUNET_PeerIdentity *peer, | 2396 | const struct GNUNET_PeerIdentity *peer, |
2402 | const struct GNUNET_TIME_Relative scope, | 2397 | const struct GNUNET_TIME_Relative scope, |
2403 | enum GNUNET_ATS_PreferenceKind kind, | 2398 | enum GNUNET_ATS_PreferenceKind kind, |
2404 | double score) | 2399 | double score) |
2405 | { | 2400 | { |
2406 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 2401 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2407 | "API_address_preference_feedback() Peer '%s' got a feedback of %+.3f from application %s for " | 2402 | "API_address_preference_feedback() Peer '%s' got a feedback of %+.3f from application %s for " |
2408 | "preference %s for %d seconds\n", GNUNET_i2s (peer), "UNKNOWN", | 2403 | "preference %s for %d seconds\n", |
2409 | GNUNET_ATS_print_preference_type (kind), scope.rel_value_us / 1000000); | 2404 | GNUNET_i2s (peer), |
2405 | "UNKNOWN", | ||
2406 | GNUNET_ATS_print_preference_type (kind), | ||
2407 | scope.rel_value_us / 1000000); | ||
2410 | } | 2408 | } |
2411 | 2409 | ||
2412 | 2410 | ||
@@ -2555,6 +2553,7 @@ GAS_ril_stop_get_preferred_address (void *solver, | |||
2555 | void * | 2553 | void * |
2556 | libgnunet_plugin_ats_ril_init (void *cls) | 2554 | libgnunet_plugin_ats_ril_init (void *cls) |
2557 | { | 2555 | { |
2556 | static struct GNUNET_ATS_SolverFunctions sf; | ||
2558 | struct GNUNET_ATS_PluginEnvironment *env = cls; | 2557 | struct GNUNET_ATS_PluginEnvironment *env = cls; |
2559 | struct GAS_RIL_Handle *solver = GNUNET_new (struct GAS_RIL_Handle); | 2558 | struct GAS_RIL_Handle *solver = GNUNET_new (struct GAS_RIL_Handle); |
2560 | struct RIL_Scope * cur; | 2559 | struct RIL_Scope * cur; |
@@ -2780,17 +2779,18 @@ libgnunet_plugin_ats_ril_init (void *cls) | |||
2780 | solver->parameters.social_welfare = RIL_DEFAULT_WELFARE; | 2779 | solver->parameters.social_welfare = RIL_DEFAULT_WELFARE; |
2781 | } | 2780 | } |
2782 | 2781 | ||
2783 | env->sf.s_add = &GAS_ril_address_add; | 2782 | solver->env = env; |
2784 | env->sf.s_address_update_property = &GAS_ril_address_property_changed; | 2783 | sf.cls = solver; |
2785 | env->sf.s_get = &GAS_ril_get_preferred_address; | 2784 | sf.s_add = &GAS_ril_address_add; |
2786 | env->sf.s_get_stop = &GAS_ril_stop_get_preferred_address; | 2785 | sf.s_address_update_property = &GAS_ril_address_property_changed; |
2787 | env->sf.s_pref = &GAS_ril_address_change_preference; | 2786 | sf.s_get = &GAS_ril_get_preferred_address; |
2788 | env->sf.s_feedback = &GAS_ril_address_preference_feedback; | 2787 | sf.s_get_stop = &GAS_ril_stop_get_preferred_address; |
2789 | env->sf.s_del = &GAS_ril_address_delete; | 2788 | sf.s_pref = &GAS_ril_address_change_preference; |
2790 | env->sf.s_bulk_start = &GAS_ril_bulk_start; | 2789 | sf.s_feedback = &GAS_ril_address_preference_feedback; |
2791 | env->sf.s_bulk_stop = &GAS_ril_bulk_stop; | 2790 | sf.s_del = &GAS_ril_address_delete; |
2791 | sf.s_bulk_start = &GAS_ril_bulk_start; | ||
2792 | sf.s_bulk_stop = &GAS_ril_bulk_stop; | ||
2792 | 2793 | ||
2793 | solver->plugin_envi = env; | ||
2794 | solver->networks_count = env->network_count; | 2794 | solver->networks_count = env->network_count; |
2795 | solver->network_entries = GNUNET_malloc (env->network_count * sizeof (struct RIL_Scope)); | 2795 | solver->network_entries = GNUNET_malloc (env->network_count * sizeof (struct RIL_Scope)); |
2796 | solver->step_count = 0; | 2796 | solver->step_count = 0; |
@@ -2818,7 +2818,7 @@ libgnunet_plugin_ats_ril_init (void *cls) | |||
2818 | LOG(GNUNET_ERROR_TYPE_DEBUG, "init() RBF_DIVISOR = %llu\n", | 2818 | LOG(GNUNET_ERROR_TYPE_DEBUG, "init() RBF_DIVISOR = %llu\n", |
2819 | solver->parameters.rbf_divisor); | 2819 | solver->parameters.rbf_divisor); |
2820 | 2820 | ||
2821 | return solver; | 2821 | return &sf; |
2822 | } | 2822 | } |
2823 | 2823 | ||
2824 | 2824 | ||
@@ -2830,7 +2830,8 @@ libgnunet_plugin_ats_ril_init (void *cls) | |||
2830 | void * | 2830 | void * |
2831 | libgnunet_plugin_ats_ril_done (void *cls) | 2831 | libgnunet_plugin_ats_ril_done (void *cls) |
2832 | { | 2832 | { |
2833 | struct GAS_RIL_Handle *s = cls; | 2833 | struct GNUNET_ATS_SolverFunctions *sf = cls; |
2834 | struct GAS_RIL_Handle *s = sf->cls; | ||
2834 | struct RIL_Peer_Agent *cur_agent; | 2835 | struct RIL_Peer_Agent *cur_agent; |
2835 | struct RIL_Peer_Agent *next_agent; | 2836 | struct RIL_Peer_Agent *next_agent; |
2836 | 2837 | ||