3 This file is part of GNUnet.
4 Copyright (C) 2001-2017 GNUnet e.V.
6 GNUnet is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 3, or (at your
9 option) any later version.
11 GNUnet is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNUnet; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
23 * @file cadet/gnunet-service-cadet-new_channel.h
24 * @brief GNUnet CADET service with encryption
25 * @author Bartlomiej Polot
26 * @author Christian Grothoff
28 #ifndef GNUNET_SERVICE_CADET_CHANNEL_H
29 #define GNUNET_SERVICE_CADET_CHANNEL_H
31 #include "gnunet-service-cadet-new.h"
32 #include "gnunet-service-cadet-new_peer.h"
36 * A channel is a bidirectional connection between two CADET
37 * clients. Communiation can be reliable, unreliable, in-order
38 * or out-of-order. One client is the "local" client, this
39 * one initiated the connection. The other client is the
40 * "incoming" client, this one listened on a port to accept
41 * the connection from the "local" client.
47 * Get the static string for identification of the channel.
51 * @return Static string with the channel IDs.
54 GCCH_2s (const struct CadetChannel *ch);
61 * @param level Debug level to use.
64 GCCH_debug (struct CadetChannel *ch,
65 enum GNUNET_ErrorType level);
69 * Get the channel's public ID.
73 * @return ID used to identify the channel with the remote peer.
75 struct GNUNET_CADET_ChannelTunnelNumber
76 GCCH_get_id (const struct CadetChannel *ch);
80 * Create a new channel.
82 * @param owner local client owning the channel
83 * @param owner_id local chid of this channel at the @a owner
84 * @param destination peer to which we should build the channel
85 * @param port desired port at @a destination
86 * @param options options for the channel
87 * @return handle to the new channel
90 GCCH_channel_local_new (struct CadetClient *owner,
91 struct GNUNET_CADET_ClientChannelNumber owner_id,
92 struct CadetPeer *destination,
93 const struct GNUNET_HashCode *port,
98 * A client is bound to the port that we have a channel
99 * open to. Send the acknowledgement for the connection
100 * request and establish the link with the client.
102 * @param ch open incoming channel
103 * @param c client listening on the respective port
106 GCCH_bind (struct CadetChannel *ch,
107 struct CadetClient *c);
111 * Destroy locally created channel. Called by the
112 * local client, so no need to tell the client.
114 * @param ch channel to destroy
117 GCCH_channel_local_destroy (struct CadetChannel *ch);
121 * Create a new channel based on a request coming in over the network.
123 * @param t tunnel to the remote peer
124 * @param chid identifier of this channel in the tunnel
125 * @param origin peer to who initiated the channel
126 * @param port desired local port
127 * @param options options for the channel
128 * @return handle to the new channel
130 struct CadetChannel *
131 GCCH_channel_incoming_new (struct CadetTunnel *t,
132 struct GNUNET_CADET_ChannelTunnelNumber chid,
133 const struct GNUNET_HashCode *port,
138 * Destroy channel that was incoming. Called by the
139 * local client, so no need to tell the client.
141 * @param ch channel to destroy
144 GCCH_channel_incoming_destroy (struct CadetChannel *ch);
148 * Destroy channel, based on the other peer closing the
149 * connection. Also needs to remove this channel from
152 * FIXME: need to make it possible to defer destruction until we have
153 * received all messages up to the destroy, and right now the destroy
154 * message (and this API) fails to give is the information we need!
156 * FIXME: also need to know if the other peer got a destroy from
159 * @param ch channel to destroy
162 GCCH_channel_remote_destroy (struct CadetChannel *ch);
166 * Handle data given by a client.
168 * Check whether the client is allowed to send in this tunnel, save if
169 * channel is reliable and send an ACK to the client if there is still
170 * buffer space in the tunnel.
173 * @param message payload to transmit.
174 * @return #GNUNET_OK if everything goes well,
175 * #GNUNET_SYSERR in case of an error.
178 GCCH_handle_local_data (struct CadetChannel *ch,
179 const struct GNUNET_MessageHeader *message);
183 * Handle ACK from client on local channel.
185 * @param ch channel to destroy
188 GCCH_handle_local_ack (struct CadetChannel *ch);