diff options
author | Arthur Dewarumez <arthur.dewarumez@etudiant.univ-lille1.fr> | 2015-04-27 15:49:12 +0000 |
---|---|---|
committer | Arthur Dewarumez <arthur.dewarumez@etudiant.univ-lille1.fr> | 2015-04-27 15:49:12 +0000 |
commit | 728f4f354734161d5b90704c8468258100f46917 (patch) | |
tree | c7aa82051624d197638c4fe665a9170f96ba0071 /src/dht | |
parent | 1d7c856588007f583751096015a6fe19b4fe4ff9 (diff) | |
download | gnunet-728f4f354734161d5b90704c8468258100f46917.tar.gz gnunet-728f4f354734161d5b90704c8468258100f46917.zip |
Finish the create of the handler for every message.
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/gnunet-service-wdht_neighbours.c | 135 |
1 files changed, 122 insertions, 13 deletions
diff --git a/src/dht/gnunet-service-wdht_neighbours.c b/src/dht/gnunet-service-wdht_neighbours.c index fa04c0c61..15d7843ad 100644 --- a/src/dht/gnunet-service-wdht_neighbours.c +++ b/src/dht/gnunet-service-wdht_neighbours.c | |||
@@ -416,9 +416,14 @@ static struct GNUNET_SCHEDULER_Task *trail_timeout_task; | |||
416 | static struct GNUNET_PeerIdentity my_identity; | 416 | static struct GNUNET_PeerIdentity my_identity; |
417 | 417 | ||
418 | /** | 418 | /** |
419 | * Peer map of all the friends of a peer | 419 | * Peer map of all the fingers of a peer |
420 | */ | 420 | */ |
421 | static struct GNUNET_CONTAINER_MultiPeerMap *friend_peermap; | 421 | static struct GNUNET_CONTAINER_MultiPeerMap *fingers_peermap; |
422 | |||
423 | /** | ||
424 | * Peer map of all the successors of a peer | ||
425 | */ | ||
426 | static struct GNUNET_CONTAINER_MultiPeerMap *successors_peermap; | ||
422 | 427 | ||
423 | /** | 428 | /** |
424 | * Tail map, mapping tail identifiers to `struct Trail`s | 429 | * Tail map, mapping tail identifiers to `struct Trail`s |
@@ -596,7 +601,8 @@ core_init (void *cls, | |||
596 | 601 | ||
597 | 602 | ||
598 | /** | 603 | /** |
599 | * Handle a `struct FingerSetupMessage`. | 604 | * Handle a `struct FingerSetupMessage` from a GNUNET_MESSAGE_TYPE_WDHT_FINGER_SETUP |
605 | * message. | ||
600 | * | 606 | * |
601 | * @param cls closure (NULL) | 607 | * @param cls closure (NULL) |
602 | * @param peer sender identity | 608 | * @param peer sender identity |
@@ -616,7 +622,8 @@ handle_dht_p2p_finger_setup (void *cls, | |||
616 | } | 622 | } |
617 | 623 | ||
618 | /** | 624 | /** |
619 | * Handle a `struct FingerSetupResponseMessage`. | 625 | * Handle a `struct FingerSetupResponseMessage` from a GNUNET_MESSAGE_TYPE_WDHT_FINGER_SETUP_RESPONSE |
626 | * message. | ||
620 | * | 627 | * |
621 | * @param cls closure (NULL) | 628 | * @param cls closure (NULL) |
622 | * @param peer sender identity | 629 | * @param peer sender identity |
@@ -630,7 +637,7 @@ handle_dht_p2p_finger_setup_response (void *cls, | |||
630 | { | 637 | { |
631 | const struct FingerSetupResponseMessage *fsrm; | 638 | const struct FingerSetupResponseMessage *fsrm; |
632 | 639 | ||
633 | fsm = (const struct *) message; | 640 | fsm = (const struct FingerSetupResponseMessage *) message; |
634 | 641 | ||
635 | return GNUNET_OK; | 642 | return GNUNET_OK; |
636 | } | 643 | } |
@@ -651,7 +658,7 @@ handle_dht_p2p_finger_destroy (void *cls, | |||
651 | { | 658 | { |
652 | const struct FingerDestroyMessage *fdm; | 659 | const struct FingerDestroyMessage *fdm; |
653 | 660 | ||
654 | fsm = (const struct *) message; | 661 | fdm = (const struct FingerDestroyMessage *) message; |
655 | 662 | ||
656 | return GNUNET_OK; | 663 | return GNUNET_OK; |
657 | } | 664 | } |
@@ -671,18 +678,19 @@ handle_dht_p2p_finger_route (void *cls, | |||
671 | { | 678 | { |
672 | const struct FingerRouteMessage *frm; | 679 | const struct FingerRouteMessage *frm; |
673 | 680 | ||
674 | fsm = (const struct *) message; | 681 | frm = (const struct FingerRouteMessage *) message; |
675 | /* FIXME: check the size of the message */ | 682 | /* FIXME: check the size of the message */ |
676 | 683 | ||
677 | return GNUNET_OK; | 684 | return GNUNET_OK; |
678 | } | 685 | } |
679 | 686 | ||
680 | /** | 687 | /** |
681 | * Handle a `struct FingerRouteMessage`. | 688 | * Handle a `struct FingerSetupMessage` from a GNUNET_MESSAGE_TYPE_WDHT_NEIGHBOUR_FIND |
689 | * message. | ||
682 | * | 690 | * |
683 | * @param cls closure (NULL) | 691 | * @param cls closure (NULL) |
684 | * @param peer sender identity | 692 | * @param peer sender identity |
685 | * @param message the finger route message | 693 | * @param message the finger setup message |
686 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 694 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
687 | */ | 695 | */ |
688 | static int | 696 | static int |
@@ -692,7 +700,97 @@ handle_dht_p2p_neighbour_find (void *cls, | |||
692 | { | 700 | { |
693 | const struct FingerSetupMessage *fsm; | 701 | const struct FingerSetupMessage *fsm; |
694 | 702 | ||
695 | fsm = (const struct *) message; | 703 | fsm = (const struct FingerSetupMessage *) message; |
704 | |||
705 | return GNUNET_OK; | ||
706 | } | ||
707 | |||
708 | /** | ||
709 | * Handle a `struct FingerSetupResponseMessage` from a GNUNET_MESSAGE_TYPE_WDHT_NEIGHBOUR_FIND | ||
710 | * message. | ||
711 | * | ||
712 | * @param cls closure (NULL) | ||
713 | * @param peer sender identity | ||
714 | * @param message the finger setup response message | ||
715 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
716 | */ | ||
717 | static int | ||
718 | handle_dht_p2p_neighbour_found (void *cls, | ||
719 | const struct GNUNET_PeerIdentity *peer, | ||
720 | const struct GNUNET_MessageHeader *message) | ||
721 | { | ||
722 | const struct FingerSetupResponseMessage *fsrm; | ||
723 | |||
724 | fsrm = (const struct FingerSetupResponseMessage *) message; | ||
725 | |||
726 | return GNUNET_OK; | ||
727 | } | ||
728 | |||
729 | /** | ||
730 | * Handle a `struct PeerGetMessage`. | ||
731 | * | ||
732 | * @param cls closure (NULL) | ||
733 | * @param peer sender identity | ||
734 | * @param message the peer get message | ||
735 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
736 | */ | ||
737 | static int | ||
738 | handle_dht_p2p_peer_get (void *cls, | ||
739 | const struct GNUNET_PeerIdentity *peer, | ||
740 | const struct GNUNET_MessageHeader *message) | ||
741 | { | ||
742 | const struct PeerGetMessage *pgm; | ||
743 | |||
744 | pgm = (const struct PeerGetMessage *) message; | ||
745 | |||
746 | /* | ||
747 | * steps : | ||
748 | * 1 extract the result | ||
749 | * 2 create a peerGetResult struct | ||
750 | * 3 send it using the good trail | ||
751 | * | ||
752 | * What do i do when i don't have the key/value? | ||
753 | */ | ||
754 | |||
755 | return GNUNET_OK; | ||
756 | } | ||
757 | |||
758 | /** | ||
759 | * Handle a `struct PeerGetResultMessage`. | ||
760 | * | ||
761 | * @param cls closure (NULL) | ||
762 | * @param peer sender identity | ||
763 | * @param message the peer get result message | ||
764 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
765 | */ | ||
766 | static int | ||
767 | handle_dht_p2p_peer_get_result (void *cls, | ||
768 | const struct GNUNET_PeerIdentity *peer, | ||
769 | const struct GNUNET_MessageHeader *message) | ||
770 | { | ||
771 | const struct PeerGetResultMessage *pgrm; | ||
772 | |||
773 | pgrm = (const struct PeerGetResultMessage *) message; | ||
774 | |||
775 | return GNUNET_OK; | ||
776 | } | ||
777 | |||
778 | /** | ||
779 | * Handle a `struct PeerPutMessage`. | ||
780 | * | ||
781 | * @param cls closure (NULL) | ||
782 | * @param peer sender identity | ||
783 | * @param message the peer put message | ||
784 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
785 | */ | ||
786 | static int | ||
787 | handle_dht_p2p_peer_put (void *cls, | ||
788 | const struct GNUNET_PeerIdentity *peer, | ||
789 | const struct GNUNET_MessageHeader *message) | ||
790 | { | ||
791 | const struct PeerGetResultMessage *pgrm; | ||
792 | |||
793 | pgrm = (const struct PeerGetResultMessage *) message; | ||
696 | 794 | ||
697 | return GNUNET_OK; | 795 | return GNUNET_OK; |
698 | } | 796 | } |
@@ -720,9 +818,18 @@ GDS_NEIGHBOURS_init (void) | |||
720 | { &handle_dht_p2p_neighbour_find, | 818 | { &handle_dht_p2p_neighbour_find, |
721 | GNUNET_MESSAGE_TYPE_WDHT_NEIGHBOUR_FIND, | 819 | GNUNET_MESSAGE_TYPE_WDHT_NEIGHBOUR_FIND, |
722 | sizeof (struct FingerSetupMessage) }, | 820 | sizeof (struct FingerSetupMessage) }, |
723 | { &handle_dht_p2p_neighbour_find, | 821 | { &handle_dht_p2p_neighbour_found, |
724 | GNUNET_MESSAGE_TYPE_WDHT_NEIGHBOUR_FOUND, | 822 | GNUNET_MESSAGE_TYPE_WDHT_NEIGHBOUR_FOUND, |
725 | sizeof (struct FingerSetupMessage) }, | 823 | sizeof (struct FingerSetupResponseMessage) }, |
824 | { &handle_dht_p2p_peer_get, | ||
825 | GNUNET_MESSAGE_TYPE_WDHT_GET, | ||
826 | sizeof (struct PeerGetMessage) }, | ||
827 | { &handle_dht_p2p_peer_get_result, | ||
828 | GNUNET_MESSAGE_TYPE_WDHT_GET_RESULT, | ||
829 | 0}, | ||
830 | { &handle_dht_p2p_peer_put, | ||
831 | GNUNET_MESSAGE_TYPE_WDHT_PUT, | ||
832 | 0}, | ||
726 | {NULL, 0, 0} | 833 | {NULL, 0, 0} |
727 | }; | 834 | }; |
728 | 835 | ||
@@ -738,7 +845,9 @@ GDS_NEIGHBOURS_init (void) | |||
738 | if (NULL == core_api) | 845 | if (NULL == core_api) |
739 | return GNUNET_SYSERR; | 846 | return GNUNET_SYSERR; |
740 | 847 | ||
741 | friend_peermap = GNUNET_CONTAINER_multipeermap_create (256, GNUNET_NO); | 848 | fingers_peermap = GNUNET_CONTAINER_multipeermap_create (256, GNUNET_NO); |
849 | successors_peermap = GNUNET_CONTAINER_multipeermap_create (256, GNUNET_NO); | ||
850 | |||
742 | return GNUNET_OK; | 851 | return GNUNET_OK; |
743 | } | 852 | } |
744 | 853 | ||