aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-04-05 11:59:03 +0000
committerBart Polot <bart@net.in.tum.de>2011-04-05 11:59:03 +0000
commitc4dec31821271d83e8895de9df11beaeb7154266 (patch)
treeb32577e58b9a20ce977349fd4b432f2d7555960a /src/mesh/gnunet-service-mesh.c
parente8b673fb299c01668f6c0ed4a4af3d2781d3895e (diff)
downloadgnunet-c4dec31821271d83e8895de9df11beaeb7154266.tar.gz
gnunet-c4dec31821271d83e8895de9df11beaeb7154266.zip
Added local mesh messages
Diffstat (limited to 'src/mesh/gnunet-service-mesh.c')
-rw-r--r--src/mesh/gnunet-service-mesh.c112
1 files changed, 90 insertions, 22 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 1598603a6..20c2315be 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -422,10 +422,10 @@ handle_mesh_path_create (void *cls,
422 */ 422 */
423static int 423static int
424handle_mesh_network_traffic (void *cls, 424handle_mesh_network_traffic (void *cls,
425 const struct GNUNET_PeerIdentity *peer, 425 const struct GNUNET_PeerIdentity *peer,
426 const struct GNUNET_MessageHeader *message, 426 const struct GNUNET_MessageHeader *message,
427 const struct GNUNET_TRANSPORT_ATS_Information 427 const struct GNUNET_TRANSPORT_ATS_Information
428 *atsi) 428 *atsi)
429{ 429{
430 if(GNUNET_MESSAGE_TYPE_MESH_DATA_GO == ntohs(message->type)) { 430 if(GNUNET_MESSAGE_TYPE_MESH_DATA_GO == ntohs(message->type)) {
431 /* Retransmit to next in path of tunnel identified by message */ 431 /* Retransmit to next in path of tunnel identified by message */
@@ -449,13 +449,81 @@ static struct GNUNET_CORE_MessageHandler core_handlers[] = {
449/** 449/**
450 * Functions to handle messages from clients 450 * Functions to handle messages from clients
451 */ 451 */
452/* MESSAGES DEFINED:
453#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT 272
454#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ANY 273
455#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ALL 274
456#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD 275
457#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL 276
458#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE 277
459#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_CANCEL 278
460#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TRANSMIT_READY 279
461#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATED 280
462#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROYED 281
463#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA 282
464#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA_BROADCAST 283
465 */
452static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = { 466static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = {
453 {&handle_local_path_create, NULL, GNUNET_MESSAGE_TYPE_LOCAL_PATH_CREATE, 0}, 467 {&handle_local_new_client, NULL, GNUNET_MESSAGE_TYPE_LOCAL_CONNECT, 0},
454 {&handle_local_network_traffic, GNUNET_MESSAGE_TYPE_LOCAL_DATA_GO, 0}, 468 {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ANY, 0},
455 {&handle_local_network_traffic, GNUNET_MESSAGE_TYPE_LOCAL_DATA_BACK, 0}, 469 {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ALL, 0},
470 {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD, 0},
471 {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL, 0},
472 {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE, sizeof(struct GNUNET_MESH_ConnectPeerByType)},
473 {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_CANCEL, sizeof(struct GNUNET_MESH_Control)},
474 {&handle_local_network_traffic, NULL, GNUNET_MESSAGE_TYPE_LOCAL_TRANSMIT_READY, sizeof(struct GNUNET_MESH_Control)},
475 {&handle_local_network_traffic, NULL, GNUNET_MESSAGE_TYPE_LOCAL_DATA, 0}, /* FIXME needed? */
476 {&handle_local_network_traffic, NULL, GNUNET_MESSAGE_TYPE_LOCAL_DATA_BROADCAST, 0}, /* FIXME needed? */
456 {NULL, NULL, 0, 0} 477 {NULL, NULL, 0, 0}
457}; 478};
458 479
480
481/**
482 * To be called on core init/fail.
483 *
484 * @param cls service closure
485 * @param server handle to the server for this service
486 * @param identity the public identity of this peer
487 * @param publicKey the public key of this peer
488 */
489static void
490core_init (void *cls,
491 struct GNUNET_CORE_Handle *server,
492 const struct GNUNET_PeerIdentity *identity,
493 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
494{
495 return;
496}
497
498/**
499 * Method called whenever a given peer connects.
500 *
501 * @param cls closure
502 * @param peer peer identity this notification is about
503 * @param atsi performance data for the connection
504 */
505static void
506core_connect (void *cls,
507 const struct GNUNET_PeerIdentity *peer,
508 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
509{
510 return;
511}
512
513/**
514 * Method called whenever a peer disconnects.
515 *
516 * @param cls closure
517 * @param peer peer identity this notification is about
518 */
519static void
520core_disconnect (void *cls,
521 const struct
522 GNUNET_PeerIdentity *peer)
523{
524 return;
525}
526
459/** 527/**
460 * Process mesh requests. FIXME NON FUNCTIONAL, COPIED FROM DHT!! 528 * Process mesh requests. FIXME NON FUNCTIONAL, COPIED FROM DHT!!
461 * 529 *
@@ -471,24 +539,24 @@ run (void *cls,
471 struct GNUNET_TIME_Relative next_send_time; 539 struct GNUNET_TIME_Relative next_send_time;
472 unsigned long long temp_config_num; 540 unsigned long long temp_config_num;
473 char *converge_modifier_buf; 541 char *converge_modifier_buf;
474 GNUNET_CORE_Handle *coreAPI; 542 GNUNET_CORE_Handle *core;
475 543
476 GNUNET_SERVER_add_handlers (server, plugin_handlers); 544 GNUNET_SERVER_add_handlers (server, plugin_handlers);
477 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); 545 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
478 coreAPI = GNUNET_CORE_connect (c, /* Main configuration */ 546 core = GNUNET_CORE_connect (c, /* Main configuration */
479 32, /* queue size */ 547 32, /* queue size */
480 NULL, /* Closure passed to DHT functions */ 548 NULL, /* Closure passed to MESH functions */
481 NULL, /* Call core_init once connected */ 549 &core_init, /* Call core_init once connected */
482 NULL, /* Handle connects */ 550 &core_connect, /* Handle connects */
483 NULL, /* remove peers on disconnects */ 551 &core_disconnect, /* remove peers on disconnects */
484 NULL, /* Do we care about "status" updates? */ 552 NULL, /* Do we care about "status" updates? */
485 NULL, /* Don't want notified about all incoming messages */ 553 NULL, /* Don't want notified about all incoming messages */
486 GNUNET_NO, /* For header only inbound notification */ 554 GNUNET_NO, /* For header only inbound notification */
487 NULL, /* Don't want notified about all outbound messages */ 555 NULL, /* Don't want notified about all outbound messages */
488 GNUNET_NO, /* For header only outbound notification */ 556 GNUNET_NO, /* For header only outbound notification */
489 core_handlers); /* Register these handlers */ 557 core_handlers); /* Register these handlers */
490 558
491 if (coreAPI == NULL) 559 if (core == NULL)
492 return; 560 return;
493} 561}
494 562