diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-01-25 22:25:48 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-01-25 22:25:48 +0100 |
commit | 519cc35772b40b7966cc7c3bb03d5961f6f265d1 (patch) | |
tree | 0bc242a8760953bd28d12965892ec4542c285629 /src/transport/transport_api2_communication.c | |
parent | 392b3c355586179fdce6a565c467eeba96027bc5 (diff) | |
download | gnunet-519cc35772b40b7966cc7c3bb03d5961f6f265d1.tar.gz gnunet-519cc35772b40b7966cc7c3bb03d5961f6f265d1.zip |
more on backchannel logic
Diffstat (limited to 'src/transport/transport_api2_communication.c')
-rw-r--r-- | src/transport/transport_api2_communication.c | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/src/transport/transport_api2_communication.c b/src/transport/transport_api2_communication.c index a816ecb67..ee1c788e5 100644 --- a/src/transport/transport_api2_communication.c +++ b/src/transport/transport_api2_communication.c | |||
@@ -22,6 +22,8 @@ | |||
22 | * @file transport/transport_api2_communication.c | 22 | * @file transport/transport_api2_communication.c |
23 | * @brief implementation of the gnunet_transport_communication_service.h API | 23 | * @brief implementation of the gnunet_transport_communication_service.h API |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * | ||
26 | * FIXME: handling of messages for "notify_cb" not implemented! | ||
25 | */ | 27 | */ |
26 | #include "platform.h" | 28 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
@@ -618,15 +620,8 @@ static int | |||
618 | check_send_msg (void *cls, | 620 | check_send_msg (void *cls, |
619 | const struct GNUNET_TRANSPORT_SendMessageTo *smt) | 621 | const struct GNUNET_TRANSPORT_SendMessageTo *smt) |
620 | { | 622 | { |
621 | uint16_t len = ntohs (smt->header.size) - sizeof (*smt); | ||
622 | const struct GNUNET_MessageHeader *mh = (const struct GNUNET_MessageHeader *) &smt[1]; | ||
623 | |||
624 | (void) cls; | 623 | (void) cls; |
625 | if (ntohs (mh->size) != len) | 624 | GNUNET_MQ_check_boxed_message (smt); |
626 | { | ||
627 | GNUNET_break (0); | ||
628 | return GNUNET_SYSERR; | ||
629 | } | ||
630 | return GNUNET_OK; | 625 | return GNUNET_OK; |
631 | } | 626 | } |
632 | 627 | ||
@@ -733,6 +728,40 @@ handle_send_msg (void *cls, | |||
733 | 728 | ||
734 | 729 | ||
735 | /** | 730 | /** |
731 | * Transport service gives us backchannel message. Check if @a bi | ||
732 | * is well-formed. | ||
733 | * | ||
734 | * @param cls our `struct GNUNET_TRANSPORT_CommunicatorHandle *` | ||
735 | * @param bi the backchannel message | ||
736 | * @return #GNUNET_OK if @a smt is well-formed | ||
737 | */ | ||
738 | static int | ||
739 | check_backchannel_incoming (void *cls, | ||
740 | const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi) | ||
741 | { | ||
742 | (void) cls; | ||
743 | GNUNET_MQ_check_boxed_message (bi); | ||
744 | return GNUNET_OK; | ||
745 | } | ||
746 | |||
747 | |||
748 | /** | ||
749 | * Transport service gives us backchannel message. Handle it. | ||
750 | * | ||
751 | * @param cls our `struct GNUNET_TRANSPORT_CommunicatorHandle *` | ||
752 | * @param bi the backchannel message | ||
753 | */ | ||
754 | static void | ||
755 | handle_backchannel_incoming (void *cls, | ||
756 | const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi) | ||
757 | { | ||
758 | struct GNUNET_TRANSPORT_CommunicatorHandle *ch = cls; | ||
759 | |||
760 | // FIXME: handle bi! | ||
761 | } | ||
762 | |||
763 | |||
764 | /** | ||
736 | * (re)connect our communicator to the transport service | 765 | * (re)connect our communicator to the transport service |
737 | * | 766 | * |
738 | * @param ch handle to reconnect | 767 | * @param ch handle to reconnect |
@@ -753,7 +782,10 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch) | |||
753 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG, | 782 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG, |
754 | struct GNUNET_TRANSPORT_SendMessageTo, | 783 | struct GNUNET_TRANSPORT_SendMessageTo, |
755 | ch), | 784 | ch), |
756 | // FIXME: handle backchannel notifications! | 785 | GNUNET_MQ_hd_var_size (backchannel_incoming, |
786 | GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING, | ||
787 | struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming, | ||
788 | ch), | ||
757 | GNUNET_MQ_handler_end() | 789 | GNUNET_MQ_handler_end() |
758 | }; | 790 | }; |
759 | struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam; | 791 | struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam; |