diff options
Diffstat (limited to 'src/ats/gnunet-service-ats_plugins.c')
-rw-r--r-- | src/ats/gnunet-service-ats_plugins.c | 601 |
1 files changed, 304 insertions, 297 deletions
diff --git a/src/ats/gnunet-service-ats_plugins.c b/src/ats/gnunet-service-ats_plugins.c index 274f89e7a..d8d6be11d 100644 --- a/src/ats/gnunet-service-ats_plugins.c +++ b/src/ats/gnunet-service-ats_plugins.c | |||
@@ -59,14 +59,14 @@ static char *plugin; | |||
59 | * @param pref_rel the new relative preference value | 59 | * @param pref_rel the new relative preference value |
60 | */ | 60 | */ |
61 | void | 61 | void |
62 | GAS_plugin_notify_preference_changed(const struct GNUNET_PeerIdentity *peer, | 62 | GAS_plugin_notify_preference_changed (const struct GNUNET_PeerIdentity *peer, |
63 | enum GNUNET_ATS_PreferenceKind kind, | 63 | enum GNUNET_ATS_PreferenceKind kind, |
64 | double pref_rel) | 64 | double pref_rel) |
65 | { | 65 | { |
66 | sf->s_pref(sf->cls, | 66 | sf->s_pref (sf->cls, |
67 | peer, | 67 | peer, |
68 | kind, | 68 | kind, |
69 | pref_rel); | 69 | pref_rel); |
70 | } | 70 | } |
71 | 71 | ||
72 | 72 | ||
@@ -76,10 +76,10 @@ GAS_plugin_notify_preference_changed(const struct GNUNET_PeerIdentity *peer, | |||
76 | * @param address the peer for which a property changed | 76 | * @param address the peer for which a property changed |
77 | */ | 77 | */ |
78 | void | 78 | void |
79 | GAS_plugin_notify_property_changed(struct ATS_Address *address) | 79 | GAS_plugin_notify_property_changed (struct ATS_Address *address) |
80 | { | 80 | { |
81 | sf->s_address_update_property(sf->cls, | 81 | sf->s_address_update_property (sf->cls, |
82 | address); | 82 | address); |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
@@ -92,116 +92,116 @@ GAS_plugin_notify_property_changed(struct ATS_Address *address) | |||
92 | * @param add additional information | 92 | * @param add additional information |
93 | */ | 93 | */ |
94 | static void | 94 | static void |
95 | solver_info_cb(void *cls, | 95 | solver_info_cb (void *cls, |
96 | enum GAS_Solver_Operation op, | 96 | enum GAS_Solver_Operation op, |
97 | enum GAS_Solver_Status status, | 97 | enum GAS_Solver_Status status, |
98 | enum GAS_Solver_Additional_Information add) | 98 | enum GAS_Solver_Additional_Information add) |
99 | { | 99 | { |
100 | const char *add_info; | 100 | const char *add_info; |
101 | 101 | ||
102 | switch (add) | 102 | switch (add) |
103 | { | 103 | { |
104 | case GAS_INFO_NONE: | 104 | case GAS_INFO_NONE: |
105 | add_info = "GAS_INFO_NONE"; | 105 | add_info = "GAS_INFO_NONE"; |
106 | break; | 106 | break; |
107 | 107 | ||
108 | case GAS_INFO_FULL: | 108 | case GAS_INFO_FULL: |
109 | add_info = "GAS_INFO_MLP_FULL"; | 109 | add_info = "GAS_INFO_MLP_FULL"; |
110 | break; | 110 | break; |
111 | 111 | ||
112 | case GAS_INFO_UPDATED: | 112 | case GAS_INFO_UPDATED: |
113 | add_info = "GAS_INFO_MLP_UPDATED"; | 113 | add_info = "GAS_INFO_MLP_UPDATED"; |
114 | break; | 114 | break; |
115 | 115 | ||
116 | case GAS_INFO_PROP_ALL: | 116 | case GAS_INFO_PROP_ALL: |
117 | add_info = "GAS_INFO_PROP_ALL"; | 117 | add_info = "GAS_INFO_PROP_ALL"; |
118 | break; | 118 | break; |
119 | 119 | ||
120 | case GAS_INFO_PROP_SINGLE: | 120 | case GAS_INFO_PROP_SINGLE: |
121 | add_info = "GAS_INFO_PROP_SINGLE"; | 121 | add_info = "GAS_INFO_PROP_SINGLE"; |
122 | break; | 122 | break; |
123 | 123 | ||
124 | default: | 124 | default: |
125 | add_info = "INVALID"; | 125 | add_info = "INVALID"; |
126 | break; | 126 | break; |
127 | } | 127 | } |
128 | switch (op) | 128 | switch (op) |
129 | { | 129 | { |
130 | case GAS_OP_SOLVE_START: | 130 | case GAS_OP_SOLVE_START: |
131 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 131 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
132 | "Solver notifies `%s' with result `%s' `%s'\n", | 132 | "Solver notifies `%s' with result `%s' `%s'\n", |
133 | "GAS_OP_SOLVE_START", | 133 | "GAS_OP_SOLVE_START", |
134 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL", | 134 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL", |
135 | add_info); | 135 | add_info); |
136 | return; | 136 | return; |
137 | 137 | ||
138 | case GAS_OP_SOLVE_STOP: | 138 | case GAS_OP_SOLVE_STOP: |
139 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 139 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
140 | "Solver notifies `%s' with result `%s'\n", | 140 | "Solver notifies `%s' with result `%s'\n", |
141 | "GAS_OP_SOLVE_STOP", | 141 | "GAS_OP_SOLVE_STOP", |
142 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 142 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); |
143 | return; | 143 | return; |
144 | 144 | ||
145 | case GAS_OP_SOLVE_SETUP_START: | 145 | case GAS_OP_SOLVE_SETUP_START: |
146 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 146 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
147 | "Solver notifies `%s' with result `%s'\n", | 147 | "Solver notifies `%s' with result `%s'\n", |
148 | "GAS_OP_SOLVE_SETUP_START", | 148 | "GAS_OP_SOLVE_SETUP_START", |
149 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 149 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); |
150 | return; | 150 | return; |
151 | 151 | ||
152 | case GAS_OP_SOLVE_SETUP_STOP: | 152 | case GAS_OP_SOLVE_SETUP_STOP: |
153 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 153 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
154 | "Solver notifies `%s' with result `%s'\n", | 154 | "Solver notifies `%s' with result `%s'\n", |
155 | "GAS_OP_SOLVE_SETUP_STOP", | 155 | "GAS_OP_SOLVE_SETUP_STOP", |
156 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 156 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); |
157 | return; | 157 | return; |
158 | 158 | ||
159 | case GAS_OP_SOLVE_MLP_LP_START: | 159 | case GAS_OP_SOLVE_MLP_LP_START: |
160 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 160 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
161 | "Solver notifies `%s' with result `%s'\n", | 161 | "Solver notifies `%s' with result `%s'\n", |
162 | "GAS_OP_SOLVE_LP_START", | 162 | "GAS_OP_SOLVE_LP_START", |
163 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 163 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); |
164 | return; | 164 | return; |
165 | 165 | ||
166 | case GAS_OP_SOLVE_MLP_LP_STOP: | 166 | case GAS_OP_SOLVE_MLP_LP_STOP: |
167 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 167 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
168 | "Solver notifies `%s' with result `%s'\n", | 168 | "Solver notifies `%s' with result `%s'\n", |
169 | "GAS_OP_SOLVE_LP_STOP", | 169 | "GAS_OP_SOLVE_LP_STOP", |
170 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 170 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); |
171 | return; | 171 | return; |
172 | 172 | ||
173 | case GAS_OP_SOLVE_MLP_MLP_START: | 173 | case GAS_OP_SOLVE_MLP_MLP_START: |
174 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 174 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
175 | "Solver notifies `%s' with result `%s'\n", | 175 | "Solver notifies `%s' with result `%s'\n", |
176 | "GAS_OP_SOLVE_MLP_START", | 176 | "GAS_OP_SOLVE_MLP_START", |
177 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 177 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); |
178 | return; | 178 | return; |
179 | 179 | ||
180 | case GAS_OP_SOLVE_MLP_MLP_STOP: | 180 | case GAS_OP_SOLVE_MLP_MLP_STOP: |
181 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 181 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
182 | "Solver notifies `%s' with result `%s'\n", | 182 | "Solver notifies `%s' with result `%s'\n", |
183 | "GAS_OP_SOLVE_MLP_STOP", | 183 | "GAS_OP_SOLVE_MLP_STOP", |
184 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 184 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); |
185 | return; | 185 | return; |
186 | 186 | ||
187 | case GAS_OP_SOLVE_UPDATE_NOTIFICATION_START: | 187 | case GAS_OP_SOLVE_UPDATE_NOTIFICATION_START: |
188 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 188 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
189 | "Solver notifies `%s' with result `%s'\n", | 189 | "Solver notifies `%s' with result `%s'\n", |
190 | "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START", | 190 | "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START", |
191 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 191 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); |
192 | return; | 192 | return; |
193 | 193 | ||
194 | case GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP: | 194 | case GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP: |
195 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 195 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
196 | "Solver notifies `%s' with result `%s'\n", | 196 | "Solver notifies `%s' with result `%s'\n", |
197 | "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP", | 197 | "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP", |
198 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); | 198 | (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL"); |
199 | return; | 199 | return; |
200 | 200 | ||
201 | default: | 201 | default: |
202 | GNUNET_break(0); | 202 | GNUNET_break (0); |
203 | break; | 203 | break; |
204 | } | 204 | } |
205 | } | 205 | } |
206 | 206 | ||
207 | 207 | ||
@@ -212,69 +212,74 @@ solver_info_cb(void *cls, | |||
212 | * @param address the address with changes | 212 | * @param address the address with changes |
213 | */ | 213 | */ |
214 | static void | 214 | static void |
215 | bandwidth_changed_cb(void *cls, | 215 | bandwidth_changed_cb (void *cls, |
216 | struct ATS_Address *address) | 216 | struct ATS_Address *address) |
217 | { | 217 | { |
218 | long long diff_out; | 218 | long long diff_out; |
219 | long long diff_in; | 219 | long long diff_in; |
220 | 220 | ||
221 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 221 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
222 | "Bandwidth assignment changed for peer %s to %u/%u\n", | 222 | "Bandwidth assignment changed for peer %s to %u/%u\n", |
223 | GNUNET_i2s(&address->peer), | 223 | GNUNET_i2s (&address->peer), |
224 | (unsigned int)address->assigned_bw_in, | 224 | (unsigned int) address->assigned_bw_in, |
225 | (unsigned int)address->assigned_bw_out); | 225 | (unsigned int) address->assigned_bw_out); |
226 | GAS_reservations_set_bandwidth(&address->peer, | 226 | GAS_reservations_set_bandwidth (&address->peer, |
227 | GNUNET_BANDWIDTH_value_init(address->assigned_bw_in)); | 227 | GNUNET_BANDWIDTH_value_init ( |
228 | address->assigned_bw_in)); | ||
228 | /* Notify performance clients about changes to address */ | 229 | /* Notify performance clients about changes to address */ |
229 | GAS_performance_notify_all_clients(&address->peer, | 230 | GAS_performance_notify_all_clients (&address->peer, |
230 | address->plugin, | 231 | address->plugin, |
231 | address->addr, | 232 | address->addr, |
232 | address->addr_len, | 233 | address->addr_len, |
233 | address->active, | 234 | address->active, |
234 | &address->properties, | 235 | &address->properties, |
235 | address->local_address_info, | 236 | address->local_address_info, |
236 | GNUNET_BANDWIDTH_value_init(address->assigned_bw_out), | 237 | GNUNET_BANDWIDTH_value_init ( |
237 | GNUNET_BANDWIDTH_value_init(address->assigned_bw_in)); | 238 | address->assigned_bw_out), |
239 | GNUNET_BANDWIDTH_value_init ( | ||
240 | address->assigned_bw_in)); | ||
238 | 241 | ||
239 | if ((0 == address->assigned_bw_in) && | 242 | if ((0 == address->assigned_bw_in) && |
240 | (0 == address->assigned_bw_out)) | 243 | (0 == address->assigned_bw_out)) |
241 | { | 244 | { |
242 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 245 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
243 | "Telling transport to disconnect peer `%s'\n", | 246 | "Telling transport to disconnect peer `%s'\n", |
244 | GNUNET_i2s(&address->peer)); | 247 | GNUNET_i2s (&address->peer)); |
245 | 248 | ||
246 | /* Notify scheduling clients about suggestion */ | 249 | /* Notify scheduling clients about suggestion */ |
247 | GAS_scheduling_transmit_address_suggestion(&address->peer, | 250 | GAS_scheduling_transmit_address_suggestion (&address->peer, |
248 | address->session_id, | 251 | address->session_id, |
249 | GNUNET_BANDWIDTH_ZERO, | 252 | GNUNET_BANDWIDTH_ZERO, |
250 | GNUNET_BANDWIDTH_ZERO); | 253 | GNUNET_BANDWIDTH_ZERO); |
251 | return; | 254 | return; |
252 | } | 255 | } |
253 | 256 | ||
254 | /* Do bandwidth stability check */ | 257 | /* Do bandwidth stability check */ |
255 | diff_out = llabs((long long)address->assigned_bw_out - | 258 | diff_out = llabs ((long long) address->assigned_bw_out |
256 | (long long)address->last_notified_bw_out); | 259 | - (long long) address->last_notified_bw_out); |
257 | diff_in = llabs((long long)address->assigned_bw_in - | 260 | diff_in = llabs ((long long) address->assigned_bw_in |
258 | (long long)address->last_notified_bw_in); | 261 | - (long long) address->last_notified_bw_in); |
259 | if ((diff_out < htonl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__)) && | 262 | if ((diff_out < htonl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__)) && |
260 | (diff_in < htonl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__))) | 263 | (diff_in < htonl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__))) |
261 | { | 264 | { |
262 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 265 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
263 | "Bandwidth change too small, not notifying client\n"); | 266 | "Bandwidth change too small, not notifying client\n"); |
264 | return; | 267 | return; |
265 | } | 268 | } |
266 | 269 | ||
267 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 270 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
268 | "Sending bandwidth update for peer `%s': %u/%u\n", | 271 | "Sending bandwidth update for peer `%s': %u/%u\n", |
269 | GNUNET_i2s(&address->peer), | 272 | GNUNET_i2s (&address->peer), |
270 | address->assigned_bw_out, | 273 | address->assigned_bw_out, |
271 | address->assigned_bw_out); | 274 | address->assigned_bw_out); |
272 | 275 | ||
273 | /* *Notify scheduling clients about suggestion */ | 276 | /* *Notify scheduling clients about suggestion */ |
274 | GAS_scheduling_transmit_address_suggestion(&address->peer, | 277 | GAS_scheduling_transmit_address_suggestion (&address->peer, |
275 | address->session_id, | 278 | address->session_id, |
276 | GNUNET_BANDWIDTH_value_init(address->assigned_bw_out), | 279 | GNUNET_BANDWIDTH_value_init ( |
277 | GNUNET_BANDWIDTH_value_init(address->assigned_bw_in)); | 280 | address->assigned_bw_out), |
281 | GNUNET_BANDWIDTH_value_init ( | ||
282 | address->assigned_bw_in)); | ||
278 | 283 | ||
279 | address->last_notified_bw_out = address->assigned_bw_out; | 284 | address->last_notified_bw_out = address->assigned_bw_out; |
280 | address->last_notified_bw_in = address->assigned_bw_in; | 285 | address->last_notified_bw_in = address->assigned_bw_in; |
@@ -290,48 +295,49 @@ bandwidth_changed_cb(void *cls, | |||
290 | * @return numeric quota value to use | 295 | * @return numeric quota value to use |
291 | */ | 296 | */ |
292 | static unsigned long long | 297 | static unsigned long long |
293 | parse_quota(const char *quota_str, | 298 | parse_quota (const char *quota_str, |
294 | const char *direction, | 299 | const char *direction, |
295 | enum GNUNET_NetworkType network) | 300 | enum GNUNET_NetworkType network) |
296 | { | 301 | { |
297 | int res; | 302 | int res; |
298 | unsigned long long ret; | 303 | unsigned long long ret; |
299 | 304 | ||
300 | res = GNUNET_NO; | 305 | res = GNUNET_NO; |
301 | if (0 == strcmp(quota_str, GNUNET_ATS_MaxBandwidthString)) | 306 | if (0 == strcmp (quota_str, GNUNET_ATS_MaxBandwidthString)) |
302 | { | 307 | { |
303 | ret = GNUNET_ATS_MaxBandwidth; | 308 | ret = GNUNET_ATS_MaxBandwidth; |
304 | res = GNUNET_YES; | 309 | res = GNUNET_YES; |
305 | } | 310 | } |
306 | if ((GNUNET_NO == res) && | 311 | if ((GNUNET_NO == res) && |
307 | (GNUNET_OK == | 312 | (GNUNET_OK == |
308 | GNUNET_STRINGS_fancy_size_to_bytes(quota_str, | 313 | GNUNET_STRINGS_fancy_size_to_bytes (quota_str, |
309 | &ret))) | 314 | &ret))) |
310 | res = GNUNET_YES; | 315 | res = GNUNET_YES; |
311 | if ((GNUNET_NO == res) && | 316 | if ((GNUNET_NO == res) && |
312 | (1 == | 317 | (1 == |
313 | sscanf(quota_str, | 318 | sscanf (quota_str, |
314 | "%llu", | 319 | "%llu", |
315 | &ret))) | 320 | &ret))) |
316 | res = GNUNET_YES; | 321 | res = GNUNET_YES; |
317 | if (GNUNET_NO == res) | 322 | if (GNUNET_NO == res) |
318 | { | 323 | { |
319 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 324 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
320 | _("Could not load %s quota for network `%s': `%s', assigning default bandwidth %llu\n"), | 325 | _ ( |
321 | direction, | 326 | "Could not load %s quota for network `%s': `%s', assigning default bandwidth %llu\n"), |
322 | GNUNET_NT_to_string(network), | 327 | direction, |
323 | quota_str, | 328 | GNUNET_NT_to_string (network), |
324 | (unsigned long long)GNUNET_ATS_DefaultBandwidth); | 329 | quota_str, |
325 | ret = GNUNET_ATS_DefaultBandwidth; | 330 | (unsigned long long) GNUNET_ATS_DefaultBandwidth); |
326 | } | 331 | ret = GNUNET_ATS_DefaultBandwidth; |
332 | } | ||
327 | else | 333 | else |
328 | { | 334 | { |
329 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 335 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
330 | _("%s quota configured for network `%s' is %llu\n"), | 336 | _ ("%s quota configured for network `%s' is %llu\n"), |
331 | direction, | 337 | direction, |
332 | GNUNET_NT_to_string(network), | 338 | GNUNET_NT_to_string (network), |
333 | ret); | 339 | ret); |
334 | } | 340 | } |
335 | return ret; | 341 | return ret; |
336 | } | 342 | } |
337 | 343 | ||
@@ -346,39 +352,40 @@ parse_quota(const char *quota_str, | |||
346 | * @return quota to apply | 352 | * @return quota to apply |
347 | */ | 353 | */ |
348 | static unsigned long long | 354 | static unsigned long long |
349 | load_quota(const struct GNUNET_CONFIGURATION_Handle *cfg, | 355 | load_quota (const struct GNUNET_CONFIGURATION_Handle *cfg, |
350 | enum GNUNET_NetworkType type, | 356 | enum GNUNET_NetworkType type, |
351 | const char *direction) | 357 | const char *direction) |
352 | { | 358 | { |
353 | char *entry; | 359 | char *entry; |
354 | char *quota_str; | 360 | char *quota_str; |
355 | unsigned long long ret; | 361 | unsigned long long ret; |
356 | 362 | ||
357 | GNUNET_asprintf(&entry, | 363 | GNUNET_asprintf (&entry, |
358 | "%s_QUOTA_%s", | 364 | "%s_QUOTA_%s", |
359 | GNUNET_NT_to_string(type), | 365 | GNUNET_NT_to_string (type), |
360 | direction); | 366 | direction); |
361 | if (GNUNET_OK == | 367 | if (GNUNET_OK == |
362 | GNUNET_CONFIGURATION_get_value_string(cfg, | 368 | GNUNET_CONFIGURATION_get_value_string (cfg, |
363 | "ats", | 369 | "ats", |
364 | entry, | 370 | entry, |
365 | "a_str)) | 371 | "a_str)) |
366 | { | 372 | { |
367 | ret = parse_quota(quota_str, | 373 | ret = parse_quota (quota_str, |
368 | direction, | 374 | direction, |
369 | type); | 375 | type); |
370 | GNUNET_free(quota_str); | 376 | GNUNET_free (quota_str); |
371 | } | 377 | } |
372 | else | 378 | else |
373 | { | 379 | { |
374 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 380 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
375 | _("No %s-quota configured for network `%s', assigning default bandwidth %llu\n"), | 381 | _ ( |
376 | direction, | 382 | "No %s-quota configured for network `%s', assigning default bandwidth %llu\n"), |
377 | GNUNET_NT_to_string(type), | 383 | direction, |
378 | (unsigned long long)GNUNET_ATS_DefaultBandwidth); | 384 | GNUNET_NT_to_string (type), |
379 | ret = GNUNET_ATS_DefaultBandwidth; | 385 | (unsigned long long) GNUNET_ATS_DefaultBandwidth); |
380 | } | 386 | ret = GNUNET_ATS_DefaultBandwidth; |
381 | GNUNET_free(entry); | 387 | } |
388 | GNUNET_free (entry); | ||
382 | return ret; | 389 | return ret; |
383 | } | 390 | } |
384 | 391 | ||
@@ -393,27 +400,27 @@ load_quota(const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
393 | * @return number of networks loaded | 400 | * @return number of networks loaded |
394 | */ | 401 | */ |
395 | static unsigned int | 402 | static unsigned int |
396 | load_quotas(const struct GNUNET_CONFIGURATION_Handle *cfg, | 403 | load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, |
397 | unsigned long long *out_dest, | 404 | unsigned long long *out_dest, |
398 | unsigned long long *in_dest, | 405 | unsigned long long *in_dest, |
399 | int dest_length) | 406 | int dest_length) |
400 | { | 407 | { |
401 | unsigned int c; | 408 | unsigned int c; |
402 | 409 | ||
403 | for (c = 0; (c < GNUNET_NT_COUNT) && (c < dest_length); c++) | 410 | for (c = 0; (c < GNUNET_NT_COUNT) && (c < dest_length); c++) |
404 | { | 411 | { |
405 | in_dest[c] = load_quota(cfg, | 412 | in_dest[c] = load_quota (cfg, |
413 | c, | ||
414 | "out"); | ||
415 | out_dest[c] = load_quota (cfg, | ||
406 | c, | 416 | c, |
407 | "out"); | 417 | "in"); |
408 | out_dest[c] = load_quota(cfg, | 418 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
409 | c, | 419 | "Loaded quota for network `%s' (in/out): %llu %llu\n", |
410 | "in"); | 420 | GNUNET_NT_to_string (c), |
411 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 421 | in_dest[c], |
412 | "Loaded quota for network `%s' (in/out): %llu %llu\n", | 422 | out_dest[c]); |
413 | GNUNET_NT_to_string(c), | 423 | } |
414 | in_dest[c], | ||
415 | out_dest[c]); | ||
416 | } | ||
417 | return c; | 424 | return c; |
418 | } | 425 | } |
419 | 426 | ||
@@ -426,21 +433,21 @@ load_quotas(const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
426 | * solver plugin) | 433 | * solver plugin) |
427 | */ | 434 | */ |
428 | int | 435 | int |
429 | GAS_plugin_init(const struct GNUNET_CONFIGURATION_Handle *cfg) | 436 | GAS_plugin_init (const struct GNUNET_CONFIGURATION_Handle *cfg) |
430 | { | 437 | { |
431 | char *mode_str; | 438 | char *mode_str; |
432 | 439 | ||
433 | /* Figure out configured solution method */ | 440 | /* Figure out configured solution method */ |
434 | if (GNUNET_SYSERR == | 441 | if (GNUNET_SYSERR == |
435 | GNUNET_CONFIGURATION_get_value_string(cfg, | 442 | GNUNET_CONFIGURATION_get_value_string (cfg, |
436 | "ats", | 443 | "ats", |
437 | "MODE", | 444 | "MODE", |
438 | &mode_str)) | 445 | &mode_str)) |
439 | { | 446 | { |
440 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 447 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
441 | "No resource assignment method configured, using proportional approach\n"); | 448 | "No resource assignment method configured, using proportional approach\n"); |
442 | mode_str = GNUNET_strdup("proportional"); | 449 | mode_str = GNUNET_strdup ("proportional"); |
443 | } | 450 | } |
444 | env.cls = NULL; | 451 | env.cls = NULL; |
445 | env.info_cb = &solver_info_cb; | 452 | env.info_cb = &solver_info_cb; |
446 | env.bandwidth_changed_cb = &bandwidth_changed_cb; | 453 | env.bandwidth_changed_cb = &bandwidth_changed_cb; |
@@ -450,24 +457,24 @@ GAS_plugin_init(const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
450 | env.stats = GSA_stats; | 457 | env.stats = GSA_stats; |
451 | env.addresses = GSA_addresses; | 458 | env.addresses = GSA_addresses; |
452 | env.network_count = GNUNET_NT_COUNT; | 459 | env.network_count = GNUNET_NT_COUNT; |
453 | load_quotas(cfg, | 460 | load_quotas (cfg, |
454 | env.out_quota, | 461 | env.out_quota, |
455 | env.in_quota, | 462 | env.in_quota, |
456 | GNUNET_NT_COUNT); | 463 | GNUNET_NT_COUNT); |
457 | GNUNET_asprintf(&plugin, | 464 | GNUNET_asprintf (&plugin, |
458 | "libgnunet_plugin_ats_%s", | 465 | "libgnunet_plugin_ats_%s", |
459 | mode_str); | 466 | mode_str); |
460 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 467 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
461 | "Initializing solver `%s'\n", | 468 | "Initializing solver `%s'\n", |
462 | mode_str); | 469 | mode_str); |
463 | GNUNET_free(mode_str); | 470 | GNUNET_free (mode_str); |
464 | if (NULL == (sf = GNUNET_PLUGIN_load(plugin, &env))) | 471 | if (NULL == (sf = GNUNET_PLUGIN_load (plugin, &env))) |
465 | { | 472 | { |
466 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 473 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
467 | _("Failed to initialize solver `%s'!\n"), | 474 | _ ("Failed to initialize solver `%s'!\n"), |
468 | plugin); | 475 | plugin); |
469 | return GNUNET_SYSERR; | 476 | return GNUNET_SYSERR; |
470 | } | 477 | } |
471 | return GNUNET_OK; | 478 | return GNUNET_OK; |
472 | } | 479 | } |
473 | 480 | ||
@@ -476,12 +483,12 @@ GAS_plugin_init(const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
476 | * Shutdown address subsystem. | 483 | * Shutdown address subsystem. |
477 | */ | 484 | */ |
478 | void | 485 | void |
479 | GAS_plugin_done() | 486 | GAS_plugin_done () |
480 | { | 487 | { |
481 | GNUNET_PLUGIN_unload(plugin, | 488 | GNUNET_PLUGIN_unload (plugin, |
482 | sf); | 489 | sf); |
483 | sf = NULL; | 490 | sf = NULL; |
484 | GNUNET_free(plugin); | 491 | GNUNET_free (plugin); |
485 | plugin = NULL; | 492 | plugin = NULL; |
486 | } | 493 | } |
487 | 494 | ||
@@ -493,11 +500,11 @@ GAS_plugin_done() | |||
493 | * @param new_address the new address | 500 | * @param new_address the new address |
494 | */ | 501 | */ |
495 | void | 502 | void |
496 | GAS_plugin_new_address(struct ATS_Address *new_address) | 503 | GAS_plugin_new_address (struct ATS_Address *new_address) |
497 | { | 504 | { |
498 | sf->s_add(sf->cls, | 505 | sf->s_add (sf->cls, |
499 | new_address, | 506 | new_address, |
500 | new_address->properties.scope); /* FIXME: remove 3rd arg here! */ | 507 | new_address->properties.scope); /* FIXME: remove 3rd arg here! */ |
501 | } | 508 | } |
502 | 509 | ||
503 | 510 | ||
@@ -508,10 +515,10 @@ GAS_plugin_new_address(struct ATS_Address *new_address) | |||
508 | * @param address address that was deleted | 515 | * @param address address that was deleted |
509 | */ | 516 | */ |
510 | void | 517 | void |
511 | GAS_plugin_delete_address(struct ATS_Address *address) | 518 | GAS_plugin_delete_address (struct ATS_Address *address) |
512 | { | 519 | { |
513 | sf->s_del(sf->cls, | 520 | sf->s_del (sf->cls, |
514 | address); | 521 | address); |
515 | } | 522 | } |
516 | 523 | ||
517 | 524 | ||
@@ -526,18 +533,18 @@ GAS_plugin_delete_address(struct ATS_Address *address) | |||
526 | * @param score_abs degree of the appreciation | 533 | * @param score_abs degree of the appreciation |
527 | */ | 534 | */ |
528 | void | 535 | void |
529 | GAS_plugin_notify_feedback(struct GNUNET_SERVICE_Client *application, | 536 | GAS_plugin_notify_feedback (struct GNUNET_SERVICE_Client *application, |
530 | const struct GNUNET_PeerIdentity *peer, | 537 | const struct GNUNET_PeerIdentity *peer, |
531 | const struct GNUNET_TIME_Relative scope, | 538 | const struct GNUNET_TIME_Relative scope, |
532 | enum GNUNET_ATS_PreferenceKind kind, | 539 | enum GNUNET_ATS_PreferenceKind kind, |
533 | float score_abs) | 540 | float score_abs) |
534 | { | 541 | { |
535 | sf->s_feedback(sf->cls, | 542 | sf->s_feedback (sf->cls, |
536 | application, | 543 | application, |
537 | peer, | 544 | peer, |
538 | scope, | 545 | scope, |
539 | kind, | 546 | kind, |
540 | score_abs); | 547 | score_abs); |
541 | } | 548 | } |
542 | 549 | ||
543 | 550 | ||
@@ -546,9 +553,9 @@ GAS_plugin_notify_feedback(struct GNUNET_SERVICE_Client *application, | |||
546 | * happening in bulk right now. | 553 | * happening in bulk right now. |
547 | */ | 554 | */ |
548 | void | 555 | void |
549 | GAS_plugin_solver_lock() | 556 | GAS_plugin_solver_lock () |
550 | { | 557 | { |
551 | sf->s_bulk_start(sf->cls); | 558 | sf->s_bulk_start (sf->cls); |
552 | } | 559 | } |
553 | 560 | ||
554 | 561 | ||
@@ -556,9 +563,9 @@ GAS_plugin_solver_lock() | |||
556 | * Resume instant solving, we are done with the bulk state updates. | 563 | * Resume instant solving, we are done with the bulk state updates. |
557 | */ | 564 | */ |
558 | void | 565 | void |
559 | GAS_plugin_solver_unlock() | 566 | GAS_plugin_solver_unlock () |
560 | { | 567 | { |
561 | sf->s_bulk_stop(sf->cls); | 568 | sf->s_bulk_stop (sf->cls); |
562 | } | 569 | } |
563 | 570 | ||
564 | 571 | ||
@@ -569,10 +576,10 @@ GAS_plugin_solver_unlock() | |||
569 | * @param pid identity of peer we now care about | 576 | * @param pid identity of peer we now care about |
570 | */ | 577 | */ |
571 | void | 578 | void |
572 | GAS_plugin_request_connect_start(const struct GNUNET_PeerIdentity *pid) | 579 | GAS_plugin_request_connect_start (const struct GNUNET_PeerIdentity *pid) |
573 | { | 580 | { |
574 | sf->s_get(sf->cls, | 581 | sf->s_get (sf->cls, |
575 | pid); | 582 | pid); |
576 | } | 583 | } |
577 | 584 | ||
578 | 585 | ||
@@ -583,10 +590,10 @@ GAS_plugin_request_connect_start(const struct GNUNET_PeerIdentity *pid) | |||
583 | * @param pid identity of peer we care now less about | 590 | * @param pid identity of peer we care now less about |
584 | */ | 591 | */ |
585 | void | 592 | void |
586 | GAS_plugin_request_connect_stop(const struct GNUNET_PeerIdentity *pid) | 593 | GAS_plugin_request_connect_stop (const struct GNUNET_PeerIdentity *pid) |
587 | { | 594 | { |
588 | sf->s_get_stop(sf->cls, | 595 | sf->s_get_stop (sf->cls, |
589 | pid); | 596 | pid); |
590 | } | 597 | } |
591 | 598 | ||
592 | 599 | ||