diff options
author | Bart Polot <bart.polot+voyager@gmail.com> | 2017-01-27 04:49:52 +0100 |
---|---|---|
committer | Bart Polot <bart.polot+voyager@gmail.com> | 2017-01-27 04:49:52 +0100 |
commit | 53dae581714145eeabdaa6239627dcc70ebe8567 (patch) | |
tree | 81c645115fe7c3873a61c90a632717b5af6925f1 /src/include/gnunet_cadet_service.h | |
parent | 356cd09ec4f7d2c02300d5eae8bec8e6b8e49635 (diff) | |
download | gnunet-53dae581714145eeabdaa6239627dcc70ebe8567.tar.gz gnunet-53dae581714145eeabdaa6239627dcc70ebe8567.zip |
- third (and hopefully final) draft for CADET API
Diffstat (limited to 'src/include/gnunet_cadet_service.h')
-rw-r--r-- | src/include/gnunet_cadet_service.h | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/include/gnunet_cadet_service.h b/src/include/gnunet_cadet_service.h index 5d6e1c1d1..99d74f223 100644 --- a/src/include/gnunet_cadet_service.h +++ b/src/include/gnunet_cadet_service.h | |||
@@ -699,6 +699,7 @@ GC_u2h (uint32_t port); | |||
699 | /** | 699 | /** |
700 | * Method called whenever a given peer connects in MQ-based CADET. | 700 | * Method called whenever a given peer connects in MQ-based CADET. |
701 | * | 701 | * |
702 | * @param cls Closure from @a GNUNET_CADET_open_porT. | ||
702 | * @param channel New handle to the channel. | 703 | * @param channel New handle to the channel. |
703 | * @param source Peer that started this channel. | 704 | * @param source Peer that started this channel. |
704 | * | 705 | * |
@@ -707,7 +708,8 @@ GC_u2h (uint32_t port); | |||
707 | * - Each the @a GNUNET_MQ_MessageCallback for each message. | 708 | * - Each the @a GNUNET_MQ_MessageCallback for each message. |
708 | */ | 709 | */ |
709 | typedef void * | 710 | typedef void * |
710 | (*GNUNET_CADET_ConnectEventHandler) (struct GNUNET_CADET_Channel *channel, | 711 | (*GNUNET_CADET_ConnectEventHandler) (void *cls, |
712 | struct GNUNET_CADET_Channel *channel, | ||
711 | const struct GNUNET_PeerIdentity *source); | 713 | const struct GNUNET_PeerIdentity *source); |
712 | 714 | ||
713 | 715 | ||
@@ -719,14 +721,31 @@ typedef void * | |||
719 | * It should clean up any associated state, including cancelling any pending | 721 | * It should clean up any associated state, including cancelling any pending |
720 | * transmission on this channel. | 722 | * transmission on this channel. |
721 | * | 723 | * |
722 | * FIXME: what about MQ-pending transmissions? | 724 | * @param cls Channel closure. |
725 | * @param channel Connection to the other end (henceforth invalid). | ||
726 | */ | ||
727 | typedef void | ||
728 | (*GNUNET_CADET_DisconnectEventHandler) (void *cls, | ||
729 | const struct GNUNET_CADET_Channel *channel); | ||
730 | |||
731 | |||
732 | /** | ||
733 | * Function called whenever an MQ-channel's transmission window size changes. | ||
734 | * | ||
735 | * The first callback in an outgoing channel will be with a non-zero value | ||
736 | * and will mean the channel is connected to the destination. | ||
737 | * | ||
738 | * For an incoming channel it will be called immediately after the | ||
739 | * @a GNUNET_CADET_ConnectEventHandler, also with a non-zero value. | ||
723 | * | 740 | * |
724 | * @param cls Channel closure. | 741 | * @param cls Channel closure. |
725 | * @param channel Connection to the other end (henceforth invalid). | 742 | * @param channel Connection to the other end (henceforth invalid). |
743 | * @param window_size New window size. | ||
726 | */ | 744 | */ |
727 | typedef void | 745 | typedef void |
728 | (GNUNET_CADET_DisconnectEventHandler) (void *cls, | 746 | (*GNUNET_CADET_WindowSizeEventHandler) (void *cls, |
729 | const struct GNUNET_CADET_Channel *channel); | 747 | const struct GNUNET_CADET_Channel *channel, |
748 | int window_size); | ||
730 | 749 | ||
731 | 750 | ||
732 | /** | 751 | /** |
@@ -746,7 +765,8 @@ GNUNET_CADET_connecT (const struct GNUNET_CONFIGURATION_Handle *cfg); | |||
746 | * @param h CADET handle. | 765 | * @param h CADET handle. |
747 | * @param port Hash identifying the port. | 766 | * @param port Hash identifying the port. |
748 | * @param connects Function called when an incoming channel is connected. | 767 | * @param connects Function called when an incoming channel is connected. |
749 | * FIXME: add connects_cls to give the incoming handler a closure? | 768 | * @param connects_cls Closure for the @a connects handler. |
769 | * @param window_changes Function called when the transmit window size changes. | ||
750 | * @param disconnects Function called when a channel is disconnected. | 770 | * @param disconnects Function called when a channel is disconnected. |
751 | * @param handlers Callbacks for messages we care about, NULL-terminated. | 771 | * @param handlers Callbacks for messages we care about, NULL-terminated. |
752 | * | 772 | * |
@@ -756,6 +776,8 @@ struct GNUNET_CADET_Port * | |||
756 | GNUNET_CADET_open_porT (struct GNUNET_CADET_Handle *h, | 776 | GNUNET_CADET_open_porT (struct GNUNET_CADET_Handle *h, |
757 | const struct GNUNET_HashCode *port, | 777 | const struct GNUNET_HashCode *port, |
758 | GNUNET_CADET_ConnectEventHandler connects, | 778 | GNUNET_CADET_ConnectEventHandler connects, |
779 | void * connects_cls, | ||
780 | GNUNET_CADET_WindowSizeEventHandler window_changes, | ||
759 | GNUNET_CADET_DisconnectEventHandler disconnects, | 781 | GNUNET_CADET_DisconnectEventHandler disconnects, |
760 | const struct GNUNET_MQ_MessageHandler *handlers); | 782 | const struct GNUNET_MQ_MessageHandler *handlers); |
761 | 783 | ||
@@ -774,6 +796,7 @@ GNUNET_CADET_open_porT (struct GNUNET_CADET_Handle *h, | |||
774 | * @param destination Peer identity the channel should go to. | 796 | * @param destination Peer identity the channel should go to. |
775 | * @param port Identification of the destination port. | 797 | * @param port Identification of the destination port. |
776 | * @param options CadetOption flag field, with all desired option bits set to 1. | 798 | * @param options CadetOption flag field, with all desired option bits set to 1. |
799 | * @param window_changes Function called when the transmit window size changes. | ||
777 | * @param disconnects Function called when the channel is disconnected. | 800 | * @param disconnects Function called when the channel is disconnected. |
778 | * @param handlers Callbacks for messages we care about, NULL-terminated. | 801 | * @param handlers Callbacks for messages we care about, NULL-terminated. |
779 | * | 802 | * |
@@ -785,6 +808,7 @@ GNUNET_CADET_channel_creatE (struct GNUNET_CADET_Handle *h, | |||
785 | const struct GNUNET_PeerIdentity *destination, | 808 | const struct GNUNET_PeerIdentity *destination, |
786 | const struct GNUNET_HashCode *port, | 809 | const struct GNUNET_HashCode *port, |
787 | enum GNUNET_CADET_ChannelOption options, | 810 | enum GNUNET_CADET_ChannelOption options, |
811 | GNUNET_CADET_WindowSizeEventHandler window_changes, | ||
788 | GNUNET_CADET_DisconnectEventHandler disconnects, | 812 | GNUNET_CADET_DisconnectEventHandler disconnects, |
789 | const struct GNUNET_MQ_MessageHandler *handlers); | 813 | const struct GNUNET_MQ_MessageHandler *handlers); |
790 | 814 | ||
@@ -795,8 +819,6 @@ GNUNET_CADET_channel_creatE (struct GNUNET_CADET_Handle *h, | |||
795 | * @param channel The channel handle from which to get the MQ. | 819 | * @param channel The channel handle from which to get the MQ. |
796 | * | 820 | * |
797 | * @return NULL if @a channel is not yet connected. | 821 | * @return NULL if @a channel is not yet connected. |
798 | * FIXME: provide an mq before a channel is connected? | ||
799 | * provide a callback to notify a client a channel connected? | ||
800 | */ | 822 | */ |
801 | struct GNUNET_MQ_Handle * | 823 | struct GNUNET_MQ_Handle * |
802 | GNUNET_CADET_get_mq (const struct GNUNET_CADET_Channel *channel); | 824 | GNUNET_CADET_get_mq (const struct GNUNET_CADET_Channel *channel); |