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);
112 * Destroy locally created channel. Called by the
113 * local client, so no need to tell the client.
115 * @param ch channel to destroy
118 GCCH_channel_local_destroy (struct CadetChannel *ch);
122 * Create a new channel.
124 * @param t tunnel to the remote peer
125 * @param gid identifier of this channel in the tunnel
126 * @param origin peer to who initiated the channel
127 * @param port desired local port
128 * @param options options for the channel
129 * @return handle to the new channel
131 struct CadetChannel *
132 GCCH_channel_incoming_new (struct CadetTunnel *t,
133 struct GNUNET_CADET_ChannelTunnelNumber gid,
134 const struct GNUNET_HashCode *port,
139 * Destroy channel that was incoming. Called by the
140 * local client, so no need to tell the client.
142 * @param ch channel to destroy
145 GCCH_channel_incoming_destroy (struct CadetChannel *ch);
149 * Handle data given by a client.
151 * Check whether the client is allowed to send in this tunnel, save if
152 * channel is reliable and send an ACK to the client if there is still
153 * buffer space in the tunnel.
156 * @param message payload to transmit.
157 * @return #GNUNET_OK if everything goes well,
158 * #GNUNET_SYSERR in case of an error.
161 GCCH_handle_local_data (struct CadetChannel *ch,
162 const struct GNUNET_MessageHeader *message);
166 * Handle ACK from client on local channel.
168 * @param ch channel to destroy
171 GCCH_handle_local_ack (struct CadetChannel *ch);