diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-25 12:11:58 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-25 12:11:58 +0000 |
commit | b67d0aa2e982ad992ef0ccd80146d38e05258cc7 (patch) | |
tree | 810f2562b475e762a3423bb4c8992666e9d4e3f8 /src/testbed/gnunet-service-testbed.h | |
parent | 4bba69ba0aeb6393adfd042f49d1e8af5a136a0c (diff) | |
download | gnunet-b67d0aa2e982ad992ef0ccd80146d38e05258cc7.tar.gz gnunet-b67d0aa2e982ad992ef0ccd80146d38e05258cc7.zip |
- separate overlay connect message handling as module
Diffstat (limited to 'src/testbed/gnunet-service-testbed.h')
-rw-r--r-- | src/testbed/gnunet-service-testbed.h | 438 |
1 files changed, 208 insertions, 230 deletions
diff --git a/src/testbed/gnunet-service-testbed.h b/src/testbed/gnunet-service-testbed.h index 4fa137780..df7d7635c 100644 --- a/src/testbed/gnunet-service-testbed.h +++ b/src/testbed/gnunet-service-testbed.h | |||
@@ -306,214 +306,51 @@ struct Peer | |||
306 | 306 | ||
307 | 307 | ||
308 | /** | 308 | /** |
309 | * Context information for transport try connect | 309 | * The main context information associated with the client which started us |
310 | */ | ||
311 | struct TryConnectContext | ||
312 | { | ||
313 | /** | ||
314 | * The identity of the peer to which the transport has to attempt a connection | ||
315 | */ | ||
316 | struct GNUNET_PeerIdentity *pid; | ||
317 | |||
318 | /** | ||
319 | * The transport handle | ||
320 | */ | ||
321 | struct GNUNET_TRANSPORT_Handle *th; | ||
322 | |||
323 | /** | ||
324 | * the try connect handle | ||
325 | */ | ||
326 | struct GNUNET_TRANSPORT_TryConnectHandle *tch; | ||
327 | |||
328 | /** | ||
329 | * The task handle | ||
330 | */ | ||
331 | GNUNET_SCHEDULER_TaskIdentifier task; | ||
332 | |||
333 | /** | ||
334 | * The id of the operation which is resposible for this context | ||
335 | */ | ||
336 | uint64_t op_id; | ||
337 | |||
338 | /** | ||
339 | * The number of times we attempted to connect | ||
340 | */ | ||
341 | unsigned int retries; | ||
342 | |||
343 | }; | ||
344 | |||
345 | |||
346 | /** | ||
347 | * Context information for connecting 2 peers in overlay | ||
348 | */ | 310 | */ |
349 | struct OverlayConnectContext | 311 | struct Context |
350 | { | 312 | { |
351 | /** | 313 | /** |
352 | * The next pointer for maintaining a DLL | 314 | * The client handle associated with this context |
353 | */ | ||
354 | struct OverlayConnectContext *next; | ||
355 | |||
356 | /** | ||
357 | * The prev pointer for maintaining a DLL | ||
358 | */ | ||
359 | struct OverlayConnectContext *prev; | ||
360 | |||
361 | /** | ||
362 | * The client which has requested for overlay connection | ||
363 | */ | 315 | */ |
364 | struct GNUNET_SERVER_Client *client; | 316 | struct GNUNET_SERVER_Client *client; |
365 | 317 | ||
366 | /** | 318 | /** |
367 | * the peer which has to connect to the other peer | 319 | * The network address of the master controller |
368 | */ | ||
369 | struct Peer *peer; | ||
370 | |||
371 | /** | ||
372 | * Transport handle of the first peer to get its HELLO | ||
373 | */ | ||
374 | struct GNUNET_TRANSPORT_Handle *p1th; | ||
375 | |||
376 | /** | ||
377 | * Core handles of the first peer; used to notify when second peer connects to it | ||
378 | */ | ||
379 | struct GNUNET_CORE_Handle *ch; | ||
380 | |||
381 | /** | ||
382 | * HELLO of the other peer | ||
383 | */ | ||
384 | struct GNUNET_MessageHeader *hello; | ||
385 | |||
386 | /** | ||
387 | * Get hello handle to acquire HELLO of first peer | ||
388 | */ | ||
389 | struct GNUNET_TRANSPORT_GetHelloHandle *ghh; | ||
390 | |||
391 | /** | ||
392 | * The handle for offering HELLO | ||
393 | */ | ||
394 | struct GNUNET_TRANSPORT_OfferHelloHandle *ohh; | ||
395 | |||
396 | /** | ||
397 | * The error message we send if this overlay connect operation has timed out | ||
398 | */ | ||
399 | char *emsg; | ||
400 | |||
401 | /** | ||
402 | * Operation context for suboperations | ||
403 | */ | ||
404 | struct OperationContext *opc; | ||
405 | |||
406 | /** | ||
407 | * Controller of peer 2; NULL if the peer is local | ||
408 | */ | ||
409 | struct GNUNET_TESTBED_Controller *peer2_controller; | ||
410 | |||
411 | /** | ||
412 | * The transport try connect context | ||
413 | */ | ||
414 | struct TryConnectContext tcc; | ||
415 | |||
416 | /** | ||
417 | * The peer identity of the first peer | ||
418 | */ | ||
419 | struct GNUNET_PeerIdentity peer_identity; | ||
420 | |||
421 | /** | ||
422 | * The peer identity of the other peer | ||
423 | */ | ||
424 | struct GNUNET_PeerIdentity other_peer_identity; | ||
425 | |||
426 | /** | ||
427 | * The id of the operation responsible for creating this context | ||
428 | */ | ||
429 | uint64_t op_id; | ||
430 | |||
431 | /** | ||
432 | * The id of the task for sending HELLO of peer 2 to peer 1 and ask peer 1 to | ||
433 | * connect to peer 2 | ||
434 | */ | ||
435 | GNUNET_SCHEDULER_TaskIdentifier send_hello_task; | ||
436 | |||
437 | /** | ||
438 | * The id of the overlay connect timeout task | ||
439 | */ | ||
440 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | ||
441 | |||
442 | /** | ||
443 | * The id of the cleanup task | ||
444 | */ | 320 | */ |
445 | GNUNET_SCHEDULER_TaskIdentifier cleanup_task; | 321 | char *master_ip; |
446 | 322 | ||
447 | /** | 323 | /** |
448 | * The id of peer A | 324 | * The TESTING system handle for starting peers locally |
449 | */ | 325 | */ |
450 | uint32_t peer_id; | 326 | struct GNUNET_TESTING_System *system; |
451 | 327 | ||
452 | /** | 328 | /** |
453 | * The id of peer B | 329 | * Our host id according to this context |
454 | */ | 330 | */ |
455 | uint32_t other_peer_id; | 331 | uint32_t host_id; |
456 | |||
457 | }; | 332 | }; |
458 | 333 | ||
459 | 334 | ||
460 | /** | 335 | /** |
461 | * Context information for RequestOverlayConnect | 336 | * The structure for identifying a shared service |
462 | * operations. RequestOverlayConnect is used when peers A, B reside on different | ||
463 | * hosts and the host controller for peer B is asked by the host controller of | ||
464 | * peer A to make peer B connect to peer A | ||
465 | */ | 337 | */ |
466 | struct RequestOverlayConnectContext | 338 | struct SharedService |
467 | { | 339 | { |
468 | /** | 340 | /** |
469 | * the next pointer for DLL | 341 | * The name of the shared service |
470 | */ | ||
471 | struct RequestOverlayConnectContext *next; | ||
472 | |||
473 | /** | ||
474 | * the prev pointer for DLL | ||
475 | */ | ||
476 | struct RequestOverlayConnectContext *prev; | ||
477 | |||
478 | /** | ||
479 | * The peer handle of peer B | ||
480 | */ | ||
481 | struct Peer *peer; | ||
482 | |||
483 | /** | ||
484 | * Peer A's HELLO | ||
485 | */ | ||
486 | struct GNUNET_MessageHeader *hello; | ||
487 | |||
488 | /** | ||
489 | * The handle for offering HELLO | ||
490 | */ | ||
491 | struct GNUNET_TRANSPORT_OfferHelloHandle *ohh; | ||
492 | |||
493 | /** | ||
494 | * The transport try connect context | ||
495 | */ | 342 | */ |
496 | struct TryConnectContext tcc; | 343 | char *name; |
497 | 344 | ||
498 | /** | 345 | /** |
499 | * The peer identity of peer A | 346 | * Number of shared peers per instance of the shared service |
500 | */ | 347 | */ |
501 | struct GNUNET_PeerIdentity a_id; | 348 | uint32_t num_shared; |
502 | 349 | ||
503 | /** | 350 | /** |
504 | * Task for offering HELLO of A to B and doing try_connect | 351 | * Number of peers currently sharing the service |
505 | */ | ||
506 | GNUNET_SCHEDULER_TaskIdentifier attempt_connect_task_id; | ||
507 | |||
508 | /** | ||
509 | * Task to timeout RequestOverlayConnect | ||
510 | */ | ||
511 | GNUNET_SCHEDULER_TaskIdentifier timeout_rocc_task_id; | ||
512 | |||
513 | /** | ||
514 | * The id of the operation responsible for creating this context | ||
515 | */ | 352 | */ |
516 | uint64_t op_id; | 353 | uint32_t num_sharing; |
517 | }; | 354 | }; |
518 | 355 | ||
519 | 356 | ||
@@ -561,55 +398,6 @@ struct ForwardedOverlayConnectContext | |||
561 | 398 | ||
562 | 399 | ||
563 | /** | 400 | /** |
564 | * The main context information associated with the client which started us | ||
565 | */ | ||
566 | struct Context | ||
567 | { | ||
568 | /** | ||
569 | * The client handle associated with this context | ||
570 | */ | ||
571 | struct GNUNET_SERVER_Client *client; | ||
572 | |||
573 | /** | ||
574 | * The network address of the master controller | ||
575 | */ | ||
576 | char *master_ip; | ||
577 | |||
578 | /** | ||
579 | * The TESTING system handle for starting peers locally | ||
580 | */ | ||
581 | struct GNUNET_TESTING_System *system; | ||
582 | |||
583 | /** | ||
584 | * Our host id according to this context | ||
585 | */ | ||
586 | uint32_t host_id; | ||
587 | }; | ||
588 | |||
589 | |||
590 | /** | ||
591 | * The structure for identifying a shared service | ||
592 | */ | ||
593 | struct SharedService | ||
594 | { | ||
595 | /** | ||
596 | * The name of the shared service | ||
597 | */ | ||
598 | char *name; | ||
599 | |||
600 | /** | ||
601 | * Number of shared peers per instance of the shared service | ||
602 | */ | ||
603 | uint32_t num_shared; | ||
604 | |||
605 | /** | ||
606 | * Number of peers currently sharing the service | ||
607 | */ | ||
608 | uint32_t num_sharing; | ||
609 | }; | ||
610 | |||
611 | |||
612 | /** | ||
613 | * This context information will be created for each host that is registered at | 401 | * This context information will be created for each host that is registered at |
614 | * slave controllers during overlay connects. | 402 | * slave controllers during overlay connects. |
615 | */ | 403 | */ |
@@ -782,6 +570,76 @@ struct LCFContextQueue | |||
782 | struct LCFContextQueue *prev; | 570 | struct LCFContextQueue *prev; |
783 | }; | 571 | }; |
784 | 572 | ||
573 | /** | ||
574 | * Our configuration | ||
575 | */ | ||
576 | struct GNUNET_CONFIGURATION_Handle *our_config; | ||
577 | |||
578 | /** | ||
579 | * The master context; generated with the first INIT message | ||
580 | */ | ||
581 | extern struct Context *TESTBED_context; | ||
582 | |||
583 | /** | ||
584 | * DLL head for forwarded operation contexts | ||
585 | */ | ||
586 | extern struct ForwardedOperationContext *fopcq_head; | ||
587 | |||
588 | /** | ||
589 | * DLL tail for forwarded operation contexts | ||
590 | */ | ||
591 | extern struct ForwardedOperationContext *fopcq_tail; | ||
592 | |||
593 | /** | ||
594 | * A list of peers we know about | ||
595 | */ | ||
596 | extern struct Peer **TESTBED_peer_list; | ||
597 | |||
598 | /** | ||
599 | * Array of hosts | ||
600 | */ | ||
601 | extern struct GNUNET_TESTBED_Host **TESTBED_host_list; | ||
602 | |||
603 | /** | ||
604 | * A list of directly linked neighbours | ||
605 | */ | ||
606 | extern struct Slave **TESTBED_slave_list; | ||
607 | |||
608 | /** | ||
609 | * The size of the peer list | ||
610 | */ | ||
611 | extern unsigned int TESTBED_peer_list_size; | ||
612 | |||
613 | /** | ||
614 | * The size of the host list | ||
615 | */ | ||
616 | extern unsigned int TESTBED_host_list_size; | ||
617 | |||
618 | /** | ||
619 | * The size of directly linked neighbours list | ||
620 | */ | ||
621 | extern unsigned int TESTBED_slave_list_size; | ||
622 | |||
623 | |||
624 | /** | ||
625 | * Queues a message in send queue for sending to the service | ||
626 | * | ||
627 | * @param client the client to whom the queued message has to be sent | ||
628 | * @param msg the message to queue | ||
629 | */ | ||
630 | void | ||
631 | TESTBED_queue_message (struct GNUNET_SERVER_Client *client, | ||
632 | struct GNUNET_MessageHeader *msg); | ||
633 | |||
634 | |||
635 | /** | ||
636 | * Function to destroy a peer | ||
637 | * | ||
638 | * @param peer the peer structure to destroy | ||
639 | */ | ||
640 | void | ||
641 | TESTBED_destroy_peer (struct Peer *peer); | ||
642 | |||
785 | 643 | ||
786 | /** | 644 | /** |
787 | * Looks up in the hello cache and returns the HELLO of the given peer | 645 | * Looks up in the hello cache and returns the HELLO of the given peer |
@@ -820,5 +678,125 @@ void | |||
820 | TESTBED_cache_clear (); | 678 | TESTBED_cache_clear (); |
821 | 679 | ||
822 | 680 | ||
681 | /** | ||
682 | * Finds the route with directly connected host as destination through which | ||
683 | * the destination host can be reached | ||
684 | * | ||
685 | * @param host_id the id of the destination host | ||
686 | * @return the route with directly connected destination host; NULL if no route | ||
687 | * is found | ||
688 | */ | ||
689 | struct Route * | ||
690 | TESTBED_find_dest_route (uint32_t host_id); | ||
691 | |||
692 | |||
693 | /** | ||
694 | * Handler for GNUNET_MESSAGE_TYPE_TESTBED_OLCONNECT messages | ||
695 | * | ||
696 | * @param cls NULL | ||
697 | * @param client identification of the client | ||
698 | * @param message the actual message | ||
699 | */ | ||
700 | void | ||
701 | TESTBED_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | ||
702 | const struct GNUNET_MessageHeader *message); | ||
703 | |||
704 | |||
705 | /** | ||
706 | * Adds a host registration's request to a slave's registration queue | ||
707 | * | ||
708 | * @param slave the slave controller at which the given host has to be | ||
709 | * registered | ||
710 | * @param cb the host registration completion callback | ||
711 | * @param cb_cls the closure for the host registration completion callback | ||
712 | * @param host the host which has to be registered | ||
713 | */ | ||
714 | void | ||
715 | TESTBED_queue_host_registration (struct Slave *slave, | ||
716 | GNUNET_TESTBED_HostRegistrationCompletion cb, | ||
717 | void *cb_cls, | ||
718 | struct GNUNET_TESTBED_Host *host); | ||
719 | |||
720 | |||
721 | /** | ||
722 | * Callback to relay the reply msg of a forwarded operation back to the client | ||
723 | * | ||
724 | * @param cls ForwardedOperationContext | ||
725 | * @param msg the message to relay | ||
726 | */ | ||
727 | void | ||
728 | TESTBED_forwarded_operation_reply_relay (void *cls, | ||
729 | const struct GNUNET_MessageHeader *msg); | ||
730 | |||
731 | |||
732 | /** | ||
733 | * Task to free resources when forwarded operation has been timedout | ||
734 | * | ||
735 | * @param cls the ForwardedOperationContext | ||
736 | * @param tc the task context from scheduler | ||
737 | */ | ||
738 | void | ||
739 | TESTBED_forwarded_operation_timeout (void *cls, | ||
740 | const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
741 | |||
742 | |||
743 | /** | ||
744 | * Send operation failure message to client | ||
745 | * | ||
746 | * @param client the client to which the failure message has to be sent to | ||
747 | * @param operation_id the id of the failed operation | ||
748 | * @param emsg the error message; can be NULL | ||
749 | */ | ||
750 | void | ||
751 | TESTBED_send_operation_fail_msg (struct GNUNET_SERVER_Client *client, | ||
752 | uint64_t operation_id, const char *emsg); | ||
753 | |||
754 | |||
755 | /** | ||
756 | * Handler for GNUNET_MESSAGE_TYPE_TESTBED_REQUESTCONNECT messages | ||
757 | * | ||
758 | * @param cls NULL | ||
759 | * @param client identification of the client | ||
760 | * @param message the actual message | ||
761 | */ | ||
762 | void | ||
763 | TESTBED_handle_overlay_request_connect (void *cls, | ||
764 | struct GNUNET_SERVER_Client *client, | ||
765 | const struct GNUNET_MessageHeader | ||
766 | *message); | ||
767 | |||
768 | |||
769 | /** | ||
770 | * Processes a forwarded overlay connect context in the queue of the given RegisteredHostContext | ||
771 | * | ||
772 | * @param rhc the RegisteredHostContext | ||
773 | */ | ||
774 | void | ||
775 | TESTBED_process_next_focc (struct RegisteredHostContext *rhc); | ||
776 | |||
777 | |||
778 | /** | ||
779 | * Cleans up ForwardedOverlayConnectContext | ||
780 | * | ||
781 | * @param focc the ForwardedOverlayConnectContext to cleanup | ||
782 | */ | ||
783 | void | ||
784 | TESTBED_cleanup_focc (struct ForwardedOverlayConnectContext *focc); | ||
785 | |||
786 | |||
787 | /** | ||
788 | * Clears all pending overlay connect contexts in queue | ||
789 | */ | ||
790 | void | ||
791 | TESTBED_free_occq (); | ||
792 | |||
793 | |||
794 | /** | ||
795 | * Clears all pending remote overlay connect contexts in queue | ||
796 | */ | ||
797 | void | ||
798 | TESTBED_free_roccq (); | ||
799 | |||
800 | |||
823 | 801 | ||
824 | /* End of gnunet-service-testbed.h */ | 802 | /* End of gnunet-service-testbed.h */ |