aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-02-02 13:39:08 +0000
committerBart Polot <bart@net.in.tum.de>2012-02-02 13:39:08 +0000
commit0f0e9c17a954e80c0baaa31b01e3f8ac27c24b03 (patch)
tree77081f45303963b7664ed0e68b5be791e241b7fd /src/mesh
parent463bedc5891215a4e496a7e45e71851dc700c54b (diff)
downloadgnunet-0f0e9c17a954e80c0baaa31b01e3f8ac27c24b03.tar.gz
gnunet-0f0e9c17a954e80c0baaa31b01e3f8ac27c24b03.zip
- Improved readibility of code by removing a ton of #if DEBUG ... #endif
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c119
-rw-r--r--src/mesh/test_mesh_small.c2
-rw-r--r--src/mesh/test_mesh_small.conf6
3 files changed, 34 insertions, 93 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 744f5d2d2..cac395521 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -42,6 +42,7 @@
42 * - add ping message 42 * - add ping message
43 * - relay corking down to core 43 * - relay corking down to core
44 * - set ttl relative to tree depth 44 * - set ttl relative to tree depth
45 * TODO END
45 */ 46 */
46 47
47#include "platform.h" 48#include "platform.h"
@@ -71,12 +72,15 @@
71 2) 72 2)
72#define DEFAULT_TTL 64 73#define DEFAULT_TTL 64
73 74
75/* TODO END */
76
74#define MESH_DEBUG_DHT GNUNET_NO 77#define MESH_DEBUG_DHT GNUNET_NO
78#define MESH_DEBUG_CONNECTION GNUNET_NO
75 79
76#if MESH_DEBUG 80#if MESH_DEBUG_CONNECTION
77#define DEBUG(...) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) 81#define DEBUG_CONN(...) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
78#else 82#else
79#define DEBUG(...) 83#define DEBUG_CONN(...)
80#endif 84#endif
81 85
82#if MESH_DEBUG_DHT 86#if MESH_DEBUG_DHT
@@ -457,12 +461,10 @@ struct MeshClient
457 */ 461 */
458 int shutting_down; 462 int shutting_down;
459 463
460#if MESH_DEBUG
461 /** 464 /**
462 * ID of the client, for debug messages 465 * ID of the client, mainly for debug messages
463 */ 466 */
464 unsigned int id; 467 unsigned int id;
465#endif
466 468
467}; 469};
468 470
@@ -592,9 +594,11 @@ GNUNET_SCHEDULER_TaskIdentifier announce_applications_task;
592 */ 594 */
593GNUNET_SCHEDULER_TaskIdentifier announce_id_task; 595GNUNET_SCHEDULER_TaskIdentifier announce_id_task;
594 596
595#if MESH_DEBUG 597/**
598 * Next ID to assign to a client
599 */
596unsigned int next_client_id; 600unsigned int next_client_id;
597#endif 601
598 602
599 603
600/******************************************************************************/ 604/******************************************************************************/
@@ -653,17 +657,16 @@ announce_applications (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
653 announce_applications_task = GNUNET_SCHEDULER_NO_TASK; 657 announce_applications_task = GNUNET_SCHEDULER_NO_TASK;
654 return; 658 return;
655 } 659 }
656#if MESH_DEBUG_DHT 660
657 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Starting PUT for apps\n"); 661 DEBUG_DHT ("MESH: Starting PUT for apps\n");
658#endif 662
659 GNUNET_CONTAINER_multihashmap_iterate (applications, &announce_application, 663 GNUNET_CONTAINER_multihashmap_iterate (applications, &announce_application,
660 NULL); 664 NULL);
661 announce_applications_task = 665 announce_applications_task =
662 GNUNET_SCHEDULER_add_delayed (APP_ANNOUNCE_TIME, &announce_applications, 666 GNUNET_SCHEDULER_add_delayed (APP_ANNOUNCE_TIME, &announce_applications,
663 cls); 667 cls);
664#if MESH_DEBUG_DHT 668 DEBUG_DHT ("MESH: Finished PUT for apps\n");
665 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Finished PUT for apps\n"); 669
666#endif
667 return; 670 return;
668} 671}
669 672
@@ -686,10 +689,8 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
686 * - Set data expiration in function of X 689 * - Set data expiration in function of X
687 * - Adapt X to churn 690 * - Adapt X to churn
688 */ 691 */
689#if MESH_DEBUG_DHT 692 DEBUG_DHT ("MESH: DHT_put for ID %s started.\n", GNUNET_i2s (&my_full_id));
690 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: DHT_put for ID %s started.\n", 693
691 GNUNET_i2s (&my_full_id));
692#endif
693 GNUNET_DHT_put (dht_handle, /* DHT handle */ 694 GNUNET_DHT_put (dht_handle, /* DHT handle */
694 &my_full_id.hashPubKey, /* Key to use */ 695 &my_full_id.hashPubKey, /* Key to use */
695 10U, /* Replication level */ 696 10U, /* Replication level */
@@ -823,6 +824,8 @@ client_is_subscribed (uint16_t message_type, struct MeshClient *c)
823 * 824 *
824 * @param cls Closure (DataDescriptor containing the task identifier) 825 * @param cls Closure (DataDescriptor containing the task identifier)
825 * @param tc Task Context 826 * @param tc Task Context
827 *
828 * FIXME reference counter cshould be just int
826 */ 829 */
827static void 830static void
828client_allow_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 831client_allow_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -831,12 +834,10 @@ client_allow_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
831 834
832 if (GNUNET_SCHEDULER_REASON_SHUTDOWN == tc->reason) 835 if (GNUNET_SCHEDULER_REASON_SHUTDOWN == tc->reason)
833 return; 836 return;
834#if MESH_DEBUG
835 GNUNET_assert (NULL != mdata->reference_counter); 837 GNUNET_assert (NULL != mdata->reference_counter);
836 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 838 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
837 "MESH: CLIENT ALLOW SEND DESPITE %u COPIES PENDING\n", 839 "MESH: CLIENT ALLOW SEND DESPITE %u COPIES PENDING\n",
838 mdata->reference_counter); 840 *(mdata->reference_counter));
839#endif
840 *(mdata->task) = GNUNET_SCHEDULER_NO_TASK; 841 *(mdata->task) = GNUNET_SCHEDULER_NO_TASK;
841 GNUNET_SERVER_receive_done (mdata->t->owner->handle, GNUNET_OK); 842 GNUNET_SERVER_receive_done (mdata->t->owner->handle, GNUNET_OK);
842} 843}
@@ -969,10 +970,8 @@ send_subscribed_clients (const struct GNUNET_MessageHeader *msg,
969 char cbuf[htons (msg->size)]; 970 char cbuf[htons (msg->size)];
970 971
971 type = ntohs (payload->type); 972 type = ntohs (payload->type);
972#if MESH_DEBUG
973 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Sending to clients...\n"); 973 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Sending to clients...\n");
974 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: message of type %u\n", type); 974 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: message of type %u\n", type);
975#endif
976 975
977 memcpy (cbuf, msg, sizeof (cbuf)); 976 memcpy (cbuf, msg, sizeof (cbuf));
978 switch (htons (msg->type)) 977 switch (htons (msg->type))
@@ -1009,9 +1008,7 @@ send_subscribed_clients (const struct GNUNET_MessageHeader *msg,
1009 1008
1010 for (count = 0, c = clients; c != NULL; c = c->next) 1009 for (count = 0, c = clients; c != NULL; c = c->next)
1011 { 1010 {
1012#if MESH_DEBUG
1013 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: client %u\n", c->id); 1011 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: client %u\n", c->id);
1014#endif
1015 if (client_is_subscribed (type, c)) 1012 if (client_is_subscribed (type, c))
1016 { 1013 {
1017 if (htons (msg->type) == GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN) 1014 if (htons (msg->type) == GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN)
@@ -2342,10 +2339,8 @@ tunnel_send_multicast_iterator (void *cls, GNUNET_PEER_Id neighbor_id)
2342 (*(mdata->reference_counter)) ++; 2339 (*(mdata->reference_counter)) ++;
2343 info->destination = neighbor_id; 2340 info->destination = neighbor_id;
2344 GNUNET_PEER_resolve (neighbor_id, &neighbor); 2341 GNUNET_PEER_resolve (neighbor_id, &neighbor);
2345#if MESH_DEBUG
2346 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: sending to %s...\n", 2342 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: sending to %s...\n",
2347 GNUNET_i2s (&neighbor)); 2343 GNUNET_i2s (&neighbor));
2348#endif
2349 info->peer = peer_info_get (&neighbor); 2344 info->peer = peer_info_get (&neighbor);
2350 GNUNET_assert (NULL != info->peer); 2345 GNUNET_assert (NULL != info->peer);
2351 i = peer_info_transmit_slot (info->peer); 2346 i = peer_info_transmit_slot (info->peer);
@@ -2374,10 +2369,8 @@ tunnel_send_multicast (struct MeshTunnel *t,
2374{ 2369{
2375 struct MeshData *mdata; 2370 struct MeshData *mdata;
2376 2371
2377#if MESH_DEBUG
2378 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2372 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2379 "MESH: sending a multicast packet...\n"); 2373 "MESH: sending a multicast packet...\n");
2380#endif
2381 mdata = GNUNET_malloc (sizeof (struct MeshData)); 2374 mdata = GNUNET_malloc (sizeof (struct MeshData));
2382 mdata->data_len = ntohs (msg->size); 2375 mdata->data_len = ntohs (msg->size);
2383 mdata->reference_counter = GNUNET_malloc (sizeof (unsigned int)); 2376 mdata->reference_counter = GNUNET_malloc (sizeof (unsigned int));
@@ -2390,14 +2383,12 @@ tunnel_send_multicast (struct MeshTunnel *t,
2390 2383
2391 mcast = (struct GNUNET_MESH_Multicast *) mdata->data; 2384 mcast = (struct GNUNET_MESH_Multicast *) mdata->data;
2392 mcast->ttl = htonl (ntohl (mcast->ttl) - 1); 2385 mcast->ttl = htonl (ntohl (mcast->ttl) - 1);
2393#if MESH_DEBUG
2394 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: data packet, ttl: %u\n", 2386 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: data packet, ttl: %u\n",
2395 ntohl (mcast->ttl)); 2387 ntohl (mcast->ttl));
2396 } 2388 }
2397 else 2389 else
2398 { 2390 {
2399 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: not a data packet, no ttl\n"); 2391 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: not a data packet, no ttl\n");
2400#endif
2401 } 2392 }
2402 if (NULL != t->owner && GNUNET_YES != t->owner->shutting_down 2393 if (NULL != t->owner && GNUNET_YES != t->owner->shutting_down
2403 && GNUNET_NO == internal) 2394 && GNUNET_NO == internal)
@@ -2424,10 +2415,8 @@ tunnel_send_multicast (struct MeshTunnel *t,
2424 // FIXME change order? 2415 // FIXME change order?
2425 GNUNET_free (mdata); 2416 GNUNET_free (mdata);
2426 } 2417 }
2427#if MESH_DEBUG
2428 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2418 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2429 "MESH: sending a multicast packet done\n"); 2419 "MESH: sending a multicast packet done\n");
2430#endif
2431 return; 2420 return;
2432} 2421}
2433 2422
@@ -2593,10 +2582,8 @@ tunnel_destroy_iterator (void *cls, const GNUNET_HashCode * key, void *value)
2593 send_client_tunnel_disconnect(t, c); 2582 send_client_tunnel_disconnect(t, c);
2594 if (c != t->owner) 2583 if (c != t->owner)
2595 { 2584 {
2596#if MESH_DEBUG
2597 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2585 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2598 "Client %u is destination, keeping the tunnel alive.\n", c->id); 2586 "Client %u is destination, keeping the tunnel alive.\n", c->id);
2599#endif
2600 tunnel_delete_client(t, c); 2587 tunnel_delete_client(t, c);
2601 client_delete_tunnel(c, t); 2588 client_delete_tunnel(c, t);
2602 return GNUNET_OK; 2589 return GNUNET_OK;
@@ -3306,13 +3293,11 @@ handle_mesh_data_multicast (void *cls, const struct GNUNET_PeerIdentity *peer,
3306 "MESH: Already seen mid %u, DROPPING!\n", t->mid); 3293 "MESH: Already seen mid %u, DROPPING!\n", t->mid);
3307 return GNUNET_OK; 3294 return GNUNET_OK;
3308 } 3295 }
3309#if MESH_DEBUG
3310 else 3296 else
3311 { 3297 {
3312 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3298 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3313 "MESH: mid %u not seen yet, forwarding\n", ntohl (msg->mid)); 3299 "MESH: mid %u not seen yet, forwarding\n", ntohl (msg->mid));
3314 } 3300 }
3315#endif
3316 t->mid = ntohl (msg->mid); 3301 t->mid = ntohl (msg->mid);
3317 tunnel_reset_timeout (t); 3302 tunnel_reset_timeout (t);
3318 3303
@@ -3322,9 +3307,7 @@ handle_mesh_data_multicast (void *cls, const struct GNUNET_PeerIdentity *peer,
3322 { 3307 {
3323 send_subscribed_clients (message, &msg[1].header); 3308 send_subscribed_clients (message, &msg[1].header);
3324 } 3309 }
3325#if MESH_DEBUG
3326 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: ttl: %u\n", ntohl (msg->ttl)); 3310 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: ttl: %u\n", ntohl (msg->ttl));
3327#endif
3328 if (ntohl (msg->ttl) == 0) 3311 if (ntohl (msg->ttl) == 0)
3329 { 3312 {
3330 /* FIXME: ttl is 0, log dropping */ 3313 /* FIXME: ttl is 0, log dropping */
@@ -3713,9 +3696,7 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp,
3713 struct MeshPeerInfo *peer_info; 3696 struct MeshPeerInfo *peer_info;
3714 struct MeshPeerPath *p; 3697 struct MeshPeerPath *p;
3715 3698
3716#if MESH_DEBUG
3717 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: got type DHT result!\n"); 3699 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: got type DHT result!\n");
3718#endif
3719 if (size != sizeof (struct GNUNET_PeerIdentity)) 3700 if (size != sizeof (struct GNUNET_PeerIdentity))
3720 { 3701 {
3721 GNUNET_break_op (0); 3702 GNUNET_break_op (0);
@@ -3754,9 +3735,7 @@ handle_local_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
3754 struct MeshClient *c; 3735 struct MeshClient *c;
3755 struct MeshClient *next; 3736 struct MeshClient *next;
3756 3737
3757#if MESH_DEBUG
3758 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: client disconnected\n"); 3738 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: client disconnected\n");
3759#endif
3760 if (client == NULL) 3739 if (client == NULL)
3761 { 3740 {
3762 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: (SERVER DOWN)\n"); 3741 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: (SERVER DOWN)\n");
@@ -3767,16 +3746,12 @@ handle_local_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
3767 { 3746 {
3768 if (c->handle != client) 3747 if (c->handle != client)
3769 { 3748 {
3770#if MESH_DEBUG
3771 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: ... searching\n"); 3749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: ... searching\n");
3772#endif
3773 c = c->next; 3750 c = c->next;
3774 continue; 3751 continue;
3775 } 3752 }
3776#if MESH_DEBUG
3777 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: matching client found (%u)\n", 3753 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: matching client found (%u)\n",
3778 c->id); 3754 c->id);
3779#endif
3780 GNUNET_SERVER_client_drop (c->handle); 3755 GNUNET_SERVER_client_drop (c->handle);
3781 c->shutting_down = GNUNET_YES; 3756 c->shutting_down = GNUNET_YES;
3782 GNUNET_assert (NULL != c->own_tunnels); 3757 GNUNET_assert (NULL != c->own_tunnels);
@@ -3807,16 +3782,11 @@ handle_local_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
3807 GNUNET_CONTAINER_multihashmap_destroy (c->types); 3782 GNUNET_CONTAINER_multihashmap_destroy (c->types);
3808 next = c->next; 3783 next = c->next;
3809 GNUNET_CONTAINER_DLL_remove (clients, clients_tail, c); 3784 GNUNET_CONTAINER_DLL_remove (clients, clients_tail, c);
3810#if MESH_DEBUG
3811 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: CLIENT FREE at %p\n", c); 3785 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: CLIENT FREE at %p\n", c);
3812#endif
3813 GNUNET_free (c); 3786 GNUNET_free (c);
3814 c = next; 3787 c = next;
3815 } 3788 }
3816
3817#if MESH_DEBUG
3818 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: done!\n"); 3789 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: done!\n");
3819#endif
3820 return; 3790 return;
3821} 3791}
3822 3792
@@ -3857,10 +3827,8 @@ handle_local_new_client (void *cls, struct GNUNET_SERVER_Client *client,
3857 3827
3858 /* Create new client structure */ 3828 /* Create new client structure */
3859 c = GNUNET_malloc (sizeof (struct MeshClient)); 3829 c = GNUNET_malloc (sizeof (struct MeshClient));
3860#if MESH_DEBUG
3861 c->id = next_client_id++; 3830 c->id = next_client_id++;
3862 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: CLIENT NEW %u\n", c->id); 3831 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: CLIENT NEW %u\n", c->id);
3863#endif
3864 c->handle = client; 3832 c->handle = client;
3865 GNUNET_SERVER_client_keep (client); 3833 GNUNET_SERVER_client_keep (client);
3866 a = (GNUNET_MESH_ApplicationType *) &cc_msg[1]; 3834 a = (GNUNET_MESH_ApplicationType *) &cc_msg[1];
@@ -3873,9 +3841,7 @@ handle_local_new_client (void *cls, struct GNUNET_SERVER_Client *client,
3873 for (i = 0; i < napps; i++) 3841 for (i = 0; i < napps; i++)
3874 { 3842 {
3875 at = ntohl (a[i]); 3843 at = ntohl (a[i]);
3876#if MESH_DEBUG
3877 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: app type: %u\n", at); 3844 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: app type: %u\n", at);
3878#endif
3879 GNUNET_CRYPTO_hash (&at, sizeof (at), &hc); 3845 GNUNET_CRYPTO_hash (&at, sizeof (at), &hc);
3880 /* store in clients hashmap */ 3846 /* store in clients hashmap */
3881 GNUNET_CONTAINER_multihashmap_put (c->apps, &hc, c, 3847 GNUNET_CONTAINER_multihashmap_put (c->apps, &hc, c,
@@ -3899,9 +3865,7 @@ handle_local_new_client (void *cls, struct GNUNET_SERVER_Client *client,
3899 for (i = 0; i < ntypes; i++) 3865 for (i = 0; i < ntypes; i++)
3900 { 3866 {
3901 u16 = ntohs (t[i]); 3867 u16 = ntohs (t[i]);
3902#if MESH_DEBUG
3903 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: msg type: %u\n", u16); 3868 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: msg type: %u\n", u16);
3904#endif
3905 GNUNET_CRYPTO_hash (&u16, sizeof (u16), &hc); 3869 GNUNET_CRYPTO_hash (&u16, sizeof (u16), &hc);
3906 3870
3907 /* store in clients hashmap */ 3871 /* store in clients hashmap */
@@ -3922,9 +3886,7 @@ handle_local_new_client (void *cls, struct GNUNET_SERVER_Client *client,
3922 GNUNET_SERVER_notification_context_add (nc, client); 3886 GNUNET_SERVER_notification_context_add (nc, client);
3923 3887
3924 GNUNET_SERVER_receive_done (client, GNUNET_OK); 3888 GNUNET_SERVER_receive_done (client, GNUNET_OK);
3925#if MESH_DEBUG
3926 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: new client processed\n"); 3889 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: new client processed\n");
3927#endif
3928} 3890}
3929 3891
3930 3892
@@ -3953,9 +3915,7 @@ handle_local_tunnel_create (void *cls, struct GNUNET_SERVER_Client *client,
3953 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 3915 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
3954 return; 3916 return;
3955 } 3917 }
3956#if MESH_DEBUG
3957 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: by client %u\n", c->id); 3918 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: by client %u\n", c->id);
3958#endif
3959 3919
3960 /* Message sanity check */ 3920 /* Message sanity check */
3961 if (sizeof (struct GNUNET_MESH_TunnelMessage) != ntohs (message->size)) 3921 if (sizeof (struct GNUNET_MESH_TunnelMessage) != ntohs (message->size))
@@ -3988,10 +3948,8 @@ handle_local_tunnel_create (void *cls, struct GNUNET_SERVER_Client *client,
3988 next_tid = next_tid & ~GNUNET_MESH_LOCAL_TUNNEL_ID_CLI; 3948 next_tid = next_tid & ~GNUNET_MESH_LOCAL_TUNNEL_ID_CLI;
3989 t->id.oid = myid; 3949 t->id.oid = myid;
3990 t->local_tid = ntohl (t_msg->tunnel_id); 3950 t->local_tid = ntohl (t_msg->tunnel_id);
3991#if MESH_DEBUG
3992 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: CREATED TUNNEL %s [%x] (%x)\n", 3951 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: CREATED TUNNEL %s [%x] (%x)\n",
3993 GNUNET_i2s (&my_full_id), t->id.tid, t->local_tid); 3952 GNUNET_i2s (&my_full_id), t->id.tid, t->local_tid);
3994#endif
3995 t->owner = c; 3953 t->owner = c;
3996 t->peers = GNUNET_CONTAINER_multihashmap_create (32); 3954 t->peers = GNUNET_CONTAINER_multihashmap_create (32);
3997 3955
@@ -4054,9 +4012,7 @@ handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
4054 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 4012 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
4055 return; 4013 return;
4056 } 4014 }
4057#if MESH_DEBUG
4058 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: by client %u\n", c->id); 4015 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: by client %u\n", c->id);
4059#endif
4060 tunnel_msg = (struct GNUNET_MESH_TunnelMessage *) message; 4016 tunnel_msg = (struct GNUNET_MESH_TunnelMessage *) message;
4061 4017
4062 /* Retrieve tunnel */ 4018 /* Retrieve tunnel */
@@ -4065,9 +4021,7 @@ handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
4065 if (NULL == t) 4021 if (NULL == t)
4066 { 4022 {
4067 GNUNET_break (0); 4023 GNUNET_break (0);
4068#if MESH_DEBUG 4024 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MESH: tunnel %X not found\n", tid);
4069 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MESH: tunnel %X not found\n", tid);
4070#endif
4071 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 4025 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
4072 return; 4026 return;
4073 } 4027 }
@@ -4471,10 +4425,8 @@ handle_local_to_origin (void *cls, struct GNUNET_SERVER_Client *client,
4471 4425
4472 /* Tunnel exists? */ 4426 /* Tunnel exists? */
4473 tid = ntohl (data_msg->tid); 4427 tid = ntohl (data_msg->tid);
4474#if MESH_DEBUG
4475 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4428 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4476 "MESH: Got a ToOrigin request from a client! Tunnel %X\n", tid); 4429 "MESH: Got a ToOrigin request from a client! Tunnel %X\n", tid);
4477#endif
4478 if (tid < GNUNET_MESH_LOCAL_TUNNEL_ID_SERV) 4430 if (tid < GNUNET_MESH_LOCAL_TUNNEL_ID_SERV)
4479 { 4431 {
4480 GNUNET_break (0); 4432 GNUNET_break (0);
@@ -4662,25 +4614,18 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
4662 struct MeshPeerInfo *peer_info; 4614 struct MeshPeerInfo *peer_info;
4663 struct MeshPeerPath *path; 4615 struct MeshPeerPath *path;
4664 4616
4665#if MESH_DEBUG_CONNECTION 4617 DEBUG_CONN ("MESH: Peer connected\n");
4666 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer connected\n"); 4618 DEBUG_CONN ("MESH: %s\n", GNUNET_i2s (&my_full_id));
4667 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: %s\n",
4668 GNUNET_i2s (&my_full_id));
4669#endif
4670 peer_info = peer_info_get (peer); 4619 peer_info = peer_info_get (peer);
4671 if (myid == peer_info->id) 4620 if (myid == peer_info->id)
4672 { 4621 {
4673#if MESH_DEBUG_CONNECTION 4622 DEBUG_CONN ("MESH: (self)\n");
4674 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: (self)\n");
4675#endif
4676 return; 4623 return;
4677 } 4624 }
4678#if MESH_DEBUG_CONNECTION
4679 else 4625 else
4680 { 4626 {
4681 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: %s\n", GNUNET_i2s (peer)); 4627 DEBUG_CONN ("MESH: %s\n", GNUNET_i2s (peer));
4682 } 4628 }
4683#endif
4684 path = path_new (2); 4629 path = path_new (2);
4685 path->peers[0] = myid; 4630 path->peers[0] = myid;
4686 path->peers[1] = peer_info->id; 4631 path->peers[1] = peer_info->id;
@@ -4702,9 +4647,7 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
4702 struct MeshPeerInfo *pi; 4647 struct MeshPeerInfo *pi;
4703 unsigned int i; 4648 unsigned int i;
4704 4649
4705#if MESH_DEBUG_CONNECTION 4650 DEBUG_CONN ("MESH: Peer disconnected\n");
4706 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer disconnected\n");
4707#endif
4708 pi = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); 4651 pi = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey);
4709 if (NULL == pi) 4652 if (NULL == pi)
4710 { 4653 {
@@ -4717,12 +4660,10 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
4717 peer_info_cancel_transmission (pi, i); 4660 peer_info_cancel_transmission (pi, i);
4718 } 4661 }
4719 peer_info_remove_path (pi, pi->id, myid); 4662 peer_info_remove_path (pi, pi->id, myid);
4720#if MESH_DEBUG_CONNECTION
4721 if (myid == pi->id) 4663 if (myid == pi->id)
4722 { 4664 {
4723 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: (self)\n"); 4665 DEBUG_CONN ("MESH: (self)\n");
4724 } 4666 }
4725#endif
4726 return; 4667 return;
4727} 4668}
4728 4669
@@ -4894,9 +4835,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
4894 4835
4895 clients = NULL; 4836 clients = NULL;
4896 clients_tail = NULL; 4837 clients_tail = NULL;
4897#if MESH_DEBUG
4898 next_client_id = 0; 4838 next_client_id = 0;
4899#endif
4900 4839
4901 announce_applications_task = GNUNET_SCHEDULER_NO_TASK; 4840 announce_applications_task = GNUNET_SCHEDULER_NO_TASK;
4902 announce_id_task = GNUNET_SCHEDULER_add_now (&announce_id, cls); 4841 announce_id_task = GNUNET_SCHEDULER_add_now (&announce_id, cls);
diff --git a/src/mesh/test_mesh_small.c b/src/mesh/test_mesh_small.c
index 3fafe0569..242062b2f 100644
--- a/src/mesh/test_mesh_small.c
+++ b/src/mesh/test_mesh_small.c
@@ -27,7 +27,7 @@
27#include "gnunet_testing_lib.h" 27#include "gnunet_testing_lib.h"
28#include "gnunet_mesh_service.h" 28#include "gnunet_mesh_service.h"
29 29
30#define VERBOSE GNUNET_NO 30#define VERBOSE GNUNET_YES
31#define REMOVE_DIR GNUNET_YES 31#define REMOVE_DIR GNUNET_YES
32 32
33struct MeshPeer 33struct MeshPeer
diff --git a/src/mesh/test_mesh_small.conf b/src/mesh/test_mesh_small.conf
index 9f524db30..289547dd8 100644
--- a/src/mesh/test_mesh_small.conf
+++ b/src/mesh/test_mesh_small.conf
@@ -53,7 +53,7 @@ PORT = 10004
53 53
54[mesh] 54[mesh]
55PORT = 10005 55PORT = 10005
56DEBUG=NO 56DEBUG = YES
57ACCEPT_FROM = 127.0.0.1; 57ACCEPT_FROM = 127.0.0.1;
58HOSTNAME = localhost 58HOSTNAME = localhost
59# PREFIX = valgrind --leak-check=full --suppressions=valgrind-mesh.supp 59# PREFIX = valgrind --leak-check=full --suppressions=valgrind-mesh.supp
@@ -63,7 +63,9 @@ HOSTNAME = localhost
63NUM_PEERS = 16 63NUM_PEERS = 16
64WEAKRANDOM = YES 64WEAKRANDOM = YES
65TOPOLOGY = NONE 65TOPOLOGY = NONE
66CONNECT_TOPOLOGY = 2D_TORUS 66CONNECT_TOPOLOGY = RING
67BLACKLIST_TOPOLOGY = RING
68BLACKLIST_TRANSPORTS = tcp udp http unix
67#TOPOLOGY_FILE = small.dat 69#TOPOLOGY_FILE = small.dat
68#CONNECT_TOPOLOGY_OPTION = CONNECT_MINIMUM 70#CONNECT_TOPOLOGY_OPTION = CONNECT_MINIMUM
69#CONNECT_TOPOLOGY_OPTION_MODIFIER = 25 71#CONNECT_TOPOLOGY_OPTION_MODIFIER = 25