aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_mesh_service_new.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-30 19:52:09 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-30 19:52:09 +0000
commit302e8874b89fb670a9dfdc5992ac6c9b20f2122d (patch)
tree8acacda3b764395cfd18e53a09ebbfe1ddf08478 /src/include/gnunet_mesh_service_new.h
parent7742b7ee0e7ef2b69228053b1a1685560eb13df4 (diff)
downloadgnunet-302e8874b89fb670a9dfdc5992ac6c9b20f2122d.tar.gz
gnunet-302e8874b89fb670a9dfdc5992ac6c9b20f2122d.zip
making the new mesh the default
Diffstat (limited to 'src/include/gnunet_mesh_service_new.h')
-rw-r--r--src/include/gnunet_mesh_service_new.h346
1 files changed, 0 insertions, 346 deletions
diff --git a/src/include/gnunet_mesh_service_new.h b/src/include/gnunet_mesh_service_new.h
deleted file mode 100644
index 0497cee2f..000000000
--- a/src/include/gnunet_mesh_service_new.h
+++ /dev/null
@@ -1,346 +0,0 @@
1/*
2 This file is part of GNUnet.
3 (C) 2009, 2010 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 include/gnunet_mesh_service.h
23 * @brief mesh service; establish tunnels to distant peers
24 * @author Christian Grothoff
25 */
26
27#ifndef GNUNET_MESH_SERVICE_H
28#define GNUNET_MESH_SERVICE_H
29
30#ifdef __cplusplus
31extern "C"
32{
33#if 0 /* keep Emacsens' auto-indent happy */
34}
35#endif
36#endif
37
38#include "gnunet_util_lib.h"
39#include "gnunet_transport_service.h"
40
41/**
42 * Version number of GNUnet-mesh API.
43 */
44#define GNUNET_MESH_VERSION 0x00000000
45
46
47/**
48 * Opaque handle to the service.
49 */
50struct GNUNET_MESH_Handle;
51
52/**
53 * Opaque handle to a tunnel.
54 */
55struct GNUNET_MESH_Tunnel;
56
57/**
58 * Functions with this signature are called whenever a message is
59 * received.
60 *
61 * @param cls closure (set from GNUNET_MESH_connect)
62 * @param tunnel connection to the other end
63 * @param tunnel_ctx place to store local state associated with the tunnel
64 * @param sender who sent the message
65 * @param message the actual message
66 * @param atsi performance data for the connection
67 * @return GNUNET_OK to keep the connection open,
68 * GNUNET_SYSERR to close it (signal serious error)
69 */
70typedef int (*GNUNET_MESH_MessageCallback) (void *cls,
71 struct GNUNET_MESH_Tunnel * tunnel,
72 void **tunnel_ctx,
73 const struct GNUNET_PeerIdentity *
74 sender,
75 const struct GNUNET_MessageHeader *
76 message,
77 const struct
78 GNUNET_ATS_Information *
79 atsi);
80
81
82/**
83 * Message handler. Each struct specifies how to handle on particular
84 * type of message received.
85 */
86struct GNUNET_MESH_MessageHandler
87{
88 /**
89 * Function to call for messages of "type".
90 */
91 GNUNET_MESH_MessageCallback callback;
92
93 /**
94 * Type of the message this handler covers.
95 */
96 uint16_t type;
97
98 /**
99 * Expected size of messages of this type. Use 0 for variable-size.
100 * If non-zero, messages of the given type will be discarded if they
101 * do not have the right size.
102 */
103 uint16_t expected_size;
104
105};
106
107
108/**
109 * Method called whenever another peer has added us to a tunnel
110 * the other peer initiated.
111 *
112 * @param cls closure
113 * @param tunnel new handle to the tunnel
114 * @param initiator peer that started the tunnel
115 * @param atsi performance information for the tunnel
116 * @return initial tunnel context for the tunnel
117 * (can be NULL -- that's not an error)
118 */
119typedef void *(GNUNET_MESH_InboundTunnelNotificationHandler) (void *cls,
120 struct
121 GNUNET_MESH_Tunnel
122 * tunnel,
123 const struct
124 GNUNET_PeerIdentity
125 * initiator,
126 const struct
127 GNUNET_ATS_Information
128 * atsi);
129
130
131/**
132 * Function called whenever an inbound tunnel is destroyed. Should clean up
133 * any associated state.
134 *
135 * @param cls closure (set from GNUNET_MESH_connect)
136 * @param tunnel connection to the other end (henceforth invalid)
137 * @param tunnel_ctx place where local state associated
138 * with the tunnel is stored
139 */
140typedef void (GNUNET_MESH_TunnelEndHandler) (void *cls,
141 const struct GNUNET_MESH_Tunnel *
142 tunnel, void *tunnel_ctx);
143
144
145/**
146 * Type for an application. Values defined in gnunet_applications.h
147 */
148typedef uint32_t GNUNET_MESH_ApplicationType;
149
150
151/**
152 * Connect to the mesh service.
153 *
154 * @param cfg configuration to use
155 * @param queue_size size of the data message queue, shared among all tunnels
156 * (each tunnel is guaranteed to accept at least one message,
157 * no matter what is the status of other tunnels)
158 * @param cls closure for the various callbacks that follow
159 * (including handlers in the handlers array)
160 * @param new_tunnel function called when an *inbound* tunnel is created
161 * @param cleaner function called when an *inbound* tunnel is destroyed
162 * @param handlers callbacks for messages we care about, NULL-terminated
163 * note that the mesh is allowed to drop notifications about
164 * inbound messages if the client does not process them fast
165 * enough (for this notification type, a bounded queue is used)
166 * @param stypes list of the applications that this client claims to provide
167 * @return handle to the mesh service NULL on error
168 * (in this case, init is never called)
169 */
170struct GNUNET_MESH_Handle *
171GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
172 unsigned int queue_size, void *cls,
173 GNUNET_MESH_InboundTunnelNotificationHandler new_tunnel,
174 GNUNET_MESH_TunnelEndHandler cleaner,
175 const struct GNUNET_MESH_MessageHandler *handlers,
176 const GNUNET_MESH_ApplicationType *stypes);
177
178
179/**
180 * Disconnect from the mesh service.
181 *
182 * @param handle connection to mesh to disconnect
183 */
184void
185GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle);
186
187
188/**
189 * Method called whenever a peer has disconnected from the tunnel.
190 *
191 * @param cls closure
192 * @param peer peer identity the tunnel stopped working with
193 */
194typedef void (*GNUNET_MESH_PeerDisconnectHandler) (void *cls,
195 const struct
196 GNUNET_PeerIdentity * peer);
197
198
199/**
200 * Method called whenever a peer has connected to the tunnel.
201 * TODO: change to typedef int? to let client allow the new peer or not
202 *
203 * @param cls closure
204 * @param peer peer identity the tunnel was created to, NULL on timeout
205 * @param atsi performance data for the connection
206 */
207typedef void (*GNUNET_MESH_PeerConnectHandler) (void *cls,
208 const struct GNUNET_PeerIdentity
209 * peer,
210 const struct
211 GNUNET_ATS_Information
212 * atsi);
213
214
215
216/**
217 * Create a new tunnel (we're initiator and will be allowed to add/remove peers
218 * and to broadcast).
219 *
220 * @param h mesh handle
221 * @param tunnel_ctx client's tunnel context to associate with the tunnel
222 * @param connect_handler function to call when peers are actually connected
223 * @param disconnect_handler function to call when peers are disconnected
224 * @param handler_cls closure for connect/disconnect handlers
225 */
226struct GNUNET_MESH_Tunnel *
227GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, void *tunnel_ctx,
228 GNUNET_MESH_PeerConnectHandler connect_handler,
229 GNUNET_MESH_PeerDisconnectHandler disconnect_handler,
230 void *handler_cls);
231
232/**
233 * Destroy an existing tunnel.
234 *
235 * @param tunnel tunnel handle
236 */
237void
238GNUNET_MESH_tunnel_destroy (struct GNUNET_MESH_Tunnel *tunnel);
239
240
241/**
242 * Request that a peer should be added to the tunnel. The connect handler
243 * will be called when the peer connects
244 *
245 * @param tunnel handle to existing tunnel
246 * @param peer peer to add
247 */
248void
249GNUNET_MESH_peer_request_connect_add (struct GNUNET_MESH_Tunnel *tunnel,
250 const struct GNUNET_PeerIdentity *peer);
251
252
253/**
254 * Request that a peer should be removed from the tunnel. The existing
255 * disconnect handler will be called ONCE if we were connected.
256 *
257 * @param tunnel handle to existing tunnel
258 * @param peer peer to remove
259 */
260void
261GNUNET_MESH_peer_request_connect_del (struct GNUNET_MESH_Tunnel *tunnel,
262 const struct GNUNET_PeerIdentity *peer);
263
264
265/**
266 * Request that the mesh should try to connect to a peer supporting the given
267 * message type.
268 *
269 * @param tunnel handle to existing tunnel
270 * @param app_type application type that must be supported by the peer
271 * (MESH should discover peer in proximity handling this type)
272 */
273void
274GNUNET_MESH_peer_request_connect_by_type (struct GNUNET_MESH_Tunnel *tunnel,
275 GNUNET_MESH_ApplicationType app_type);
276
277
278/**
279 * Handle for a transmission request.
280 */
281struct GNUNET_MESH_TransmitHandle;
282
283
284/**
285 * Ask the mesh to call "notify" once it is ready to transmit the
286 * given number of bytes to the specified tunnel or target.
287 *
288 * @param tunnel tunnel to use for transmission
289 * @param cork is corking allowed for this transmission?
290 * @param priority how important is the message?
291 * @param maxdelay how long can the message wait?
292 * @param target destination for the message
293 * NULL for multicast to all tunnel targets
294 * @param notify_size how many bytes of buffer space does notify want?
295 * @param notify function to call when buffer space is available;
296 * will be called with NULL on timeout or if the overall queue
297 * for this peer is larger than queue_size and this is currently
298 * the message with the lowest priority
299 * @param notify_cls closure for notify
300 * @return non-NULL if the notify callback was queued,
301 * NULL if we can not even queue the request (insufficient
302 * memory); if NULL is returned, "notify" will NOT be called.
303 */
304struct GNUNET_MESH_TransmitHandle *
305GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, int cork,
306 uint32_t priority,
307 struct GNUNET_TIME_Relative maxdelay,
308 const struct GNUNET_PeerIdentity *target,
309 size_t notify_size,
310 GNUNET_CONNECTION_TransmitReadyNotify notify,
311 void *notify_cls);
312
313
314/**
315 * Cancel the specified transmission-ready notification.
316 *
317 * @param th handle that was returned by "notify_transmit_ready".
318 */
319void
320GNUNET_MESH_notify_transmit_ready_cancel (struct GNUNET_MESH_TransmitHandle
321 *th);
322
323
324/**
325 * Transition API for tunnel ctx management
326 */
327void
328GNUNET_MESH_tunnel_set_data (struct GNUNET_MESH_Tunnel *tunnel, void *data);
329
330/**
331 * Transition API for tunnel ctx management
332 */
333void *
334GNUNET_MESH_tunnel_get_data (struct GNUNET_MESH_Tunnel *tunnel);
335
336
337#if 0 /* keep Emacsens' auto-indent happy */
338{
339#endif
340#ifdef __cplusplus
341}
342#endif
343
344/* ifndef GNUNET_MESH_SERVICE_H */
345#endif
346/* end of gnunet_mesh_service.h */