diff options
Diffstat (limited to 'src/testbed/gnunet-service-testbed_oc.c')
-rw-r--r-- | src/testbed/gnunet-service-testbed_oc.c | 1658 |
1 files changed, 826 insertions, 832 deletions
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c index 4d6a4d446..391b95b12 100644 --- a/src/testbed/gnunet-service-testbed_oc.c +++ b/src/testbed/gnunet-service-testbed_oc.c | |||
@@ -1,22 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2008--2016 GNUnet e.V. | 3 | Copyright (C) 2008--2016 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 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file testbed/gnunet-service-testbed_oc.c | 22 | * @file testbed/gnunet-service-testbed_oc.c |
@@ -34,16 +34,14 @@ | |||
34 | #ifdef LOG | 34 | #ifdef LOG |
35 | #undef LOG | 35 | #undef LOG |
36 | #endif | 36 | #endif |
37 | #define LOG(kind,...) \ | 37 | #define LOG(kind, ...) \ |
38 | GNUNET_log_from (kind, "testbed-OC", __VA_ARGS__) | 38 | GNUNET_log_from(kind, "testbed-OC", __VA_ARGS__) |
39 | 39 | ||
40 | 40 | ||
41 | /** | 41 | /** |
42 | * Context information for requesting ATS to connect to a peer | 42 | * Context information for requesting ATS to connect to a peer |
43 | */ | 43 | */ |
44 | struct ConnectivitySuggestContext | 44 | struct ConnectivitySuggestContext { |
45 | { | ||
46 | |||
47 | /** | 45 | /** |
48 | * The transport handle obtained from cache. Do NOT close/disconnect. | 46 | * The transport handle obtained from cache. Do NOT close/disconnect. |
49 | */ | 47 | */ |
@@ -69,15 +67,13 @@ struct ConnectivitySuggestContext | |||
69 | * The ATS handle for the connectivity suggestion. | 67 | * The ATS handle for the connectivity suggestion. |
70 | */ | 68 | */ |
71 | struct GNUNET_ATS_ConnectivitySuggestHandle *csh; | 69 | struct GNUNET_ATS_ConnectivitySuggestHandle *csh; |
72 | |||
73 | }; | 70 | }; |
74 | 71 | ||
75 | 72 | ||
76 | /** | 73 | /** |
77 | * Types for context information we create for overlay connect requests | 74 | * Types for context information we create for overlay connect requests |
78 | */ | 75 | */ |
79 | enum OverlayConnectContextType | 76 | enum OverlayConnectContextType { |
80 | { | ||
81 | /** | 77 | /** |
82 | * This type is used if the overlay connection is local i.e. the connection | 78 | * This type is used if the overlay connection is local i.e. the connection |
83 | * has to be made between local peers | 79 | * has to be made between local peers |
@@ -102,8 +98,7 @@ enum OverlayConnectContextType | |||
102 | * Context data for operations on second peer in local overlay connection | 98 | * Context data for operations on second peer in local overlay connection |
103 | * contexts | 99 | * contexts |
104 | */ | 100 | */ |
105 | struct LocalPeer2Context | 101 | struct LocalPeer2Context { |
106 | { | ||
107 | /** | 102 | /** |
108 | * The handle for offering the HELLO of the first peer to the second | 103 | * The handle for offering the HELLO of the first peer to the second |
109 | * peer. | 104 | * peer. |
@@ -121,8 +116,7 @@ struct LocalPeer2Context | |||
121 | * Context data for operations on second peer in remote overlay connection | 116 | * Context data for operations on second peer in remote overlay connection |
122 | * contexts | 117 | * contexts |
123 | */ | 118 | */ |
124 | struct RemotePeer2Context | 119 | struct RemotePeer2Context { |
125 | { | ||
126 | /** | 120 | /** |
127 | * Controller of peer 2; If #OCC_TYPE_REMOTE_LATERAL is the type of overlay | 121 | * Controller of peer 2; If #OCC_TYPE_REMOTE_LATERAL is the type of overlay |
128 | * connection then this can be NULL until the connection to the controller is | 122 | * connection then this can be NULL until the connection to the controller is |
@@ -152,8 +146,7 @@ struct RemotePeer2Context | |||
152 | /** | 146 | /** |
153 | * Context information for connecting 2 peers in overlay. | 147 | * Context information for connecting 2 peers in overlay. |
154 | */ | 148 | */ |
155 | struct OverlayConnectContext | 149 | struct OverlayConnectContext { |
156 | { | ||
157 | /** | 150 | /** |
158 | * The next pointer for maintaining a DLL of all OverlayConnectContexts | 151 | * The next pointer for maintaining a DLL of all OverlayConnectContexts |
159 | */ | 152 | */ |
@@ -211,7 +204,6 @@ struct OverlayConnectContext | |||
211 | * Context information for operations on the second peer | 204 | * Context information for operations on the second peer |
212 | */ | 205 | */ |
213 | union { | 206 | union { |
214 | |||
215 | /** | 207 | /** |
216 | * Context information to be used if the second peer is local | 208 | * Context information to be used if the second peer is local |
217 | */ | 209 | */ |
@@ -221,7 +213,6 @@ struct OverlayConnectContext | |||
221 | * Context information to be used if the second peer is remote | 213 | * Context information to be used if the second peer is remote |
222 | */ | 214 | */ |
223 | struct RemotePeer2Context remote; | 215 | struct RemotePeer2Context remote; |
224 | |||
225 | } p2ctx; | 216 | } p2ctx; |
226 | 217 | ||
227 | /** | 218 | /** |
@@ -274,8 +265,7 @@ struct OverlayConnectContext | |||
274 | * peer A to make peer B connect to peer A by sending the controller of peer B | 265 | * peer A to make peer B connect to peer A by sending the controller of peer B |
275 | * the HELLO of peer A. | 266 | * the HELLO of peer A. |
276 | */ | 267 | */ |
277 | struct RemoteOverlayConnectCtx | 268 | struct RemoteOverlayConnectCtx { |
278 | { | ||
279 | /** | 269 | /** |
280 | * the next pointer for DLL | 270 | * the next pointer for DLL |
281 | */ | 271 | */ |
@@ -356,15 +346,15 @@ static struct RemoteOverlayConnectCtx *roccq_tail; | |||
356 | * @param focc the ForwardedOverlayConnectContext to cleanup | 346 | * @param focc the ForwardedOverlayConnectContext to cleanup |
357 | */ | 347 | */ |
358 | void | 348 | void |
359 | GST_cleanup_focc (struct ForwardedOverlayConnectContext *focc) | 349 | GST_cleanup_focc(struct ForwardedOverlayConnectContext *focc) |
360 | { | 350 | { |
361 | struct RegisteredHostContext *rhc = focc->rhc; | 351 | struct RegisteredHostContext *rhc = focc->rhc; |
362 | 352 | ||
363 | GNUNET_CONTAINER_DLL_remove (rhc->focc_dll_head, | 353 | GNUNET_CONTAINER_DLL_remove(rhc->focc_dll_head, |
364 | rhc->focc_dll_tail, | 354 | rhc->focc_dll_tail, |
365 | focc); | 355 | focc); |
366 | GNUNET_free_non_null (focc->orig_msg); | 356 | GNUNET_free_non_null(focc->orig_msg); |
367 | GNUNET_free (focc); | 357 | GNUNET_free(focc); |
368 | } | 358 | } |
369 | 359 | ||
370 | 360 | ||
@@ -374,7 +364,7 @@ GST_cleanup_focc (struct ForwardedOverlayConnectContext *focc) | |||
374 | * @param cls the `struct ForwardedOperationContext` | 364 | * @param cls the `struct ForwardedOperationContext` |
375 | */ | 365 | */ |
376 | static void | 366 | static void |
377 | forwarded_overlay_connect_timeout (void *cls) | 367 | forwarded_overlay_connect_timeout(void *cls) |
378 | { | 368 | { |
379 | struct ForwardedOperationContext *fopc = cls; | 369 | struct ForwardedOperationContext *fopc = cls; |
380 | struct RegisteredHostContext *rhc; | 370 | struct RegisteredHostContext *rhc; |
@@ -383,13 +373,13 @@ forwarded_overlay_connect_timeout (void *cls) | |||
383 | fopc->timeout_task = NULL; | 373 | fopc->timeout_task = NULL; |
384 | rhc = fopc->cls; | 374 | rhc = fopc->cls; |
385 | focc = rhc->focc_dll_head; | 375 | focc = rhc->focc_dll_head; |
386 | LOG_DEBUG ("Overlay linking between peers %u and %u failed\n", | 376 | LOG_DEBUG("Overlay linking between peers %u and %u failed\n", |
387 | focc->peer1, | 377 | focc->peer1, |
388 | focc->peer2); | 378 | focc->peer2); |
389 | GST_cleanup_focc (focc); | 379 | GST_cleanup_focc(focc); |
390 | GST_forwarded_operation_timeout (fopc); | 380 | GST_forwarded_operation_timeout(fopc); |
391 | if (NULL != rhc->focc_dll_head) | 381 | if (NULL != rhc->focc_dll_head) |
392 | GST_process_next_focc (rhc); | 382 | GST_process_next_focc(rhc); |
393 | } | 383 | } |
394 | 384 | ||
395 | 385 | ||
@@ -402,19 +392,19 @@ forwarded_overlay_connect_timeout (void *cls) | |||
402 | * @param msg the peer create success message | 392 | * @param msg the peer create success message |
403 | */ | 393 | */ |
404 | static void | 394 | static void |
405 | forwarded_overlay_connect_listener (void *cls, | 395 | forwarded_overlay_connect_listener(void *cls, |
406 | const struct GNUNET_MessageHeader *msg) | 396 | const struct GNUNET_MessageHeader *msg) |
407 | { | 397 | { |
408 | struct ForwardedOperationContext *fopc = cls; | 398 | struct ForwardedOperationContext *fopc = cls; |
409 | struct RegisteredHostContext *rhc; | 399 | struct RegisteredHostContext *rhc; |
410 | struct ForwardedOverlayConnectContext *focc; | 400 | struct ForwardedOverlayConnectContext *focc; |
411 | 401 | ||
412 | rhc = fopc->cls; | 402 | rhc = fopc->cls; |
413 | GST_forwarded_operation_reply_relay (cls, msg); | 403 | GST_forwarded_operation_reply_relay(cls, msg); |
414 | focc = rhc->focc_dll_head; | 404 | focc = rhc->focc_dll_head; |
415 | GST_cleanup_focc (focc); | 405 | GST_cleanup_focc(focc); |
416 | if (NULL != rhc->focc_dll_head) | 406 | if (NULL != rhc->focc_dll_head) |
417 | GST_process_next_focc (rhc); | 407 | GST_process_next_focc(rhc); |
418 | } | 408 | } |
419 | 409 | ||
420 | 410 | ||
@@ -424,7 +414,7 @@ forwarded_overlay_connect_listener (void *cls, | |||
424 | * @param rhc the RegisteredHostContext | 414 | * @param rhc the RegisteredHostContext |
425 | */ | 415 | */ |
426 | void | 416 | void |
427 | GST_process_next_focc (struct RegisteredHostContext *rhc) | 417 | GST_process_next_focc(struct RegisteredHostContext *rhc) |
428 | { | 418 | { |
429 | struct ForwardedOperationContext *fopc; | 419 | struct ForwardedOperationContext *fopc; |
430 | struct ForwardedOverlayConnectContext *focc; | 420 | struct ForwardedOverlayConnectContext *focc; |
@@ -432,31 +422,31 @@ GST_process_next_focc (struct RegisteredHostContext *rhc) | |||
432 | struct Slave *slave; | 422 | struct Slave *slave; |
433 | 423 | ||
434 | focc = rhc->focc_dll_head; | 424 | focc = rhc->focc_dll_head; |
435 | GNUNET_assert (NULL != focc); | 425 | GNUNET_assert(NULL != focc); |
436 | GNUNET_assert (RHC_DONE == rhc->state); | 426 | GNUNET_assert(RHC_DONE == rhc->state); |
437 | GNUNET_assert (VALID_PEER_ID (focc->peer1)); | 427 | GNUNET_assert(VALID_PEER_ID(focc->peer1)); |
438 | peer = GST_peer_list[focc->peer1]; | 428 | peer = GST_peer_list[focc->peer1]; |
439 | GNUNET_assert (GNUNET_YES == peer->is_remote); | 429 | GNUNET_assert(GNUNET_YES == peer->is_remote); |
440 | GNUNET_assert (NULL != (slave = peer->details.remote.slave)); | 430 | GNUNET_assert(NULL != (slave = peer->details.remote.slave)); |
441 | fopc = GNUNET_new (struct ForwardedOperationContext); | 431 | fopc = GNUNET_new(struct ForwardedOperationContext); |
442 | fopc->client = focc->client; | 432 | fopc->client = focc->client; |
443 | fopc->operation_id = focc->operation_id; | 433 | fopc->operation_id = focc->operation_id; |
444 | fopc->cls = rhc; | 434 | fopc->cls = rhc; |
445 | fopc->type = OP_OVERLAY_CONNECT; | 435 | fopc->type = OP_OVERLAY_CONNECT; |
446 | fopc->opc = | 436 | fopc->opc = |
447 | GNUNET_TESTBED_forward_operation_msg_ (slave->controller, | 437 | GNUNET_TESTBED_forward_operation_msg_(slave->controller, |
448 | focc->operation_id, | 438 | focc->operation_id, |
449 | focc->orig_msg, | 439 | focc->orig_msg, |
450 | &forwarded_overlay_connect_listener, | 440 | &forwarded_overlay_connect_listener, |
451 | fopc); | 441 | fopc); |
452 | GNUNET_free (focc->orig_msg); | 442 | GNUNET_free(focc->orig_msg); |
453 | focc->orig_msg = NULL; | 443 | focc->orig_msg = NULL; |
454 | fopc->timeout_task = GNUNET_SCHEDULER_add_delayed (GST_timeout, | 444 | fopc->timeout_task = GNUNET_SCHEDULER_add_delayed(GST_timeout, |
455 | &forwarded_overlay_connect_timeout, | 445 | &forwarded_overlay_connect_timeout, |
456 | fopc); | 446 | fopc); |
457 | GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, | 447 | GNUNET_CONTAINER_DLL_insert_tail(fopcq_head, |
458 | fopcq_tail, | 448 | fopcq_tail, |
459 | fopc); | 449 | fopc); |
460 | } | 450 | } |
461 | 451 | ||
462 | 452 | ||
@@ -466,28 +456,28 @@ GST_process_next_focc (struct RegisteredHostContext *rhc) | |||
466 | * @param lp2c the local peer2 context information | 456 | * @param lp2c the local peer2 context information |
467 | */ | 457 | */ |
468 | static void | 458 | static void |
469 | cleanup_occ_lp2c (struct LocalPeer2Context *lp2c) | 459 | cleanup_occ_lp2c(struct LocalPeer2Context *lp2c) |
470 | { | 460 | { |
471 | if (NULL != lp2c->ohh) | 461 | if (NULL != lp2c->ohh) |
472 | { | 462 | { |
473 | GNUNET_TRANSPORT_offer_hello_cancel (lp2c->ohh); | 463 | GNUNET_TRANSPORT_offer_hello_cancel(lp2c->ohh); |
474 | lp2c->ohh = NULL; | 464 | lp2c->ohh = NULL; |
475 | } | 465 | } |
476 | if (NULL != lp2c->tcc.cgh_p2_th) | 466 | if (NULL != lp2c->tcc.cgh_p2_th) |
477 | { | 467 | { |
478 | GST_connection_pool_get_handle_done (lp2c->tcc.cgh_p2_th); | 468 | GST_connection_pool_get_handle_done(lp2c->tcc.cgh_p2_th); |
479 | lp2c->tcc.cgh_p2_th = NULL; | 469 | lp2c->tcc.cgh_p2_th = NULL; |
480 | } | 470 | } |
481 | if (NULL != lp2c->tcc.cgh_p2_ats) | 471 | if (NULL != lp2c->tcc.cgh_p2_ats) |
482 | { | 472 | { |
483 | GST_connection_pool_get_handle_done (lp2c->tcc.cgh_p2_ats); | 473 | GST_connection_pool_get_handle_done(lp2c->tcc.cgh_p2_ats); |
484 | lp2c->tcc.cgh_p2_ats = NULL; | 474 | lp2c->tcc.cgh_p2_ats = NULL; |
485 | } | 475 | } |
486 | if (NULL != lp2c->tcc.csh) | 476 | if (NULL != lp2c->tcc.csh) |
487 | { | 477 | { |
488 | GNUNET_ATS_connectivity_suggest_cancel (lp2c->tcc.csh); | 478 | GNUNET_ATS_connectivity_suggest_cancel(lp2c->tcc.csh); |
489 | lp2c->tcc.csh = NULL; | 479 | lp2c->tcc.csh = NULL; |
490 | } | 480 | } |
491 | } | 481 | } |
492 | 482 | ||
493 | 483 | ||
@@ -498,23 +488,23 @@ cleanup_occ_lp2c (struct LocalPeer2Context *lp2c) | |||
498 | * @param rp2c the remote peer2 context information | 488 | * @param rp2c the remote peer2 context information |
499 | */ | 489 | */ |
500 | static void | 490 | static void |
501 | cleanup_occ_rp2c (struct RemotePeer2Context *rp2c) | 491 | cleanup_occ_rp2c(struct RemotePeer2Context *rp2c) |
502 | { | 492 | { |
503 | if (NULL != rp2c->opc) | 493 | if (NULL != rp2c->opc) |
504 | { | 494 | { |
505 | GNUNET_TESTBED_forward_operation_msg_cancel_ (rp2c->opc); | 495 | GNUNET_TESTBED_forward_operation_msg_cancel_(rp2c->opc); |
506 | rp2c->opc = NULL; | 496 | rp2c->opc = NULL; |
507 | } | 497 | } |
508 | if (NULL != rp2c->ncn) | 498 | if (NULL != rp2c->ncn) |
509 | { | 499 | { |
510 | GST_neighbour_get_connection_cancel (rp2c->ncn); | 500 | GST_neighbour_get_connection_cancel(rp2c->ncn); |
511 | rp2c->ncn = NULL; | 501 | rp2c->ncn = NULL; |
512 | } | 502 | } |
513 | if ( (NULL != rp2c->p2c) && (NULL != rp2c->p2n) ) | 503 | if ((NULL != rp2c->p2c) && (NULL != rp2c->p2n)) |
514 | { | 504 | { |
515 | GST_neighbour_release_connection (rp2c->p2n); | 505 | GST_neighbour_release_connection(rp2c->p2n); |
516 | rp2c->p2n = NULL; | 506 | rp2c->p2n = NULL; |
517 | } | 507 | } |
518 | } | 508 | } |
519 | 509 | ||
520 | /** | 510 | /** |
@@ -523,7 +513,7 @@ cleanup_occ_rp2c (struct RemotePeer2Context *rp2c) | |||
523 | * @param peer the peer to check | 513 | * @param peer the peer to check |
524 | */ | 514 | */ |
525 | #define PEER_EXPIRED(peer) \ | 515 | #define PEER_EXPIRED(peer) \ |
526 | ( (GNUNET_YES == peer->destroy_flag) && (0 == peer->reference_cnt) ) | 516 | ((GNUNET_YES == peer->destroy_flag) && (0 == peer->reference_cnt)) |
527 | 517 | ||
528 | /** | 518 | /** |
529 | * Cleanup overlay connect context structure | 519 | * Cleanup overlay connect context structure |
@@ -531,49 +521,50 @@ cleanup_occ_rp2c (struct RemotePeer2Context *rp2c) | |||
531 | * @param occ the overlay connect context | 521 | * @param occ the overlay connect context |
532 | */ | 522 | */ |
533 | static void | 523 | static void |
534 | cleanup_occ (struct OverlayConnectContext *occ) | 524 | cleanup_occ(struct OverlayConnectContext *occ) |
535 | { | 525 | { |
536 | struct Peer *peer2; | 526 | struct Peer *peer2; |
537 | 527 | ||
538 | LOG_DEBUG ("0x%llx: Cleaning up occ\n", | 528 | LOG_DEBUG("0x%llx: Cleaning up occ\n", |
539 | occ->op_id); | 529 | occ->op_id); |
540 | GNUNET_free_non_null (occ->emsg); | 530 | GNUNET_free_non_null(occ->emsg); |
541 | GNUNET_free_non_null (occ->hello); | 531 | GNUNET_free_non_null(occ->hello); |
542 | if (NULL != occ->send_hello_task) | 532 | if (NULL != occ->send_hello_task) |
543 | GNUNET_SCHEDULER_cancel (occ->send_hello_task); | 533 | GNUNET_SCHEDULER_cancel(occ->send_hello_task); |
544 | if (NULL != occ->cleanup_task) | 534 | if (NULL != occ->cleanup_task) |
545 | GNUNET_SCHEDULER_cancel (occ->cleanup_task); | 535 | GNUNET_SCHEDULER_cancel(occ->cleanup_task); |
546 | if (NULL != occ->timeout_task) | 536 | if (NULL != occ->timeout_task) |
547 | GNUNET_SCHEDULER_cancel (occ->timeout_task); | 537 | GNUNET_SCHEDULER_cancel(occ->timeout_task); |
548 | if (NULL != occ->cgh_ch) | 538 | if (NULL != occ->cgh_ch) |
549 | GST_connection_pool_get_handle_done (occ->cgh_ch); | 539 | GST_connection_pool_get_handle_done(occ->cgh_ch); |
550 | if (NULL != occ->ghh) | 540 | if (NULL != occ->ghh) |
551 | GNUNET_TRANSPORT_hello_get_cancel (occ->ghh); | 541 | GNUNET_TRANSPORT_hello_get_cancel(occ->ghh); |
552 | GST_connection_pool_get_handle_done (occ->cgh_p1th); | 542 | GST_connection_pool_get_handle_done(occ->cgh_p1th); |
553 | GNUNET_assert (NULL != GST_peer_list); | 543 | GNUNET_assert(NULL != GST_peer_list); |
554 | GNUNET_assert (occ->peer->reference_cnt > 0); | 544 | GNUNET_assert(occ->peer->reference_cnt > 0); |
555 | occ->peer->reference_cnt--; | 545 | occ->peer->reference_cnt--; |
556 | if (PEER_EXPIRED (occ->peer)) | 546 | if (PEER_EXPIRED(occ->peer)) |
557 | GST_destroy_peer (occ->peer); | 547 | GST_destroy_peer(occ->peer); |
558 | switch (occ->type) | 548 | switch (occ->type) |
559 | { | 549 | { |
560 | case OCC_TYPE_LOCAL: | 550 | case OCC_TYPE_LOCAL: |
561 | peer2 = GST_peer_list[occ->other_peer_id]; | 551 | peer2 = GST_peer_list[occ->other_peer_id]; |
562 | GNUNET_assert (peer2->reference_cnt > 0); | 552 | GNUNET_assert(peer2->reference_cnt > 0); |
563 | peer2->reference_cnt--; | 553 | peer2->reference_cnt--; |
564 | if (PEER_EXPIRED (peer2)) | 554 | if (PEER_EXPIRED(peer2)) |
565 | GST_destroy_peer (peer2); | 555 | GST_destroy_peer(peer2); |
566 | cleanup_occ_lp2c (&occ->p2ctx.local); | 556 | cleanup_occ_lp2c(&occ->p2ctx.local); |
567 | break; | 557 | break; |
568 | case OCC_TYPE_REMOTE_SLAVE: | 558 | |
569 | case OCC_TYPE_REMOTE_LATERAL: | 559 | case OCC_TYPE_REMOTE_SLAVE: |
570 | cleanup_occ_rp2c (&occ->p2ctx.remote); | 560 | case OCC_TYPE_REMOTE_LATERAL: |
571 | break; | 561 | cleanup_occ_rp2c(&occ->p2ctx.remote); |
572 | } | 562 | break; |
573 | GNUNET_CONTAINER_DLL_remove (occq_head, | 563 | } |
574 | occq_tail, | 564 | GNUNET_CONTAINER_DLL_remove(occq_head, |
575 | occ); | 565 | occq_tail, |
576 | GNUNET_free (occ); | 566 | occ); |
567 | GNUNET_free(occ); | ||
577 | } | 568 | } |
578 | 569 | ||
579 | 570 | ||
@@ -583,12 +574,12 @@ cleanup_occ (struct OverlayConnectContext *occ) | |||
583 | * @param cls the overlay connect context | 574 | * @param cls the overlay connect context |
584 | */ | 575 | */ |
585 | static void | 576 | static void |
586 | do_cleanup_occ (void *cls) | 577 | do_cleanup_occ(void *cls) |
587 | { | 578 | { |
588 | struct OverlayConnectContext *occ = cls; | 579 | struct OverlayConnectContext *occ = cls; |
589 | 580 | ||
590 | occ->cleanup_task = NULL; | 581 | occ->cleanup_task = NULL; |
591 | cleanup_occ (occ); | 582 | cleanup_occ(occ); |
592 | } | 583 | } |
593 | 584 | ||
594 | 585 | ||
@@ -598,19 +589,19 @@ do_cleanup_occ (void *cls) | |||
598 | * @param cls the OverlayConnectContext | 589 | * @param cls the OverlayConnectContext |
599 | */ | 590 | */ |
600 | static void | 591 | static void |
601 | timeout_overlay_connect (void *cls) | 592 | timeout_overlay_connect(void *cls) |
602 | { | 593 | { |
603 | struct OverlayConnectContext *occ = cls; | 594 | struct OverlayConnectContext *occ = cls; |
604 | 595 | ||
605 | GNUNET_assert (NULL != occ->timeout_task); | 596 | GNUNET_assert(NULL != occ->timeout_task); |
606 | occ->timeout_task = NULL; | 597 | occ->timeout_task = NULL; |
607 | /* LOG (GNUNET_ERROR_TYPE_WARNING, */ | 598 | /* LOG (GNUNET_ERROR_TYPE_WARNING, */ |
608 | /* "0x%llx: Timeout while connecting peers %u and %u: %s\n", occ->op_id, */ | 599 | /* "0x%llx: Timeout while connecting peers %u and %u: %s\n", occ->op_id, */ |
609 | /* occ->peer->id, occ->other_peer_id, occ->emsg); */ | 600 | /* occ->peer->id, occ->other_peer_id, occ->emsg); */ |
610 | GST_send_operation_fail_msg (occ->client, | 601 | GST_send_operation_fail_msg(occ->client, |
611 | occ->op_id, | 602 | occ->op_id, |
612 | occ->emsg); | 603 | occ->emsg); |
613 | cleanup_occ (occ); | 604 | cleanup_occ(occ); |
614 | } | 605 | } |
615 | 606 | ||
616 | 607 | ||
@@ -620,7 +611,7 @@ timeout_overlay_connect (void *cls) | |||
620 | * @param client the client that disconnected | 611 | * @param client the client that disconnected |
621 | */ | 612 | */ |
622 | void | 613 | void |
623 | GST_notify_client_disconnect_oc (struct GNUNET_SERVICE_Client *client) | 614 | GST_notify_client_disconnect_oc(struct GNUNET_SERVICE_Client *client) |
624 | { | 615 | { |
625 | struct ForwardedOperationContext *fopc; | 616 | struct ForwardedOperationContext *fopc; |
626 | struct ForwardedOperationContext *fopcn; | 617 | struct ForwardedOperationContext *fopcn; |
@@ -628,20 +619,20 @@ GST_notify_client_disconnect_oc (struct GNUNET_SERVICE_Client *client) | |||
628 | struct OverlayConnectContext *occn; | 619 | struct OverlayConnectContext *occn; |
629 | 620 | ||
630 | for (fopc = fopcq_head; NULL != fopc; fopc = fopcn) | 621 | for (fopc = fopcq_head; NULL != fopc; fopc = fopcn) |
631 | { | ||
632 | fopcn = fopc->next; | ||
633 | if (fopc->client == client) | ||
634 | { | 622 | { |
635 | GNUNET_SCHEDULER_cancel (fopc->timeout_task); | 623 | fopcn = fopc->next; |
636 | GST_forwarded_operation_timeout (fopc); | 624 | if (fopc->client == client) |
625 | { | ||
626 | GNUNET_SCHEDULER_cancel(fopc->timeout_task); | ||
627 | GST_forwarded_operation_timeout(fopc); | ||
628 | } | ||
637 | } | 629 | } |
638 | } | ||
639 | for (occ = occq_head; NULL != occ; occ = occn) | 630 | for (occ = occq_head; NULL != occ; occ = occn) |
640 | { | 631 | { |
641 | occn = occ->next; | 632 | occn = occ->next; |
642 | if (occ->client == client) | 633 | if (occ->client == client) |
643 | cleanup_occ (occ); | 634 | cleanup_occ(occ); |
644 | } | 635 | } |
645 | // FIXME: implement clean up for client_keep replacements! | 636 | // FIXME: implement clean up for client_keep replacements! |
646 | } | 637 | } |
647 | 638 | ||
@@ -652,21 +643,21 @@ GST_notify_client_disconnect_oc (struct GNUNET_SERVICE_Client *client) | |||
652 | * FIXME. | 643 | * FIXME. |
653 | */ | 644 | */ |
654 | static void | 645 | static void |
655 | send_overlay_connect_success_msg (struct OverlayConnectContext *occ) | 646 | send_overlay_connect_success_msg(struct OverlayConnectContext *occ) |
656 | { | 647 | { |
657 | struct GNUNET_MQ_Envelope *env; | 648 | struct GNUNET_MQ_Envelope *env; |
658 | struct GNUNET_TESTBED_ConnectionEventMessage *msg; | 649 | struct GNUNET_TESTBED_ConnectionEventMessage *msg; |
659 | 650 | ||
660 | LOG_DEBUG ("0x%llx: Peers connected - Sending overlay connect success\n", | 651 | LOG_DEBUG("0x%llx: Peers connected - Sending overlay connect success\n", |
661 | occ->op_id); | 652 | occ->op_id); |
662 | env = GNUNET_MQ_msg (msg, | 653 | env = GNUNET_MQ_msg(msg, |
663 | GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT); | 654 | GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT); |
664 | msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT); | 655 | msg->event_type = htonl(GNUNET_TESTBED_ET_CONNECT); |
665 | msg->peer1 = htonl (occ->peer->id); | 656 | msg->peer1 = htonl(occ->peer->id); |
666 | msg->peer2 = htonl (occ->other_peer_id); | 657 | msg->peer2 = htonl(occ->other_peer_id); |
667 | msg->operation_id = GNUNET_htonll (occ->op_id); | 658 | msg->operation_id = GNUNET_htonll(occ->op_id); |
668 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (occ->client), | 659 | GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(occ->client), |
669 | env); | 660 | env); |
670 | } | 661 | } |
671 | 662 | ||
672 | 663 | ||
@@ -678,61 +669,62 @@ send_overlay_connect_success_msg (struct OverlayConnectContext *occ) | |||
678 | * @param new_peer the peer that connected | 669 | * @param new_peer the peer that connected |
679 | */ | 670 | */ |
680 | static void | 671 | static void |
681 | overlay_connect_notify (void *cls, | 672 | overlay_connect_notify(void *cls, |
682 | const struct GNUNET_PeerIdentity *new_peer) | 673 | const struct GNUNET_PeerIdentity *new_peer) |
683 | { | 674 | { |
684 | struct OverlayConnectContext *occ = cls; | 675 | struct OverlayConnectContext *occ = cls; |
685 | char *new_peer_str; | 676 | char *new_peer_str; |
686 | char *other_peer_str; | 677 | char *other_peer_str; |
687 | 678 | ||
688 | LOG_DEBUG ("Overlay connect notify\n"); | 679 | LOG_DEBUG("Overlay connect notify\n"); |
689 | if (0 == | 680 | if (0 == |
690 | memcmp (new_peer, &occ->peer_identity, | 681 | memcmp(new_peer, &occ->peer_identity, |
691 | sizeof (struct GNUNET_PeerIdentity))) | 682 | sizeof(struct GNUNET_PeerIdentity))) |
692 | return; | 683 | return; |
693 | new_peer_str = GNUNET_strdup (GNUNET_i2s (new_peer)); | 684 | new_peer_str = GNUNET_strdup(GNUNET_i2s(new_peer)); |
694 | other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); | 685 | other_peer_str = GNUNET_strdup(GNUNET_i2s(&occ->other_peer_identity)); |
695 | if (0 != | 686 | if (0 != |
696 | memcmp (new_peer, | 687 | memcmp(new_peer, |
697 | &occ->other_peer_identity, | 688 | &occ->other_peer_identity, |
698 | sizeof (struct GNUNET_PeerIdentity))) | 689 | sizeof(struct GNUNET_PeerIdentity))) |
699 | { | 690 | { |
700 | LOG_DEBUG ("Unexpected peer %s connected when expecting peer %s\n", | 691 | LOG_DEBUG("Unexpected peer %s connected when expecting peer %s\n", |
701 | new_peer_str, | 692 | new_peer_str, |
702 | other_peer_str); | 693 | other_peer_str); |
703 | GNUNET_free (new_peer_str); | 694 | GNUNET_free(new_peer_str); |
704 | GNUNET_free (other_peer_str); | 695 | GNUNET_free(other_peer_str); |
705 | return; | 696 | return; |
706 | } | 697 | } |
707 | GNUNET_free (new_peer_str); | 698 | GNUNET_free(new_peer_str); |
708 | LOG_DEBUG ("0x%llx: Peer %s connected to peer %s\n", | 699 | LOG_DEBUG("0x%llx: Peer %s connected to peer %s\n", |
709 | occ->op_id, | 700 | occ->op_id, |
710 | other_peer_str, | 701 | other_peer_str, |
711 | GNUNET_i2s (&occ->peer_identity)); | 702 | GNUNET_i2s(&occ->peer_identity)); |
712 | GNUNET_free (other_peer_str); | 703 | GNUNET_free(other_peer_str); |
713 | if (NULL != occ->send_hello_task) | 704 | if (NULL != occ->send_hello_task) |
714 | { | 705 | { |
715 | GNUNET_SCHEDULER_cancel (occ->send_hello_task); | 706 | GNUNET_SCHEDULER_cancel(occ->send_hello_task); |
716 | occ->send_hello_task = NULL; | 707 | occ->send_hello_task = NULL; |
717 | } | 708 | } |
718 | GNUNET_assert (NULL != occ->timeout_task); | 709 | GNUNET_assert(NULL != occ->timeout_task); |
719 | GNUNET_SCHEDULER_cancel (occ->timeout_task); | 710 | GNUNET_SCHEDULER_cancel(occ->timeout_task); |
720 | occ->timeout_task = NULL; | 711 | occ->timeout_task = NULL; |
721 | switch (occ->type) | 712 | switch (occ->type) |
722 | { | 713 | { |
723 | case OCC_TYPE_LOCAL: | 714 | case OCC_TYPE_LOCAL: |
724 | cleanup_occ_lp2c (&occ->p2ctx.local); | 715 | cleanup_occ_lp2c(&occ->p2ctx.local); |
725 | break; | 716 | break; |
726 | case OCC_TYPE_REMOTE_SLAVE: | 717 | |
727 | case OCC_TYPE_REMOTE_LATERAL: | 718 | case OCC_TYPE_REMOTE_SLAVE: |
728 | cleanup_occ_rp2c (&occ->p2ctx.remote); | 719 | case OCC_TYPE_REMOTE_LATERAL: |
729 | break; | 720 | cleanup_occ_rp2c(&occ->p2ctx.remote); |
730 | } | 721 | break; |
731 | GNUNET_free_non_null (occ->emsg); | 722 | } |
723 | GNUNET_free_non_null(occ->emsg); | ||
732 | occ->emsg = NULL; | 724 | occ->emsg = NULL; |
733 | send_overlay_connect_success_msg (occ); | 725 | send_overlay_connect_success_msg(occ); |
734 | occ->cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup_occ, | 726 | occ->cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup_occ, |
735 | occ); | 727 | occ); |
736 | } | 728 | } |
737 | 729 | ||
738 | 730 | ||
@@ -747,43 +739,43 @@ overlay_connect_notify (void *cls, | |||
747 | * @param cfg configuration of the peer | 739 | * @param cfg configuration of the peer |
748 | */ | 740 | */ |
749 | static void | 741 | static void |
750 | occ_cache_get_handle_ats_occ_cb (void *cls, | 742 | occ_cache_get_handle_ats_occ_cb(void *cls, |
751 | struct GNUNET_CORE_Handle *ch, | 743 | struct GNUNET_CORE_Handle *ch, |
752 | struct GNUNET_TRANSPORT_CoreHandle *th, | 744 | struct GNUNET_TRANSPORT_CoreHandle *th, |
753 | struct GNUNET_ATS_ConnectivityHandle *ac, | 745 | struct GNUNET_ATS_ConnectivityHandle *ac, |
754 | const struct GNUNET_PeerIdentity *my_identity, | 746 | const struct GNUNET_PeerIdentity *my_identity, |
755 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 747 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
756 | { | 748 | { |
757 | struct OverlayConnectContext *occ = cls; | 749 | struct OverlayConnectContext *occ = cls; |
758 | struct LocalPeer2Context *lp2c; | 750 | struct LocalPeer2Context *lp2c; |
759 | 751 | ||
760 | GNUNET_assert (OCC_TYPE_LOCAL == occ->type); | 752 | GNUNET_assert(OCC_TYPE_LOCAL == occ->type); |
761 | GNUNET_assert (NULL != occ->timeout_task); | 753 | GNUNET_assert(NULL != occ->timeout_task); |
762 | GNUNET_free_non_null (occ->emsg); | 754 | GNUNET_free_non_null(occ->emsg); |
763 | if (NULL == ac) | 755 | if (NULL == ac) |
764 | { | 756 | { |
765 | GNUNET_asprintf (&occ->emsg, | 757 | GNUNET_asprintf(&occ->emsg, |
766 | "0x%llx: Failed to connect to ATS of peer with id: %u", | 758 | "0x%llx: Failed to connect to ATS of peer with id: %u", |
767 | occ->op_id, | 759 | occ->op_id, |
768 | occ->peer->id); | 760 | occ->peer->id); |
769 | GNUNET_SCHEDULER_cancel (occ->timeout_task); | 761 | GNUNET_SCHEDULER_cancel(occ->timeout_task); |
770 | occ->timeout_task = | 762 | occ->timeout_task = |
771 | GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, | 763 | GNUNET_SCHEDULER_add_now(&timeout_overlay_connect, |
772 | occ); | 764 | occ); |
773 | return; | 765 | return; |
774 | } | 766 | } |
775 | occ->emsg = NULL; | 767 | occ->emsg = NULL; |
776 | 768 | ||
777 | GNUNET_asprintf (&occ->emsg, | 769 | GNUNET_asprintf(&occ->emsg, |
778 | "0x%llx: Timeout during GNUNET_ATS_connectivity_suggest() at peer %s", | 770 | "0x%llx: Timeout during GNUNET_ATS_connectivity_suggest() at peer %s", |
779 | occ->op_id, | 771 | occ->op_id, |
780 | GNUNET_i2s (&occ->other_peer_identity)); | 772 | GNUNET_i2s(&occ->other_peer_identity)); |
781 | 773 | ||
782 | lp2c = &occ->p2ctx.local; | 774 | lp2c = &occ->p2ctx.local; |
783 | lp2c->tcc.csh = | 775 | lp2c->tcc.csh = |
784 | GNUNET_ATS_connectivity_suggest (ac, | 776 | GNUNET_ATS_connectivity_suggest(ac, |
785 | &occ->peer_identity, | 777 | &occ->peer_identity, |
786 | 1); | 778 | 1); |
787 | } | 779 | } |
788 | 780 | ||
789 | 781 | ||
@@ -797,19 +789,19 @@ occ_cache_get_handle_ats_occ_cb (void *cls, | |||
797 | * @param my_identity the identity of our peer | 789 | * @param my_identity the identity of our peer |
798 | */ | 790 | */ |
799 | static void | 791 | static void |
800 | occ_cache_get_handle_ats_rocc_cb (void *cls, | 792 | occ_cache_get_handle_ats_rocc_cb(void *cls, |
801 | struct GNUNET_CORE_Handle *ch, | 793 | struct GNUNET_CORE_Handle *ch, |
802 | struct GNUNET_TRANSPORT_CoreHandle *th, | 794 | struct GNUNET_TRANSPORT_CoreHandle *th, |
803 | struct GNUNET_ATS_ConnectivityHandle *ac, | 795 | struct GNUNET_ATS_ConnectivityHandle *ac, |
804 | const struct GNUNET_PeerIdentity *my_identity, | 796 | const struct GNUNET_PeerIdentity *my_identity, |
805 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 797 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
806 | { | 798 | { |
807 | struct RemoteOverlayConnectCtx *rocc = cls; | 799 | struct RemoteOverlayConnectCtx *rocc = cls; |
808 | 800 | ||
809 | rocc->tcc.csh = | 801 | rocc->tcc.csh = |
810 | GNUNET_ATS_connectivity_suggest (ac, | 802 | GNUNET_ATS_connectivity_suggest(ac, |
811 | &rocc->a_id, | 803 | &rocc->a_id, |
812 | 1); | 804 | 1); |
813 | } | 805 | } |
814 | 806 | ||
815 | 807 | ||
@@ -820,7 +812,7 @@ occ_cache_get_handle_ats_rocc_cb (void *cls, | |||
820 | * @param cls the OverlayConnectContext | 812 | * @param cls the OverlayConnectContext |
821 | */ | 813 | */ |
822 | static void | 814 | static void |
823 | send_hello (void *cls); | 815 | send_hello(void *cls); |
824 | 816 | ||
825 | 817 | ||
826 | /** | 818 | /** |
@@ -831,31 +823,31 @@ send_hello (void *cls); | |||
831 | * @param cls the overlay connect context | 823 | * @param cls the overlay connect context |
832 | */ | 824 | */ |
833 | static void | 825 | static void |
834 | occ_hello_sent_cb (void *cls) | 826 | occ_hello_sent_cb(void *cls) |
835 | { | 827 | { |
836 | struct OverlayConnectContext *occ = cls; | 828 | struct OverlayConnectContext *occ = cls; |
837 | struct LocalPeer2Context *lp2c; | 829 | struct LocalPeer2Context *lp2c; |
838 | struct Peer *peer2; | 830 | struct Peer *peer2; |
839 | 831 | ||
840 | GNUNET_assert (OCC_TYPE_LOCAL == occ->type); | 832 | GNUNET_assert(OCC_TYPE_LOCAL == occ->type); |
841 | GNUNET_assert (NULL != occ->timeout_task); | 833 | GNUNET_assert(NULL != occ->timeout_task); |
842 | lp2c = &occ->p2ctx.local; | 834 | lp2c = &occ->p2ctx.local; |
843 | lp2c->ohh = NULL; | 835 | lp2c->ohh = NULL; |
844 | 836 | ||
845 | GNUNET_assert (NULL == occ->send_hello_task); | 837 | GNUNET_assert(NULL == occ->send_hello_task); |
846 | GNUNET_free_non_null (occ->emsg); | 838 | GNUNET_free_non_null(occ->emsg); |
847 | 839 | ||
848 | GNUNET_asprintf (&occ->emsg, | 840 | GNUNET_asprintf(&occ->emsg, |
849 | "0x%llx: Timeout while acquiring ATS of %s from cache", | 841 | "0x%llx: Timeout while acquiring ATS of %s from cache", |
850 | occ->op_id, | 842 | occ->op_id, |
851 | GNUNET_i2s (&occ->other_peer_identity)); | 843 | GNUNET_i2s(&occ->other_peer_identity)); |
852 | GNUNET_assert (NULL != (peer2 = GST_peer_list[occ->other_peer_id])); | 844 | GNUNET_assert(NULL != (peer2 = GST_peer_list[occ->other_peer_id])); |
853 | lp2c->tcc.cgh_p2_ats = | 845 | lp2c->tcc.cgh_p2_ats = |
854 | GST_connection_pool_get_handle (occ->other_peer_id, | 846 | GST_connection_pool_get_handle(occ->other_peer_id, |
855 | peer2->details.local.cfg, | 847 | peer2->details.local.cfg, |
856 | GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY, | 848 | GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY, |
857 | &occ_cache_get_handle_ats_occ_cb, | 849 | &occ_cache_get_handle_ats_occ_cb, |
858 | occ, NULL, NULL, NULL); | 850 | occ, NULL, NULL, NULL); |
859 | } | 851 | } |
860 | 852 | ||
861 | 853 | ||
@@ -867,36 +859,36 @@ occ_hello_sent_cb (void *cls) | |||
867 | * #OCC_TYPE_REMOTE_SLAVE or #OCC_TYPE_REMOTE_LATERAL | 859 | * #OCC_TYPE_REMOTE_SLAVE or #OCC_TYPE_REMOTE_LATERAL |
868 | */ | 860 | */ |
869 | static void | 861 | static void |
870 | send_hello_thru_rocc (struct OverlayConnectContext *occ) | 862 | send_hello_thru_rocc(struct OverlayConnectContext *occ) |
871 | { | 863 | { |
872 | struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg; | 864 | struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg; |
873 | char *other_peer_str; | 865 | char *other_peer_str; |
874 | uint16_t msize; | 866 | uint16_t msize; |
875 | uint16_t hello_size; | 867 | uint16_t hello_size; |
876 | 868 | ||
877 | GNUNET_assert (OCC_TYPE_LOCAL != occ->type); | 869 | GNUNET_assert(OCC_TYPE_LOCAL != occ->type); |
878 | GNUNET_assert (NULL != occ->hello); | 870 | GNUNET_assert(NULL != occ->hello); |
879 | other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); | 871 | other_peer_str = GNUNET_strdup(GNUNET_i2s(&occ->other_peer_identity)); |
880 | LOG_DEBUG ("0x%llx: Offering HELLO of %s (size: %u) to %s via Remote Overlay Request\n", | 872 | LOG_DEBUG("0x%llx: Offering HELLO of %s (size: %u) to %s via Remote Overlay Request\n", |
881 | occ->op_id, | 873 | occ->op_id, |
882 | GNUNET_i2s (&occ->peer_identity), | 874 | GNUNET_i2s(&occ->peer_identity), |
883 | ntohs (occ->hello->size), | 875 | ntohs(occ->hello->size), |
884 | other_peer_str); | 876 | other_peer_str); |
885 | GNUNET_free (other_peer_str); | 877 | GNUNET_free(other_peer_str); |
886 | hello_size = ntohs (occ->hello->size); | 878 | hello_size = ntohs(occ->hello->size); |
887 | msize = sizeof (struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hello_size; | 879 | msize = sizeof(struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hello_size; |
888 | msg = GNUNET_malloc (msize); | 880 | msg = GNUNET_malloc(msize); |
889 | msg->header.type = | 881 | msg->header.type = |
890 | htons (GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT); | 882 | htons(GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT); |
891 | msg->header.size = htons (msize); | 883 | msg->header.size = htons(msize); |
892 | msg->peer = htonl (occ->other_peer_id); | 884 | msg->peer = htonl(occ->other_peer_id); |
893 | msg->operation_id = GNUNET_htonll (occ->op_id); | 885 | msg->operation_id = GNUNET_htonll(occ->op_id); |
894 | msg->peer_identity = occ->peer_identity; | 886 | msg->peer_identity = occ->peer_identity; |
895 | GNUNET_memcpy (msg->hello, | 887 | GNUNET_memcpy(msg->hello, |
896 | occ->hello, | 888 | occ->hello, |
897 | hello_size); | 889 | hello_size); |
898 | GNUNET_TESTBED_queue_message_ (occ->p2ctx.remote.p2c, | 890 | GNUNET_TESTBED_queue_message_(occ->p2ctx.remote.p2c, |
899 | &msg->header); | 891 | &msg->header); |
900 | } | 892 | } |
901 | 893 | ||
902 | 894 | ||
@@ -908,43 +900,43 @@ send_hello_thru_rocc (struct OverlayConnectContext *occ) | |||
908 | * @param cls the OverlayConnectContext | 900 | * @param cls the OverlayConnectContext |
909 | */ | 901 | */ |
910 | static void | 902 | static void |
911 | send_hello (void *cls) | 903 | send_hello(void *cls) |
912 | { | 904 | { |
913 | struct OverlayConnectContext *occ = cls; | 905 | struct OverlayConnectContext *occ = cls; |
914 | struct LocalPeer2Context *lp2c; | 906 | struct LocalPeer2Context *lp2c; |
915 | char *other_peer_str; | 907 | char *other_peer_str; |
916 | 908 | ||
917 | occ->send_hello_task = NULL; | 909 | occ->send_hello_task = NULL; |
918 | GNUNET_assert (NULL != occ->timeout_task); | 910 | GNUNET_assert(NULL != occ->timeout_task); |
919 | GNUNET_assert (NULL != occ->hello); | 911 | GNUNET_assert(NULL != occ->hello); |
920 | if (OCC_TYPE_LOCAL != occ->type) | 912 | if (OCC_TYPE_LOCAL != occ->type) |
921 | { | 913 | { |
922 | send_hello_thru_rocc (occ); | 914 | send_hello_thru_rocc(occ); |
923 | return; | 915 | return; |
924 | } | 916 | } |
925 | lp2c = &occ->p2ctx.local; | 917 | lp2c = &occ->p2ctx.local; |
926 | other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); | 918 | other_peer_str = GNUNET_strdup(GNUNET_i2s(&occ->other_peer_identity)); |
927 | LOG_DEBUG ("0x%llx: Offering HELLO of %s to %s\n", | 919 | LOG_DEBUG("0x%llx: Offering HELLO of %s to %s\n", |
928 | occ->op_id, | 920 | occ->op_id, |
929 | GNUNET_i2s (&occ->peer_identity), | 921 | GNUNET_i2s(&occ->peer_identity), |
930 | other_peer_str); | 922 | other_peer_str); |
931 | GNUNET_free (other_peer_str); | 923 | GNUNET_free(other_peer_str); |
932 | lp2c->ohh = | 924 | lp2c->ohh = |
933 | GNUNET_TRANSPORT_offer_hello (lp2c->tcc.cfg, | 925 | GNUNET_TRANSPORT_offer_hello(lp2c->tcc.cfg, |
934 | occ->hello, | 926 | occ->hello, |
935 | &occ_hello_sent_cb, | 927 | &occ_hello_sent_cb, |
936 | occ); | 928 | occ); |
937 | if (NULL == lp2c->ohh) | 929 | if (NULL == lp2c->ohh) |
938 | { | 930 | { |
939 | GNUNET_break (0); | 931 | GNUNET_break(0); |
940 | occ->send_hello_task = | 932 | occ->send_hello_task = |
941 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 933 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply |
942 | (GNUNET_TIME_UNIT_MILLISECONDS, | 934 | (GNUNET_TIME_UNIT_MILLISECONDS, |
943 | 100 + | 935 | 100 + |
944 | GNUNET_CRYPTO_random_u32 | 936 | GNUNET_CRYPTO_random_u32 |
945 | (GNUNET_CRYPTO_QUALITY_WEAK, 500)), | 937 | (GNUNET_CRYPTO_QUALITY_WEAK, 500)), |
946 | &send_hello, occ); | 938 | &send_hello, occ); |
947 | } | 939 | } |
948 | } | 940 | } |
949 | 941 | ||
950 | 942 | ||
@@ -957,36 +949,36 @@ send_hello (void *cls) | |||
957 | * @param ac the handle to ATS. Can be NULL if it is not requested | 949 | * @param ac the handle to ATS. Can be NULL if it is not requested |
958 | * @param ignore_ peer identity which is ignored in this callback | 950 | * @param ignore_ peer identity which is ignored in this callback |
959 | * @param cfg configuration of the peer | 951 | * @param cfg configuration of the peer |
960 | */ | 952 | */ |
961 | static void | 953 | static void |
962 | p2_transport_connect_cache_callback (void *cls, | 954 | p2_transport_connect_cache_callback(void *cls, |
963 | struct GNUNET_CORE_Handle *ch, | 955 | struct GNUNET_CORE_Handle *ch, |
964 | struct GNUNET_TRANSPORT_CoreHandle *th, | 956 | struct GNUNET_TRANSPORT_CoreHandle *th, |
965 | struct GNUNET_ATS_ConnectivityHandle *ac, | 957 | struct GNUNET_ATS_ConnectivityHandle *ac, |
966 | const struct GNUNET_PeerIdentity *ignore_, | 958 | const struct GNUNET_PeerIdentity *ignore_, |
967 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 959 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
968 | { | 960 | { |
969 | struct OverlayConnectContext *occ = cls; | 961 | struct OverlayConnectContext *occ = cls; |
970 | 962 | ||
971 | GNUNET_assert (OCC_TYPE_LOCAL == occ->type); | 963 | GNUNET_assert(OCC_TYPE_LOCAL == occ->type); |
972 | if (NULL == th) | 964 | if (NULL == th) |
973 | { | 965 | { |
974 | GNUNET_asprintf (&occ->emsg, | 966 | GNUNET_asprintf(&occ->emsg, |
975 | "0x%llx: Cannot connect to TRANSPORT of %s", | 967 | "0x%llx: Cannot connect to TRANSPORT of %s", |
976 | occ->op_id, | 968 | occ->op_id, |
977 | GNUNET_i2s (&occ->other_peer_identity)); | 969 | GNUNET_i2s(&occ->other_peer_identity)); |
978 | GNUNET_SCHEDULER_cancel (occ->timeout_task); | 970 | GNUNET_SCHEDULER_cancel(occ->timeout_task); |
979 | occ->timeout_task = | 971 | occ->timeout_task = |
980 | GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); | 972 | GNUNET_SCHEDULER_add_now(&timeout_overlay_connect, occ); |
981 | return; | 973 | return; |
982 | } | 974 | } |
983 | occ->p2ctx.local.tcc.th_ = th; | 975 | occ->p2ctx.local.tcc.th_ = th; |
984 | occ->p2ctx.local.tcc.cfg = cfg; | 976 | occ->p2ctx.local.tcc.cfg = cfg; |
985 | GNUNET_asprintf (&occ->emsg, | 977 | GNUNET_asprintf(&occ->emsg, |
986 | "0x%llx: Timeout while offering HELLO to %s", | 978 | "0x%llx: Timeout while offering HELLO to %s", |
987 | occ->op_id, | 979 | occ->op_id, |
988 | GNUNET_i2s (&occ->other_peer_identity)); | 980 | GNUNET_i2s(&occ->other_peer_identity)); |
989 | occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello, occ); | 981 | occ->send_hello_task = GNUNET_SCHEDULER_add_now(&send_hello, occ); |
990 | } | 982 | } |
991 | 983 | ||
992 | 984 | ||
@@ -997,36 +989,36 @@ p2_transport_connect_cache_callback (void *cls, | |||
997 | * @param occ the overlay connect context | 989 | * @param occ the overlay connect context |
998 | */ | 990 | */ |
999 | static void | 991 | static void |
1000 | p2_transport_connect (struct OverlayConnectContext *occ) | 992 | p2_transport_connect(struct OverlayConnectContext *occ) |
1001 | { | 993 | { |
1002 | struct Peer *peer2; | 994 | struct Peer *peer2; |
1003 | 995 | ||
1004 | /* HUH? Why to *obtain* HELLO? Seems we use this to *SEND* the | 996 | /* HUH? Why to *obtain* HELLO? Seems we use this to *SEND* the |
1005 | HELLO! */ | 997 | HELLO! */ |
1006 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 998 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1007 | "Connecting to transport of peer %s to obtain HELLO\n", | 999 | "Connecting to transport of peer %s to obtain HELLO\n", |
1008 | GNUNET_i2s (&occ->other_peer_identity)); | 1000 | GNUNET_i2s(&occ->other_peer_identity)); |
1009 | GNUNET_assert (NULL == occ->emsg); | 1001 | GNUNET_assert(NULL == occ->emsg); |
1010 | GNUNET_assert (NULL != occ->hello); | 1002 | GNUNET_assert(NULL != occ->hello); |
1011 | GNUNET_assert (NULL == occ->ghh); | 1003 | GNUNET_assert(NULL == occ->ghh); |
1012 | GNUNET_assert (NULL == occ->p1th_); | 1004 | GNUNET_assert(NULL == occ->p1th_); |
1013 | GNUNET_assert (NULL == occ->cgh_p1th); | 1005 | GNUNET_assert(NULL == occ->cgh_p1th); |
1014 | if (OCC_TYPE_LOCAL == occ->type) | 1006 | if (OCC_TYPE_LOCAL == occ->type) |
1015 | { | 1007 | { |
1016 | GNUNET_assert (NULL != (peer2 = GST_peer_list[occ->other_peer_id])); | 1008 | GNUNET_assert(NULL != (peer2 = GST_peer_list[occ->other_peer_id])); |
1017 | occ->p2ctx.local.tcc.cgh_p2_th = | 1009 | occ->p2ctx.local.tcc.cgh_p2_th = |
1018 | GST_connection_pool_get_handle (occ->other_peer_id, | 1010 | GST_connection_pool_get_handle(occ->other_peer_id, |
1019 | peer2->details.local.cfg, | 1011 | peer2->details.local.cfg, |
1020 | GST_CONNECTIONPOOL_SERVICE_TRANSPORT, | 1012 | GST_CONNECTIONPOOL_SERVICE_TRANSPORT, |
1021 | &p2_transport_connect_cache_callback, | 1013 | &p2_transport_connect_cache_callback, |
1022 | occ, NULL, NULL, NULL); | 1014 | occ, NULL, NULL, NULL); |
1023 | return; | 1015 | return; |
1024 | } | 1016 | } |
1025 | GNUNET_asprintf (&occ->emsg, | 1017 | GNUNET_asprintf(&occ->emsg, |
1026 | "0x%llx: Timeout while offering HELLO to %s", | 1018 | "0x%llx: Timeout while offering HELLO to %s", |
1027 | occ->op_id, | 1019 | occ->op_id, |
1028 | GNUNET_i2s (&occ->other_peer_identity)); | 1020 | GNUNET_i2s(&occ->other_peer_identity)); |
1029 | occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello, occ); | 1021 | occ->send_hello_task = GNUNET_SCHEDULER_add_now(&send_hello, occ); |
1030 | } | 1022 | } |
1031 | 1023 | ||
1032 | 1024 | ||
@@ -1039,9 +1031,9 @@ p2_transport_connect (struct OverlayConnectContext *occ) | |||
1039 | * @return #GNUNET_OK | 1031 | * @return #GNUNET_OK |
1040 | */ | 1032 | */ |
1041 | static int | 1033 | static int |
1042 | test_address (void *cls, | 1034 | test_address(void *cls, |
1043 | const struct GNUNET_HELLO_Address *address, | 1035 | const struct GNUNET_HELLO_Address *address, |
1044 | struct GNUNET_TIME_Absolute expiration) | 1036 | struct GNUNET_TIME_Absolute expiration) |
1045 | { | 1037 | { |
1046 | int *empty = cls; | 1038 | int *empty = cls; |
1047 | 1039 | ||
@@ -1059,40 +1051,40 @@ test_address (void *cls, | |||
1059 | * @param hello our updated HELLO | 1051 | * @param hello our updated HELLO |
1060 | */ | 1052 | */ |
1061 | static void | 1053 | static void |
1062 | hello_update_cb (void *cls, | 1054 | hello_update_cb(void *cls, |
1063 | const struct GNUNET_MessageHeader *hello) | 1055 | const struct GNUNET_MessageHeader *hello) |
1064 | { | 1056 | { |
1065 | struct OverlayConnectContext *occ = cls; | 1057 | struct OverlayConnectContext *occ = cls; |
1066 | int empty; | 1058 | int empty; |
1067 | uint16_t msize; | 1059 | uint16_t msize; |
1068 | 1060 | ||
1069 | msize = ntohs (hello->size); | 1061 | msize = ntohs(hello->size); |
1070 | empty = GNUNET_YES; | 1062 | empty = GNUNET_YES; |
1071 | (void) GNUNET_HELLO_iterate_addresses ((const struct GNUNET_HELLO_Message *) | 1063 | (void)GNUNET_HELLO_iterate_addresses((const struct GNUNET_HELLO_Message *) |
1072 | hello, GNUNET_NO, | 1064 | hello, GNUNET_NO, |
1073 | &test_address, | 1065 | &test_address, |
1074 | &empty); | 1066 | &empty); |
1075 | if (GNUNET_YES == empty) | 1067 | if (GNUNET_YES == empty) |
1076 | { | 1068 | { |
1077 | LOG_DEBUG ("0x%llx: HELLO of %s is empty\n", | 1069 | LOG_DEBUG("0x%llx: HELLO of %s is empty\n", |
1078 | occ->op_id, | 1070 | occ->op_id, |
1079 | GNUNET_i2s (&occ->peer_identity)); | 1071 | GNUNET_i2s(&occ->peer_identity)); |
1080 | return; | 1072 | return; |
1081 | } | 1073 | } |
1082 | LOG_DEBUG ("0x%llx: Received HELLO of %s\n", | 1074 | LOG_DEBUG("0x%llx: Received HELLO of %s\n", |
1083 | occ->op_id, | 1075 | occ->op_id, |
1084 | GNUNET_i2s (&occ->peer_identity)); | 1076 | GNUNET_i2s(&occ->peer_identity)); |
1085 | occ->hello = GNUNET_malloc (msize); | 1077 | occ->hello = GNUNET_malloc(msize); |
1086 | GST_cache_add_hello (occ->peer->id, hello); | 1078 | GST_cache_add_hello(occ->peer->id, hello); |
1087 | GNUNET_memcpy (occ->hello, hello, msize); | 1079 | GNUNET_memcpy(occ->hello, hello, msize); |
1088 | GNUNET_TRANSPORT_hello_get_cancel (occ->ghh); | 1080 | GNUNET_TRANSPORT_hello_get_cancel(occ->ghh); |
1089 | occ->ghh = NULL; | 1081 | occ->ghh = NULL; |
1090 | GST_connection_pool_get_handle_done (occ->cgh_p1th); | 1082 | GST_connection_pool_get_handle_done(occ->cgh_p1th); |
1091 | occ->cgh_p1th = NULL; | 1083 | occ->cgh_p1th = NULL; |
1092 | occ->p1th_ = NULL; | 1084 | occ->p1th_ = NULL; |
1093 | GNUNET_free_non_null (occ->emsg); | 1085 | GNUNET_free_non_null(occ->emsg); |
1094 | occ->emsg = NULL; | 1086 | occ->emsg = NULL; |
1095 | p2_transport_connect (occ); | 1087 | p2_transport_connect(occ); |
1096 | } | 1088 | } |
1097 | 1089 | ||
1098 | 1090 | ||
@@ -1106,39 +1098,39 @@ hello_update_cb (void *cls, | |||
1106 | * @param ignore_ peer identity which is ignored in this callback | 1098 | * @param ignore_ peer identity which is ignored in this callback |
1107 | */ | 1099 | */ |
1108 | static void | 1100 | static void |
1109 | p1_transport_connect_cache_callback (void *cls, | 1101 | p1_transport_connect_cache_callback(void *cls, |
1110 | struct GNUNET_CORE_Handle *ch, | 1102 | struct GNUNET_CORE_Handle *ch, |
1111 | struct GNUNET_TRANSPORT_CoreHandle *th, | 1103 | struct GNUNET_TRANSPORT_CoreHandle *th, |
1112 | struct GNUNET_ATS_ConnectivityHandle *ac, | 1104 | struct GNUNET_ATS_ConnectivityHandle *ac, |
1113 | const struct GNUNET_PeerIdentity *ignore_, | 1105 | const struct GNUNET_PeerIdentity *ignore_, |
1114 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 1106 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
1115 | { | 1107 | { |
1116 | struct OverlayConnectContext *occ = cls; | 1108 | struct OverlayConnectContext *occ = cls; |
1117 | 1109 | ||
1118 | GNUNET_free_non_null (occ->emsg); | 1110 | GNUNET_free_non_null(occ->emsg); |
1119 | occ->emsg = NULL; | 1111 | occ->emsg = NULL; |
1120 | if (NULL == th) | 1112 | if (NULL == th) |
1121 | { | 1113 | { |
1122 | GNUNET_asprintf (&occ->emsg, | 1114 | GNUNET_asprintf(&occ->emsg, |
1123 | "0x%llx: Cannot connect to TRANSPORT of %s", | 1115 | "0x%llx: Cannot connect to TRANSPORT of %s", |
1124 | occ->op_id, | 1116 | occ->op_id, |
1125 | GNUNET_i2s (&occ->peer_identity)); | 1117 | GNUNET_i2s(&occ->peer_identity)); |
1126 | GNUNET_SCHEDULER_cancel (occ->timeout_task); | 1118 | GNUNET_SCHEDULER_cancel(occ->timeout_task); |
1127 | occ->timeout_task = | 1119 | occ->timeout_task = |
1128 | GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); | 1120 | GNUNET_SCHEDULER_add_now(&timeout_overlay_connect, occ); |
1129 | return; | 1121 | return; |
1130 | } | 1122 | } |
1131 | GNUNET_assert (NULL == occ->p1th_); | 1123 | GNUNET_assert(NULL == occ->p1th_); |
1132 | GNUNET_assert (NULL != occ->cgh_p1th); | 1124 | GNUNET_assert(NULL != occ->cgh_p1th); |
1133 | occ->p1th_ = th; | 1125 | occ->p1th_ = th; |
1134 | GNUNET_asprintf (&occ->emsg, | 1126 | GNUNET_asprintf(&occ->emsg, |
1135 | "0x%llx: Timeout while acquiring HELLO of peer %s", | 1127 | "0x%llx: Timeout while acquiring HELLO of peer %s", |
1136 | occ->op_id, | 1128 | occ->op_id, |
1137 | GNUNET_i2s (&occ->peer_identity)); | 1129 | GNUNET_i2s(&occ->peer_identity)); |
1138 | occ->ghh = GNUNET_TRANSPORT_hello_get (cfg, | 1130 | occ->ghh = GNUNET_TRANSPORT_hello_get(cfg, |
1139 | GNUNET_TRANSPORT_AC_ANY, | 1131 | GNUNET_TRANSPORT_AC_ANY, |
1140 | &hello_update_cb, | 1132 | &hello_update_cb, |
1141 | occ); | 1133 | occ); |
1142 | } | 1134 | } |
1143 | 1135 | ||
1144 | 1136 | ||
@@ -1152,68 +1144,68 @@ p1_transport_connect_cache_callback (void *cls, | |||
1152 | * @param my_identity the identity of our peer | 1144 | * @param my_identity the identity of our peer |
1153 | */ | 1145 | */ |
1154 | static void | 1146 | static void |
1155 | occ_cache_get_handle_core_cb (void *cls, | 1147 | occ_cache_get_handle_core_cb(void *cls, |
1156 | struct GNUNET_CORE_Handle *ch, | 1148 | struct GNUNET_CORE_Handle *ch, |
1157 | struct GNUNET_TRANSPORT_CoreHandle *th, | 1149 | struct GNUNET_TRANSPORT_CoreHandle *th, |
1158 | struct GNUNET_ATS_ConnectivityHandle *ac, | 1150 | struct GNUNET_ATS_ConnectivityHandle *ac, |
1159 | const struct GNUNET_PeerIdentity *my_identity, | 1151 | const struct GNUNET_PeerIdentity *my_identity, |
1160 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 1152 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
1161 | { | 1153 | { |
1162 | struct OverlayConnectContext *occ = cls; | 1154 | struct OverlayConnectContext *occ = cls; |
1163 | const struct GNUNET_MessageHeader *hello; | 1155 | const struct GNUNET_MessageHeader *hello; |
1164 | 1156 | ||
1165 | GNUNET_assert (NULL != occ->timeout_task); | 1157 | GNUNET_assert(NULL != occ->timeout_task); |
1166 | GNUNET_free_non_null (occ->emsg); | 1158 | GNUNET_free_non_null(occ->emsg); |
1167 | if ((NULL == ch) || (NULL == my_identity)) | 1159 | if ((NULL == ch) || (NULL == my_identity)) |
1168 | { | 1160 | { |
1169 | GNUNET_asprintf (&occ->emsg, | 1161 | GNUNET_asprintf(&occ->emsg, |
1170 | "0x%llx: Failed to connect to CORE of peer with " | 1162 | "0x%llx: Failed to connect to CORE of peer with " |
1171 | "id: %u", | 1163 | "id: %u", |
1172 | occ->op_id, | 1164 | occ->op_id, |
1173 | occ->peer->id); | 1165 | occ->peer->id); |
1174 | GNUNET_SCHEDULER_cancel (occ->timeout_task); | 1166 | GNUNET_SCHEDULER_cancel(occ->timeout_task); |
1175 | occ->timeout_task = | 1167 | occ->timeout_task = |
1176 | GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); | 1168 | GNUNET_SCHEDULER_add_now(&timeout_overlay_connect, occ); |
1177 | return; | 1169 | return; |
1178 | } | 1170 | } |
1179 | occ->emsg = NULL; | 1171 | occ->emsg = NULL; |
1180 | if (NULL != | 1172 | if (NULL != |
1181 | GNUNET_CORE_get_mq (ch, | 1173 | GNUNET_CORE_get_mq(ch, |
1182 | &occ->other_peer_identity)) | 1174 | &occ->other_peer_identity)) |
1183 | { | 1175 | { |
1184 | LOG_DEBUG ("0x%llx: Target peer already connected\n", | 1176 | LOG_DEBUG("0x%llx: Target peer already connected\n", |
1185 | occ->op_id); | 1177 | occ->op_id); |
1186 | GNUNET_SCHEDULER_cancel (occ->timeout_task); | 1178 | GNUNET_SCHEDULER_cancel(occ->timeout_task); |
1187 | occ->timeout_task = NULL; | 1179 | occ->timeout_task = NULL; |
1188 | send_overlay_connect_success_msg (occ); | 1180 | send_overlay_connect_success_msg(occ); |
1189 | occ->cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup_occ, occ); | 1181 | occ->cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup_occ, occ); |
1190 | return; | 1182 | return; |
1191 | } | 1183 | } |
1192 | occ->peer_identity = *my_identity; | 1184 | occ->peer_identity = *my_identity; |
1193 | LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n", | 1185 | LOG_DEBUG("0x%llx: Acquiring HELLO of peer %s\n", |
1194 | occ->op_id, | 1186 | occ->op_id, |
1195 | GNUNET_i2s (&occ->peer_identity)); | 1187 | GNUNET_i2s(&occ->peer_identity)); |
1196 | /* Lookup for HELLO in hello cache */ | 1188 | /* Lookup for HELLO in hello cache */ |
1197 | if (NULL != (hello = GST_cache_lookup_hello (occ->peer->id))) | 1189 | if (NULL != (hello = GST_cache_lookup_hello(occ->peer->id))) |
1198 | { | 1190 | { |
1199 | LOG_DEBUG ("0x%llx: HELLO of peer %s found in cache\n", | 1191 | LOG_DEBUG("0x%llx: HELLO of peer %s found in cache\n", |
1200 | occ->op_id, | 1192 | occ->op_id, |
1201 | GNUNET_i2s (&occ->peer_identity)); | 1193 | GNUNET_i2s(&occ->peer_identity)); |
1202 | occ->hello = GNUNET_copy_message (hello); | 1194 | occ->hello = GNUNET_copy_message(hello); |
1203 | p2_transport_connect (occ); | 1195 | p2_transport_connect(occ); |
1204 | return; | 1196 | return; |
1205 | } | 1197 | } |
1206 | GNUNET_asprintf (&occ->emsg, | 1198 | GNUNET_asprintf(&occ->emsg, |
1207 | "0x%llx: Timeout while acquiring TRANSPORT of %s from cache", | 1199 | "0x%llx: Timeout while acquiring TRANSPORT of %s from cache", |
1208 | occ->op_id, | 1200 | occ->op_id, |
1209 | GNUNET_i2s (&occ->peer_identity)); | 1201 | GNUNET_i2s(&occ->peer_identity)); |
1210 | occ->cgh_p1th = | 1202 | occ->cgh_p1th = |
1211 | GST_connection_pool_get_handle (occ->peer->id, | 1203 | GST_connection_pool_get_handle(occ->peer->id, |
1212 | occ->peer->details.local.cfg, | 1204 | occ->peer->details.local.cfg, |
1213 | GST_CONNECTIONPOOL_SERVICE_TRANSPORT, | 1205 | GST_CONNECTIONPOOL_SERVICE_TRANSPORT, |
1214 | p1_transport_connect_cache_callback, | 1206 | p1_transport_connect_cache_callback, |
1215 | occ, | 1207 | occ, |
1216 | NULL, NULL, NULL); | 1208 | NULL, NULL, NULL); |
1217 | } | 1209 | } |
1218 | 1210 | ||
1219 | 1211 | ||
@@ -1226,41 +1218,41 @@ occ_cache_get_handle_core_cb (void *cls, | |||
1226 | * @param msg the peer create success message | 1218 | * @param msg the peer create success message |
1227 | */ | 1219 | */ |
1228 | static void | 1220 | static void |
1229 | overlay_connect_get_config (void *cls, | 1221 | overlay_connect_get_config(void *cls, |
1230 | const struct GNUNET_MessageHeader *msg) | 1222 | const struct GNUNET_MessageHeader *msg) |
1231 | { | 1223 | { |
1232 | struct OverlayConnectContext *occ = cls; | 1224 | struct OverlayConnectContext *occ = cls; |
1233 | struct RemotePeer2Context *rp2c; | 1225 | struct RemotePeer2Context *rp2c; |
1234 | const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *cmsg; | 1226 | const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *cmsg; |
1235 | 1227 | ||
1236 | GNUNET_assert (OCC_TYPE_LOCAL != occ->type); | 1228 | GNUNET_assert(OCC_TYPE_LOCAL != occ->type); |
1237 | rp2c = &occ->p2ctx.remote; | 1229 | rp2c = &occ->p2ctx.remote; |
1238 | rp2c->opc = NULL; | 1230 | rp2c->opc = NULL; |
1239 | GNUNET_assert (NULL != occ->timeout_task); | 1231 | GNUNET_assert(NULL != occ->timeout_task); |
1240 | if (GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION != ntohs (msg->type)) | 1232 | if (GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION != ntohs(msg->type)) |
1241 | { | 1233 | { |
1242 | GNUNET_SCHEDULER_cancel (occ->timeout_task); | 1234 | GNUNET_SCHEDULER_cancel(occ->timeout_task); |
1243 | occ->timeout_task = | 1235 | occ->timeout_task = |
1244 | GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); | 1236 | GNUNET_SCHEDULER_add_now(&timeout_overlay_connect, occ); |
1245 | } | 1237 | } |
1246 | cmsg = | 1238 | cmsg = |
1247 | (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) msg; | 1239 | (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *)msg; |
1248 | occ->other_peer_identity = cmsg->peer_identity; | 1240 | occ->other_peer_identity = cmsg->peer_identity; |
1249 | GNUNET_free_non_null (occ->emsg); | 1241 | GNUNET_free_non_null(occ->emsg); |
1250 | GNUNET_asprintf (&occ->emsg, | 1242 | GNUNET_asprintf(&occ->emsg, |
1251 | "0x%llx: Timeout while connecting to CORE of peer with " | 1243 | "0x%llx: Timeout while connecting to CORE of peer with " |
1252 | "id: %u", | 1244 | "id: %u", |
1253 | occ->op_id, | 1245 | occ->op_id, |
1254 | occ->peer->id); | 1246 | occ->peer->id); |
1255 | occ->cgh_ch = | 1247 | occ->cgh_ch = |
1256 | GST_connection_pool_get_handle (occ->peer->id, | 1248 | GST_connection_pool_get_handle(occ->peer->id, |
1257 | occ->peer->details.local.cfg, | 1249 | occ->peer->details.local.cfg, |
1258 | GST_CONNECTIONPOOL_SERVICE_CORE, | 1250 | GST_CONNECTIONPOOL_SERVICE_CORE, |
1259 | occ_cache_get_handle_core_cb, | 1251 | occ_cache_get_handle_core_cb, |
1260 | occ, | 1252 | occ, |
1261 | &occ->other_peer_identity, | 1253 | &occ->other_peer_identity, |
1262 | &overlay_connect_notify, | 1254 | &overlay_connect_notify, |
1263 | occ); | 1255 | occ); |
1264 | return; | 1256 | return; |
1265 | } | 1257 | } |
1266 | 1258 | ||
@@ -1272,12 +1264,12 @@ overlay_connect_get_config (void *cls, | |||
1272 | * @param emsg the error message; NULL if host registration is successful | 1264 | * @param emsg the error message; NULL if host registration is successful |
1273 | */ | 1265 | */ |
1274 | static void | 1266 | static void |
1275 | host_registration_comp (void *cls, const char *emsg) | 1267 | host_registration_comp(void *cls, const char *emsg) |
1276 | { | 1268 | { |
1277 | struct RegisteredHostContext *rhc = cls; | 1269 | struct RegisteredHostContext *rhc = cls; |
1278 | 1270 | ||
1279 | rhc->state = RHC_DONE; | 1271 | rhc->state = RHC_DONE; |
1280 | GST_process_next_focc (rhc); | 1272 | GST_process_next_focc(rhc); |
1281 | } | 1273 | } |
1282 | 1274 | ||
1283 | 1275 | ||
@@ -1292,19 +1284,19 @@ host_registration_comp (void *cls, const char *emsg) | |||
1292 | * #GNUNET_NO if not. | 1284 | * #GNUNET_NO if not. |
1293 | */ | 1285 | */ |
1294 | static int | 1286 | static int |
1295 | reghost_match_iterator (void *cls, | 1287 | reghost_match_iterator(void *cls, |
1296 | const struct GNUNET_HashCode *key, | 1288 | const struct GNUNET_HashCode *key, |
1297 | void *value) | 1289 | void *value) |
1298 | { | 1290 | { |
1299 | struct RegisteredHostContext **rh = cls; | 1291 | struct RegisteredHostContext **rh = cls; |
1300 | struct RegisteredHostContext *rh_val = value; | 1292 | struct RegisteredHostContext *rh_val = value; |
1301 | 1293 | ||
1302 | if ((rh_val->host == (*rh)->host) && (rh_val->reg_host == (*rh)->reg_host)) | 1294 | if ((rh_val->host == (*rh)->host) && (rh_val->reg_host == (*rh)->reg_host)) |
1303 | { | 1295 | { |
1304 | GNUNET_free (*rh); | 1296 | GNUNET_free(*rh); |
1305 | *rh = rh_val; | 1297 | *rh = rh_val; |
1306 | return GNUNET_NO; | 1298 | return GNUNET_NO; |
1307 | } | 1299 | } |
1308 | return GNUNET_YES; | 1300 | return GNUNET_YES; |
1309 | } | 1301 | } |
1310 | 1302 | ||
@@ -1317,15 +1309,15 @@ reghost_match_iterator (void *cls, | |||
1317 | * @return the hashcode | 1309 | * @return the hashcode |
1318 | */ | 1310 | */ |
1319 | static struct GNUNET_HashCode | 1311 | static struct GNUNET_HashCode |
1320 | hash_hosts (struct GNUNET_TESTBED_Host *reg_host, | 1312 | hash_hosts(struct GNUNET_TESTBED_Host *reg_host, |
1321 | struct GNUNET_TESTBED_Host *host) | 1313 | struct GNUNET_TESTBED_Host *host) |
1322 | { | 1314 | { |
1323 | struct GNUNET_HashCode hash; | 1315 | struct GNUNET_HashCode hash; |
1324 | uint32_t host_ids[2]; | 1316 | uint32_t host_ids[2]; |
1325 | 1317 | ||
1326 | host_ids[0] = GNUNET_TESTBED_host_get_id_ (reg_host); | 1318 | host_ids[0] = GNUNET_TESTBED_host_get_id_(reg_host); |
1327 | host_ids[1] = GNUNET_TESTBED_host_get_id_ (host); | 1319 | host_ids[1] = GNUNET_TESTBED_host_get_id_(host); |
1328 | GNUNET_CRYPTO_hash (host_ids, sizeof (host_ids), &hash); | 1320 | GNUNET_CRYPTO_hash(host_ids, sizeof(host_ids), &hash); |
1329 | return hash; | 1321 | return hash; |
1330 | } | 1322 | } |
1331 | 1323 | ||
@@ -1344,48 +1336,48 @@ hash_hosts (struct GNUNET_TESTBED_Host *reg_host, | |||
1344 | * already registered, NULL is returned. | 1336 | * already registered, NULL is returned. |
1345 | */ | 1337 | */ |
1346 | static struct RegisteredHostContext * | 1338 | static struct RegisteredHostContext * |
1347 | register_host (struct Slave *slave, | 1339 | register_host(struct Slave *slave, |
1348 | struct GNUNET_TESTBED_Host *host) | 1340 | struct GNUNET_TESTBED_Host *host) |
1349 | { | 1341 | { |
1350 | struct GNUNET_HashCode hash; | 1342 | struct GNUNET_HashCode hash; |
1351 | struct RegisteredHostContext *rhc; | 1343 | struct RegisteredHostContext *rhc; |
1352 | 1344 | ||
1353 | rhc = GNUNET_new (struct RegisteredHostContext); | 1345 | rhc = GNUNET_new(struct RegisteredHostContext); |
1354 | rhc->reg_host = host; | 1346 | rhc->reg_host = host; |
1355 | rhc->host = GST_host_list[slave->host_id]; | 1347 | rhc->host = GST_host_list[slave->host_id]; |
1356 | GNUNET_assert (NULL != rhc->reg_host); | 1348 | GNUNET_assert(NULL != rhc->reg_host); |
1357 | GNUNET_assert (NULL != rhc->host); | 1349 | GNUNET_assert(NULL != rhc->host); |
1358 | rhc->state = RHC_INIT; | 1350 | rhc->state = RHC_INIT; |
1359 | hash = hash_hosts (rhc->reg_host, rhc->host); | 1351 | hash = hash_hosts(rhc->reg_host, rhc->host); |
1360 | if ((GNUNET_NO == | 1352 | if ((GNUNET_NO == |
1361 | GNUNET_CONTAINER_multihashmap_contains (slave->reghost_map, | 1353 | GNUNET_CONTAINER_multihashmap_contains(slave->reghost_map, |
1362 | &hash)) || | 1354 | &hash)) || |
1363 | (GNUNET_SYSERR != | 1355 | (GNUNET_SYSERR != |
1364 | GNUNET_CONTAINER_multihashmap_get_multiple (slave->reghost_map, | 1356 | GNUNET_CONTAINER_multihashmap_get_multiple(slave->reghost_map, |
1365 | &hash, | 1357 | &hash, |
1366 | reghost_match_iterator, | 1358 | reghost_match_iterator, |
1367 | &rhc))) | 1359 | &rhc))) |
1368 | { | 1360 | { |
1369 | /* create and add a new registerd host context */ | 1361 | /* create and add a new registerd host context */ |
1370 | /* add the focc to its queue */ | 1362 | /* add the focc to its queue */ |
1371 | GNUNET_CONTAINER_multihashmap_put (slave->reghost_map, | 1363 | GNUNET_CONTAINER_multihashmap_put(slave->reghost_map, |
1372 | &hash, | 1364 | &hash, |
1373 | rhc, | 1365 | rhc, |
1374 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 1366 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
1375 | GST_queue_host_registration (slave, | 1367 | GST_queue_host_registration(slave, |
1376 | host_registration_comp, | 1368 | host_registration_comp, |
1377 | rhc, | 1369 | rhc, |
1378 | rhc->reg_host); | 1370 | rhc->reg_host); |
1379 | } | 1371 | } |
1380 | else | 1372 | else |
1381 | { | 1373 | { |
1382 | /* rhc is now set to the existing one from the hash map by | 1374 | /* rhc is now set to the existing one from the hash map by |
1383 | * reghost_match_iterator() */ | 1375 | * reghost_match_iterator() */ |
1384 | /* if queue is empty then ignore creating focc and proceed with normal | 1376 | /* if queue is empty then ignore creating focc and proceed with normal |
1385 | * forwarding */ | 1377 | * forwarding */ |
1386 | if (RHC_DONE == rhc->state) | 1378 | if (RHC_DONE == rhc->state) |
1387 | return NULL; | 1379 | return NULL; |
1388 | } | 1380 | } |
1389 | return rhc; | 1381 | return rhc; |
1390 | } | 1382 | } |
1391 | 1383 | ||
@@ -1400,8 +1392,8 @@ register_host (struct Slave *slave, | |||
1400 | * be notified | 1392 | * be notified |
1401 | */ | 1393 | */ |
1402 | static void | 1394 | static void |
1403 | forward_overlay_connect (const struct GNUNET_TESTBED_OverlayConnectMessage *msg, | 1395 | forward_overlay_connect(const struct GNUNET_TESTBED_OverlayConnectMessage *msg, |
1404 | struct GNUNET_SERVICE_Client *client) | 1396 | struct GNUNET_SERVICE_Client *client) |
1405 | { | 1397 | { |
1406 | struct ForwardedOperationContext *fopc; | 1398 | struct ForwardedOperationContext *fopc; |
1407 | struct Route *route_to_peer2_host; | 1399 | struct Route *route_to_peer2_host; |
@@ -1414,61 +1406,61 @@ forward_overlay_connect (const struct GNUNET_TESTBED_OverlayConnectMessage *msg, | |||
1414 | uint32_t p1; | 1406 | uint32_t p1; |
1415 | uint32_t p2; | 1407 | uint32_t p2; |
1416 | 1408 | ||
1417 | p1 = ntohl (msg->peer1); | 1409 | p1 = ntohl(msg->peer1); |
1418 | p2 = ntohl (msg->peer2); | 1410 | p2 = ntohl(msg->peer2); |
1419 | op_id = GNUNET_ntohll (msg->operation_id); | 1411 | op_id = GNUNET_ntohll(msg->operation_id); |
1420 | peer2_host_id = ntohl (msg->peer2_host_id); | 1412 | peer2_host_id = ntohl(msg->peer2_host_id); |
1421 | GNUNET_assert (VALID_PEER_ID (p1)); | 1413 | GNUNET_assert(VALID_PEER_ID(p1)); |
1422 | GNUNET_assert (VALID_HOST_ID (peer2_host_id)); | 1414 | GNUNET_assert(VALID_HOST_ID(peer2_host_id)); |
1423 | peer = GST_peer_list[p1]; | 1415 | peer = GST_peer_list[p1]; |
1424 | GNUNET_assert (GNUNET_YES == peer->is_remote); | 1416 | GNUNET_assert(GNUNET_YES == peer->is_remote); |
1425 | LOG_DEBUG ("0x%llx: Forwarding overlay connect\n", op_id); | 1417 | LOG_DEBUG("0x%llx: Forwarding overlay connect\n", op_id); |
1426 | route_to_peer2_host = GST_find_dest_route (peer2_host_id); | 1418 | route_to_peer2_host = GST_find_dest_route(peer2_host_id); |
1427 | route_to_peer1_host = GST_find_dest_route | 1419 | route_to_peer1_host = GST_find_dest_route |
1428 | (peer->details.remote.remote_host_id); | 1420 | (peer->details.remote.remote_host_id); |
1429 | GNUNET_assert (NULL != route_to_peer1_host); | 1421 | GNUNET_assert(NULL != route_to_peer1_host); |
1430 | if ((NULL != route_to_peer2_host) && | 1422 | if ((NULL != route_to_peer2_host) && |
1431 | (route_to_peer1_host->dest == route_to_peer2_host->dest)) | 1423 | (route_to_peer1_host->dest == route_to_peer2_host->dest)) |
1432 | goto forward; | 1424 | goto forward; |
1433 | /* Peer2 is either with us OR peer1 and peer2 can be reached through | 1425 | /* Peer2 is either with us OR peer1 and peer2 can be reached through |
1434 | different subtrees OR peer2 is on a subtree unknown to us */ | 1426 | different subtrees OR peer2 is on a subtree unknown to us */ |
1435 | if (NULL != (rhc = register_host (peer->details.remote.slave, | 1427 | if (NULL != (rhc = register_host(peer->details.remote.slave, |
1436 | GST_host_list[peer2_host_id]))) | 1428 | GST_host_list[peer2_host_id]))) |
1437 | { | 1429 | { |
1438 | LOG_DEBUG ("Queueing forwarding FOCC for connecting peers %u and %u\n", p1, p2); | 1430 | LOG_DEBUG("Queueing forwarding FOCC for connecting peers %u and %u\n", p1, p2); |
1439 | focc = GNUNET_new (struct ForwardedOverlayConnectContext); | 1431 | focc = GNUNET_new(struct ForwardedOverlayConnectContext); |
1440 | focc->rhc = rhc; | 1432 | focc->rhc = rhc; |
1441 | focc->peer1 = p1; | 1433 | focc->peer1 = p1; |
1442 | focc->peer2 = p2; | 1434 | focc->peer2 = p2; |
1443 | focc->peer2_host_id = peer2_host_id; | 1435 | focc->peer2_host_id = peer2_host_id; |
1444 | focc->orig_msg = GNUNET_copy_message (&msg->header); | 1436 | focc->orig_msg = GNUNET_copy_message(&msg->header); |
1445 | focc->operation_id = op_id; | 1437 | focc->operation_id = op_id; |
1446 | focc->client = client; | 1438 | focc->client = client; |
1447 | GNUNET_CONTAINER_DLL_insert_tail (rhc->focc_dll_head, | 1439 | GNUNET_CONTAINER_DLL_insert_tail(rhc->focc_dll_head, |
1448 | rhc->focc_dll_tail, | 1440 | rhc->focc_dll_tail, |
1449 | focc); | 1441 | focc); |
1450 | return; | 1442 | return; |
1451 | } | 1443 | } |
1452 | 1444 | ||
1453 | forward: | 1445 | forward: |
1454 | LOG_DEBUG ("Forwarding without FOCC for connecting peers %u and %u\n", p1, p2); | 1446 | LOG_DEBUG("Forwarding without FOCC for connecting peers %u and %u\n", p1, p2); |
1455 | fopc = GNUNET_new (struct ForwardedOperationContext); | 1447 | fopc = GNUNET_new(struct ForwardedOperationContext); |
1456 | fopc->client = client; | 1448 | fopc->client = client; |
1457 | fopc->operation_id = op_id; | 1449 | fopc->operation_id = op_id; |
1458 | fopc->type = OP_OVERLAY_CONNECT; | 1450 | fopc->type = OP_OVERLAY_CONNECT; |
1459 | fopc->opc = | 1451 | fopc->opc = |
1460 | GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote. | 1452 | GNUNET_TESTBED_forward_operation_msg_(peer->details.remote. |
1461 | slave->controller, op_id, | 1453 | slave->controller, op_id, |
1462 | &msg->header, | 1454 | &msg->header, |
1463 | &GST_forwarded_operation_reply_relay, | 1455 | &GST_forwarded_operation_reply_relay, |
1464 | fopc); | 1456 | fopc); |
1465 | fopc->timeout_task = | 1457 | fopc->timeout_task = |
1466 | GNUNET_SCHEDULER_add_delayed (GST_timeout, | 1458 | GNUNET_SCHEDULER_add_delayed(GST_timeout, |
1467 | &GST_forwarded_operation_timeout, | 1459 | &GST_forwarded_operation_timeout, |
1468 | fopc); | 1460 | fopc); |
1469 | GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, | 1461 | GNUNET_CONTAINER_DLL_insert_tail(fopcq_head, |
1470 | fopcq_tail, | 1462 | fopcq_tail, |
1471 | fopc); | 1463 | fopc); |
1472 | } | 1464 | } |
1473 | 1465 | ||
1474 | 1466 | ||
@@ -1480,35 +1472,35 @@ forward_overlay_connect (const struct GNUNET_TESTBED_OverlayConnectMessage *msg, | |||
1480 | * @param c handle to the controller connection | 1472 | * @param c handle to the controller connection |
1481 | */ | 1473 | */ |
1482 | static void | 1474 | static void |
1483 | p2_controller_connect_cb (void *cls, | 1475 | p2_controller_connect_cb(void *cls, |
1484 | struct GNUNET_TESTBED_Controller *c) | 1476 | struct GNUNET_TESTBED_Controller *c) |
1485 | { | 1477 | { |
1486 | struct OverlayConnectContext *occ = cls; | 1478 | struct OverlayConnectContext *occ = cls; |
1487 | struct RemotePeer2Context *rp2c; | 1479 | struct RemotePeer2Context *rp2c; |
1488 | struct GNUNET_TESTBED_PeerGetConfigurationMessage cmsg; | 1480 | struct GNUNET_TESTBED_PeerGetConfigurationMessage cmsg; |
1489 | 1481 | ||
1490 | GNUNET_assert (OCC_TYPE_LOCAL != occ->type); | 1482 | GNUNET_assert(OCC_TYPE_LOCAL != occ->type); |
1491 | rp2c = &occ->p2ctx.remote; | 1483 | rp2c = &occ->p2ctx.remote; |
1492 | rp2c->ncn = NULL; | 1484 | rp2c->ncn = NULL; |
1493 | rp2c->p2c = c; | 1485 | rp2c->p2c = c; |
1494 | cmsg.header.size = | 1486 | cmsg.header.size = |
1495 | htons (sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage)); | 1487 | htons(sizeof(struct GNUNET_TESTBED_PeerGetConfigurationMessage)); |
1496 | cmsg.header.type = | 1488 | cmsg.header.type = |
1497 | htons (GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION); | 1489 | htons(GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION); |
1498 | cmsg.peer_id = htonl (occ->other_peer_id); | 1490 | cmsg.peer_id = htonl(occ->other_peer_id); |
1499 | cmsg.operation_id = GNUNET_htonll (occ->op_id); | 1491 | cmsg.operation_id = GNUNET_htonll(occ->op_id); |
1500 | rp2c->opc = | 1492 | rp2c->opc = |
1501 | GNUNET_TESTBED_forward_operation_msg_ (rp2c->p2c, | 1493 | GNUNET_TESTBED_forward_operation_msg_(rp2c->p2c, |
1502 | occ->op_id, | 1494 | occ->op_id, |
1503 | &cmsg.header, | 1495 | &cmsg.header, |
1504 | &overlay_connect_get_config, | 1496 | &overlay_connect_get_config, |
1505 | occ); | 1497 | occ); |
1506 | GNUNET_free_non_null (occ->emsg); | 1498 | GNUNET_free_non_null(occ->emsg); |
1507 | GNUNET_asprintf (&occ->emsg, | 1499 | GNUNET_asprintf(&occ->emsg, |
1508 | "0x%llx: Timeout while getting peer identity of peer " | 1500 | "0x%llx: Timeout while getting peer identity of peer " |
1509 | "with id: %u", | 1501 | "with id: %u", |
1510 | occ->op_id, | 1502 | occ->op_id, |
1511 | occ->other_peer_id); | 1503 | occ->other_peer_id); |
1512 | } | 1504 | } |
1513 | 1505 | ||
1514 | 1506 | ||
@@ -1519,8 +1511,8 @@ p2_controller_connect_cb (void *cls, | |||
1519 | * @param msg the actual message | 1511 | * @param msg the actual message |
1520 | */ | 1512 | */ |
1521 | void | 1513 | void |
1522 | handle_overlay_connect (void *cls, | 1514 | handle_overlay_connect(void *cls, |
1523 | const struct GNUNET_TESTBED_OverlayConnectMessage *msg) | 1515 | const struct GNUNET_TESTBED_OverlayConnectMessage *msg) |
1524 | { | 1516 | { |
1525 | struct GNUNET_SERVICE_Client *client = cls; | 1517 | struct GNUNET_SERVICE_Client *client = cls; |
1526 | struct Peer *peer; | 1518 | struct Peer *peer; |
@@ -1532,112 +1524,114 @@ handle_overlay_connect (void *cls, | |||
1532 | uint32_t p2; | 1524 | uint32_t p2; |
1533 | uint32_t peer2_host_id; | 1525 | uint32_t peer2_host_id; |
1534 | 1526 | ||
1535 | p1 = ntohl (msg->peer1); | 1527 | p1 = ntohl(msg->peer1); |
1536 | p2 = ntohl (msg->peer2); | 1528 | p2 = ntohl(msg->peer2); |
1537 | if (! VALID_PEER_ID (p1)) | 1529 | if (!VALID_PEER_ID(p1)) |
1538 | { | 1530 | { |
1539 | GNUNET_break (0); | 1531 | GNUNET_break(0); |
1540 | GNUNET_SERVICE_client_drop (client); | 1532 | GNUNET_SERVICE_client_drop(client); |
1541 | return; | 1533 | return; |
1542 | } | 1534 | } |
1543 | peer = GST_peer_list[p1]; | 1535 | peer = GST_peer_list[p1]; |
1544 | operation_id = GNUNET_ntohll (msg->operation_id); | 1536 | operation_id = GNUNET_ntohll(msg->operation_id); |
1545 | LOG_DEBUG | 1537 | LOG_DEBUG |
1546 | ("Received overlay connect for peers %u and %u with op id: 0x%llx\n", | 1538 | ("Received overlay connect for peers %u and %u with op id: 0x%llx\n", |
1547 | p1, | 1539 | p1, |
1548 | p2, | 1540 | p2, |
1549 | operation_id); | 1541 | operation_id); |
1550 | peer2_host_id = ntohl (msg->peer2_host_id); | 1542 | peer2_host_id = ntohl(msg->peer2_host_id); |
1551 | if (GNUNET_YES == peer->is_remote) | 1543 | if (GNUNET_YES == peer->is_remote) |
1552 | { | ||
1553 | if (! VALID_HOST_ID (peer2_host_id)) | ||
1554 | { | 1544 | { |
1555 | GNUNET_break (0); | 1545 | if (!VALID_HOST_ID(peer2_host_id)) |
1556 | GNUNET_SERVICE_client_drop (client); | 1546 | { |
1547 | GNUNET_break(0); | ||
1548 | GNUNET_SERVICE_client_drop(client); | ||
1549 | return; | ||
1550 | } | ||
1551 | forward_overlay_connect(msg, client); | ||
1552 | GNUNET_SERVICE_client_continue(client); | ||
1557 | return; | 1553 | return; |
1558 | } | 1554 | } |
1559 | forward_overlay_connect (msg, client); | ||
1560 | GNUNET_SERVICE_client_continue (client); | ||
1561 | return; | ||
1562 | } | ||
1563 | p2n = NULL; | 1555 | p2n = NULL; |
1564 | occ = GNUNET_new (struct OverlayConnectContext); | 1556 | occ = GNUNET_new(struct OverlayConnectContext); |
1565 | occ->type = OCC_TYPE_LOCAL; | 1557 | occ->type = OCC_TYPE_LOCAL; |
1566 | if (! VALID_PEER_ID (p2)) /* May be peer2 is on a another controller */ | 1558 | if (!VALID_PEER_ID(p2)) /* May be peer2 is on a another controller */ |
1567 | { | ||
1568 | if (NULL == (p2n = GST_get_neighbour (peer2_host_id))) | ||
1569 | { | 1559 | { |
1570 | if (! VALID_HOST_ID (peer2_host_id)) | 1560 | if (NULL == (p2n = GST_get_neighbour(peer2_host_id))) |
1571 | { | 1561 | { |
1572 | GNUNET_break (0); | 1562 | if (!VALID_HOST_ID(peer2_host_id)) |
1573 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1563 | { |
1574 | "0x%llx: Peer %u's host not in our neighbours list\n", | 1564 | GNUNET_break(0); |
1575 | operation_id, p2); | 1565 | LOG(GNUNET_ERROR_TYPE_WARNING, |
1576 | GNUNET_SERVICE_client_drop (client); | 1566 | "0x%llx: Peer %u's host not in our neighbours list\n", |
1577 | GNUNET_free (occ); | 1567 | operation_id, p2); |
1578 | return; | 1568 | GNUNET_SERVICE_client_drop(client); |
1579 | } | 1569 | GNUNET_free(occ); |
1580 | p2n = GST_create_neighbour (GST_host_list[peer2_host_id]); | 1570 | return; |
1571 | } | ||
1572 | p2n = GST_create_neighbour(GST_host_list[peer2_host_id]); | ||
1573 | } | ||
1574 | occ->type = OCC_TYPE_REMOTE_LATERAL; | ||
1575 | occ->p2ctx.remote.p2n = p2n; | ||
1581 | } | 1576 | } |
1582 | occ->type = OCC_TYPE_REMOTE_LATERAL; | ||
1583 | occ->p2ctx.remote.p2n = p2n; | ||
1584 | } | ||
1585 | else if (GNUNET_YES == GST_peer_list[p2]->is_remote) | 1577 | else if (GNUNET_YES == GST_peer_list[p2]->is_remote) |
1586 | { | 1578 | { |
1587 | occ->type = OCC_TYPE_REMOTE_SLAVE; | 1579 | occ->type = OCC_TYPE_REMOTE_SLAVE; |
1588 | occ->p2ctx.remote.p2c = GST_peer_list[p2]->details.remote.slave->controller; | 1580 | occ->p2ctx.remote.p2c = GST_peer_list[p2]->details.remote.slave->controller; |
1589 | } | 1581 | } |
1590 | GNUNET_CONTAINER_DLL_insert_tail (occq_head, | 1582 | GNUNET_CONTAINER_DLL_insert_tail(occq_head, |
1591 | occq_tail, | 1583 | occq_tail, |
1592 | occ); | 1584 | occ); |
1593 | occ->client = client; | 1585 | occ->client = client; |
1594 | occ->other_peer_id = p2; | 1586 | occ->other_peer_id = p2; |
1595 | GST_peer_list[p1]->reference_cnt++; | 1587 | GST_peer_list[p1]->reference_cnt++; |
1596 | occ->peer = GST_peer_list[p1]; | 1588 | occ->peer = GST_peer_list[p1]; |
1597 | occ->op_id = operation_id; | 1589 | occ->op_id = operation_id; |
1598 | GNUNET_assert (NULL == occ->timeout_task); | 1590 | GNUNET_assert(NULL == occ->timeout_task); |
1599 | occ->timeout_task = | 1591 | occ->timeout_task = |
1600 | GNUNET_SCHEDULER_add_delayed (GST_timeout, | 1592 | GNUNET_SCHEDULER_add_delayed(GST_timeout, |
1601 | &timeout_overlay_connect, | 1593 | &timeout_overlay_connect, |
1602 | occ); | 1594 | occ); |
1603 | switch (occ->type) | 1595 | switch (occ->type) |
1604 | { | 1596 | { |
1605 | case OCC_TYPE_REMOTE_LATERAL: | 1597 | case OCC_TYPE_REMOTE_LATERAL: |
1606 | GNUNET_asprintf (&occ->emsg, | 1598 | GNUNET_asprintf(&occ->emsg, |
1607 | "0x%llx: Timeout while acquiring connection to peer %u's " | 1599 | "0x%llx: Timeout while acquiring connection to peer %u's " |
1608 | "host: %u\n", | 1600 | "host: %u\n", |
1609 | occ->op_id, | 1601 | occ->op_id, |
1610 | occ->other_peer_id, | 1602 | occ->other_peer_id, |
1611 | peer2_host_id); | 1603 | peer2_host_id); |
1612 | occ->p2ctx.remote.ncn | 1604 | occ->p2ctx.remote.ncn |
1613 | = GST_neighbour_get_connection (p2n, | 1605 | = GST_neighbour_get_connection(p2n, |
1614 | &p2_controller_connect_cb, | 1606 | &p2_controller_connect_cb, |
1615 | occ); | 1607 | occ); |
1616 | break; | 1608 | break; |
1617 | case OCC_TYPE_REMOTE_SLAVE: | 1609 | |
1618 | p2_controller_connect_cb (occ, | 1610 | case OCC_TYPE_REMOTE_SLAVE: |
1619 | occ->p2ctx.remote.p2c); | 1611 | p2_controller_connect_cb(occ, |
1620 | break; | 1612 | occ->p2ctx.remote.p2c); |
1621 | case OCC_TYPE_LOCAL: | 1613 | break; |
1622 | peer2 = GST_peer_list[occ->other_peer_id]; | 1614 | |
1623 | peer2->reference_cnt++; | 1615 | case OCC_TYPE_LOCAL: |
1624 | GNUNET_TESTING_peer_get_identity (peer2->details.local.peer, | 1616 | peer2 = GST_peer_list[occ->other_peer_id]; |
1625 | &occ->other_peer_identity); | 1617 | peer2->reference_cnt++; |
1626 | GNUNET_asprintf (&occ->emsg, | 1618 | GNUNET_TESTING_peer_get_identity(peer2->details.local.peer, |
1627 | "0x%llx: Timeout while connecting to CORE of peer with " | 1619 | &occ->other_peer_identity); |
1628 | "id: %u", | 1620 | GNUNET_asprintf(&occ->emsg, |
1629 | occ->op_id, | 1621 | "0x%llx: Timeout while connecting to CORE of peer with " |
1630 | occ->peer->id); | 1622 | "id: %u", |
1631 | occ->cgh_ch = | 1623 | occ->op_id, |
1632 | GST_connection_pool_get_handle (occ->peer->id, | 1624 | occ->peer->id); |
1633 | occ->peer->details.local.cfg, | 1625 | occ->cgh_ch = |
1634 | GST_CONNECTIONPOOL_SERVICE_CORE, | 1626 | GST_connection_pool_get_handle(occ->peer->id, |
1635 | occ_cache_get_handle_core_cb, occ, | 1627 | occ->peer->details.local.cfg, |
1636 | &occ->other_peer_identity, | 1628 | GST_CONNECTIONPOOL_SERVICE_CORE, |
1637 | &overlay_connect_notify, occ); | 1629 | occ_cache_get_handle_core_cb, occ, |
1638 | break; | 1630 | &occ->other_peer_identity, |
1639 | } | 1631 | &overlay_connect_notify, occ); |
1640 | GNUNET_SERVICE_client_continue (client); | 1632 | break; |
1633 | } | ||
1634 | GNUNET_SERVICE_client_continue(client); | ||
1641 | } | 1635 | } |
1642 | 1636 | ||
1643 | 1637 | ||
@@ -1648,30 +1642,30 @@ handle_overlay_connect (void *cls, | |||
1648 | * @param rocc the RemoteOverlayConnectCtx | 1642 | * @param rocc the RemoteOverlayConnectCtx |
1649 | */ | 1643 | */ |
1650 | static void | 1644 | static void |
1651 | cleanup_rocc (struct RemoteOverlayConnectCtx *rocc) | 1645 | cleanup_rocc(struct RemoteOverlayConnectCtx *rocc) |
1652 | { | 1646 | { |
1653 | LOG_DEBUG ("0x%llx: Cleaning up rocc\n", | 1647 | LOG_DEBUG("0x%llx: Cleaning up rocc\n", |
1654 | rocc->op_id); | 1648 | rocc->op_id); |
1655 | if (NULL != rocc->attempt_connect_task_id) | 1649 | if (NULL != rocc->attempt_connect_task_id) |
1656 | GNUNET_SCHEDULER_cancel (rocc->attempt_connect_task_id); | 1650 | GNUNET_SCHEDULER_cancel(rocc->attempt_connect_task_id); |
1657 | if (NULL != rocc->timeout_rocc_task_id) | 1651 | if (NULL != rocc->timeout_rocc_task_id) |
1658 | GNUNET_SCHEDULER_cancel (rocc->timeout_rocc_task_id); | 1652 | GNUNET_SCHEDULER_cancel(rocc->timeout_rocc_task_id); |
1659 | if (NULL != rocc->ohh) | 1653 | if (NULL != rocc->ohh) |
1660 | GNUNET_TRANSPORT_offer_hello_cancel (rocc->ohh); | 1654 | GNUNET_TRANSPORT_offer_hello_cancel(rocc->ohh); |
1661 | if (NULL != rocc->tcc.csh) | 1655 | if (NULL != rocc->tcc.csh) |
1662 | GNUNET_ATS_connectivity_suggest_cancel (rocc->tcc.csh); | 1656 | GNUNET_ATS_connectivity_suggest_cancel(rocc->tcc.csh); |
1663 | GST_connection_pool_get_handle_done (rocc->tcc.cgh_p2_th); | 1657 | GST_connection_pool_get_handle_done(rocc->tcc.cgh_p2_th); |
1664 | GST_connection_pool_get_handle_done (rocc->tcc.cgh_p2_ats); | 1658 | GST_connection_pool_get_handle_done(rocc->tcc.cgh_p2_ats); |
1665 | GNUNET_assert (rocc->peer->reference_cnt > 0); | 1659 | GNUNET_assert(rocc->peer->reference_cnt > 0); |
1666 | rocc->peer->reference_cnt--; | 1660 | rocc->peer->reference_cnt--; |
1667 | if ((GNUNET_YES == rocc->peer->destroy_flag) && | 1661 | if ((GNUNET_YES == rocc->peer->destroy_flag) && |
1668 | (0 == rocc->peer->reference_cnt)) | 1662 | (0 == rocc->peer->reference_cnt)) |
1669 | GST_destroy_peer (rocc->peer); | 1663 | GST_destroy_peer(rocc->peer); |
1670 | GNUNET_free_non_null (rocc->hello); | 1664 | GNUNET_free_non_null(rocc->hello); |
1671 | GNUNET_CONTAINER_DLL_remove (roccq_head, | 1665 | GNUNET_CONTAINER_DLL_remove(roccq_head, |
1672 | roccq_tail, | 1666 | roccq_tail, |
1673 | rocc); | 1667 | rocc); |
1674 | GNUNET_free (rocc); | 1668 | GNUNET_free(rocc); |
1675 | } | 1669 | } |
1676 | 1670 | ||
1677 | 1671 | ||
@@ -1681,15 +1675,15 @@ cleanup_rocc (struct RemoteOverlayConnectCtx *rocc) | |||
1681 | * @param cls the RemoteOverlayConnectCtx | 1675 | * @param cls the RemoteOverlayConnectCtx |
1682 | */ | 1676 | */ |
1683 | static void | 1677 | static void |
1684 | timeout_rocc_task (void *cls) | 1678 | timeout_rocc_task(void *cls) |
1685 | { | 1679 | { |
1686 | struct RemoteOverlayConnectCtx *rocc = cls; | 1680 | struct RemoteOverlayConnectCtx *rocc = cls; |
1687 | 1681 | ||
1688 | GNUNET_assert (rocc->timeout_rocc_task_id != NULL); | 1682 | GNUNET_assert(rocc->timeout_rocc_task_id != NULL); |
1689 | rocc->timeout_rocc_task_id = NULL; | 1683 | rocc->timeout_rocc_task_id = NULL; |
1690 | LOG_DEBUG ("0x%llx: rocc timed out\n", | 1684 | LOG_DEBUG("0x%llx: rocc timed out\n", |
1691 | rocc->op_id); | 1685 | rocc->op_id); |
1692 | cleanup_rocc (rocc); | 1686 | cleanup_rocc(rocc); |
1693 | } | 1687 | } |
1694 | 1688 | ||
1695 | 1689 | ||
@@ -1701,20 +1695,20 @@ timeout_rocc_task (void *cls) | |||
1701 | * @param new_peer the peer that connected | 1695 | * @param new_peer the peer that connected |
1702 | */ | 1696 | */ |
1703 | static void | 1697 | static void |
1704 | cache_transport_peer_connect_notify (void *cls, | 1698 | cache_transport_peer_connect_notify(void *cls, |
1705 | const struct GNUNET_PeerIdentity *new_peer) | 1699 | const struct GNUNET_PeerIdentity *new_peer) |
1706 | { | 1700 | { |
1707 | struct RemoteOverlayConnectCtx *rocc = cls; | 1701 | struct RemoteOverlayConnectCtx *rocc = cls; |
1708 | 1702 | ||
1709 | LOG_DEBUG ("0x%llx: Request Overlay connect notify\n", | 1703 | LOG_DEBUG("0x%llx: Request Overlay connect notify\n", |
1710 | rocc->op_id); | 1704 | rocc->op_id); |
1711 | GNUNET_assert (0 == | 1705 | GNUNET_assert(0 == |
1712 | memcmp (new_peer, &rocc->a_id, | 1706 | memcmp(new_peer, &rocc->a_id, |
1713 | sizeof (struct GNUNET_PeerIdentity))); | 1707 | sizeof(struct GNUNET_PeerIdentity))); |
1714 | LOG_DEBUG ("0x%llx: Peer %s connected\n", | 1708 | LOG_DEBUG("0x%llx: Peer %s connected\n", |
1715 | rocc->op_id, | 1709 | rocc->op_id, |
1716 | GNUNET_i2s (&rocc->a_id)); | 1710 | GNUNET_i2s(&rocc->a_id)); |
1717 | cleanup_rocc (rocc); | 1711 | cleanup_rocc(rocc); |
1718 | } | 1712 | } |
1719 | 1713 | ||
1720 | 1714 | ||
@@ -1725,7 +1719,7 @@ cache_transport_peer_connect_notify (void *cls, | |||
1725 | * @param cls the RemoteOverlayConnectCtx | 1719 | * @param cls the RemoteOverlayConnectCtx |
1726 | */ | 1720 | */ |
1727 | static void | 1721 | static void |
1728 | attempt_connect_task (void *cls); | 1722 | attempt_connect_task(void *cls); |
1729 | 1723 | ||
1730 | 1724 | ||
1731 | /** | 1725 | /** |
@@ -1736,22 +1730,22 @@ attempt_connect_task (void *cls); | |||
1736 | * @param cls the overlay connect context | 1730 | * @param cls the overlay connect context |
1737 | */ | 1731 | */ |
1738 | static void | 1732 | static void |
1739 | rocc_hello_sent_cb (void *cls) | 1733 | rocc_hello_sent_cb(void *cls) |
1740 | { | 1734 | { |
1741 | struct RemoteOverlayConnectCtx *rocc = cls; | 1735 | struct RemoteOverlayConnectCtx *rocc = cls; |
1742 | 1736 | ||
1743 | rocc->ohh = NULL; | 1737 | rocc->ohh = NULL; |
1744 | GNUNET_assert (NULL == rocc->attempt_connect_task_id); | 1738 | GNUNET_assert(NULL == rocc->attempt_connect_task_id); |
1745 | LOG_DEBUG ("0x%llx: HELLO of peer %s delivered to local peer with id: %u\n", | 1739 | LOG_DEBUG("0x%llx: HELLO of peer %s delivered to local peer with id: %u\n", |
1746 | rocc->op_id, | 1740 | rocc->op_id, |
1747 | GNUNET_i2s (&rocc->a_id), | 1741 | GNUNET_i2s(&rocc->a_id), |
1748 | rocc->peer->id); | 1742 | rocc->peer->id); |
1749 | rocc->tcc.cgh_p2_ats = | 1743 | rocc->tcc.cgh_p2_ats = |
1750 | GST_connection_pool_get_handle (rocc->peer->id, | 1744 | GST_connection_pool_get_handle(rocc->peer->id, |
1751 | rocc->peer->details.local.cfg, | 1745 | rocc->peer->details.local.cfg, |
1752 | GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY, | 1746 | GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY, |
1753 | &occ_cache_get_handle_ats_rocc_cb, | 1747 | &occ_cache_get_handle_ats_rocc_cb, |
1754 | rocc, NULL, NULL, NULL); | 1748 | rocc, NULL, NULL, NULL); |
1755 | } | 1749 | } |
1756 | 1750 | ||
1757 | 1751 | ||
@@ -1762,29 +1756,29 @@ rocc_hello_sent_cb (void *cls) | |||
1762 | * @param cls the RemoteOverlayConnectCtx | 1756 | * @param cls the RemoteOverlayConnectCtx |
1763 | */ | 1757 | */ |
1764 | static void | 1758 | static void |
1765 | attempt_connect_task (void *cls) | 1759 | attempt_connect_task(void *cls) |
1766 | { | 1760 | { |
1767 | struct RemoteOverlayConnectCtx *rocc = cls; | 1761 | struct RemoteOverlayConnectCtx *rocc = cls; |
1768 | 1762 | ||
1769 | GNUNET_assert (NULL != rocc->attempt_connect_task_id); | 1763 | GNUNET_assert(NULL != rocc->attempt_connect_task_id); |
1770 | rocc->attempt_connect_task_id = NULL; | 1764 | rocc->attempt_connect_task_id = NULL; |
1771 | LOG_DEBUG ("0x%llx: Offering HELLO of peer %s to remote peer with id: %u\n", | 1765 | LOG_DEBUG("0x%llx: Offering HELLO of peer %s to remote peer with id: %u\n", |
1772 | rocc->op_id, | 1766 | rocc->op_id, |
1773 | GNUNET_i2s (&rocc->a_id), | 1767 | GNUNET_i2s(&rocc->a_id), |
1774 | rocc->peer->id); | 1768 | rocc->peer->id); |
1775 | rocc->ohh = | 1769 | rocc->ohh = |
1776 | GNUNET_TRANSPORT_offer_hello (rocc->tcc.cfg, | 1770 | GNUNET_TRANSPORT_offer_hello(rocc->tcc.cfg, |
1777 | rocc->hello, | 1771 | rocc->hello, |
1778 | &rocc_hello_sent_cb, | 1772 | &rocc_hello_sent_cb, |
1779 | rocc); | 1773 | rocc); |
1780 | if (NULL == rocc->ohh) | 1774 | if (NULL == rocc->ohh) |
1781 | rocc->attempt_connect_task_id = | 1775 | rocc->attempt_connect_task_id = |
1782 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 1776 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply |
1783 | (GNUNET_TIME_UNIT_MILLISECONDS, | 1777 | (GNUNET_TIME_UNIT_MILLISECONDS, |
1784 | 100 + | 1778 | 100 + |
1785 | GNUNET_CRYPTO_random_u32 | 1779 | GNUNET_CRYPTO_random_u32 |
1786 | (GNUNET_CRYPTO_QUALITY_WEAK, 500)), | 1780 | (GNUNET_CRYPTO_QUALITY_WEAK, 500)), |
1787 | &attempt_connect_task, rocc); | 1781 | &attempt_connect_task, rocc); |
1788 | } | 1782 | } |
1789 | 1783 | ||
1790 | 1784 | ||
@@ -1798,36 +1792,36 @@ attempt_connect_task (void *cls) | |||
1798 | * @param ignore_ peer identity which is ignored in this callback | 1792 | * @param ignore_ peer identity which is ignored in this callback |
1799 | */ | 1793 | */ |
1800 | static void | 1794 | static void |
1801 | rocc_cache_get_handle_transport_cb (void *cls, | 1795 | rocc_cache_get_handle_transport_cb(void *cls, |
1802 | struct GNUNET_CORE_Handle *ch, | 1796 | struct GNUNET_CORE_Handle *ch, |
1803 | struct GNUNET_TRANSPORT_CoreHandle *th, | 1797 | struct GNUNET_TRANSPORT_CoreHandle *th, |
1804 | struct GNUNET_ATS_ConnectivityHandle *ac, | 1798 | struct GNUNET_ATS_ConnectivityHandle *ac, |
1805 | const struct GNUNET_PeerIdentity *ignore_, | 1799 | const struct GNUNET_PeerIdentity *ignore_, |
1806 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 1800 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
1807 | { | 1801 | { |
1808 | struct RemoteOverlayConnectCtx *rocc = cls; | 1802 | struct RemoteOverlayConnectCtx *rocc = cls; |
1809 | 1803 | ||
1810 | if (NULL == th) | 1804 | if (NULL == th) |
1811 | { | 1805 | { |
1812 | rocc->timeout_rocc_task_id = | 1806 | rocc->timeout_rocc_task_id = |
1813 | GNUNET_SCHEDULER_add_now (&timeout_rocc_task, rocc); | 1807 | GNUNET_SCHEDULER_add_now(&timeout_rocc_task, rocc); |
1814 | return; | 1808 | return; |
1815 | } | 1809 | } |
1816 | rocc->tcc.th_ = th; | 1810 | rocc->tcc.th_ = th; |
1817 | rocc->tcc.cfg = cfg; | 1811 | rocc->tcc.cfg = cfg; |
1818 | if (NULL != | 1812 | if (NULL != |
1819 | GNUNET_TRANSPORT_core_get_mq (rocc->tcc.th_, | 1813 | GNUNET_TRANSPORT_core_get_mq(rocc->tcc.th_, |
1820 | &rocc->a_id)) | 1814 | &rocc->a_id)) |
1821 | { | 1815 | { |
1822 | LOG_DEBUG ("0x%llx: Target peer %s already connected to local peer: %u\n", | 1816 | LOG_DEBUG("0x%llx: Target peer %s already connected to local peer: %u\n", |
1823 | rocc->op_id, | 1817 | rocc->op_id, |
1824 | GNUNET_i2s (&rocc->a_id), | 1818 | GNUNET_i2s(&rocc->a_id), |
1825 | rocc->peer->id); | 1819 | rocc->peer->id); |
1826 | cleanup_rocc (rocc); | 1820 | cleanup_rocc(rocc); |
1827 | return; | 1821 | return; |
1828 | } | 1822 | } |
1829 | rocc->attempt_connect_task_id = | 1823 | rocc->attempt_connect_task_id = |
1830 | GNUNET_SCHEDULER_add_now (&attempt_connect_task, rocc); | 1824 | GNUNET_SCHEDULER_add_now(&attempt_connect_task, rocc); |
1831 | } | 1825 | } |
1832 | 1826 | ||
1833 | 1827 | ||
@@ -1839,32 +1833,32 @@ rocc_cache_get_handle_transport_cb (void *cls, | |||
1839 | * @return #GNUNET_OK if @a msg is well-formed | 1833 | * @return #GNUNET_OK if @a msg is well-formed |
1840 | */ | 1834 | */ |
1841 | int | 1835 | int |
1842 | check_remote_overlay_connect (void *cls, | 1836 | check_remote_overlay_connect(void *cls, |
1843 | const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg) | 1837 | const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg) |
1844 | { | 1838 | { |
1845 | uint32_t peer_id; | 1839 | uint32_t peer_id; |
1846 | uint16_t msize; | 1840 | uint16_t msize; |
1847 | uint16_t hsize; | 1841 | uint16_t hsize; |
1848 | 1842 | ||
1849 | msize = ntohs (msg->header.size); | 1843 | msize = ntohs(msg->header.size); |
1850 | if (GNUNET_MESSAGE_TYPE_HELLO != ntohs (msg->hello->type)) | 1844 | if (GNUNET_MESSAGE_TYPE_HELLO != ntohs(msg->hello->type)) |
1851 | { | 1845 | { |
1852 | GNUNET_break (0); | 1846 | GNUNET_break(0); |
1853 | return GNUNET_SYSERR; | 1847 | return GNUNET_SYSERR; |
1854 | } | 1848 | } |
1855 | hsize = ntohs (msg->hello->size); | 1849 | hsize = ntohs(msg->hello->size); |
1856 | if ((sizeof (struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hsize) != msize) | 1850 | if ((sizeof(struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hsize) != msize) |
1857 | { | 1851 | { |
1858 | GNUNET_break (0); | 1852 | GNUNET_break(0); |
1859 | return GNUNET_SYSERR; | 1853 | return GNUNET_SYSERR; |
1860 | } | 1854 | } |
1861 | peer_id = ntohl (msg->peer); | 1855 | peer_id = ntohl(msg->peer); |
1862 | if ((peer_id >= GST_peer_list_size) || | 1856 | if ((peer_id >= GST_peer_list_size) || |
1863 | (NULL == GST_peer_list[peer_id])) | 1857 | (NULL == GST_peer_list[peer_id])) |
1864 | { | 1858 | { |
1865 | GNUNET_break_op (0); | 1859 | GNUNET_break_op(0); |
1866 | return GNUNET_SYSERR; | 1860 | return GNUNET_SYSERR; |
1867 | } | 1861 | } |
1868 | return GNUNET_OK; | 1862 | return GNUNET_OK; |
1869 | } | 1863 | } |
1870 | 1864 | ||
@@ -1876,8 +1870,8 @@ check_remote_overlay_connect (void *cls, | |||
1876 | * @param msg the actual message | 1870 | * @param msg the actual message |
1877 | */ | 1871 | */ |
1878 | void | 1872 | void |
1879 | handle_remote_overlay_connect (void *cls, | 1873 | handle_remote_overlay_connect(void *cls, |
1880 | const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg) | 1874 | const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg) |
1881 | { | 1875 | { |
1882 | struct GNUNET_SERVICE_Client *client = cls; | 1876 | struct GNUNET_SERVICE_Client *client = cls; |
1883 | struct RemoteOverlayConnectCtx *rocc; | 1877 | struct RemoteOverlayConnectCtx *rocc; |
@@ -1887,55 +1881,55 @@ handle_remote_overlay_connect (void *cls, | |||
1887 | uint32_t peer_id; | 1881 | uint32_t peer_id; |
1888 | uint16_t hsize; | 1882 | uint16_t hsize; |
1889 | 1883 | ||
1890 | hsize = ntohs (msg->hello->size); | 1884 | hsize = ntohs(msg->hello->size); |
1891 | peer_id = ntohl (msg->peer); | 1885 | peer_id = ntohl(msg->peer); |
1892 | peer = GST_peer_list[peer_id]; | 1886 | peer = GST_peer_list[peer_id]; |
1893 | if (GNUNET_YES == peer->is_remote) | 1887 | if (GNUNET_YES == peer->is_remote) |
1894 | { | 1888 | { |
1895 | struct GNUNET_MessageHeader *msg2; | 1889 | struct GNUNET_MessageHeader *msg2; |
1896 | 1890 | ||
1897 | msg2 = GNUNET_copy_message (&msg->header); | 1891 | msg2 = GNUNET_copy_message(&msg->header); |
1898 | GNUNET_TESTBED_queue_message_ (peer->details.remote.slave->controller, | 1892 | GNUNET_TESTBED_queue_message_(peer->details.remote.slave->controller, |
1899 | msg2); | 1893 | msg2); |
1900 | GNUNET_SERVICE_client_continue (client); | 1894 | GNUNET_SERVICE_client_continue(client); |
1901 | return; | 1895 | return; |
1902 | } | 1896 | } |
1903 | rocc = GNUNET_new (struct RemoteOverlayConnectCtx); | 1897 | rocc = GNUNET_new(struct RemoteOverlayConnectCtx); |
1904 | rocc->op_id = GNUNET_ntohll (msg->operation_id); | 1898 | rocc->op_id = GNUNET_ntohll(msg->operation_id); |
1905 | GNUNET_CONTAINER_DLL_insert_tail (roccq_head, | 1899 | GNUNET_CONTAINER_DLL_insert_tail(roccq_head, |
1906 | roccq_tail, | 1900 | roccq_tail, |
1907 | rocc); | 1901 | rocc); |
1908 | rocc->a_id = msg->peer_identity; | 1902 | rocc->a_id = msg->peer_identity; |
1909 | GNUNET_TESTING_peer_get_identity (peer->details.local.peer, | 1903 | GNUNET_TESTING_peer_get_identity(peer->details.local.peer, |
1910 | &pid); | 1904 | &pid); |
1911 | (void) GNUNET_strlcpy (pid_str, | 1905 | (void)GNUNET_strlcpy(pid_str, |
1912 | GNUNET_i2s (&pid), | 1906 | GNUNET_i2s(&pid), |
1913 | sizeof (pid_str)); | 1907 | sizeof(pid_str)); |
1914 | LOG_DEBUG ("0x%llx: Remote overlay connect %s to peer %s with hello size: %u\n", | 1908 | LOG_DEBUG("0x%llx: Remote overlay connect %s to peer %s with hello size: %u\n", |
1915 | rocc->op_id, | 1909 | rocc->op_id, |
1916 | pid_str, | 1910 | pid_str, |
1917 | GNUNET_i2s (&rocc->a_id), | 1911 | GNUNET_i2s(&rocc->a_id), |
1918 | hsize); | 1912 | hsize); |
1919 | rocc->peer = peer; | 1913 | rocc->peer = peer; |
1920 | rocc->peer->reference_cnt++; | 1914 | rocc->peer->reference_cnt++; |
1921 | rocc->hello = GNUNET_malloc (hsize); | 1915 | rocc->hello = GNUNET_malloc(hsize); |
1922 | GNUNET_memcpy (rocc->hello, | 1916 | GNUNET_memcpy(rocc->hello, |
1923 | msg->hello, | 1917 | msg->hello, |
1924 | hsize); | 1918 | hsize); |
1925 | rocc->tcc.cgh_p2_th = | 1919 | rocc->tcc.cgh_p2_th = |
1926 | GST_connection_pool_get_handle (peer_id, | 1920 | GST_connection_pool_get_handle(peer_id, |
1927 | rocc->peer->details.local.cfg, | 1921 | rocc->peer->details.local.cfg, |
1928 | GST_CONNECTIONPOOL_SERVICE_TRANSPORT, | 1922 | GST_CONNECTIONPOOL_SERVICE_TRANSPORT, |
1929 | &rocc_cache_get_handle_transport_cb, | 1923 | &rocc_cache_get_handle_transport_cb, |
1930 | rocc, | 1924 | rocc, |
1931 | &rocc->a_id, | 1925 | &rocc->a_id, |
1932 | &cache_transport_peer_connect_notify, | 1926 | &cache_transport_peer_connect_notify, |
1933 | rocc); | 1927 | rocc); |
1934 | rocc->timeout_rocc_task_id = | 1928 | rocc->timeout_rocc_task_id = |
1935 | GNUNET_SCHEDULER_add_delayed (GST_timeout, | 1929 | GNUNET_SCHEDULER_add_delayed(GST_timeout, |
1936 | &timeout_rocc_task, | 1930 | &timeout_rocc_task, |
1937 | rocc); | 1931 | rocc); |
1938 | GNUNET_SERVICE_client_continue (client); | 1932 | GNUNET_SERVICE_client_continue(client); |
1939 | } | 1933 | } |
1940 | 1934 | ||
1941 | 1935 | ||
@@ -1943,12 +1937,12 @@ handle_remote_overlay_connect (void *cls, | |||
1943 | * Clears all pending overlay connect contexts in queue | 1937 | * Clears all pending overlay connect contexts in queue |
1944 | */ | 1938 | */ |
1945 | void | 1939 | void |
1946 | GST_free_occq () | 1940 | GST_free_occq() |
1947 | { | 1941 | { |
1948 | struct OverlayConnectContext *occ; | 1942 | struct OverlayConnectContext *occ; |
1949 | 1943 | ||
1950 | while (NULL != (occ = occq_head)) | 1944 | while (NULL != (occ = occq_head)) |
1951 | cleanup_occ (occ); | 1945 | cleanup_occ(occ); |
1952 | } | 1946 | } |
1953 | 1947 | ||
1954 | 1948 | ||
@@ -1956,10 +1950,10 @@ GST_free_occq () | |||
1956 | * Clears all pending remote overlay connect contexts in queue | 1950 | * Clears all pending remote overlay connect contexts in queue |
1957 | */ | 1951 | */ |
1958 | void | 1952 | void |
1959 | GST_free_roccq () | 1953 | GST_free_roccq() |
1960 | { | 1954 | { |
1961 | struct RemoteOverlayConnectCtx *rocc; | 1955 | struct RemoteOverlayConnectCtx *rocc; |
1962 | 1956 | ||
1963 | while (NULL != (rocc = roccq_head)) | 1957 | while (NULL != (rocc = roccq_head)) |
1964 | cleanup_rocc (rocc); | 1958 | cleanup_rocc(rocc); |
1965 | } | 1959 | } |