aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/mesh_api_new.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-04-07 11:36:07 +0000
committerBart Polot <bart@net.in.tum.de>2011-04-07 11:36:07 +0000
commit83e0dcf80c9ade6c9e83c33b4add635a258bdbb4 (patch)
tree90cc49151fbdee192a3ff836689f218d6eec641e /src/mesh/mesh_api_new.c
parent8b099f451e69cb0e2f8c27e441a7d08a739c08e0 (diff)
downloadgnunet-83e0dcf80c9ade6c9e83c33b4add635a258bdbb4.tar.gz
gnunet-83e0dcf80c9ade6c9e83c33b4add635a258bdbb4.zip
Work in progress
Diffstat (limited to 'src/mesh/mesh_api_new.c')
-rw-r--r--src/mesh/mesh_api_new.c125
1 files changed, 125 insertions, 0 deletions
diff --git a/src/mesh/mesh_api_new.c b/src/mesh/mesh_api_new.c
new file mode 100644
index 000000000..f7b0e9034
--- /dev/null
+++ b/src/mesh/mesh_api_new.c
@@ -0,0 +1,125 @@
1/*
2 This file is part of GNUnet.
3 (C) 2011 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/mesh_api_new.c
23 * @brief mesh api: client implementation of mesh service
24 * @author Bartlomiej Polot
25 */
26
27#ifdef __cplusplus
28
29extern "C"
30{
31#if 0 /* keep Emacsens' auto-indent happy */
32}
33#endif
34#endif
35
36
37#include <stdint.h>
38#include "gnunet_mesh_service.h"
39
40/**
41 * Opaque handle to the service.
42 */
43struct GNUNET_MESH_Handle {
44 struct GNUNET_MESH_Tunnel *head;
45 struct GNUNET_MESH_Tunnel *tail;
46 GNUNET_MESH_TunnelEndHandler cleaner;
47};
48
49/**
50 * Opaque handle to a tunnel.
51 */
52struct GNUNET_MESH_Tunnel {
53 GNUNET_PEER_Id owner;
54 GNUNET_PEER_Id destination;
55 GNUNET_MESH_TunnelConnectHandler connect_handler;
56 GNUNET_MESH_TunnelDisconnectHandler disconnect_handler;
57 GNUNET_PEER_Id *peers;
58};
59
60
61/**
62 * Connect to the mesh service.
63 *
64 * @param cfg configuration to use
65 * @param cls closure for the various callbacks that follow (including handlers in the handlers array)
66 * @param cleaner function called when an *inbound* tunnel is destroyed
67 * @param handlers callbacks for messages we care about, NULL-terminated
68 * note that the mesh is allowed to drop notifications about inbound
69 * messages if the client does not process them fast enough (for this
70 * notification type, a bounded queue is used)
71 * @return handle to the mesh service
72 * NULL on error (in this case, init is never called)
73 */
74struct GNUNET_MESH_Handle *
75GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
76 void *cls,
77 GNUNET_MESH_TunnelEndHandler cleaner,
78 const struct GNUNET_MESH_MessageHandler *handlers,
79 const GNUNET_MESH_ApplicationType *stypes) {
80 GNUNET_MESH_Handle *h;
81 h = GNUNET_malloc(sizeof(GNUNET_MESH_Handle));
82
83 h->cleaner = cleaner;
84 return h;
85}
86
87/**
88 * Disconnect from the mesh service.
89 *
90 * @param handle connection to mesh to disconnect
91 */
92void GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) {
93 return;
94}
95
96/**
97 * Create a new tunnel (we're initiator and will be allowed to add/remove peers and
98 * to broadcast).
99 *
100 * @param h mesh handle
101 * @param connect_handler function to call when peers are actually connected
102 * @param disconnect_handler function to call when peers are disconnected
103 * @param handler_cls closure for connect/disconnect handlers
104 */
105struct GNUNET_MESH_Tunnel *
106GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h,
107 GNUNET_MESH_TunnelConnectHandler connect_handler,
108 GNUNET_MESH_TunnelDisconnectHandler disconnect_handler,
109 void *handler_cls) {
110 GNUNET_MESH_Tunnel *tunnel;
111 tunnel = GNUNET_malloc(sizeof(GNUNET_MESH_Tunnel));
112
113 tunnel->connect_handler = connect_handler;
114 tunnel->disconnect_handler = disconnect_handler;
115 tunnel->peers = NULL;
116
117 return tunnel;
118}
119
120#if 0 /* keep Emacsens' auto-indent happy */
121{
122#endif
123#ifdef __cplusplus
124}
125#endif \ No newline at end of file