diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-04-07 11:36:07 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-04-07 11:36:07 +0000 |
commit | 83e0dcf80c9ade6c9e83c33b4add635a258bdbb4 (patch) | |
tree | 90cc49151fbdee192a3ff836689f218d6eec641e /src/mesh/gnunet-service-mesh.c | |
parent | 8b099f451e69cb0e2f8c27e441a7d08a739c08e0 (diff) | |
download | gnunet-83e0dcf80c9ade6c9e83c33b4add635a258bdbb4.tar.gz gnunet-83e0dcf80c9ade6c9e83c33b4add635a258bdbb4.zip |
Work in progress
Diffstat (limited to 'src/mesh/gnunet-service-mesh.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 134 |
1 files changed, 80 insertions, 54 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 8332100b6..e927d2737 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -23,6 +23,14 @@ | |||
23 | * @brief GNUnet MESH service | 23 | * @brief GNUnet MESH service |
24 | * @author Bartlomiej Polot | 24 | * @author Bartlomiej Polot |
25 | * | 25 | * |
26 | * STRUCTURE: | ||
27 | * - MESH NETWORK MESSAGES | ||
28 | * - DATA STRUCTURES | ||
29 | * - GLOBAL VARIABLES | ||
30 | * - MESH NETWORK HANDLES | ||
31 | * - MESH LOCAL HANDLES | ||
32 | * - MAIN FUNCTIONS (main & run) | ||
33 | * | ||
26 | * TODO: | 34 | * TODO: |
27 | * - soft stateing (keep-alive (CHANGE?) / timeout / disconnect) -- not a message issue | 35 | * - soft stateing (keep-alive (CHANGE?) / timeout / disconnect) -- not a message issue |
28 | * - error reporting (CREATE/CHANGE/ADD/DEL?) -- new message! | 36 | * - error reporting (CREATE/CHANGE/ADD/DEL?) -- new message! |
@@ -52,12 +60,14 @@ struct GNUNET_MESH_ManipulatePath | |||
52 | /** | 60 | /** |
53 | * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_[CREATE|CHANGE|ADD|DEL] | 61 | * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_[CREATE|CHANGE|ADD|DEL] |
54 | * | 62 | * |
55 | * Size: sizeof(struct GNUNET_MESH_ManipulatePath) + path_length * sizeof (struct GNUNET_PeerIdentity) | 63 | * Size: sizeof(struct GNUNET_MESH_ManipulatePath) + |
64 | * path_length * sizeof (struct GNUNET_PeerIdentity) | ||
56 | */ | 65 | */ |
57 | struct GNUNET_MessageHeader header; | 66 | struct GNUNET_MessageHeader header; |
58 | 67 | ||
59 | /** | 68 | /** |
60 | * (global) Id of the tunnel this path belongs to, unique in conjunction with the origin. | 69 | * Global id of the tunnel this path belongs to, |
70 | * unique in conjunction with the origin. | ||
61 | */ | 71 | */ |
62 | uint32_t tid GNUNET_PACKED; | 72 | uint32_t tid GNUNET_PACKED; |
63 | 73 | ||
@@ -76,7 +86,7 @@ struct GNUNET_MESH_ManipulatePath | |||
76 | * path_length structs defining the *whole* path from the origin [0] to the | 86 | * path_length structs defining the *whole* path from the origin [0] to the |
77 | * final destination [path_length-1]. | 87 | * final destination [path_length-1]. |
78 | */ | 88 | */ |
79 | // struct GNUNET_PeerIdentity peers[path_length]; | 89 | /* struct GNUNET_PeerIdentity peers[path_length]; */ |
80 | }; | 90 | }; |
81 | 91 | ||
82 | /** | 92 | /** |
@@ -215,12 +225,8 @@ enum PeerState | |||
215 | /** | 225 | /** |
216 | * Peer connected previosly but not responding | 226 | * Peer connected previosly but not responding |
217 | */ | 227 | */ |
218 | MESH_PEER_UNAVAILABLE, | 228 | MESH_PEER_RECONNECTING, |
219 | 229 | ||
220 | /** | ||
221 | * Peer requested but not ever connected | ||
222 | */ | ||
223 | MESH_PEER_UNREACHABLE | ||
224 | }; | 230 | }; |
225 | 231 | ||
226 | /** | 232 | /** |
@@ -231,7 +237,7 @@ struct PeerInfo | |||
231 | /** | 237 | /** |
232 | * ID of the peer | 238 | * ID of the peer |
233 | */ | 239 | */ |
234 | GNUNET_PEER_Id id; | 240 | GNUNET_PEER_Id id; |
235 | 241 | ||
236 | /** | 242 | /** |
237 | * Is the peer reachable? Is the peer even connected? | 243 | * Is the peer reachable? Is the peer even connected? |
@@ -241,14 +247,15 @@ struct PeerInfo | |||
241 | /** | 247 | /** |
242 | * Who to send the data to --- what about multiple (alternate) paths? | 248 | * Who to send the data to --- what about multiple (alternate) paths? |
243 | */ | 249 | */ |
244 | GNUNET_PEER_Id first_hop; | 250 | GNUNET_PEER_Id first_hop; |
245 | 251 | ||
246 | /** | 252 | /** |
247 | * Max data rate to this peer | 253 | * Max data rate to this peer |
248 | */ | 254 | */ |
249 | uint32_t max_speed; | 255 | uint32_t max_speed; |
250 | }; | 256 | }; |
251 | 257 | ||
258 | typedef uint32_t MESH_PathID; | ||
252 | /** | 259 | /** |
253 | * Information regarding a path | 260 | * Information regarding a path |
254 | */ | 261 | */ |
@@ -257,19 +264,20 @@ struct Path | |||
257 | /** | 264 | /** |
258 | * Id of the path, in case it's needed | 265 | * Id of the path, in case it's needed |
259 | */ | 266 | */ |
260 | uint32_t id; | 267 | MESH_PathID id; |
261 | 268 | ||
262 | /** | 269 | /** |
263 | * Whether the path is serving traffic in a tunnel or is a backup | 270 | * Whether the path is serving traffic in a tunnel or is a backup |
264 | */ | 271 | */ |
265 | int in_use; | 272 | int in_use; |
266 | 273 | ||
267 | /** | 274 | /** |
268 | * List of all the peers that form the path from origin to target | 275 | * List of all the peers that form the path from origin to target |
269 | */ | 276 | */ |
270 | GNUNET_PEER_Id *peers; | 277 | GNUNET_PEER_Id *peers; |
271 | }; | 278 | }; |
272 | 279 | ||
280 | typedef uint32_t MESH_TunnelID; | ||
273 | /** | 281 | /** |
274 | * Struct containing all information regarding a tunnel | 282 | * Struct containing all information regarding a tunnel |
275 | * For an intermediate node the improtant info used will be: | 283 | * For an intermediate node the improtant info used will be: |
@@ -282,34 +290,36 @@ struct Path | |||
282 | struct MESH_tunnel | 290 | struct MESH_tunnel |
283 | { | 291 | { |
284 | 292 | ||
285 | struct MESH_tunnel *next; | 293 | /** |
286 | 294 | * Double linked list | |
287 | struct MESH_tunnel *prev; | 295 | */ |
296 | struct MESH_tunnel *next; | ||
297 | struct MESH_tunnel *prev; | ||
288 | 298 | ||
289 | /** | 299 | /** |
290 | * Origin ID: Node that created the tunnel | 300 | * Origin ID: Node that created the tunnel |
291 | */ | 301 | */ |
292 | GNUNET_PEER_Id oid; | 302 | GNUNET_PEER_Id oid; |
293 | 303 | ||
294 | /** | 304 | /** |
295 | * Tunnel number (unique for a given oid) | 305 | * Tunnel number (unique for a given oid) |
296 | */ | 306 | */ |
297 | uint32_t tid; | 307 | MESH_TunnelID tid; |
298 | 308 | ||
299 | /** | 309 | /** |
300 | * Whether the tunnel is in a state to transmit data | 310 | * Whether the tunnel is in a state to transmit data |
301 | */ | 311 | */ |
302 | int ready; | 312 | int ready; |
303 | 313 | ||
304 | /** | 314 | /** |
305 | * Minimal speed for this tunnel in kb/s | 315 | * Minimal speed for this tunnel in kb/s |
306 | */ | 316 | */ |
307 | uint32_t speed_min; | 317 | uint32_t speed_min; |
308 | 318 | ||
309 | /** | 319 | /** |
310 | * Maximal speed for this tunnel in kb/s | 320 | * Maximal speed for this tunnel in kb/s |
311 | */ | 321 | */ |
312 | uint32_t speed_max; | 322 | uint32_t speed_max; |
313 | 323 | ||
314 | /** | 324 | /** |
315 | * Last time the tunnel was used | 325 | * Last time the tunnel was used |
@@ -319,20 +329,20 @@ struct MESH_tunnel | |||
319 | /** | 329 | /** |
320 | * Peers in the tunnel, for future optimizations | 330 | * Peers in the tunnel, for future optimizations |
321 | */ | 331 | */ |
322 | struct PeerInfo *peers; | 332 | struct PeerInfo *peers; |
323 | 333 | ||
324 | /** | 334 | /** |
325 | * Paths (used and backup) | 335 | * Paths (used and backup) |
326 | */ | 336 | */ |
327 | struct Path *paths; | 337 | struct Path *paths; |
328 | 338 | ||
329 | /** | 339 | /** |
330 | * Messages ready to transmit??? -- real queues needed | 340 | * Messages ready to transmit??? -- FIXME real queues needed |
331 | */ | 341 | */ |
332 | struct GNUNET_MessageHeader *msg_out; | 342 | struct GNUNET_MessageHeader *msg_out; |
333 | 343 | ||
334 | /** | 344 | /** |
335 | * Messages received and not processed??? -- real queues needed | 345 | * Messages received and not processed??? -- FIXME real queues needed |
336 | */ | 346 | */ |
337 | struct GNUNET_MessageHeader *msg_in; | 347 | struct GNUNET_MessageHeader *msg_in; |
338 | 348 | ||
@@ -348,32 +358,46 @@ struct MESH_tunnel | |||
348 | */ | 358 | */ |
349 | struct Client | 359 | struct Client |
350 | { | 360 | { |
361 | /** | ||
362 | * Double linked list | ||
363 | */ | ||
364 | struct Client *next; | ||
365 | struct Client *prev; | ||
351 | 366 | ||
352 | struct Client *next; | 367 | /** |
353 | 368 | * Tunnels that belong to this client | |
354 | struct Client *prev; | 369 | */ |
355 | 370 | struct MESH_tunnel *my_tunnels_head; | |
356 | struct MESH_tunnel *my_tunnels_head; | 371 | struct MESH_tunnel *my_tunnels_tail; |
357 | |||
358 | struct MESH_tunnel *my_tunnels_tail; | ||
359 | 372 | ||
360 | /** | 373 | /** |
361 | * If this tunnel was created by a local client, what's its handle? | 374 | * If this tunnel was created by a local client, what's its handle? |
362 | */ | 375 | */ |
363 | struct GNUNET_SERVER_Client *handle; | 376 | struct GNUNET_SERVER_Client *handle; |
364 | 377 | ||
365 | unsigned int messages_subscribed_counter; | 378 | /** |
366 | 379 | * Messages that this client has declared interest in | |
367 | uint16_t *messages_subscribed; | 380 | */ |
381 | uint16_t *messages_subscribed; | ||
382 | unsigned int messages_subscribed_counter; | ||
368 | 383 | ||
369 | }; | 384 | }; |
370 | 385 | ||
386 | /******************************************************************************/ | ||
387 | /*********************** GLOBAL VARIABLES ****************************/ | ||
388 | /******************************************************************************/ | ||
371 | 389 | ||
372 | // static struct MESH_tunnel *tunnel_participation_head; | 390 | /** |
373 | 391 | * All the clients | |
374 | // static struct MESH_tunnel *tunnel_participation_tail; | 392 | */ |
375 | 393 | // static struct Client clients_head; | |
394 | // static struct Client clients_tail; | ||
376 | 395 | ||
396 | /** | ||
397 | * All the tunnels | ||
398 | */ | ||
399 | // static struct MESH_tunnel *tunnel_participation_head; | ||
400 | // static struct MESH_tunnel *tunnel_participation_tail; | ||
377 | 401 | ||
378 | 402 | ||
379 | /******************************************************************************/ | 403 | /******************************************************************************/ |
@@ -549,8 +573,6 @@ handle_local_network_traffic (void *cls, | |||
549 | */ | 573 | */ |
550 | static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = { | 574 | static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = { |
551 | {&handle_local_new_client, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT, 0}, | 575 | {&handle_local_new_client, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT, 0}, |
552 | {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ANY, 0}, | ||
553 | {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ALL, 0}, | ||
554 | {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD, 0}, | 576 | {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD, 0}, |
555 | {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL, 0}, | 577 | {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL, 0}, |
556 | {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE, sizeof(struct GNUNET_MESH_ConnectPeerByType)}, | 578 | {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE, sizeof(struct GNUNET_MESH_ConnectPeerByType)}, |
@@ -608,6 +630,10 @@ core_disconnect (void *cls, | |||
608 | return; | 630 | return; |
609 | } | 631 | } |
610 | 632 | ||
633 | /******************************************************************************/ | ||
634 | /************************ MAIN FUNCTIONS ****************************/ | ||
635 | /******************************************************************************/ | ||
636 | |||
611 | /** | 637 | /** |
612 | * Process mesh requests. FIXME NON FUNCTIONAL, SKELETON | 638 | * Process mesh requests. FIXME NON FUNCTIONAL, SKELETON |
613 | * | 639 | * |
@@ -624,17 +650,17 @@ run (void *cls, | |||
624 | 650 | ||
625 | GNUNET_SERVER_add_handlers (server, plugin_handlers); | 651 | GNUNET_SERVER_add_handlers (server, plugin_handlers); |
626 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); | 652 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); |
627 | core = GNUNET_CORE_connect (c, /* Main configuration */ | 653 | core = GNUNET_CORE_connect (c, /* Main configuration */ |
628 | 32, /* queue size */ | 654 | 32, /* queue size */ |
629 | NULL, /* Closure passed to MESH functions */ | 655 | NULL, /* Closure passed to MESH functions */ |
630 | &core_init, /* Call core_init once connected */ | 656 | &core_init, /* Call core_init once connected */ |
631 | &core_connect, /* Handle connects */ | 657 | &core_connect, /* Handle connects */ |
632 | &core_disconnect, /* remove peers on disconnects */ | 658 | &core_disconnect, /* remove peers on disconnects */ |
633 | NULL, /* Do we care about "status" updates? */ | 659 | NULL, /* Do we care about "status" updates? */ |
634 | NULL, /* Don't want notified about all incoming messages */ | 660 | NULL, /* Don't notify about all incoming messages */ |
635 | GNUNET_NO, /* For header only inbound notification */ | 661 | GNUNET_NO, /* For header only in notification */ |
636 | NULL, /* Don't want notified about all outbound messages */ | 662 | NULL, /* Don't notify about all outbound messages */ |
637 | GNUNET_NO, /* For header only outbound notification */ | 663 | GNUNET_NO, /* For header-only out notification */ |
638 | core_handlers); /* Register these handlers */ | 664 | core_handlers); /* Register these handlers */ |
639 | 665 | ||
640 | if (core == NULL) | 666 | if (core == NULL) |