aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesh/gnunet-service-mesh-new.c100
1 files changed, 49 insertions, 51 deletions
diff --git a/src/mesh/gnunet-service-mesh-new.c b/src/mesh/gnunet-service-mesh-new.c
index a0f5f1a24..657d35829 100644
--- a/src/mesh/gnunet-service-mesh-new.c
+++ b/src/mesh/gnunet-service-mesh-new.c
@@ -19,29 +19,16 @@
19*/ 19*/
20 20
21/** 21/**
22 * @file mesh/gnunet-service-mesh.c 22 * @file mesh/gnunet-service-mesh-new.c
23 * @brief GNUnet MESH service 23 * @brief GNUnet MESH service
24 * @author Bartlomiej Polot 24 * @author Bartlomiej Polot
25 * 25 *
26 * STRUCTURE:
27 * - DATA STRUCTURES
28 * - GLOBAL VARIABLES
29 * - GENERAL HELPERS
30 * - PERIODIC FUNCTIONS
31 * - MESH NETWORK HANDLER HELPERS
32 * - MESH NETWORK HANDLES
33 * - MESH LOCAL HANDLER HELPERS
34 * - MESH LOCAL HANDLES
35 * - MAIN FUNCTIONS (main & run)
36 *
37 * TODO: 26 * TODO:
38 * - error reporting (CREATE/CHANGE/ADD/DEL?) -- new message!
39 * - partial disconnect reporting -- same as error reporting?
40 * - add ping message
41 * - relay corking down to core 27 * - relay corking down to core
42 * - set ttl relative to tree depth 28 * - set ttl relative to path length
43 * - Add data ACK count in path ACK 29 * - add signatures
44 * - Make common GNUNET_MESH_Data header for unicast, to_orig, multicast 30 * - add encryption
31 * - add port numbers
45 * TODO END 32 * TODO END
46 */ 33 */
47 34
@@ -4577,38 +4564,6 @@ static struct GNUNET_SERVER_MessageHandler client_handlers[] = {
4577 4564
4578 4565
4579/** 4566/**
4580 * To be called on core init/fail.
4581 *
4582 * @param cls service closure
4583 * @param server handle to the server for this service
4584 * @param identity the public identity of this peer
4585 */
4586static void
4587core_init (void *cls, struct GNUNET_CORE_Handle *server,
4588 const struct GNUNET_PeerIdentity *identity)
4589{
4590 static int i = 0;
4591 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core init\n");
4592 core_handle = server;
4593 if (0 != memcmp (identity, &my_full_id, sizeof (my_full_id)) ||
4594 NULL == server)
4595 {
4596 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Wrong CORE service\n"));
4597 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
4598 " core id %s\n",
4599 GNUNET_i2s (identity));
4600 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
4601 " my id %s\n",
4602 GNUNET_i2s (&my_full_id));
4603 GNUNET_SCHEDULER_shutdown (); // Try gracefully
4604 if (10 < i++)
4605 GNUNET_abort(); // Try harder
4606 }
4607 return;
4608}
4609
4610
4611/**
4612 * Method called whenever a given peer connects. 4567 * Method called whenever a given peer connects.
4613 * 4568 *
4614 * @param cls closure 4569 * @param cls closure
@@ -4686,6 +4641,50 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
4686} 4641}
4687 4642
4688 4643
4644/**
4645 * To be called on core init/fail.
4646 *
4647 * @param cls Closure (config)
4648 * @param server handle to the server for this service
4649 * @param identity the public identity of this peer
4650 */
4651static void
4652core_init (void *cls, struct GNUNET_CORE_Handle *server,
4653 const struct GNUNET_PeerIdentity *identity)
4654{
4655 const struct GNUNET_CONFIGURATION_Handle *c = cls;
4656 static int i = 0;
4657
4658 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core init\n");
4659 core_handle = server;
4660 if (0 != memcmp (identity, &my_full_id, sizeof (my_full_id)) ||
4661 NULL == server)
4662 {
4663 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Wrong CORE service\n"));
4664 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
4665 " core id %s\n",
4666 GNUNET_i2s (identity));
4667 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
4668 " my id %s\n",
4669 GNUNET_i2s (&my_full_id));
4670 GNUNET_CORE_disconnect (core_handle);
4671 core_handle = GNUNET_CORE_connect (c, /* Main configuration */
4672 NULL, /* Closure passed to MESH functions */
4673 &core_init, /* Call core_init once connected */
4674 &core_connect, /* Handle connects */
4675 &core_disconnect, /* remove peers on disconnects */
4676 NULL, /* Don't notify about all incoming messages */
4677 GNUNET_NO, /* For header only in notification */
4678 NULL, /* Don't notify about all outbound messages */
4679 GNUNET_NO, /* For header-only out notification */
4680 core_handlers); /* Register these handlers */
4681 if (10 < i++)
4682 GNUNET_abort();
4683 }
4684 return;
4685}
4686
4687
4689/******************************************************************************/ 4688/******************************************************************************/
4690/************************ MAIN FUNCTIONS ****************************/ 4689/************************ MAIN FUNCTIONS ****************************/
4691/******************************************************************************/ 4690/******************************************************************************/
@@ -4825,7 +4824,6 @@ key_generation_cb (void *cls,
4825 NULL, /* Don't notify about all outbound messages */ 4824 NULL, /* Don't notify about all outbound messages */
4826 GNUNET_NO, /* For header-only out notification */ 4825 GNUNET_NO, /* For header-only out notification */
4827 core_handlers); /* Register these handlers */ 4826 core_handlers); /* Register these handlers */
4828
4829 if (core_handle == NULL) 4827 if (core_handle == NULL)
4830 { 4828 {
4831 GNUNET_break (0); 4829 GNUNET_break (0);