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