2 This file is part of GNUnet.
3 (C) 2013 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file mesh/gnunet-service-mesh_channel.h
23 * @brief mesh service; dealing with end-to-end channels
24 * @author Bartlomiej Polot
26 * All functions in this file should use the prefix GMCH (Gnunet Mesh CHannel)
29 #ifndef GNUNET_SERVICE_MESH_CHANNEL_H
30 #define GNUNET_SERVICE_MESH_CHANNEL_H
35 #if 0 /* keep Emacsens' auto-indent happy */
41 #include "gnunet_util_lib.h"
43 #include "mesh_protocol.h"
47 * Struct containing all information regarding a channel to a remote client.
52 #include "gnunet-service-mesh_tunnel.h"
53 #include "gnunet-service-mesh_local.h"
57 * Destroy a channel and free all resources.
59 * @param ch Channel to destroy.
62 GMCH_destroy (struct MeshChannel *ch);
72 GMCH_get_id (const struct MeshChannel *ch);
75 * Get the channel tunnel.
77 * @param ch Channel to get the tunnel from.
79 * @return tunnel of the channel.
82 GMCH_get_tunnel (const struct MeshChannel *ch);
85 * Get free buffer space towards the client on a specific channel.
88 * @param fwd Is query about FWD traffic?
90 * @return Free buffer space [0 - 64]
93 GMCH_get_buffer (struct MeshChannel *ch, int fwd);
97 * Get flow control status of end point: is client allow to send?
100 * @param fwd Is query about FWD traffic? (Request root status).
102 * @return #GNUNET_YES if client is allowed to send us data.
105 GMCH_get_allowed (struct MeshChannel *ch, int fwd);
109 * Is the root client for this channel on this peer?
112 * @param fwd Is this for fwd traffic?
114 * @return #GNUNET_YES in case it is.
117 GMCH_is_origin (struct MeshChannel *ch, int fwd);
120 * Is the destination client for this channel on this peer?
123 * @param fwd Is this for fwd traffic?
125 * @return #GNUNET_YES in case it is.
128 GMCH_is_terminal (struct MeshChannel *ch, int fwd);
131 * Send an end-to-end ACK message for the most recent in-sequence payload.
133 * If channel is not reliable, do nothing.
135 * @param ch Channel this is about.
136 * @param fwd Is for FWD traffic? (ACK dest->owner)
139 GMCH_send_data_ack (struct MeshChannel *ch, int fwd);
142 * Notify the destination client that a new incoming channel was created.
144 * @param ch Channel that was created.
147 GMCH_send_create (struct MeshChannel *ch);
150 * Allow a client to send us more data, in case it was choked.
153 * @param fwd Is this about FWD traffic? (Root client).
156 GMCH_allow_client (struct MeshChannel *ch, int fwd);
164 GMCH_debug (struct MeshChannel *ch);
167 * Handle an ACK given by a client.
169 * Mark client as ready and send him any buffered data we could have for him.
172 * @param fwd Is this a "FWD ACK"? (FWD ACKs are sent by root and go BCK)
175 GMCH_handle_local_ack (struct MeshChannel *ch, int fwd);
178 * Handle data given by a client.
180 * Check whether the client is allowed to send in this tunnel, save if channel
181 * is reliable and send an ACK to the client if there is still buffer space
185 * @param c Client which sent the data.
186 * @param message Message.
187 * @param fwd Is this a FWD data?
189 * @return GNUNET_OK if everything goes well, GNUNET_SYSERR in case of en error.
192 GMCH_handle_local_data (struct MeshChannel *ch,
193 struct MeshClient *c,
194 struct GNUNET_MessageHeader *message,
198 * Handle a channel destroy requested by a client.
200 * Destroy the channel and the tunnel in case this was the last channel.
203 * @param c Client that requested the destruction (to avoid notifying him).
204 * @param is_root Is the request coming from root?
207 GMCH_handle_local_destroy (struct MeshChannel *ch,
208 struct MeshClient *c,
212 * Handle a channel create requested by a client.
214 * Create the channel and the tunnel in case this was the first0 channel.
216 * @param c Client that requested the creation (will be the root).
217 * @param msg Create Channel message.
219 * @return GNUNET_OK if everything went fine, GNUNET_SYSERR otherwise.
222 GMCH_handle_local_create (struct MeshClient *c,
223 struct GNUNET_MESH_ChannelMessage *msg);
226 * Handler for mesh network payload traffic.
228 * @param ch Channel for the message.
229 * @param msg Unencryted data message.
230 * @param fwd Is this message fwd? This only is meaningful in loopback channels.
231 * #GNUNET_YES if message is FWD on the respective channel (loopback)
232 * #GNUNET_NO if message is BCK on the respective channel (loopback)
233 * #GNUNET_SYSERR if message on a one-ended channel (remote)
236 GMCH_handle_data (struct MeshChannel *ch,
237 const struct GNUNET_MESH_Data *msg,
241 * Handler for mesh network traffic end-to-end ACKs.
243 * @param ch Channel on which we got this message.
244 * @param msg Data message.
245 * @param fwd Is this message fwd? This only is meaningful in loopback channels.
246 * #GNUNET_YES if message is FWD on the respective channel (loopback)
247 * #GNUNET_NO if message is BCK on the respective channel (loopback)
248 * #GNUNET_SYSERR if message on a one-ended channel (remote)
251 GMCH_handle_data_ack (struct MeshChannel *ch,
252 const struct GNUNET_MESH_DataACK *msg,
256 * Handler for channel create messages.
258 * Does not have fwd parameter because it's always 'FWD': channel is incoming.
260 * @param t Tunnel this channel will be in.
261 * @param msg Channel crate message.
264 GMCH_handle_create (struct MeshTunnel3 *t,
265 const struct GNUNET_MESH_ChannelCreate *msg);
268 * Handler for channel NACK messages.
270 * NACK messages always go dest -> root, no need for 'fwd' or 'msg' parameter.
275 GMCH_handle_nack (struct MeshChannel *ch);
278 * Handler for channel ack messages.
280 * @param ch Channel this channel is to be created in.
281 * @param msg Message.
282 * @param fwd Is this message fwd? This only is meaningful in loopback channels.
283 * #GNUNET_YES if message is FWD on the respective channel (loopback)
284 * #GNUNET_NO if message is BCK on the respective channel (loopback)
285 * #GNUNET_SYSERR if message on a one-ended channel (remote)
288 GMCH_handle_ack (struct MeshChannel *ch,
289 const struct GNUNET_MESH_ChannelManage *msg,
293 * Handler for channel destroy messages.
295 * @param ch Channel this channel is to be destroyed of.
296 * @param msg Message.
297 * @param fwd Is this message fwd? This only is meaningful in loopback channels.
298 * #GNUNET_YES if message is FWD on the respective channel (loopback)
299 * #GNUNET_NO if message is BCK on the respective channel (loopback)
300 * #GNUNET_SYSERR if message on a one-ended channel (remote)
303 GMCH_handle_destroy (struct MeshChannel *ch,
304 const struct GNUNET_MESH_ChannelManage *msg,
308 * Sends an already built message on a channel.
310 * If the channel is on a loopback tunnel, notifies the appropriate destination
313 * On a normal channel passes the message to the tunnel for encryption and
314 * sending on a connection.
316 * @param message Message to send. Function makes a copy of it.
317 * @param ch Channel on which this message is transmitted.
318 * @param fwd Is this a fwd message?
319 * @param retransmission Is this a retransmission? (Don't save a copy)
322 GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
323 struct MeshChannel *ch, int fwd,
327 * Get the static string for identification of the channel.
329 * @param ch Channel.i
331 * @return Static string with the channel IDs.
334 GMCH_2s (const struct MeshChannel *ch);
337 #if 0 /* keep Emacsens' auto-indent happy */
344 /* ifndef GNUNET_SERVICE_MESH_CHANNEL_H */
346 /* end of gnunet-service-mesh_channel.h */