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_enc.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"
64 GMCH_get_id (const struct MeshChannel *ch);
67 * Get the channel tunnel.
69 * @param ch Channel to get the tunnel from.
71 * @return tunnel of the channel.
74 GMCH_get_tunnel (const struct MeshChannel *ch);
77 * Get free buffer space towards the client on a specific channel.
80 * @param fwd Is query about FWD traffic?
82 * @return Free buffer space [0 - 64]
85 GMCH_get_buffer (struct MeshChannel *ch, int fwd);
88 * Is the root client for this channel on this peer?
91 * @param fwd Is this for fwd traffic?
93 * @return GNUNET_YES in case it is.
96 GMCH_is_origin (struct MeshChannel *ch, int fwd);
99 * Is the destination client for this channel on this peer?
102 * @param fwd Is this for fwd traffic?
104 * @return GNUNET_YES in case it is.
107 GMCH_is_terminal (struct MeshChannel *ch, int fwd);
110 * Send an end-to-end ACK message for the most recent in-sequence payload.
112 * If channel is not reliable, do nothing.
114 * @param ch Channel this is about.
115 * @param fwd Is for FWD traffic? (ACK dest->owner)
118 GMCH_send_ack (struct MeshChannel *ch, int fwd);
121 * Send data on a channel.
123 * If the destination is local, send it to client, otherwise encrypt and
127 * @param msg Message.
128 * @param fwd Is this a fwd (root->dest) message?
131 GMCH_send_data (struct MeshChannel *ch,
132 const struct GNUNET_MESH_Data *msg,
136 * Notify the destination client that a new incoming channel was created.
138 * @param ch Channel that was created.
141 GMCH_send_create (struct MeshChannel *ch);
144 * Notify a client that the channel is no longer valid.
146 * @param ch Channel that is destroyed.
149 GMCH_send_destroy (struct MeshChannel *ch);
157 GMCH_debug (struct MeshChannel *ch);
160 * Handle an ACK given by a client.
162 * Mark client as ready and send him any buffered data we could have for him.
165 * @param fwd Is this a "FWD ACK"? (FWD ACKs are sent by root and go BCK)
168 GMCH_handle_local_ack (struct MeshChannel *ch, int fwd);
171 * Handle data given by a client.
173 * Check whether the client is allowed to send in this tunnel, save if channel
174 * is reliable and send an ACK to the client if there is still buffer space
178 * @param fwd Is this a FWD data?
180 * @return GNUNET_OK if everything goes well, GNUNET_SYSERR in case of en error.
183 GMCH_handle_local_data (struct MeshChannel *ch,
184 struct MeshClient *c,
185 struct GNUNET_MessageHeader *message,
189 * Handle a channel destroy requested by a client.
191 * Destroy the channel and the tunnel in case this was the last channel.
194 * @param c Client that requested the destruction (to avoid notifying him).
195 * @param chid Channel ID used.
198 GMCH_handle_local_destroy (struct MeshChannel *ch,
199 struct MeshClient *c,
200 MESH_ChannelNumber chid);
203 * Handler for mesh network payload traffic.
205 * @param ch Channel for the message.
206 * @param message Unencryted data message.
207 * @param fwd Is this FWD traffic? GNUNET_YES : GNUNET_NO;
210 GMCH_handle_data (struct MeshChannel *ch,
211 const struct GNUNET_MESH_Data *msg,
215 * Handler for mesh network traffic end-to-end ACKs.
217 * @param t Tunnel on which we got this message.
218 * @param message Data message.
219 * @param fwd Is this a fwd ACK? (dest->orig)
222 GMCH_handle_data_ack (struct MeshChannel *ch,
223 const struct GNUNET_MESH_DataACK *msg,
227 * Handler for channel create messages.
229 * @param t Tunnel this channel is to be created in.
230 * @param msg Message.
231 * @param fwd Is this FWD traffic? GNUNET_YES : GNUNET_NO;
234 GMCH_handle_create (const struct GNUNET_MESH_ChannelCreate *msg,
238 * Handler for channel ack messages.
240 * @param t Tunnel this channel is to be created in.
241 * @param msg Message.
242 * @param fwd Is this FWD traffic? GNUNET_YES : GNUNET_NO;
245 GMCH_handle_ack (struct MeshChannel *ch,
246 const struct GNUNET_MESH_ChannelManage *msg,
250 * Handler for channel destroy messages.
252 * @param t Tunnel this channel is to be destroyed of.
253 * @param msg Message.
254 * @param fwd Is this FWD traffic? GNUNET_YES : GNUNET_NO;
257 GMCH_handle_destroy (struct MeshChannel *ch,
258 const struct GNUNET_MESH_ChannelManage *msg,
262 * Sends an already built message on a channel.
264 * If the channel is on a loopback tunnel, notifies the appropriate destination
267 * On a normal channel passes the message to the tunnel for encryption and
268 * sending on a connection.
270 * @param message Message to send. Function makes a copy of it.
271 * @param ch Channel on which this message is transmitted.
272 * @param fwd Is this a fwd message?
275 GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
276 struct MeshChannel *ch, int fwd);
279 #if 0 /* keep Emacsens' auto-indent happy */
286 /* ifndef GNUNET_SERVICE_MESH_CHANNEL_H */
288 /* end of gnunet-service-mesh_channel.h */