diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-20 11:28:30 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-20 11:28:30 +0100 |
commit | 6b25953f27639c7b87c98a6cb55fd173c9dc5016 (patch) | |
tree | 4117a8906544fa2366debd61abd6d20fd1362e6b /src/cadet | |
parent | 7d96a8234bbd9d9a4dc431c52d92ebb604084c70 (diff) | |
download | gnunet-6b25953f27639c7b87c98a6cb55fd173c9dc5016.tar.gz gnunet-6b25953f27639c7b87c98a6cb55fd173c9dc5016.zip |
pass messages from tunnel to channel
Diffstat (limited to 'src/cadet')
-rw-r--r-- | src/cadet/cadet_protocol.h | 4 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_channel.c | 47 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_channel.h | 35 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_tunnels.c | 58 |
4 files changed, 128 insertions, 16 deletions
diff --git a/src/cadet/cadet_protocol.h b/src/cadet/cadet_protocol.h index f85ef17ae..070be3e28 100644 --- a/src/cadet/cadet_protocol.h +++ b/src/cadet/cadet_protocol.h | |||
@@ -496,7 +496,7 @@ struct GNUNET_CADET_ChannelAppDataMessage | |||
496 | /** | 496 | /** |
497 | * ID of the channel | 497 | * ID of the channel |
498 | */ | 498 | */ |
499 | struct GNUNET_CADET_ChannelTunnelNumber gid; | 499 | struct GNUNET_CADET_ChannelTunnelNumber chid; |
500 | 500 | ||
501 | /** | 501 | /** |
502 | * Payload follows | 502 | * Payload follows |
@@ -517,7 +517,7 @@ struct GNUNET_CADET_ChannelDataAckMessage | |||
517 | /** | 517 | /** |
518 | * ID of the channel | 518 | * ID of the channel |
519 | */ | 519 | */ |
520 | struct GNUNET_CADET_ChannelTunnelNumber gid; | 520 | struct GNUNET_CADET_ChannelTunnelNumber chid; |
521 | 521 | ||
522 | /** | 522 | /** |
523 | * Bitfield of already-received messages past @e mid. | 523 | * Bitfield of already-received messages past @e mid. |
diff --git a/src/cadet/gnunet-service-cadet-new_channel.c b/src/cadet/gnunet-service-cadet-new_channel.c index 70f16dbe6..c6adc351b 100644 --- a/src/cadet/gnunet-service-cadet-new_channel.c +++ b/src/cadet/gnunet-service-cadet-new_channel.c | |||
@@ -602,7 +602,7 @@ send_channel_ack (struct CadetChannel *ch) | |||
602 | 602 | ||
603 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK); | 603 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK); |
604 | msg.header.size = htons (sizeof (msg)); | 604 | msg.header.size = htons (sizeof (msg)); |
605 | msg.gid = ch->chid; | 605 | msg.chid = ch->chid; |
606 | msg.mid.mid = htonl (ntohl (ch->mid_recv.mid) - 1); | 606 | msg.mid.mid = htonl (ntohl (ch->mid_recv.mid) - 1); |
607 | msg.futures = GNUNET_htonll (ch->mid_futures); | 607 | msg.futures = GNUNET_htonll (ch->mid_futures); |
608 | if (NULL != ch->last_control_qe) | 608 | if (NULL != ch->last_control_qe) |
@@ -730,6 +730,47 @@ GCCH_channel_incoming_destroy (struct CadetChannel *ch) | |||
730 | 730 | ||
731 | 731 | ||
732 | /** | 732 | /** |
733 | * We got an acknowledgement for the creation of the channel | ||
734 | * (the port is open on the other side). Begin transmissions. | ||
735 | * | ||
736 | * @param ch channel to destroy | ||
737 | */ | ||
738 | void | ||
739 | GCCH_handle_channel_create_ack (struct CadetChannel *ch) | ||
740 | { | ||
741 | GNUNET_break (0); // FIXME! | ||
742 | } | ||
743 | |||
744 | |||
745 | /** | ||
746 | * We got payload data for a channel. Pass it on to the client. | ||
747 | * | ||
748 | * @param ch channel that got data | ||
749 | */ | ||
750 | void | ||
751 | GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | ||
752 | const struct GNUNET_CADET_ChannelAppDataMessage *msg) | ||
753 | { | ||
754 | GNUNET_break (0); // FIXME! | ||
755 | } | ||
756 | |||
757 | |||
758 | /** | ||
759 | * We got an acknowledgement for payload data for a channel. | ||
760 | * Possibly resume transmissions. | ||
761 | * | ||
762 | * @param ch channel that got the ack | ||
763 | * @param ack details about what was received | ||
764 | */ | ||
765 | void | ||
766 | GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch, | ||
767 | const struct GNUNET_CADET_ChannelDataAckMessage *ack) | ||
768 | { | ||
769 | GNUNET_break (0); // FIXME! | ||
770 | } | ||
771 | |||
772 | |||
773 | /** | ||
733 | * Destroy channel, based on the other peer closing the | 774 | * Destroy channel, based on the other peer closing the |
734 | * connection. Also needs to remove this channel from | 775 | * connection. Also needs to remove this channel from |
735 | * the tunnel. | 776 | * the tunnel. |
@@ -744,7 +785,7 @@ GCCH_channel_incoming_destroy (struct CadetChannel *ch) | |||
744 | * @param ch channel to destroy | 785 | * @param ch channel to destroy |
745 | */ | 786 | */ |
746 | void | 787 | void |
747 | GCCH_channel_remote_destroy (struct CadetChannel *ch) | 788 | GCCH_handle_remote_destroy (struct CadetChannel *ch) |
748 | { | 789 | { |
749 | GNUNET_break (0); // FIXME! | 790 | GNUNET_break (0); // FIXME! |
750 | } | 791 | } |
@@ -934,7 +975,7 @@ GCCH_handle_local_data (struct CadetChannel *ch, | |||
934 | crm->data_message.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA); | 975 | crm->data_message.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA); |
935 | ch->mid_send.mid = htonl (ntohl (ch->mid_send.mid) + 1); | 976 | ch->mid_send.mid = htonl (ntohl (ch->mid_send.mid) + 1); |
936 | crm->data_message.mid = ch->mid_send; | 977 | crm->data_message.mid = ch->mid_send; |
937 | crm->data_message.gid = ch->chid; | 978 | crm->data_message.chid = ch->chid; |
938 | GNUNET_memcpy (&crm[1], | 979 | GNUNET_memcpy (&crm[1], |
939 | message, | 980 | message, |
940 | payload_size); | 981 | payload_size); |
diff --git a/src/cadet/gnunet-service-cadet-new_channel.h b/src/cadet/gnunet-service-cadet-new_channel.h index 0d56d8ae0..2e1eb4115 100644 --- a/src/cadet/gnunet-service-cadet-new_channel.h +++ b/src/cadet/gnunet-service-cadet-new_channel.h | |||
@@ -30,6 +30,7 @@ | |||
30 | 30 | ||
31 | #include "gnunet-service-cadet-new.h" | 31 | #include "gnunet-service-cadet-new.h" |
32 | #include "gnunet-service-cadet-new_peer.h" | 32 | #include "gnunet-service-cadet-new_peer.h" |
33 | #include "cadet_protocol.h" | ||
33 | 34 | ||
34 | 35 | ||
35 | /** | 36 | /** |
@@ -145,6 +146,38 @@ GCCH_channel_incoming_destroy (struct CadetChannel *ch); | |||
145 | 146 | ||
146 | 147 | ||
147 | /** | 148 | /** |
149 | * We got payload data for a channel. Pass it on to the client. | ||
150 | * | ||
151 | * @param ch channel that got data | ||
152 | */ | ||
153 | void | ||
154 | GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | ||
155 | const struct GNUNET_CADET_ChannelAppDataMessage *msg); | ||
156 | |||
157 | |||
158 | /** | ||
159 | * We got an acknowledgement for payload data for a channel. | ||
160 | * Possibly resume transmissions. | ||
161 | * | ||
162 | * @param ch channel that got the ack | ||
163 | * @param ack details about what was received | ||
164 | */ | ||
165 | void | ||
166 | GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch, | ||
167 | const struct GNUNET_CADET_ChannelDataAckMessage *ack); | ||
168 | |||
169 | |||
170 | /** | ||
171 | * We got an acknowledgement for the creation of the channel | ||
172 | * (the port is open on the other side). Begin transmissions. | ||
173 | * | ||
174 | * @param ch channel to destroy | ||
175 | */ | ||
176 | void | ||
177 | GCCH_handle_channel_create_ack (struct CadetChannel *ch); | ||
178 | |||
179 | |||
180 | /** | ||
148 | * Destroy channel, based on the other peer closing the | 181 | * Destroy channel, based on the other peer closing the |
149 | * connection. Also needs to remove this channel from | 182 | * connection. Also needs to remove this channel from |
150 | * the tunnel. | 183 | * the tunnel. |
@@ -159,7 +192,7 @@ GCCH_channel_incoming_destroy (struct CadetChannel *ch); | |||
159 | * @param ch channel to destroy | 192 | * @param ch channel to destroy |
160 | */ | 193 | */ |
161 | void | 194 | void |
162 | GCCH_channel_remote_destroy (struct CadetChannel *ch); | 195 | GCCH_handle_remote_destroy (struct CadetChannel *ch); |
163 | 196 | ||
164 | 197 | ||
165 | /** | 198 | /** |
diff --git a/src/cadet/gnunet-service-cadet-new_tunnels.c b/src/cadet/gnunet-service-cadet-new_tunnels.c index 6873fb396..9b359ed58 100644 --- a/src/cadet/gnunet-service-cadet-new_tunnels.c +++ b/src/cadet/gnunet-service-cadet-new_tunnels.c | |||
@@ -35,9 +35,8 @@ | |||
35 | #include "gnunet_util_lib.h" | 35 | #include "gnunet_util_lib.h" |
36 | #include "gnunet_statistics_service.h" | 36 | #include "gnunet_statistics_service.h" |
37 | #include "gnunet_signatures.h" | 37 | #include "gnunet_signatures.h" |
38 | #include "cadet_protocol.h" | ||
39 | #include "cadet_path.h" | ||
40 | #include "gnunet-service-cadet-new.h" | 38 | #include "gnunet-service-cadet-new.h" |
39 | #include "cadet_protocol.h" | ||
41 | #include "gnunet-service-cadet-new_channel.h" | 40 | #include "gnunet-service-cadet-new_channel.h" |
42 | #include "gnunet-service-cadet-new_connection.h" | 41 | #include "gnunet-service-cadet-new_connection.h" |
43 | #include "gnunet-service-cadet-new_tunnels.h" | 42 | #include "gnunet-service-cadet-new_tunnels.h" |
@@ -1433,7 +1432,8 @@ connection_ready_cb (void *cls, | |||
1433 | ct->is_ready = GNUNET_NO; | 1432 | ct->is_ready = GNUNET_NO; |
1434 | GCC_transmit (ct->cc, | 1433 | GCC_transmit (ct->cc, |
1435 | tq->env); | 1434 | tq->env); |
1436 | tq->cont (tq->cont_cls); | 1435 | if (NULL != tq->cont) |
1436 | tq->cont (tq->cont_cls); | ||
1437 | GNUNET_free (tq); | 1437 | GNUNET_free (tq); |
1438 | } | 1438 | } |
1439 | 1439 | ||
@@ -1626,7 +1626,8 @@ check_plaintext_data (void *cls, | |||
1626 | 1626 | ||
1627 | 1627 | ||
1628 | /** | 1628 | /** |
1629 | * | 1629 | * We received payload data for a channel. Locate the channel |
1630 | * and process the data, or return an error if the channel is unknown. | ||
1630 | * | 1631 | * |
1631 | * @param cls the `struct CadetTunnel` for which we decrypted the message | 1632 | * @param cls the `struct CadetTunnel` for which we decrypted the message |
1632 | * @param msg the message we received on the tunnel | 1633 | * @param msg the message we received on the tunnel |
@@ -1636,12 +1637,27 @@ handle_plaintext_data (void *cls, | |||
1636 | const struct GNUNET_CADET_ChannelAppDataMessage *msg) | 1637 | const struct GNUNET_CADET_ChannelAppDataMessage *msg) |
1637 | { | 1638 | { |
1638 | struct CadetTunnel *t = cls; | 1639 | struct CadetTunnel *t = cls; |
1639 | GNUNET_break (0); // FIXME! | 1640 | struct CadetChannel *ch; |
1641 | |||
1642 | ch = lookup_channel (t, | ||
1643 | msg->chid); | ||
1644 | if (NULL == ch) | ||
1645 | { | ||
1646 | /* We don't know about such a channel, might have been destroyed on our | ||
1647 | end in the meantime, or never existed. Send back a DESTROY. */ | ||
1648 | GCT_send_channel_destroy (t, | ||
1649 | msg->chid); | ||
1650 | return; | ||
1651 | } | ||
1652 | GCCH_handle_channel_plaintext_data (ch, | ||
1653 | msg); | ||
1640 | } | 1654 | } |
1641 | 1655 | ||
1642 | 1656 | ||
1643 | /** | 1657 | /** |
1644 | * | 1658 | * We received an acknowledgement for data we sent on a channel. |
1659 | * Locate the channel and process it, or return an error if the | ||
1660 | * channel is unknown. | ||
1645 | * | 1661 | * |
1646 | * @param cls the `struct CadetTunnel` for which we decrypted the message | 1662 | * @param cls the `struct CadetTunnel` for which we decrypted the message |
1647 | * @param ack the message we received on the tunnel | 1663 | * @param ack the message we received on the tunnel |
@@ -1651,7 +1667,20 @@ handle_plaintext_data_ack (void *cls, | |||
1651 | const struct GNUNET_CADET_ChannelDataAckMessage *ack) | 1667 | const struct GNUNET_CADET_ChannelDataAckMessage *ack) |
1652 | { | 1668 | { |
1653 | struct CadetTunnel *t = cls; | 1669 | struct CadetTunnel *t = cls; |
1654 | GNUNET_break (0); // FIXME! | 1670 | struct CadetChannel *ch; |
1671 | |||
1672 | ch = lookup_channel (t, | ||
1673 | ack->chid); | ||
1674 | if (NULL == ch) | ||
1675 | { | ||
1676 | /* We don't know about such a channel, might have been destroyed on our | ||
1677 | end in the meantime, or never existed. Send back a DESTROY. */ | ||
1678 | GCT_send_channel_destroy (t, | ||
1679 | ack->chid); | ||
1680 | return; | ||
1681 | } | ||
1682 | GCCH_handle_channel_plaintext_data_ack (ch, | ||
1683 | ack); | ||
1655 | } | 1684 | } |
1656 | 1685 | ||
1657 | 1686 | ||
@@ -1693,7 +1722,16 @@ void | |||
1693 | GCT_send_channel_destroy (struct CadetTunnel *t, | 1722 | GCT_send_channel_destroy (struct CadetTunnel *t, |
1694 | struct GNUNET_CADET_ChannelTunnelNumber chid) | 1723 | struct GNUNET_CADET_ChannelTunnelNumber chid) |
1695 | { | 1724 | { |
1696 | GNUNET_break (0); // FIXME! | 1725 | struct GNUNET_CADET_ChannelManageMessage msg; |
1726 | |||
1727 | msg.header.size = htons (sizeof (msg)); | ||
1728 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY); | ||
1729 | msg.reserved = htonl (0); | ||
1730 | msg.chid = chid; | ||
1731 | GCT_send (t, | ||
1732 | &msg.header, | ||
1733 | NULL, | ||
1734 | NULL); | ||
1697 | } | 1735 | } |
1698 | 1736 | ||
1699 | 1737 | ||
@@ -1722,7 +1760,7 @@ handle_plaintext_channel_ack (void *cls, | |||
1722 | cm->chid); | 1760 | cm->chid); |
1723 | return; | 1761 | return; |
1724 | } | 1762 | } |
1725 | GNUNET_break (0); // FIXME! | 1763 | GCCH_handle_channel_create_ack (ch); |
1726 | } | 1764 | } |
1727 | 1765 | ||
1728 | 1766 | ||
@@ -1741,7 +1779,7 @@ handle_plaintext_channel_destroy (void *cls, | |||
1741 | struct CadetChannel *cc = lookup_channel (t, | 1779 | struct CadetChannel *cc = lookup_channel (t, |
1742 | cm->chid); | 1780 | cm->chid); |
1743 | 1781 | ||
1744 | GCCH_channel_remote_destroy (cc); | 1782 | GCCH_handle_remote_destroy (cc); |
1745 | } | 1783 | } |
1746 | 1784 | ||
1747 | 1785 | ||