aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh_connection.h
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-10-01 11:05:12 +0000
committerBart Polot <bart@net.in.tum.de>2013-10-01 11:05:12 +0000
commit6e0d1b08237cba5ce900a95f231cb0164ff3606f (patch)
tree60874299ba0be683c7ad515137b29d743a9054e9 /src/mesh/gnunet-service-mesh_connection.h
parent941a901163d150d701e12d9b0b85cbb582c114b6 (diff)
downloadgnunet-6e0d1b08237cba5ce900a95f231cb0164ff3606f.tar.gz
gnunet-6e0d1b08237cba5ce900a95f231cb0164ff3606f.zip
- too much uncommited work
Diffstat (limited to 'src/mesh/gnunet-service-mesh_connection.h')
-rw-r--r--src/mesh/gnunet-service-mesh_connection.h197
1 files changed, 197 insertions, 0 deletions
diff --git a/src/mesh/gnunet-service-mesh_connection.h b/src/mesh/gnunet-service-mesh_connection.h
new file mode 100644
index 000000000..a1715e3cd
--- /dev/null
+++ b/src/mesh/gnunet-service-mesh_connection.h
@@ -0,0 +1,197 @@
1/*
2 This file is part of GNUnet.
3 (C) 2013 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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.
19*/
20
21/**
22 * @file mesh/gnunet-service-mesh_connection.h
23 * @brief mesh service; dealing with connections
24 * @author Bartlomiej Polot
25 *
26 * All functions in this file should use the prefix GMC (Gnunet Mesh Connection)
27 */
28
29#ifndef GNUNET_SERVICE_MESH_CONNECTION_H
30#define GNUNET_SERVICE_MESH_CONNECTION_H
31
32#ifdef __cplusplus
33extern "C"
34{
35#if 0 /* keep Emacsens' auto-indent happy */
36}
37#endif
38#endif
39
40#include "gnunet_util_lib.h"
41
42
43struct MeshConnection;
44
45/**
46 * Initialize the connections subsystem
47 *
48 * @param c Configuration handle.
49 */
50void
51GMC_init (struct GNUNET_CONFIGURATION_Handle *c);
52
53/**
54 * Create a connection.
55 *
56 * @param cid Connection ID.
57 */
58struct MeshConnection *
59GMC_new (const struct GNUNET_HashCode *cid);
60
61/**
62 * Connection is no longer needed: destroy it and remove from tunnel.
63 *
64 * @param c Connection to destroy.
65 */
66void
67GMC_destroy (struct MeshConnection *c);
68
69/**
70 * Count connections in a DLL.
71 */
72unsigned int
73GMC_count (const struct MeshConnection *head);
74
75/**
76 * Send FWD keepalive packets for a connection.
77 *
78 * @param cls Closure (connection for which to send the keepalive).
79 * @param tc Notification context.
80 */
81void
82GMC_fwd_keepalive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
83
84/**
85 * Send BCK keepalive packets for a connection.
86 *
87 * @param cls Closure (connection for which to send the keepalive).
88 * @param tc Notification context.
89 */
90void
91GMC_bck_keepalive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
92
93
94/**
95 * Change the tunnel state.
96 *
97 * @param c Connection whose state to change.
98 * @param state New state.
99 */
100void
101GMC_change_state (struct MeshConnection* c, enum MeshConnectionState state);
102
103/**
104 * Iterator to notify all connections of a broken link. Mark connections
105 * to destroy after all traffic has been sent.
106 *
107 * @param cls Closure (peer disconnected).
108 * @param key Current key code (tid).
109 * @param value Value in the hash map (connection).
110 *
111 * @return GNUNET_YES if we should continue to iterate,
112 * GNUNET_NO if not.
113 */
114int
115GMC_notify_broken (void *cls,
116 const struct GNUNET_HashCode *key,
117 void *value);
118
119/**
120 * @brief Queue and pass message to core when possible.
121 *
122 * @param cls Closure (@c type dependant). It will be used by queue_send to
123 * build the message to be sent if not already prebuilt.
124 * @param type Type of the message, 0 for a raw message.
125 * @param size Size of the message.
126 * @param c Connection this message belongs to (cannot be NULL).
127 * @param ch Channel this message belongs to, if applicable (otherwise NULL).
128 * @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!)
129 */
130void
131GMC_queue_add (void* cls,
132 uint16_t type,
133 size_t size,
134 struct MeshConnection* c,
135 struct MeshChannel* ch,
136 int fwd);
137
138
139/**
140 * Free a transmission that was already queued with all resources
141 * associated to the request.
142 *
143 * @param queue Queue handler to cancel.
144 * @param clear_cls Is it necessary to free associated cls?
145 */
146void
147GMC_queue_destroy (struct MeshPeerQueue *queue, int clear_cls);
148
149
150/**
151 * Core callback to write a queued packet to core buffer
152 *
153 * @param cls Closure (peer info).
154 * @param size Number of bytes available in buf.
155 * @param buf Where the to write the message.
156 *
157 * @return number of bytes written to buf
158 */
159size_t
160GMC_queue_send (void *cls, size_t size, void *buf);
161
162
163
164/**
165 * Is this peer the first one on the connection?
166 *
167 * @param c Connection.
168 * @param fwd Is this about fwd traffic?
169 *
170 * @return GNUNET_YES if origin, GNUNET_NO if relay/terminal.
171 */
172int
173GMC_is_origin (struct MeshConnection *c, int fwd);
174
175/**
176 * Is this peer the last one on the connection?
177 *
178 * @param c Connection.
179 * @param fwd Is this about fwd traffic?
180 * Note that the ROOT is the terminal for BCK traffic!
181 *
182 * @return GNUNET_YES if terminal, GNUNET_NO if relay/origin.
183 */
184int
185GMC_is_terminal (struct MeshConnection *c, int fwd);
186
187
188#if 0 /* keep Emacsens' auto-indent happy */
189{
190#endif
191#ifdef __cplusplus
192}
193#endif
194
195/* ifndef GNUNET_SERVICE_MESH_CONNECTION_H */
196#endif
197/* end of gnunet-service-mesh_connection.h */ \ No newline at end of file