diff options
Diffstat (limited to 'src/transport/gnunet-service-transport_manipulation.c')
-rw-r--r-- | src/transport/gnunet-service-transport_manipulation.c | 508 |
1 files changed, 253 insertions, 255 deletions
diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c index 0b042dd6a..07f7eb618 100644 --- a/src/transport/gnunet-service-transport_manipulation.c +++ b/src/transport/gnunet-service-transport_manipulation.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2013 GNUnet e.V. | 3 | Copyright (C) 2010-2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation, either version 3 of the License, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -36,8 +36,7 @@ | |||
36 | /** | 36 | /** |
37 | * Struct containing information about manipulations to a specific peer | 37 | * Struct containing information about manipulations to a specific peer |
38 | */ | 38 | */ |
39 | struct TM_Peer | 39 | struct TM_Peer { |
40 | { | ||
41 | /** | 40 | /** |
42 | * Peer ID | 41 | * Peer ID |
43 | */ | 42 | */ |
@@ -78,8 +77,7 @@ struct TM_Peer | |||
78 | /** | 77 | /** |
79 | * Entry in the delay queue for an outbound delayed message | 78 | * Entry in the delay queue for an outbound delayed message |
80 | */ | 79 | */ |
81 | struct DelayQueueEntry | 80 | struct DelayQueueEntry { |
82 | { | ||
83 | /** | 81 | /** |
84 | * Next in DLL | 82 | * Next in DLL |
85 | */ | 83 | */ |
@@ -171,39 +169,39 @@ static struct GNUNET_SCHEDULER_Task *generic_send_delay_task; | |||
171 | * @param message containing information | 169 | * @param message containing information |
172 | */ | 170 | */ |
173 | void | 171 | void |
174 | GST_manipulation_set_metric (const struct TrafficMetricMessage *tm) | 172 | GST_manipulation_set_metric(const struct TrafficMetricMessage *tm) |
175 | { | 173 | { |
176 | static struct GNUNET_PeerIdentity zero; | 174 | static struct GNUNET_PeerIdentity zero; |
177 | struct TM_Peer *tmp; | 175 | struct TM_Peer *tmp; |
178 | 176 | ||
179 | if (0 == memcmp (&tm->peer, | 177 | if (0 == memcmp(&tm->peer, |
180 | &zero, | 178 | &zero, |
181 | sizeof(struct GNUNET_PeerIdentity))) | 179 | sizeof(struct GNUNET_PeerIdentity))) |
182 | { | 180 | { |
183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 181 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
184 | "Received traffic metrics for all peers\n"); | 182 | "Received traffic metrics for all peers\n"); |
185 | delay_in = GNUNET_TIME_relative_ntoh (tm->delay_in); | 183 | delay_in = GNUNET_TIME_relative_ntoh(tm->delay_in); |
186 | delay_out = GNUNET_TIME_relative_ntoh (tm->delay_out); | 184 | delay_out = GNUNET_TIME_relative_ntoh(tm->delay_out); |
187 | return; | 185 | return; |
188 | } | 186 | } |
189 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 187 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
190 | "Received traffic metrics for peer `%s'\n", | 188 | "Received traffic metrics for peer `%s'\n", |
191 | GNUNET_i2s (&tm->peer)); | 189 | GNUNET_i2s(&tm->peer)); |
192 | if (NULL == | 190 | if (NULL == |
193 | (tmp = GNUNET_CONTAINER_multipeermap_get (peers, | 191 | (tmp = GNUNET_CONTAINER_multipeermap_get(peers, |
194 | &tm->peer))) | 192 | &tm->peer))) |
195 | { | 193 | { |
196 | tmp = GNUNET_new (struct TM_Peer); | 194 | tmp = GNUNET_new(struct TM_Peer); |
197 | tmp->peer = tm->peer; | 195 | tmp->peer = tm->peer; |
198 | GNUNET_CONTAINER_multipeermap_put (peers, | 196 | GNUNET_CONTAINER_multipeermap_put(peers, |
199 | &tm->peer, | 197 | &tm->peer, |
200 | tmp, | 198 | tmp, |
201 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 199 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
202 | } | 200 | } |
203 | GNUNET_ATS_properties_ntoh (&tmp->properties, | 201 | GNUNET_ATS_properties_ntoh(&tmp->properties, |
204 | &tm->properties); | 202 | &tm->properties); |
205 | tmp->delay_in = GNUNET_TIME_relative_ntoh (tm->delay_in); | 203 | tmp->delay_in = GNUNET_TIME_relative_ntoh(tm->delay_in); |
206 | tmp->delay_out = GNUNET_TIME_relative_ntoh (tm->delay_out); | 204 | tmp->delay_out = GNUNET_TIME_relative_ntoh(tm->delay_out); |
207 | } | 205 | } |
208 | 206 | ||
209 | 207 | ||
@@ -214,51 +212,51 @@ GST_manipulation_set_metric (const struct TrafficMetricMessage *tm) | |||
214 | * @param cls the `struct DelayQueueEntry` to transmit | 212 | * @param cls the `struct DelayQueueEntry` to transmit |
215 | */ | 213 | */ |
216 | static void | 214 | static void |
217 | send_delayed (void *cls) | 215 | send_delayed(void *cls) |
218 | { | 216 | { |
219 | struct DelayQueueEntry *dqe = cls; | 217 | struct DelayQueueEntry *dqe = cls; |
220 | struct DelayQueueEntry *next; | 218 | struct DelayQueueEntry *next; |
221 | struct TM_Peer *tmp = dqe->tmp; | 219 | struct TM_Peer *tmp = dqe->tmp; |
222 | 220 | ||
223 | GNUNET_break (GNUNET_YES == | 221 | GNUNET_break(GNUNET_YES == |
224 | GST_neighbours_test_connected (&dqe->id)); | 222 | GST_neighbours_test_connected(&dqe->id)); |
225 | if (NULL != tmp) | 223 | if (NULL != tmp) |
226 | { | ||
227 | tmp->send_delay_task = NULL; | ||
228 | GNUNET_CONTAINER_DLL_remove (tmp->send_head, | ||
229 | tmp->send_tail, | ||
230 | dqe); | ||
231 | next = tmp->send_head; | ||
232 | if (NULL != next) | ||
233 | { | 224 | { |
234 | /* More delayed messages */ | 225 | tmp->send_delay_task = NULL; |
235 | tmp->send_delay_task = GNUNET_SCHEDULER_add_at (next->sent_at, | 226 | GNUNET_CONTAINER_DLL_remove(tmp->send_head, |
236 | &send_delayed, | 227 | tmp->send_tail, |
237 | next); | 228 | dqe); |
229 | next = tmp->send_head; | ||
230 | if (NULL != next) | ||
231 | { | ||
232 | /* More delayed messages */ | ||
233 | tmp->send_delay_task = GNUNET_SCHEDULER_add_at(next->sent_at, | ||
234 | &send_delayed, | ||
235 | next); | ||
236 | } | ||
238 | } | 237 | } |
239 | } | ||
240 | else | 238 | else |
241 | { | ||
242 | /* Remove from generic queue */ | ||
243 | generic_send_delay_task = NULL; | ||
244 | GNUNET_CONTAINER_DLL_remove (generic_dqe_head, | ||
245 | generic_dqe_tail, | ||
246 | dqe); | ||
247 | next = generic_dqe_head; | ||
248 | if (NULL != next) | ||
249 | { | 239 | { |
250 | /* More delayed messages */ | 240 | /* Remove from generic queue */ |
251 | generic_send_delay_task = GNUNET_SCHEDULER_add_at (next->sent_at, | 241 | generic_send_delay_task = NULL; |
252 | &send_delayed, | 242 | GNUNET_CONTAINER_DLL_remove(generic_dqe_head, |
253 | next); | 243 | generic_dqe_tail, |
244 | dqe); | ||
245 | next = generic_dqe_head; | ||
246 | if (NULL != next) | ||
247 | { | ||
248 | /* More delayed messages */ | ||
249 | generic_send_delay_task = GNUNET_SCHEDULER_add_at(next->sent_at, | ||
250 | &send_delayed, | ||
251 | next); | ||
252 | } | ||
254 | } | 253 | } |
255 | } | 254 | GST_neighbours_send(&dqe->id, |
256 | GST_neighbours_send (&dqe->id, | 255 | dqe->msg, |
257 | dqe->msg, | 256 | dqe->msg_size, |
258 | dqe->msg_size, | 257 | dqe->timeout, |
259 | dqe->timeout, | 258 | dqe->cont, |
260 | dqe->cont, | 259 | dqe->cont_cls); |
261 | dqe->cont_cls); | ||
262 | GNUNET_free(dqe); | 260 | GNUNET_free(dqe); |
263 | } | 261 | } |
264 | 262 | ||
@@ -275,71 +273,71 @@ send_delayed (void *cls) | |||
275 | * @param cont_cls cls for @a cont | 273 | * @param cont_cls cls for @a cont |
276 | */ | 274 | */ |
277 | void | 275 | void |
278 | GST_manipulation_send (const struct GNUNET_PeerIdentity *target, | 276 | GST_manipulation_send(const struct GNUNET_PeerIdentity *target, |
279 | const void *msg, | 277 | const void *msg, |
280 | size_t msg_size, | 278 | size_t msg_size, |
281 | struct GNUNET_TIME_Relative timeout, | 279 | struct GNUNET_TIME_Relative timeout, |
282 | GST_NeighbourSendContinuation cont, | 280 | GST_NeighbourSendContinuation cont, |
283 | void *cont_cls) | 281 | void *cont_cls) |
284 | { | 282 | { |
285 | struct TM_Peer *tmp; | 283 | struct TM_Peer *tmp; |
286 | struct DelayQueueEntry *dqe; | 284 | struct DelayQueueEntry *dqe; |
287 | struct GNUNET_TIME_Relative delay; | 285 | struct GNUNET_TIME_Relative delay; |
288 | 286 | ||
289 | if (NULL != (tmp = | 287 | if (NULL != (tmp = |
290 | GNUNET_CONTAINER_multipeermap_get (peers, | 288 | GNUNET_CONTAINER_multipeermap_get(peers, |
291 | target))) | 289 | target))) |
292 | delay = tmp->delay_out; | 290 | delay = tmp->delay_out; |
293 | else | 291 | else |
294 | delay = delay_out; | 292 | delay = delay_out; |
295 | if (0 == delay.rel_value_us) | 293 | if (0 == delay.rel_value_us) |
296 | { | 294 | { |
297 | /* Normal sending */ | 295 | /* Normal sending */ |
298 | GST_neighbours_send (target, | 296 | GST_neighbours_send(target, |
299 | msg, | 297 | msg, |
300 | msg_size, | 298 | msg_size, |
301 | timeout, | 299 | timeout, |
302 | cont, cont_cls); | 300 | cont, cont_cls); |
303 | return; | 301 | return; |
304 | } | 302 | } |
305 | dqe = GNUNET_malloc (sizeof (struct DelayQueueEntry) + msg_size); | 303 | dqe = GNUNET_malloc(sizeof(struct DelayQueueEntry) + msg_size); |
306 | dqe->id = *target; | 304 | dqe->id = *target; |
307 | dqe->tmp = tmp; | 305 | dqe->tmp = tmp; |
308 | dqe->sent_at = GNUNET_TIME_relative_to_absolute (delay); | 306 | dqe->sent_at = GNUNET_TIME_relative_to_absolute(delay); |
309 | dqe->cont = cont; | 307 | dqe->cont = cont; |
310 | dqe->cont_cls = cont_cls; | 308 | dqe->cont_cls = cont_cls; |
311 | dqe->msg = &dqe[1]; | 309 | dqe->msg = &dqe[1]; |
312 | dqe->msg_size = msg_size; | 310 | dqe->msg_size = msg_size; |
313 | dqe->timeout = timeout; | 311 | dqe->timeout = timeout; |
314 | GNUNET_memcpy (dqe->msg, | 312 | GNUNET_memcpy(dqe->msg, |
315 | msg, | 313 | msg, |
316 | msg_size); | 314 | msg_size); |
317 | if (NULL == tmp) | 315 | if (NULL == tmp) |
318 | { | 316 | { |
319 | GNUNET_CONTAINER_DLL_insert_tail (generic_dqe_head, | 317 | GNUNET_CONTAINER_DLL_insert_tail(generic_dqe_head, |
320 | generic_dqe_tail, | 318 | generic_dqe_tail, |
321 | dqe); | 319 | dqe); |
322 | if (NULL == generic_send_delay_task) | 320 | if (NULL == generic_send_delay_task) |
323 | generic_send_delay_task = GNUNET_SCHEDULER_add_delayed (delay, | 321 | generic_send_delay_task = GNUNET_SCHEDULER_add_delayed(delay, |
324 | &send_delayed, | 322 | &send_delayed, |
325 | dqe); | 323 | dqe); |
326 | } | 324 | } |
327 | else | 325 | else |
328 | { | 326 | { |
329 | GNUNET_CONTAINER_DLL_insert_tail (tmp->send_head, | 327 | GNUNET_CONTAINER_DLL_insert_tail(tmp->send_head, |
330 | tmp->send_tail, | 328 | tmp->send_tail, |
331 | dqe); | 329 | dqe); |
332 | if (NULL == tmp->send_delay_task) | 330 | if (NULL == tmp->send_delay_task) |
333 | tmp->send_delay_task = GNUNET_SCHEDULER_add_delayed (delay, | 331 | tmp->send_delay_task = GNUNET_SCHEDULER_add_delayed(delay, |
334 | &send_delayed, | 332 | &send_delayed, |
335 | dqe); | 333 | dqe); |
336 | } | 334 | } |
337 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 335 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
338 | "Delaying %u byte message to peer `%s' with peer specific delay for %s\n", | 336 | "Delaying %u byte message to peer `%s' with peer specific delay for %s\n", |
339 | (unsigned int) msg_size, | 337 | (unsigned int)msg_size, |
340 | GNUNET_i2s (target), | 338 | GNUNET_i2s(target), |
341 | GNUNET_STRINGS_relative_time_to_string (delay, | 339 | GNUNET_STRINGS_relative_time_to_string(delay, |
342 | GNUNET_YES)); | 340 | GNUNET_YES)); |
343 | } | 341 | } |
344 | 342 | ||
345 | 343 | ||
@@ -352,15 +350,15 @@ GST_manipulation_send (const struct GNUNET_PeerIdentity *target, | |||
352 | * @param prop[IN|OUT] metrics to modify | 350 | * @param prop[IN|OUT] metrics to modify |
353 | */ | 351 | */ |
354 | void | 352 | void |
355 | GST_manipulation_manipulate_metrics (const struct GNUNET_HELLO_Address *address, | 353 | GST_manipulation_manipulate_metrics(const struct GNUNET_HELLO_Address *address, |
356 | struct GNUNET_ATS_Session *session, | 354 | struct GNUNET_ATS_Session *session, |
357 | struct GNUNET_ATS_Properties *prop) | 355 | struct GNUNET_ATS_Properties *prop) |
358 | { | 356 | { |
359 | const struct GNUNET_PeerIdentity *peer = &address->peer; | 357 | const struct GNUNET_PeerIdentity *peer = &address->peer; |
360 | struct TM_Peer *tmp; | 358 | struct TM_Peer *tmp; |
361 | 359 | ||
362 | tmp = GNUNET_CONTAINER_multipeermap_get (peers, | 360 | tmp = GNUNET_CONTAINER_multipeermap_get(peers, |
363 | peer); | 361 | peer); |
364 | if (NULL != tmp) | 362 | if (NULL != tmp) |
365 | *prop = tmp->properties; | 363 | *prop = tmp->properties; |
366 | } | 364 | } |
@@ -377,33 +375,33 @@ GST_manipulation_manipulate_metrics (const struct GNUNET_HELLO_Address *address, | |||
377 | * @return manipulated delay for next receive | 375 | * @return manipulated delay for next receive |
378 | */ | 376 | */ |
379 | struct GNUNET_TIME_Relative | 377 | struct GNUNET_TIME_Relative |
380 | GST_manipulation_recv (void *cls, | 378 | GST_manipulation_recv(void *cls, |
381 | const struct GNUNET_HELLO_Address *address, | 379 | const struct GNUNET_HELLO_Address *address, |
382 | struct GNUNET_ATS_Session *session, | 380 | struct GNUNET_ATS_Session *session, |
383 | const struct GNUNET_MessageHeader *message) | 381 | const struct GNUNET_MessageHeader *message) |
384 | { | 382 | { |
385 | struct TM_Peer *tmp; | 383 | struct TM_Peer *tmp; |
386 | struct GNUNET_TIME_Relative quota_delay; | 384 | struct GNUNET_TIME_Relative quota_delay; |
387 | struct GNUNET_TIME_Relative m_delay; | 385 | struct GNUNET_TIME_Relative m_delay; |
388 | 386 | ||
389 | if (NULL != | 387 | if (NULL != |
390 | (tmp = GNUNET_CONTAINER_multipeermap_get (peers, | 388 | (tmp = GNUNET_CONTAINER_multipeermap_get(peers, |
391 | &address->peer))) | 389 | &address->peer))) |
392 | m_delay = tmp->delay_in; | 390 | m_delay = tmp->delay_in; |
393 | else | 391 | else |
394 | m_delay = delay_in; | 392 | m_delay = delay_in; |
395 | 393 | ||
396 | quota_delay = GST_receive_callback (cls, | 394 | quota_delay = GST_receive_callback(cls, |
397 | address, | 395 | address, |
398 | session, | 396 | session, |
399 | message); | 397 | message); |
400 | m_delay = GNUNET_TIME_relative_max (m_delay, | 398 | m_delay = GNUNET_TIME_relative_max(m_delay, |
401 | quota_delay); | 399 | quota_delay); |
402 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 400 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
403 | "Delaying next receive for peer `%s' for %s\n", | 401 | "Delaying next receive for peer `%s' for %s\n", |
404 | GNUNET_i2s (&address->peer), | 402 | GNUNET_i2s(&address->peer), |
405 | GNUNET_STRINGS_relative_time_to_string (m_delay, | 403 | GNUNET_STRINGS_relative_time_to_string(m_delay, |
406 | GNUNET_YES)); | 404 | GNUNET_YES)); |
407 | return m_delay; | 405 | return m_delay; |
408 | } | 406 | } |
409 | 407 | ||
@@ -412,38 +410,38 @@ GST_manipulation_recv (void *cls, | |||
412 | * Initialize traffic manipulation | 410 | * Initialize traffic manipulation |
413 | */ | 411 | */ |
414 | void | 412 | void |
415 | GST_manipulation_init () | 413 | GST_manipulation_init() |
416 | { | 414 | { |
417 | struct GNUNET_TIME_Relative delay; | 415 | struct GNUNET_TIME_Relative delay; |
418 | 416 | ||
419 | if ( (GNUNET_OK == | 417 | if ((GNUNET_OK == |
420 | GNUNET_CONFIGURATION_get_value_time (GST_cfg, | 418 | GNUNET_CONFIGURATION_get_value_time(GST_cfg, |
421 | "transport", | 419 | "transport", |
422 | "MANIPULATE_DELAY_IN", | 420 | "MANIPULATE_DELAY_IN", |
423 | &delay)) && | 421 | &delay)) && |
424 | (delay.rel_value_us > 0) ) | 422 | (delay.rel_value_us > 0)) |
425 | { | 423 | { |
426 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 424 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
427 | "Delaying inbound traffic for %s\n", | 425 | "Delaying inbound traffic for %s\n", |
428 | GNUNET_STRINGS_relative_time_to_string (delay, | 426 | GNUNET_STRINGS_relative_time_to_string(delay, |
429 | GNUNET_YES)); | 427 | GNUNET_YES)); |
430 | delay_in = delay; | 428 | delay_in = delay; |
431 | } | 429 | } |
432 | if ( (GNUNET_OK == | 430 | if ((GNUNET_OK == |
433 | GNUNET_CONFIGURATION_get_value_time (GST_cfg, | 431 | GNUNET_CONFIGURATION_get_value_time(GST_cfg, |
434 | "transport", | 432 | "transport", |
435 | "MANIPULATE_DELAY_OUT", | 433 | "MANIPULATE_DELAY_OUT", |
436 | &delay)) && | 434 | &delay)) && |
437 | (delay.rel_value_us > 0) ) | 435 | (delay.rel_value_us > 0)) |
438 | { | 436 | { |
439 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 437 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
440 | "Delaying outbound traffic for %s\n", | 438 | "Delaying outbound traffic for %s\n", |
441 | GNUNET_STRINGS_relative_time_to_string (delay, | 439 | GNUNET_STRINGS_relative_time_to_string(delay, |
442 | GNUNET_YES)); | 440 | GNUNET_YES)); |
443 | delay_out = delay; | 441 | delay_out = delay; |
444 | } | 442 | } |
445 | peers = GNUNET_CONTAINER_multipeermap_create (4, | 443 | peers = GNUNET_CONTAINER_multipeermap_create(4, |
446 | GNUNET_NO); | 444 | GNUNET_NO); |
447 | } | 445 | } |
448 | 446 | ||
449 | 447 | ||
@@ -453,58 +451,58 @@ GST_manipulation_init () | |||
453 | * @param peer the disconnecting peer | 451 | * @param peer the disconnecting peer |
454 | */ | 452 | */ |
455 | void | 453 | void |
456 | GST_manipulation_peer_disconnect (const struct GNUNET_PeerIdentity *peer) | 454 | GST_manipulation_peer_disconnect(const struct GNUNET_PeerIdentity *peer) |
457 | { | 455 | { |
458 | struct TM_Peer *tmp; | 456 | struct TM_Peer *tmp; |
459 | struct DelayQueueEntry *dqe; | 457 | struct DelayQueueEntry *dqe; |
460 | struct DelayQueueEntry *next; | 458 | struct DelayQueueEntry *next; |
461 | 459 | ||
462 | tmp = GNUNET_CONTAINER_multipeermap_get (peers, | 460 | tmp = GNUNET_CONTAINER_multipeermap_get(peers, |
463 | peer); | 461 | peer); |
464 | if (NULL != tmp) | 462 | if (NULL != tmp) |
465 | { | ||
466 | while (NULL != (dqe = tmp->send_head)) | ||
467 | { | 463 | { |
468 | GNUNET_CONTAINER_DLL_remove (tmp->send_head, | 464 | while (NULL != (dqe = tmp->send_head)) |
469 | tmp->send_tail, | 465 | { |
470 | dqe); | 466 | GNUNET_CONTAINER_DLL_remove(tmp->send_head, |
471 | if (NULL != dqe->cont) | 467 | tmp->send_tail, |
472 | dqe->cont (dqe->cont_cls, | 468 | dqe); |
473 | GNUNET_SYSERR, | 469 | if (NULL != dqe->cont) |
474 | dqe->msg_size, | 470 | dqe->cont(dqe->cont_cls, |
475 | 0); | 471 | GNUNET_SYSERR, |
476 | GNUNET_free(dqe); | 472 | dqe->msg_size, |
473 | 0); | ||
474 | GNUNET_free(dqe); | ||
475 | } | ||
477 | } | 476 | } |
478 | } | ||
479 | next = generic_dqe_head; | 477 | next = generic_dqe_head; |
480 | while (NULL != (dqe = next)) | 478 | while (NULL != (dqe = next)) |
481 | { | ||
482 | next = dqe->next; | ||
483 | if (0 == memcmp (peer, | ||
484 | &dqe->id, | ||
485 | sizeof (dqe->id))) | ||
486 | { | 479 | { |
487 | GNUNET_CONTAINER_DLL_remove (generic_dqe_head, | 480 | next = dqe->next; |
488 | generic_dqe_tail, | 481 | if (0 == memcmp(peer, |
489 | dqe); | 482 | &dqe->id, |
490 | if (NULL != dqe->cont) | 483 | sizeof(dqe->id))) |
491 | dqe->cont (dqe->cont_cls, | 484 | { |
492 | GNUNET_SYSERR, | 485 | GNUNET_CONTAINER_DLL_remove(generic_dqe_head, |
493 | dqe->msg_size, | 486 | generic_dqe_tail, |
494 | 0); | 487 | dqe); |
495 | GNUNET_free(dqe); | 488 | if (NULL != dqe->cont) |
489 | dqe->cont(dqe->cont_cls, | ||
490 | GNUNET_SYSERR, | ||
491 | dqe->msg_size, | ||
492 | 0); | ||
493 | GNUNET_free(dqe); | ||
494 | } | ||
496 | } | 495 | } |
497 | } | ||
498 | if (NULL != generic_send_delay_task) | 496 | if (NULL != generic_send_delay_task) |
499 | { | 497 | { |
500 | GNUNET_SCHEDULER_cancel (generic_send_delay_task); | 498 | GNUNET_SCHEDULER_cancel(generic_send_delay_task); |
501 | generic_send_delay_task = NULL; | 499 | generic_send_delay_task = NULL; |
502 | if (NULL != generic_dqe_head) | 500 | if (NULL != generic_dqe_head) |
503 | generic_send_delay_task | 501 | generic_send_delay_task |
504 | = GNUNET_SCHEDULER_add_at (generic_dqe_head->sent_at, | 502 | = GNUNET_SCHEDULER_add_at(generic_dqe_head->sent_at, |
505 | &send_delayed, | 503 | &send_delayed, |
506 | generic_dqe_head); | 504 | generic_dqe_head); |
507 | } | 505 | } |
508 | } | 506 | } |
509 | 507 | ||
510 | 508 | ||
@@ -517,35 +515,35 @@ GST_manipulation_peer_disconnect (const struct GNUNET_PeerIdentity *peer) | |||
517 | * @return #GNUNET_OK (continue to iterate) | 515 | * @return #GNUNET_OK (continue to iterate) |
518 | */ | 516 | */ |
519 | static int | 517 | static int |
520 | free_tmps (void *cls, | 518 | free_tmps(void *cls, |
521 | const struct GNUNET_PeerIdentity *key, | 519 | const struct GNUNET_PeerIdentity *key, |
522 | void *value) | 520 | void *value) |
523 | { | 521 | { |
524 | struct TM_Peer *tmp = value; | 522 | struct TM_Peer *tmp = value; |
525 | struct DelayQueueEntry *dqe; | 523 | struct DelayQueueEntry *dqe; |
526 | 524 | ||
527 | GNUNET_break (GNUNET_YES == | 525 | GNUNET_break(GNUNET_YES == |
528 | GNUNET_CONTAINER_multipeermap_remove (peers, | 526 | GNUNET_CONTAINER_multipeermap_remove(peers, |
529 | key, | 527 | key, |
530 | value)); | 528 | value)); |
531 | while (NULL != (dqe = tmp->send_head)) | 529 | while (NULL != (dqe = tmp->send_head)) |
532 | { | 530 | { |
533 | GNUNET_CONTAINER_DLL_remove (tmp->send_head, | 531 | GNUNET_CONTAINER_DLL_remove(tmp->send_head, |
534 | tmp->send_tail, | 532 | tmp->send_tail, |
535 | dqe); | 533 | dqe); |
536 | if (NULL != dqe->cont) | 534 | if (NULL != dqe->cont) |
537 | dqe->cont (dqe->cont_cls, | 535 | dqe->cont(dqe->cont_cls, |
538 | GNUNET_SYSERR, | 536 | GNUNET_SYSERR, |
539 | dqe->msg_size, | 537 | dqe->msg_size, |
540 | 0); | 538 | 0); |
541 | GNUNET_free (dqe); | 539 | GNUNET_free(dqe); |
542 | } | 540 | } |
543 | if (NULL != tmp->send_delay_task) | 541 | if (NULL != tmp->send_delay_task) |
544 | { | 542 | { |
545 | GNUNET_SCHEDULER_cancel (tmp->send_delay_task); | 543 | GNUNET_SCHEDULER_cancel(tmp->send_delay_task); |
546 | tmp->send_delay_task = NULL; | 544 | tmp->send_delay_task = NULL; |
547 | } | 545 | } |
548 | GNUNET_free (tmp); | 546 | GNUNET_free(tmp); |
549 | return GNUNET_OK; | 547 | return GNUNET_OK; |
550 | } | 548 | } |
551 | 549 | ||
@@ -554,32 +552,32 @@ free_tmps (void *cls, | |||
554 | * Stop traffic manipulation | 552 | * Stop traffic manipulation |
555 | */ | 553 | */ |
556 | void | 554 | void |
557 | GST_manipulation_stop () | 555 | GST_manipulation_stop() |
558 | { | 556 | { |
559 | struct DelayQueueEntry *cur; | 557 | struct DelayQueueEntry *cur; |
560 | 558 | ||
561 | GNUNET_CONTAINER_multipeermap_iterate (peers, | 559 | GNUNET_CONTAINER_multipeermap_iterate(peers, |
562 | &free_tmps, | 560 | &free_tmps, |
563 | NULL); | 561 | NULL); |
564 | GNUNET_CONTAINER_multipeermap_destroy (peers); | 562 | GNUNET_CONTAINER_multipeermap_destroy(peers); |
565 | peers = NULL; | 563 | peers = NULL; |
566 | while (NULL != (cur = generic_dqe_head)) | 564 | while (NULL != (cur = generic_dqe_head)) |
567 | { | 565 | { |
568 | GNUNET_CONTAINER_DLL_remove (generic_dqe_head, | 566 | GNUNET_CONTAINER_DLL_remove(generic_dqe_head, |
569 | generic_dqe_tail, | 567 | generic_dqe_tail, |
570 | cur); | 568 | cur); |
571 | if (NULL != cur->cont) | 569 | if (NULL != cur->cont) |
572 | cur->cont (cur->cont_cls, | 570 | cur->cont(cur->cont_cls, |
573 | GNUNET_SYSERR, | 571 | GNUNET_SYSERR, |
574 | cur->msg_size, | 572 | cur->msg_size, |
575 | 0); | 573 | 0); |
576 | GNUNET_free (cur); | 574 | GNUNET_free(cur); |
577 | } | 575 | } |
578 | if (NULL != generic_send_delay_task) | 576 | if (NULL != generic_send_delay_task) |
579 | { | 577 | { |
580 | GNUNET_SCHEDULER_cancel (generic_send_delay_task); | 578 | GNUNET_SCHEDULER_cancel(generic_send_delay_task); |
581 | generic_send_delay_task = NULL; | 579 | generic_send_delay_task = NULL; |
582 | } | 580 | } |
583 | } | 581 | } |
584 | 582 | ||
585 | /* end of file gnunet-service-transport_manipulation.c */ | 583 | /* end of file gnunet-service-transport_manipulation.c */ |