2 This file is part of GNUnet.
3 (C) 2001 - 2011 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.c
23 * @brief GNUnet MESH service
24 * @author Bartlomiej Polot
30 * All the states a peer participating in a tunnel can be in.
35 * Request sent, not yet answered.
40 * Peer connected and ready to accept data
45 * Peer connected previosly but not responding
47 MESH_PEER_UNAVAILABLE,
50 * Peer requested but not ever connected
56 * Struct containing all information regarding a given peer
63 struct GNUNET_PeerIdentity id;
66 * Is the peer reachable? Is the peer even connected?
68 struct PeerState state;
71 * Who to send the data to
76 * Max data rate to this peer
82 * Information regarding a path
87 * Id of the path, in case it's needed
92 * Whether the path is serving traffic in a tunnel or is a backup
97 * List of all the peers that form the path from origin to target
103 * Struct containing all information regarding a tunnel
104 * For an intermediate node the improtant info used will be:
105 * - OID \ To identify
107 * - paths[0] | To know where to send it next
108 * - metainfo: ready, speeds, accounting
109 * For an end node more fields will be needed (client-handling)
114 * Origin ID: Node that created the tunnel
116 struct GNUNET_PeerIdentity oid;
119 * Tunnel number (unique for a given oid)
124 * Whether the tunnel is in state to transmit data
129 * Minimal speed for this tunnel in kb/s
134 * Maximal speed for this tunnel in kb/s
139 * Peers in the tunnel, for future optimizations
141 struct PeerInfo *peers;
144 * Paths (used and backup)
149 * Messages ready to transmit
151 struct GNUNET_MessageHeader *msg_out;
154 * Messages received and not processed
156 struct GNUNET_MessageHeader *msg_in;
159 * FIXME Clients. Is anyone to be notified for traffic here?
164 * So, I'm an endpoint. Why am I receiveing traffic?
165 * Who is interested in this? How to communicate with them?
170 * FIXME add structures needed to handle client connections
178 * Process mesh requests. FIXME NON FUNCTIONAL, COPIED FROM DHT!!
181 * @param server the initialized server
182 * @param c configuration to use
186 struct GNUNET_SERVER_Handle *server,
187 const struct GNUNET_CONFIGURATION_Handle *c)
189 struct GNUNET_TIME_Relative next_send_time;
190 unsigned long long temp_config_num;
191 char *converge_modifier_buf;
194 datacache = GNUNET_DATACACHE_create (cfg, "dhtcache");
195 GNUNET_SERVER_add_handlers (server, plugin_handlers);
196 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
197 coreAPI = GNUNET_CORE_connect (cfg, /* Main configuration */
198 DEFAULT_CORE_QUEUE_SIZE, /* queue size */
199 NULL, /* Closure passed to DHT functions */
200 &core_init, /* Call core_init once connected */
201 &handle_core_connect, /* Handle connects */
202 &handle_core_disconnect, /* remove peers on disconnects */
203 NULL, /* Do we care about "status" updates? */
204 NULL, /* Don't want notified about all incoming messages */
205 GNUNET_NO, /* For header only inbound notification */
206 NULL, /* Don't want notified about all outbound messages */
207 GNUNET_NO, /* For header only outbound notification */
208 core_handlers); /* Register these handlers */
215 * The main function for the mesh service.
217 * @param argc number of arguments from the command line
218 * @param argv command line arguments
219 * @return 0 ok, 1 on error
222 main (int argc, char *const *argv)
227 GNUNET_SERVICE_run (argc,
230 GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1;