diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-07 13:01:42 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-07 13:01:42 +0000 |
commit | b85b68adb5960859e735319eb27a0d1594020d52 (patch) | |
tree | 08df639e7e008e37dd9d095b910c087b98ca93ac /src/ats/gnunet-service-ats_plugins.c | |
parent | 3fa5361da7754b5080ae52963c99eb9dc848221f (diff) | |
download | gnunet-b85b68adb5960859e735319eb27a0d1594020d52.tar.gz gnunet-b85b68adb5960859e735319eb27a0d1594020d52.zip |
minor cleanup
Diffstat (limited to 'src/ats/gnunet-service-ats_plugins.c')
-rw-r--r-- | src/ats/gnunet-service-ats_plugins.c | 226 |
1 files changed, 126 insertions, 100 deletions
diff --git a/src/ats/gnunet-service-ats_plugins.c b/src/ats/gnunet-service-ats_plugins.c index 53f12ec10..900183c1b 100644 --- a/src/ats/gnunet-service-ats_plugins.c +++ b/src/ats/gnunet-service-ats_plugins.c | |||
@@ -62,8 +62,10 @@ GAS_normalized_preference_changed (const struct GNUNET_PeerIdentity *peer, | |||
62 | enum GNUNET_ATS_PreferenceKind kind, | 62 | enum GNUNET_ATS_PreferenceKind kind, |
63 | double pref_rel) | 63 | double pref_rel) |
64 | { | 64 | { |
65 | /* Tell solver about update */ | 65 | sf->s_pref (sf->cls, |
66 | sf->s_pref (sf->cls, peer, kind, pref_rel); | 66 | peer, |
67 | kind, | ||
68 | pref_rel); | ||
67 | } | 69 | } |
68 | 70 | ||
69 | 71 | ||
@@ -106,7 +108,7 @@ solver_info_cb (void *cls, | |||
106 | enum GAS_Solver_Status status, | 108 | enum GAS_Solver_Status status, |
107 | enum GAS_Solver_Additional_Information add) | 109 | enum GAS_Solver_Additional_Information add) |
108 | { | 110 | { |
109 | char *add_info; | 111 | const char *add_info; |
110 | 112 | ||
111 | switch (add) { | 113 | switch (add) { |
112 | case GAS_INFO_NONE: | 114 | case GAS_INFO_NONE: |
@@ -130,63 +132,71 @@ solver_info_cb (void *cls, | |||
130 | } | 132 | } |
131 | switch (op) | 133 | switch (op) |
132 | { | 134 | { |
133 | case GAS_OP_SOLVE_START: | 135 | case GAS_OP_SOLVE_START: |
134 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 136 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
135 | "Solver notifies `%s' with result `%s' `%s'\n", "GAS_OP_SOLVE_START", | 137 | "Solver notifies `%s' with result `%s' `%s'\n", |
136 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL", add_info); | 138 | "GAS_OP_SOLVE_START", |
137 | return; | 139 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL", |
138 | case GAS_OP_SOLVE_STOP: | 140 | add_info); |
139 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 141 | return; |
140 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_STOP", | 142 | case GAS_OP_SOLVE_STOP: |
141 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL", add_info); | 143 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
142 | return; | 144 | "Solver notifies `%s' with result `%s'\n", |
143 | 145 | "GAS_OP_SOLVE_STOP", | |
144 | case GAS_OP_SOLVE_SETUP_START: | 146 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL", |
145 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 147 | add_info); |
146 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_START", | 148 | return; |
147 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 149 | case GAS_OP_SOLVE_SETUP_START: |
148 | return; | 150 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
149 | 151 | "Solver notifies `%s' with result `%s'\n", | |
150 | case GAS_OP_SOLVE_SETUP_STOP: | 152 | "GAS_OP_SOLVE_SETUP_START", |
151 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 153 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); |
152 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_STOP", | 154 | return; |
153 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 155 | case GAS_OP_SOLVE_SETUP_STOP: |
154 | return; | 156 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
155 | 157 | "Solver notifies `%s' with result `%s'\n", | |
156 | case GAS_OP_SOLVE_MLP_LP_START: | 158 | "GAS_OP_SOLVE_SETUP_STOP", |
157 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 159 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); |
158 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_START", | 160 | return; |
159 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 161 | case GAS_OP_SOLVE_MLP_LP_START: |
160 | return; | 162 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
161 | case GAS_OP_SOLVE_MLP_LP_STOP: | 163 | "Solver notifies `%s' with result `%s'\n", |
162 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 164 | "GAS_OP_SOLVE_LP_START", |
163 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_STOP", | 165 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); |
164 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 166 | return; |
165 | return; | 167 | case GAS_OP_SOLVE_MLP_LP_STOP: |
166 | 168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
167 | case GAS_OP_SOLVE_MLP_MLP_START: | 169 | "Solver notifies `%s' with result `%s'\n", |
168 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 170 | "GAS_OP_SOLVE_LP_STOP", |
169 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_START", | 171 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); |
170 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 172 | return; |
171 | return; | 173 | case GAS_OP_SOLVE_MLP_MLP_START: |
172 | case GAS_OP_SOLVE_MLP_MLP_STOP: | 174 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
173 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 175 | "Solver notifies `%s' with result `%s'\n", |
174 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_STOP", | 176 | "GAS_OP_SOLVE_MLP_START", |
175 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 177 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); |
176 | return; | 178 | return; |
177 | case GAS_OP_SOLVE_UPDATE_NOTIFICATION_START: | 179 | case GAS_OP_SOLVE_MLP_MLP_STOP: |
178 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 180 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
179 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START", | 181 | "Solver notifies `%s' with result `%s'\n", |
180 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 182 | "GAS_OP_SOLVE_MLP_STOP", |
181 | return; | 183 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); |
182 | case GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP: | 184 | return; |
183 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 185 | case GAS_OP_SOLVE_UPDATE_NOTIFICATION_START: |
184 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP", | 186 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
185 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 187 | "Solver notifies `%s' with result `%s'\n", |
186 | return; | 188 | "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START", |
187 | default: | 189 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); |
188 | break; | 190 | return; |
189 | } | 191 | case GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP: |
192 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
193 | "Solver notifies `%s' with result `%s'\n", | ||
194 | "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP", | ||
195 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | ||
196 | return; | ||
197 | default: | ||
198 | break; | ||
199 | } | ||
190 | } | 200 | } |
191 | 201 | ||
192 | 202 | ||
@@ -242,9 +252,10 @@ bandwidth_changed_cb (void *cls, | |||
242 | return; | 252 | return; |
243 | 253 | ||
244 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 254 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
245 | "Sending bandwidth update for peer `%s': %u %u\n", | 255 | "Sending bandwidth update for peer `%s': %u/%u\n", |
246 | GNUNET_i2s (&address->peer), address->assigned_bw_out, | 256 | GNUNET_i2s (&address->peer), |
247 | address->assigned_bw_out); | 257 | address->assigned_bw_out, |
258 | address->assigned_bw_out); | ||
248 | 259 | ||
249 | /* *Notify scheduling clients about suggestion */ | 260 | /* *Notify scheduling clients about suggestion */ |
250 | GAS_scheduling_transmit_address_suggestion (&address->peer, | 261 | GAS_scheduling_transmit_address_suggestion (&address->peer, |
@@ -291,9 +302,11 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
291 | GNUNET_ATS_print_network_type (c)); | 302 | GNUNET_ATS_print_network_type (c)); |
292 | 303 | ||
293 | /* quota out */ | 304 | /* quota out */ |
294 | if (GNUNET_OK | 305 | if (GNUNET_OK == |
295 | == GNUNET_CONFIGURATION_get_value_string (cfg, "ats", entry_out, | 306 | GNUNET_CONFIGURATION_get_value_string (cfg, |
296 | "a_out_str)) | 307 | "ats", |
308 | entry_out, | ||
309 | "a_out_str)) | ||
297 | { | 310 | { |
298 | res = GNUNET_NO; | 311 | res = GNUNET_NO; |
299 | if (0 == strcmp (quota_out_str, GNUNET_ATS_MaxBandwidthString)) | 312 | if (0 == strcmp (quota_out_str, GNUNET_ATS_MaxBandwidthString)) |
@@ -314,35 +327,37 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
314 | 327 | ||
315 | if (GNUNET_NO == res) | 328 | if (GNUNET_NO == res) |
316 | { | 329 | { |
317 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 330 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
318 | _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), | 331 | _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), |
319 | GNUNET_ATS_print_network_type (c), | 332 | GNUNET_ATS_print_network_type (c), |
320 | quota_out_str, | 333 | quota_out_str, |
321 | GNUNET_ATS_DefaultBandwidth); | 334 | GNUNET_ATS_DefaultBandwidth); |
322 | out_dest[c] = GNUNET_ATS_DefaultBandwidth; | 335 | out_dest[c] = GNUNET_ATS_DefaultBandwidth; |
323 | } | 336 | } |
324 | else | 337 | else |
325 | { | 338 | { |
326 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 339 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
327 | _("Outbound quota configure for network `%s' is %llu\n"), | 340 | _("Outbound quota configure for network `%s' is %llu\n"), |
328 | GNUNET_ATS_print_network_type (c), | 341 | GNUNET_ATS_print_network_type (c), |
329 | out_dest[c]); | 342 | out_dest[c]); |
330 | } | 343 | } |
331 | GNUNET_free(quota_out_str); | 344 | GNUNET_free (quota_out_str); |
332 | } | 345 | } |
333 | else | 346 | else |
334 | { | 347 | { |
335 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 348 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
336 | _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"), | 349 | _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"), |
337 | GNUNET_ATS_print_network_type (c), | 350 | GNUNET_ATS_print_network_type (c), |
338 | GNUNET_ATS_DefaultBandwidth); | 351 | GNUNET_ATS_DefaultBandwidth); |
339 | out_dest[c] = GNUNET_ATS_DefaultBandwidth; | 352 | out_dest[c] = GNUNET_ATS_DefaultBandwidth; |
340 | } | 353 | } |
341 | 354 | ||
342 | /* quota in */ | 355 | /* quota in */ |
343 | if (GNUNET_OK | 356 | if (GNUNET_OK == |
344 | == GNUNET_CONFIGURATION_get_value_string (cfg, "ats", entry_in, | 357 | GNUNET_CONFIGURATION_get_value_string (cfg, |
345 | "a_in_str)) | 358 | "ats", |
359 | entry_in, | ||
360 | "a_in_str)) | ||
346 | { | 361 | { |
347 | res = GNUNET_NO; | 362 | res = GNUNET_NO; |
348 | if (0 == strcmp (quota_in_str, GNUNET_ATS_MaxBandwidthString)) | 363 | if (0 == strcmp (quota_in_str, GNUNET_ATS_MaxBandwidthString)) |
@@ -350,14 +365,17 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
350 | in_dest[c] = GNUNET_ATS_MaxBandwidth; | 365 | in_dest[c] = GNUNET_ATS_MaxBandwidth; |
351 | res = GNUNET_YES; | 366 | res = GNUNET_YES; |
352 | } | 367 | } |
353 | if ((GNUNET_NO == res) | 368 | if ((GNUNET_NO == res) && |
354 | && (GNUNET_OK | 369 | (GNUNET_OK == |
355 | == GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, &in_dest[c]))) | 370 | GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, |
371 | &in_dest[c]))) | ||
356 | res = GNUNET_YES; | 372 | res = GNUNET_YES; |
357 | if ((GNUNET_NO == res) | 373 | if ((GNUNET_NO == res) && |
358 | && (GNUNET_OK | 374 | (GNUNET_OK == |
359 | == GNUNET_CONFIGURATION_get_value_number (cfg, "ats", entry_in, | 375 | GNUNET_CONFIGURATION_get_value_number (cfg, |
360 | &in_dest[c]))) | 376 | "ats", |
377 | entry_in, | ||
378 | &in_dest[c]))) | ||
361 | res = GNUNET_YES; | 379 | res = GNUNET_YES; |
362 | 380 | ||
363 | if (GNUNET_NO == res) | 381 | if (GNUNET_NO == res) |
@@ -371,12 +389,12 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
371 | } | 389 | } |
372 | else | 390 | else |
373 | { | 391 | { |
374 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 392 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
375 | _("Inbound quota configured for network `%s' is %llu\n"), | 393 | _("Inbound quota configured for network `%s' is %llu\n"), |
376 | GNUNET_ATS_print_network_type (c), | 394 | GNUNET_ATS_print_network_type (c), |
377 | in_dest[c]); | 395 | in_dest[c]); |
378 | } | 396 | } |
379 | GNUNET_free(quota_in_str); | 397 | GNUNET_free (quota_in_str); |
380 | } | 398 | } |
381 | else | 399 | else |
382 | { | 400 | { |
@@ -415,10 +433,13 @@ GAS_plugins_init (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
415 | 433 | ||
416 | /* Figure out configured solution method */ | 434 | /* Figure out configured solution method */ |
417 | if (GNUNET_SYSERR == | 435 | if (GNUNET_SYSERR == |
418 | GNUNET_CONFIGURATION_get_value_string (cfg, "ats", "MODE", &mode_str)) | 436 | GNUNET_CONFIGURATION_get_value_string (cfg, |
437 | "ats", | ||
438 | "MODE", | ||
439 | &mode_str)) | ||
419 | { | 440 | { |
420 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 441 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
421 | "No resource assignment method configured, using proportional approach\n"); | 442 | "No resource assignment method configured, using proportional approach\n"); |
422 | mode_str = GNUNET_strdup ("proportional"); | 443 | mode_str = GNUNET_strdup ("proportional"); |
423 | } | 444 | } |
424 | load_quotas (cfg, | 445 | load_quotas (cfg, |
@@ -487,7 +508,9 @@ GAS_plugin_new_address (struct ATS_Address *new_address, | |||
487 | const struct GNUNET_ATS_Information *atsi, | 508 | const struct GNUNET_ATS_Information *atsi, |
488 | uint32_t atsi_count) | 509 | uint32_t atsi_count) |
489 | { | 510 | { |
490 | sf->s_add (sf->cls, new_address, addr_net); | 511 | sf->s_add (sf->cls, |
512 | new_address, | ||
513 | addr_net); | ||
491 | sf->s_bulk_start (sf->cls); | 514 | sf->s_bulk_start (sf->cls); |
492 | GAS_normalization_normalize_property (new_address, | 515 | GAS_normalization_normalize_property (new_address, |
493 | atsi, | 516 | atsi, |
@@ -505,7 +528,9 @@ GAS_plugin_new_address (struct ATS_Address *new_address, | |||
505 | void | 528 | void |
506 | GAS_plugin_delete_address (struct ATS_Address *address) | 529 | GAS_plugin_delete_address (struct ATS_Address *address) |
507 | { | 530 | { |
508 | sf->s_del (sf->cls, address, GNUNET_NO); | 531 | sf->s_del (sf->cls, |
532 | address, | ||
533 | GNUNET_NO); | ||
509 | } | 534 | } |
510 | 535 | ||
511 | 536 | ||
@@ -595,7 +620,8 @@ GAS_plugin_request_connect_start (const struct GNUNET_PeerIdentity *pid) | |||
595 | void | 620 | void |
596 | GAS_plugin_request_connect_stop (const struct GNUNET_PeerIdentity *pid) | 621 | GAS_plugin_request_connect_stop (const struct GNUNET_PeerIdentity *pid) |
597 | { | 622 | { |
598 | sf->s_get_stop (sf->cls, pid); | 623 | sf->s_get_stop (sf->cls, |
624 | pid); | ||
599 | } | 625 | } |
600 | 626 | ||
601 | 627 | ||