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_connection.h
23 * @brief mesh service; dealing with connections
24 * @author Bartlomiej Polot
26 * All functions in this file should use the prefix GMC (Gnunet Mesh Connection)
29 #ifndef GNUNET_SERVICE_MESH_CONNECTION_H
30 #define GNUNET_SERVICE_MESH_CONNECTION_H
35 #if 0 /* keep Emacsens' auto-indent happy */
40 #include "gnunet_util_lib.h"
43 * Struct containing all information regarding a connection to a peer.
45 struct MeshConnection;
48 * Initialize the connections subsystem
50 * @param c Configuration handle.
53 GMC_init (const struct GNUNET_CONFIGURATION_Handle *c);
56 * Shut down the connections subsystem.
62 * Create a connection.
64 * @param cid Connection ID.
66 struct MeshConnection *
67 GMC_new (const struct GNUNET_HashCode *cid);
70 * Connection is no longer needed: destroy it and remove from tunnel.
72 * @param c Connection to destroy.
75 GMC_destroy (struct MeshConnection *c);
78 * Count connections in a DLL.
81 GMC_count (const struct MeshConnection *head);
84 * Send FWD keepalive packets for a connection.
86 * @param cls Closure (connection for which to send the keepalive).
87 * @param tc Notification context.
90 GMC_fwd_keepalive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
93 * Send BCK keepalive packets for a connection.
95 * @param cls Closure (connection for which to send the keepalive).
96 * @param tc Notification context.
99 GMC_bck_keepalive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
103 * Change the tunnel state.
105 * @param c Connection whose state to change.
106 * @param state New state.
109 GMC_change_state (struct MeshConnection* c, enum MeshConnectionState state);
112 * Iterator to notify all connections of a broken link. Mark connections
113 * to destroy after all traffic has been sent.
115 * @param cls Closure (peer disconnected).
116 * @param key Current key code (tid).
117 * @param value Value in the hash map (connection).
119 * @return GNUNET_YES if we should continue to iterate,
123 GMC_notify_broken (void *cls,
124 const struct GNUNET_HashCode *key,
128 * @brief Queue and pass message to core when possible.
130 * @param cls Closure (@c type dependant). It will be used by queue_send to
131 * build the message to be sent if not already prebuilt.
132 * @param type Type of the message, 0 for a raw message.
133 * @param size Size of the message.
134 * @param c Connection this message belongs to (cannot be NULL).
135 * @param ch Channel this message belongs to, if applicable (otherwise NULL).
136 * @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!)
139 GMC_queue_add (void* cls,
142 struct MeshConnection* c,
143 struct MeshChannel* ch,
148 * Free a transmission that was already queued with all resources
149 * associated to the request.
151 * @param queue Queue handler to cancel.
152 * @param clear_cls Is it necessary to free associated cls?
155 GMC_queue_destroy (struct MeshPeerQueue *queue, int clear_cls);
159 * Core callback to write a queued packet to core buffer
161 * @param cls Closure (peer info).
162 * @param size Number of bytes available in buf.
163 * @param buf Where the to write the message.
165 * @return number of bytes written to buf
168 GMC_queue_send (void *cls, size_t size, void *buf);
173 * Is this peer the first one on the connection?
175 * @param c Connection.
176 * @param fwd Is this about fwd traffic?
178 * @return GNUNET_YES if origin, GNUNET_NO if relay/terminal.
181 GMC_is_origin (struct MeshConnection *c, int fwd);
184 * Is this peer the last one on the connection?
186 * @param c Connection.
187 * @param fwd Is this about fwd traffic?
188 * Note that the ROOT is the terminal for BCK traffic!
190 * @return GNUNET_YES if terminal, GNUNET_NO if relay/origin.
193 GMC_is_terminal (struct MeshConnection *c, int fwd);
197 #if 0 /* keep Emacsens' auto-indent happy */
204 /* ifndef GNUNET_SERVICE_MESH_CONNECTION_H */
206 /* end of gnunet-service-mesh_connection.h */