diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-12 09:59:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-12 09:59:00 +0000 |
commit | 47f8e95b1b10961d37e7fd3ae26c697130ce9e91 (patch) | |
tree | c786f63a8355131a92af74800b46858ab9694536 /src/ats/plugin_ats_mlp.c | |
parent | e2e4a05a592edb53c7ba182564b2c9b4c11388ca (diff) | |
download | gnunet-47f8e95b1b10961d37e7fd3ae26c697130ce9e91.tar.gz gnunet-47f8e95b1b10961d37e7fd3ae26c697130ce9e91.zip |
code cleanup
Diffstat (limited to 'src/ats/plugin_ats_mlp.c')
-rw-r--r-- | src/ats/plugin_ats_mlp.c | 463 |
1 files changed, 433 insertions, 30 deletions
diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c index 436a58b0e..98244c9ae 100644 --- a/src/ats/plugin_ats_mlp.c +++ b/src/ats/plugin_ats_mlp.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2011 Christian Grothoff (and other contributing authors) | 3 | (C) 2011-2014 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -26,6 +26,398 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "plugin_ats_mlp.h" | 28 | #include "plugin_ats_mlp.h" |
29 | #include "platform.h" | ||
30 | #include "gnunet_util_lib.h" | ||
31 | #include "gnunet_ats_service.h" | ||
32 | #include "gnunet_ats_plugin.h" | ||
33 | #include "gnunet-service-ats_addresses.h" | ||
34 | #include "gnunet_statistics_service.h" | ||
35 | #include <float.h> | ||
36 | #include <glpk.h> | ||
37 | |||
38 | |||
39 | #define BIG_M_VALUE (UINT32_MAX) /10 | ||
40 | #define BIG_M_STRING "unlimited" | ||
41 | |||
42 | #define MLP_AVERAGING_QUEUE_LENGTH 3 | ||
43 | |||
44 | #define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) | ||
45 | #define MLP_MAX_ITERATIONS 4096 | ||
46 | |||
47 | #define DEFAULT_D 1.0 | ||
48 | #define DEFAULT_R 1.0 | ||
49 | #define DEFAULT_U 1.0 | ||
50 | #define DEFAULT_QUALITY 1.0 | ||
51 | #define DEFAULT_MIN_CONNECTIONS 4 | ||
52 | #define DEFAULT_PEER_PREFERENCE 1.0 | ||
53 | |||
54 | #define MLP_NaN -1 | ||
55 | #define MLP_UNDEFINED 0 | ||
56 | #define GLP_YES 1.0 | ||
57 | #define GLP_NO 0.0 | ||
58 | |||
59 | enum MLP_Output_Format | ||
60 | { | ||
61 | MLP_MPS, | ||
62 | MLP_CPLEX, | ||
63 | MLP_GLPK | ||
64 | }; | ||
65 | |||
66 | |||
67 | struct MLP_Solution | ||
68 | { | ||
69 | int lp_res; | ||
70 | int lp_presolv; | ||
71 | int mip_res; | ||
72 | int mip_presolv; | ||
73 | |||
74 | double lp_objective_value; | ||
75 | double mlp_objective_value; | ||
76 | double mlp_gap; | ||
77 | double lp_mlp_gap; | ||
78 | |||
79 | int p_elements; | ||
80 | int p_cols; | ||
81 | int p_rows; | ||
82 | |||
83 | int n_peers; | ||
84 | int n_addresses; | ||
85 | |||
86 | }; | ||
87 | |||
88 | struct ATS_Peer | ||
89 | { | ||
90 | struct GNUNET_PeerIdentity id; | ||
91 | |||
92 | /* Was this peer already added to the current problem? */ | ||
93 | int processed; | ||
94 | |||
95 | /* constraint 2: 1 address per peer*/ | ||
96 | unsigned int r_c2; | ||
97 | |||
98 | /* constraint 9: relativity */ | ||
99 | unsigned int r_c9; | ||
100 | |||
101 | /* Legacy preference value */ | ||
102 | double f; | ||
103 | }; | ||
104 | |||
105 | struct MLP_Problem | ||
106 | { | ||
107 | /** | ||
108 | * GLPK (MLP) problem object | ||
109 | */ | ||
110 | glp_prob *prob; | ||
111 | |||
112 | /* Number of addresses in problem */ | ||
113 | unsigned int num_addresses; | ||
114 | /* Number of peers in problem */ | ||
115 | unsigned int num_peers; | ||
116 | /* Number of elements in problem matrix */ | ||
117 | unsigned int num_elements; | ||
118 | |||
119 | /* Row index constraint 2: */ | ||
120 | unsigned int r_c2; | ||
121 | /* Row index constraint 4: minimum connections */ | ||
122 | unsigned int r_c4; | ||
123 | /* Row index constraint 6: maximize diversity */ | ||
124 | unsigned int r_c6; | ||
125 | /* Row index constraint 8: utilization*/ | ||
126 | unsigned int r_c8; | ||
127 | /* Row index constraint 9: relativity*/ | ||
128 | unsigned int r_c9; | ||
129 | /* Row indices quality metrics */ | ||
130 | int r_q[GNUNET_ATS_QualityPropertiesCount]; | ||
131 | /* Row indices ATS network quotas */ | ||
132 | int r_quota[GNUNET_ATS_NetworkTypeCount]; | ||
133 | |||
134 | /* Column index Diversity (D) column */ | ||
135 | int c_d; | ||
136 | /* Column index Utilization (U) column */ | ||
137 | int c_u; | ||
138 | /* Column index Proportionality (R) column */ | ||
139 | int c_r; | ||
140 | /* Column index quality metrics */ | ||
141 | int c_q[GNUNET_ATS_QualityPropertiesCount]; | ||
142 | |||
143 | /* Problem matrix */ | ||
144 | /* Current index */ | ||
145 | unsigned int ci; | ||
146 | /* Row index array */ | ||
147 | int *ia; | ||
148 | /* Column index array */ | ||
149 | int *ja; | ||
150 | /* Column index value */ | ||
151 | double *ar; | ||
152 | |||
153 | }; | ||
154 | |||
155 | struct MLP_Variables | ||
156 | { | ||
157 | /* Big M value for bandwidth capping */ | ||
158 | double BIG_M; | ||
159 | |||
160 | /* MIP Gap */ | ||
161 | double mip_gap; | ||
162 | |||
163 | /* LP MIP Gap */ | ||
164 | double lp_mip_gap; | ||
165 | |||
166 | /* ATS Quality metrics | ||
167 | * | ||
168 | * Array with GNUNET_ATS_QualityPropertiesCount elements | ||
169 | * contains mapping to GNUNET_ATS_Property*/ | ||
170 | int q[GNUNET_ATS_QualityPropertiesCount]; | ||
171 | |||
172 | /* Number of quality metrics */ | ||
173 | int m_q; | ||
174 | |||
175 | /* Number of quality metrics */ | ||
176 | int m_rc; | ||
177 | |||
178 | /* Quality metric coefficients*/ | ||
179 | double co_Q[GNUNET_ATS_QualityPropertiesCount]; | ||
180 | |||
181 | /* Ressource costs coefficients*/ | ||
182 | double co_RC[GNUNET_ATS_QualityPropertiesCount]; | ||
183 | |||
184 | /* Diversity coefficient */ | ||
185 | double co_D; | ||
186 | |||
187 | /* Utility coefficient */ | ||
188 | double co_U; | ||
189 | |||
190 | /* Relativity coefficient */ | ||
191 | double co_R; | ||
192 | |||
193 | /* Minimum bandwidth assigned to an address */ | ||
194 | unsigned int b_min; | ||
195 | |||
196 | /* Minimum number of addresses with bandwidth assigned */ | ||
197 | unsigned int n_min; | ||
198 | |||
199 | /* Quotas */ | ||
200 | /* Array mapping array index to ATS network */ | ||
201 | int quota_index[GNUNET_ATS_NetworkTypeCount]; | ||
202 | /* Outbound quotas */ | ||
203 | unsigned long long quota_out[GNUNET_ATS_NetworkTypeCount]; | ||
204 | /* Inbound quotas */ | ||
205 | |||
206 | unsigned long long quota_in[GNUNET_ATS_NetworkTypeCount]; | ||
207 | |||
208 | /* ATS ressource costs | ||
209 | * array with GNUNET_ATS_QualityPropertiesCount elements | ||
210 | * contains mapping to GNUNET_ATS_Property | ||
211 | * */ | ||
212 | int rc[GNUNET_ATS_QualityPropertiesCount]; | ||
213 | |||
214 | }; | ||
215 | |||
216 | /** | ||
217 | * MLP Handle | ||
218 | */ | ||
219 | struct GAS_MLP_Handle | ||
220 | { | ||
221 | struct GNUNET_ATS_PluginEnvironment *env; | ||
222 | |||
223 | /** | ||
224 | * Statistics handle | ||
225 | */ | ||
226 | struct GNUNET_STATISTICS_Handle *stats; | ||
227 | |||
228 | /** | ||
229 | * Address hashmap for lookups | ||
230 | */ | ||
231 | const struct GNUNET_CONTAINER_MultiPeerMap *addresses; | ||
232 | |||
233 | /** | ||
234 | * Addresses' bandwidth changed callback | ||
235 | */ | ||
236 | GAS_bandwidth_changed_cb bw_changed_cb; | ||
237 | |||
238 | /** | ||
239 | * Addresses' bandwidth changed callback closure | ||
240 | */ | ||
241 | void *bw_changed_cb_cls; | ||
242 | |||
243 | /** | ||
244 | * ATS function to get preferences | ||
245 | */ | ||
246 | GAS_get_preferences get_preferences; | ||
247 | |||
248 | /** | ||
249 | * Closure for ATS function to get preferences | ||
250 | */ | ||
251 | void *get_preferences_cls; | ||
252 | |||
253 | /** | ||
254 | * ATS function to get properties | ||
255 | */ | ||
256 | GAS_get_properties get_properties; | ||
257 | |||
258 | /** | ||
259 | * Closure for ATS function to get properties | ||
260 | */ | ||
261 | void *get_properties_cls; | ||
262 | |||
263 | /** | ||
264 | * Exclude peer from next result propagation | ||
265 | */ | ||
266 | const struct GNUNET_PeerIdentity *exclude_peer; | ||
267 | |||
268 | /** | ||
269 | * Encapsulation for the MLP problem | ||
270 | */ | ||
271 | struct MLP_Problem p; | ||
272 | |||
273 | /** | ||
274 | * Encapsulation for the MLP problem variables | ||
275 | */ | ||
276 | struct MLP_Variables pv; | ||
277 | |||
278 | /** | ||
279 | * Encapsulation for the MLP solution | ||
280 | */ | ||
281 | struct MLP_Solution ps; | ||
282 | |||
283 | /** | ||
284 | * Bulk lock | ||
285 | */ | ||
286 | |||
287 | int stat_bulk_lock; | ||
288 | |||
289 | /** | ||
290 | * Number of changes while solver was locked | ||
291 | */ | ||
292 | int stat_bulk_requests; | ||
293 | |||
294 | /** | ||
295 | * GLPK LP control parameter | ||
296 | */ | ||
297 | glp_smcp control_param_lp; | ||
298 | |||
299 | /** | ||
300 | * GLPK LP control parameter | ||
301 | */ | ||
302 | glp_iocp control_param_mlp; | ||
303 | |||
304 | /** | ||
305 | * Peers with pending address requests | ||
306 | */ | ||
307 | struct GNUNET_CONTAINER_MultiPeerMap *requested_peers; | ||
308 | |||
309 | /** | ||
310 | * Was the problem updated since last solution | ||
311 | */ | ||
312 | int stat_mlp_prob_updated; | ||
313 | |||
314 | /** | ||
315 | * Has the problem size changed since last solution | ||
316 | */ | ||
317 | int stat_mlp_prob_changed; | ||
318 | |||
319 | /** | ||
320 | * Solve the problem automatically when updates occur? | ||
321 | * Default: GNUNET_YES | ||
322 | * Can be disabled for test and measurements | ||
323 | */ | ||
324 | int opt_mlp_auto_solve; | ||
325 | |||
326 | /** | ||
327 | * Write all MILP problems to a MPS file | ||
328 | */ | ||
329 | int opt_dump_problem_all; | ||
330 | |||
331 | /** | ||
332 | * Write all MILP problem solutions to a file | ||
333 | */ | ||
334 | int opt_dump_solution_all; | ||
335 | |||
336 | /** | ||
337 | * Write MILP problems to a MPS file when solver fails | ||
338 | */ | ||
339 | int opt_dump_problem_on_fail; | ||
340 | |||
341 | /** | ||
342 | * Write MILP problem solutions to a file when solver fails | ||
343 | */ | ||
344 | int opt_dump_solution_on_fail; | ||
345 | |||
346 | /** | ||
347 | * solve feasibility only | ||
348 | */ | ||
349 | int opt_dbg_feasibility_only; | ||
350 | |||
351 | /** | ||
352 | * solve autoscale the problem | ||
353 | */ | ||
354 | int opt_dbg_autoscale_problem; | ||
355 | |||
356 | /** | ||
357 | * use the intopt presolver instead of simplex | ||
358 | */ | ||
359 | int opt_dbg_intopt_presolver; | ||
360 | |||
361 | /** | ||
362 | * Print GLPK output | ||
363 | */ | ||
364 | int opt_dbg_glpk_verbose; | ||
365 | |||
366 | /** | ||
367 | * solve autoscale the problem | ||
368 | */ | ||
369 | int opt_dbg_optimize_relativity; | ||
370 | |||
371 | /** | ||
372 | * solve autoscale the problem | ||
373 | */ | ||
374 | int opt_dbg_optimize_diversity; | ||
375 | |||
376 | /** | ||
377 | * solve autoscale the problem | ||
378 | */ | ||
379 | int opt_dbg_optimize_quality; | ||
380 | |||
381 | /** | ||
382 | * solve autoscale the problem | ||
383 | */ | ||
384 | int opt_dbg_optimize_utility; | ||
385 | |||
386 | |||
387 | /** | ||
388 | * Output format | ||
389 | */ | ||
390 | enum MLP_Output_Format opt_log_format; | ||
391 | }; | ||
392 | |||
393 | /** | ||
394 | * Address specific MLP information | ||
395 | */ | ||
396 | struct MLP_information | ||
397 | { | ||
398 | |||
399 | /* Bandwidth assigned */ | ||
400 | struct GNUNET_BANDWIDTH_Value32NBO b_out; | ||
401 | struct GNUNET_BANDWIDTH_Value32NBO b_in; | ||
402 | |||
403 | /* Address selected */ | ||
404 | int n; | ||
405 | |||
406 | /* bandwidth column index */ | ||
407 | signed int c_b; | ||
408 | |||
409 | /* address usage column */ | ||
410 | signed int c_n; | ||
411 | |||
412 | /* row indexes */ | ||
413 | |||
414 | /* constraint 1: bandwidth capping */ | ||
415 | unsigned int r_c1; | ||
416 | |||
417 | /* constraint 3: minimum bandwidth */ | ||
418 | unsigned int r_c3; | ||
419 | }; | ||
420 | |||
29 | 421 | ||
30 | 422 | ||
31 | /** | 423 | /** |
@@ -148,6 +540,7 @@ static int | |||
148 | mlp_term_hook (void *info, const char *s) | 540 | mlp_term_hook (void *info, const char *s) |
149 | { | 541 | { |
150 | struct GAS_MLP_Handle *mlp = info; | 542 | struct GAS_MLP_Handle *mlp = info; |
543 | |||
151 | if (mlp->opt_dbg_glpk_verbose) | 544 | if (mlp->opt_dbg_glpk_verbose) |
152 | LOG (GNUNET_ERROR_TYPE_ERROR, "%s", s); | 545 | LOG (GNUNET_ERROR_TYPE_ERROR, "%s", s); |
153 | return 1; | 546 | return 1; |
@@ -237,7 +630,7 @@ mlp_delete_problem (struct GAS_MLP_Handle *mlp) | |||
237 | * @param ats_index the ATS index | 630 | * @param ats_index the ATS index |
238 | * @return string with result | 631 | * @return string with result |
239 | */ | 632 | */ |
240 | const char * | 633 | static const char * |
241 | mlp_ats_to_string (int ats_index) | 634 | mlp_ats_to_string (int ats_index) |
242 | { | 635 | { |
243 | switch (ats_index) { | 636 | switch (ats_index) { |
@@ -274,7 +667,7 @@ mlp_ats_to_string (int ats_index) | |||
274 | * @param retcode return code | 667 | * @param retcode return code |
275 | * @return string with result | 668 | * @return string with result |
276 | */ | 669 | */ |
277 | const char * | 670 | static const char * |
278 | mlp_status_to_string (int retcode) | 671 | mlp_status_to_string (int retcode) |
279 | { | 672 | { |
280 | switch (retcode) { | 673 | switch (retcode) { |
@@ -296,12 +689,13 @@ mlp_status_to_string (int retcode) | |||
296 | } | 689 | } |
297 | } | 690 | } |
298 | 691 | ||
692 | |||
299 | /** | 693 | /** |
300 | * Translate glpk solver error codes to text | 694 | * Translate glpk solver error codes to text |
301 | * @param retcode return code | 695 | * @param retcode return code |
302 | * @return string with result | 696 | * @return string with result |
303 | */ | 697 | */ |
304 | const char * | 698 | static const char * |
305 | mlp_solve_to_string (int retcode) | 699 | mlp_solve_to_string (int retcode) |
306 | { | 700 | { |
307 | switch (retcode) { | 701 | switch (retcode) { |
@@ -798,6 +1192,7 @@ mlp_create_problem_add_address_information (void *cls, | |||
798 | return GNUNET_OK; | 1192 | return GNUNET_OK; |
799 | } | 1193 | } |
800 | 1194 | ||
1195 | |||
801 | /** | 1196 | /** |
802 | * Create the invariant columns c4, c6, c10, c8, c7 | 1197 | * Create the invariant columns c4, c6, c10, c8, c7 |
803 | */ | 1198 | */ |
@@ -899,7 +1294,7 @@ mlp_create_problem_add_invariant_columns (struct GAS_MLP_Handle *mlp, struct MLP | |||
899 | * Create the MLP problem | 1294 | * Create the MLP problem |
900 | * | 1295 | * |
901 | * @param mlp the MLP handle | 1296 | * @param mlp the MLP handle |
902 | * @return GNUNET_OK or GNUNET_SYSERR | 1297 | * @return #GNUNET_OK or #GNUNET_SYSERR |
903 | */ | 1298 | */ |
904 | static int | 1299 | static int |
905 | mlp_create_problem (struct GAS_MLP_Handle *mlp) | 1300 | mlp_create_problem (struct GAS_MLP_Handle *mlp) |
@@ -972,11 +1367,12 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp) | |||
972 | return res; | 1367 | return res; |
973 | } | 1368 | } |
974 | 1369 | ||
1370 | |||
975 | /** | 1371 | /** |
976 | * Solves the LP problem | 1372 | * Solves the LP problem |
977 | * | 1373 | * |
978 | * @param mlp the MLP Handle | 1374 | * @param mlp the MLP Handle |
979 | * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure | 1375 | * @return #GNUNET_OK if could be solved, #GNUNET_SYSERR on failure |
980 | */ | 1376 | */ |
981 | static int | 1377 | static int |
982 | mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp) | 1378 | mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp) |
@@ -1018,7 +1414,7 @@ mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp) | |||
1018 | * @param value the address | 1414 | * @param value the address |
1019 | * @return #GNUNET_OK to continue | 1415 | * @return #GNUNET_OK to continue |
1020 | */ | 1416 | */ |
1021 | int | 1417 | static int |
1022 | mlp_propagate_results (void *cls, | 1418 | mlp_propagate_results (void *cls, |
1023 | const struct GNUNET_PeerIdentity *key, | 1419 | const struct GNUNET_PeerIdentity *key, |
1024 | void *value) | 1420 | void *value) |
@@ -1133,16 +1529,20 @@ mlp_propagate_results (void *cls, | |||
1133 | return GNUNET_OK; | 1529 | return GNUNET_OK; |
1134 | } | 1530 | } |
1135 | 1531 | ||
1136 | static void notify (struct GAS_MLP_Handle *mlp, | 1532 | |
1137 | enum GAS_Solver_Operation op, | 1533 | static void |
1138 | enum GAS_Solver_Status stat, | 1534 | notify (struct GAS_MLP_Handle *mlp, |
1139 | enum GAS_Solver_Additional_Information add) | 1535 | enum GAS_Solver_Operation op, |
1536 | enum GAS_Solver_Status stat, | ||
1537 | enum GAS_Solver_Additional_Information add) | ||
1140 | { | 1538 | { |
1141 | if (NULL != mlp->env->info_cb) | 1539 | if (NULL != mlp->env->info_cb) |
1142 | mlp->env->info_cb (mlp->env->info_cb_cls, op, stat, add); | 1540 | mlp->env->info_cb (mlp->env->info_cb_cls, op, stat, add); |
1143 | } | 1541 | } |
1144 | 1542 | ||
1145 | static void mlp_branch_and_cut_cb (glp_tree *tree, void *info) | 1543 | |
1544 | static void | ||
1545 | mlp_branch_and_cut_cb (glp_tree *tree, void *info) | ||
1146 | { | 1546 | { |
1147 | struct GAS_MLP_Handle *mlp = info; | 1547 | struct GAS_MLP_Handle *mlp = info; |
1148 | double mlp_obj = 0; | 1548 | double mlp_obj = 0; |
@@ -1206,9 +1606,9 @@ static void mlp_branch_and_cut_cb (glp_tree *tree, void *info) | |||
1206 | * Solves the MLP problem | 1606 | * Solves the MLP problem |
1207 | * | 1607 | * |
1208 | * @param solver the MLP Handle | 1608 | * @param solver the MLP Handle |
1209 | * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure | 1609 | * @return #GNUNET_OK if could be solved, #GNUNET_SYSERR on failure |
1210 | */ | 1610 | */ |
1211 | int | 1611 | static int |
1212 | GAS_mlp_solve_problem (void *solver) | 1612 | GAS_mlp_solve_problem (void *solver) |
1213 | { | 1613 | { |
1214 | struct GAS_MLP_Handle *mlp = solver; | 1614 | struct GAS_MLP_Handle *mlp = solver; |
@@ -1516,7 +1916,7 @@ GAS_mlp_solve_problem (void *solver) | |||
1516 | * @param address the address to add | 1916 | * @param address the address to add |
1517 | * @param network network type of this address | 1917 | * @param network network type of this address |
1518 | */ | 1918 | */ |
1519 | void | 1919 | static void |
1520 | GAS_mlp_address_add (void *solver, | 1920 | GAS_mlp_address_add (void *solver, |
1521 | struct ATS_Address *address, | 1921 | struct ATS_Address *address, |
1522 | uint32_t network) | 1922 | uint32_t network) |
@@ -1567,7 +1967,7 @@ GAS_mlp_address_add (void *solver, | |||
1567 | * @param abs_value the absolute value of the property | 1967 | * @param abs_value the absolute value of the property |
1568 | * @param rel_value the normalized value | 1968 | * @param rel_value the normalized value |
1569 | */ | 1969 | */ |
1570 | void | 1970 | static void |
1571 | GAS_mlp_address_property_changed (void *solver, | 1971 | GAS_mlp_address_property_changed (void *solver, |
1572 | struct ATS_Address *address, | 1972 | struct ATS_Address *address, |
1573 | uint32_t type, | 1973 | uint32_t type, |
@@ -1647,7 +2047,7 @@ GAS_mlp_address_property_changed (void *solver, | |||
1647 | * @param cur_session the current session | 2047 | * @param cur_session the current session |
1648 | * @param new_session the new session | 2048 | * @param new_session the new session |
1649 | */ | 2049 | */ |
1650 | void | 2050 | static void |
1651 | GAS_mlp_address_session_changed (void *solver, | 2051 | GAS_mlp_address_session_changed (void *solver, |
1652 | struct ATS_Address *address, | 2052 | struct ATS_Address *address, |
1653 | uint32_t cur_session, | 2053 | uint32_t cur_session, |
@@ -1667,7 +2067,7 @@ GAS_mlp_address_session_changed (void *solver, | |||
1667 | * @param address the address | 2067 | * @param address the address |
1668 | * @param in_use usage state | 2068 | * @param in_use usage state |
1669 | */ | 2069 | */ |
1670 | void | 2070 | static void |
1671 | GAS_mlp_address_inuse_changed (void *solver, | 2071 | GAS_mlp_address_inuse_changed (void *solver, |
1672 | struct ATS_Address *address, | 2072 | struct ATS_Address *address, |
1673 | int in_use) | 2073 | int in_use) |
@@ -1687,7 +2087,7 @@ GAS_mlp_address_inuse_changed (void *solver, | |||
1687 | * @param current_network the current network | 2087 | * @param current_network the current network |
1688 | * @param new_network the new network | 2088 | * @param new_network the new network |
1689 | */ | 2089 | */ |
1690 | void | 2090 | static void |
1691 | GAS_mlp_address_change_network (void *solver, | 2091 | GAS_mlp_address_change_network (void *solver, |
1692 | struct ATS_Address *address, | 2092 | struct ATS_Address *address, |
1693 | uint32_t current_network, | 2093 | uint32_t current_network, |
@@ -1790,10 +2190,10 @@ GAS_mlp_address_change_network (void *solver, | |||
1790 | * @param address the address to delete | 2190 | * @param address the address to delete |
1791 | * @param session_only delete only session not whole address | 2191 | * @param session_only delete only session not whole address |
1792 | */ | 2192 | */ |
1793 | void | 2193 | static void |
1794 | GAS_mlp_address_delete (void *solver, | 2194 | GAS_mlp_address_delete (void *solver, |
1795 | struct ATS_Address *address, | 2195 | struct ATS_Address *address, |
1796 | int session_only) | 2196 | int session_only) |
1797 | { | 2197 | { |
1798 | struct ATS_Peer *p; | 2198 | struct ATS_Peer *p; |
1799 | struct GAS_MLP_Handle *mlp = solver; | 2199 | struct GAS_MLP_Handle *mlp = solver; |
@@ -1925,7 +2325,7 @@ get_peer_pref_value (struct GAS_MLP_Handle *mlp, const struct GNUNET_PeerIdentit | |||
1925 | * @param peer the peer | 2325 | * @param peer the peer |
1926 | * @return suggested address | 2326 | * @return suggested address |
1927 | */ | 2327 | */ |
1928 | const struct ATS_Address * | 2328 | static const struct ATS_Address * |
1929 | GAS_mlp_get_preferred_address (void *solver, | 2329 | GAS_mlp_get_preferred_address (void *solver, |
1930 | const struct GNUNET_PeerIdentity *peer) | 2330 | const struct GNUNET_PeerIdentity *peer) |
1931 | { | 2331 | { |
@@ -1978,7 +2378,7 @@ GAS_mlp_get_preferred_address (void *solver, | |||
1978 | * | 2378 | * |
1979 | * @param solver the solver | 2379 | * @param solver the solver |
1980 | */ | 2380 | */ |
1981 | void | 2381 | static void |
1982 | GAS_mlp_bulk_start (void *solver) | 2382 | GAS_mlp_bulk_start (void *solver) |
1983 | { | 2383 | { |
1984 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Locking solver for bulk operation ...\n"); | 2384 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Locking solver for bulk operation ...\n"); |
@@ -1989,7 +2389,8 @@ GAS_mlp_bulk_start (void *solver) | |||
1989 | s->stat_bulk_lock ++; | 2389 | s->stat_bulk_lock ++; |
1990 | } | 2390 | } |
1991 | 2391 | ||
1992 | void | 2392 | |
2393 | static void | ||
1993 | GAS_mlp_bulk_stop (void *solver) | 2394 | GAS_mlp_bulk_stop (void *solver) |
1994 | { | 2395 | { |
1995 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Unlocking solver from bulk operation ...\n"); | 2396 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Unlocking solver from bulk operation ...\n"); |
@@ -2019,7 +2420,7 @@ GAS_mlp_bulk_stop (void *solver) | |||
2019 | * @param solver the MLP handle | 2420 | * @param solver the MLP handle |
2020 | * @param peer the peer | 2421 | * @param peer the peer |
2021 | */ | 2422 | */ |
2022 | void | 2423 | static void |
2023 | GAS_mlp_stop_get_preferred_address (void *solver, | 2424 | GAS_mlp_stop_get_preferred_address (void *solver, |
2024 | const struct GNUNET_PeerIdentity *peer) | 2425 | const struct GNUNET_PeerIdentity *peer) |
2025 | { | 2426 | { |
@@ -2050,7 +2451,7 @@ GAS_mlp_stop_get_preferred_address (void *solver, | |||
2050 | * @param kind the kind to change the preference | 2451 | * @param kind the kind to change the preference |
2051 | * @param pref_rel the relative score | 2452 | * @param pref_rel the relative score |
2052 | */ | 2453 | */ |
2053 | void | 2454 | static void |
2054 | GAS_mlp_address_change_preference (void *solver, | 2455 | GAS_mlp_address_change_preference (void *solver, |
2055 | const struct GNUNET_PeerIdentity *peer, | 2456 | const struct GNUNET_PeerIdentity *peer, |
2056 | enum GNUNET_ATS_PreferenceKind kind, | 2457 | enum GNUNET_ATS_PreferenceKind kind, |
@@ -2097,7 +2498,7 @@ GAS_mlp_address_change_preference (void *solver, | |||
2097 | * @param kind the kind to change the preference | 2498 | * @param kind the kind to change the preference |
2098 | * @param score the score | 2499 | * @param score the score |
2099 | */ | 2500 | */ |
2100 | void | 2501 | static void |
2101 | GAS_mlp_address_preference_feedback (void *solver, | 2502 | GAS_mlp_address_preference_feedback (void *solver, |
2102 | void *application, | 2503 | void *application, |
2103 | const struct GNUNET_PeerIdentity *peer, | 2504 | const struct GNUNET_PeerIdentity *peer, |
@@ -2139,7 +2540,8 @@ libgnunet_plugin_ats_mlp_done (void *cls) | |||
2139 | struct GAS_MLP_Handle *mlp = cls; | 2540 | struct GAS_MLP_Handle *mlp = cls; |
2140 | GNUNET_assert (mlp != NULL); | 2541 | GNUNET_assert (mlp != NULL); |
2141 | 2542 | ||
2142 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down mlp solver\n"); | 2543 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2544 | "Shutting down mlp solver\n"); | ||
2143 | mlp_delete_problem (mlp); | 2545 | mlp_delete_problem (mlp); |
2144 | 2546 | ||
2145 | GNUNET_CONTAINER_multipeermap_iterate (mlp->requested_peers, | 2547 | GNUNET_CONTAINER_multipeermap_iterate (mlp->requested_peers, |
@@ -2152,7 +2554,8 @@ libgnunet_plugin_ats_mlp_done (void *cls) | |||
2152 | glp_free_env(); | 2554 | glp_free_env(); |
2153 | GNUNET_free (mlp); | 2555 | GNUNET_free (mlp); |
2154 | 2556 | ||
2155 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutdown down of mlp solver complete\n"); | 2557 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2558 | "Shutdown down of mlp solver complete\n"); | ||
2156 | return NULL; | 2559 | return NULL; |
2157 | } | 2560 | } |
2158 | 2561 | ||