diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-08-12 13:31:46 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-08-12 13:31:46 +0000 |
commit | 4b210b2242e28da3d01f5d904bc92c898b000bbc (patch) | |
tree | d099b3e892b013f1874c5773efc3f47775834370 /src | |
parent | 9a2acd24918e45cec9c20e968089a2325a06fbf4 (diff) | |
download | gnunet-4b210b2242e28da3d01f5d904bc92c898b000bbc.tar.gz gnunet-4b210b2242e28da3d01f5d904bc92c898b000bbc.zip |
- aux function
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/gnunet-service-mesh-enc.c | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/src/mesh/gnunet-service-mesh-enc.c b/src/mesh/gnunet-service-mesh-enc.c index 23d851287..f0ba32902 100644 --- a/src/mesh/gnunet-service-mesh-enc.c +++ b/src/mesh/gnunet-service-mesh-enc.c | |||
@@ -1978,6 +1978,20 @@ peer_delete_oldest (void) | |||
1978 | 1978 | ||
1979 | 1979 | ||
1980 | /** | 1980 | /** |
1981 | * Get the static string for a peer ID. | ||
1982 | * | ||
1983 | * @param peer Peer. | ||
1984 | * | ||
1985 | * @return Static string for it's ID. | ||
1986 | */ | ||
1987 | static const char * | ||
1988 | peer2s (const struct MeshPeer *peer) | ||
1989 | { | ||
1990 | return GNUNET_i2s (GNUNET_PEER_resolve2 (peer->id)); | ||
1991 | } | ||
1992 | |||
1993 | |||
1994 | /** | ||
1981 | * Retrieve the MeshPeer stucture associated with the peer, create one | 1995 | * Retrieve the MeshPeer stucture associated with the peer, create one |
1982 | * and insert it in the appropriate structures if the peer is not known yet. | 1996 | * and insert it in the appropriate structures if the peer is not known yet. |
1983 | * | 1997 | * |
@@ -2087,7 +2101,7 @@ peer_get_best_path (const struct MeshPeer *peer) | |||
2087 | for (c = peer->tunnel->connection_head; NULL != c; c = c->next) | 2101 | for (c = peer->tunnel->connection_head; NULL != c; c = c->next) |
2088 | if (c->path == p) | 2102 | if (c->path == p) |
2089 | break; | 2103 | break; |
2090 | if (NULL != p) | 2104 | if (NULL != c) |
2091 | continue; /* If path is in use in a connection, skip it. */ | 2105 | continue; /* If path is in use in a connection, skip it. */ |
2092 | 2106 | ||
2093 | if ((cost = peer_get_path_cost (peer, p)) < best_cost) | 2107 | if ((cost = peer_get_path_cost (peer, p)) < best_cost) |
@@ -2157,12 +2171,17 @@ peer_connect (struct MeshPeer *peer) | |||
2157 | struct MeshPeerPath *p; | 2171 | struct MeshPeerPath *p; |
2158 | struct MeshConnection *c; | 2172 | struct MeshConnection *c; |
2159 | 2173 | ||
2174 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2175 | "peer_connect towards %s\n", | ||
2176 | peer2s (peer)); | ||
2160 | t = peer->tunnel; | 2177 | t = peer->tunnel; |
2161 | if (NULL != peer->path_head) | 2178 | if (NULL != peer->path_head) |
2162 | { | 2179 | { |
2180 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "path exists\n"); | ||
2163 | p = peer_get_best_path (peer); | 2181 | p = peer_get_best_path (peer); |
2164 | if (NULL != p) | 2182 | if (NULL != p) |
2165 | { | 2183 | { |
2184 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " %u hops\n", p->length); | ||
2166 | c = tunnel_use_path (t, p); | 2185 | c = tunnel_use_path (t, p); |
2167 | send_connection_create (c); | 2186 | send_connection_create (c); |
2168 | } | 2187 | } |
@@ -2173,7 +2192,7 @@ peer_connect (struct MeshPeer *peer) | |||
2173 | 2192 | ||
2174 | id = GNUNET_PEER_resolve2 (peer->id); | 2193 | id = GNUNET_PEER_resolve2 (peer->id); |
2175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2194 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2176 | " Starting DHT GET for peer %s\n", GNUNET_i2s (id)); | 2195 | " Starting DHT GET for peer %s\n", peer2s (peer)); |
2177 | peer->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */ | 2196 | peer->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */ |
2178 | GNUNET_BLOCK_TYPE_MESH_PEER, /* type */ | 2197 | GNUNET_BLOCK_TYPE_MESH_PEER, /* type */ |
2179 | &id->hashPubKey, /* key to search */ | 2198 | &id->hashPubKey, /* key to search */ |
@@ -2415,15 +2434,10 @@ peer_add_path (struct MeshPeer *peer_info, struct MeshPeerPath *path, | |||
2415 | GNUNET_realloc (path->peers, path->length * sizeof (GNUNET_PEER_Id)); | 2434 | GNUNET_realloc (path->peers, path->length * sizeof (GNUNET_PEER_Id)); |
2416 | } | 2435 | } |
2417 | } | 2436 | } |
2418 | #if MESH_DEBUG | ||
2419 | { | ||
2420 | struct GNUNET_PeerIdentity id; | ||
2421 | 2437 | ||
2422 | GNUNET_PEER_resolve (peer_info->id, &id); | 2438 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "adding path [%u] to peer %s\n", |
2423 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "adding path [%u] to peer %s\n", | 2439 | path->length, peer2s (peer_info)); |
2424 | path->length, GNUNET_i2s (&id)); | 2440 | |
2425 | } | ||
2426 | #endif | ||
2427 | l = path_get_length (path); | 2441 | l = path_get_length (path); |
2428 | if (0 == l) | 2442 | if (0 == l) |
2429 | { | 2443 | { |
@@ -2500,7 +2514,7 @@ connection_poll (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2500 | c = fc->c; | 2514 | c = fc->c; |
2501 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " *** Polling!\n"); | 2515 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " *** Polling!\n"); |
2502 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " *** connection %s[%X]\n", | 2516 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " *** connection %s[%X]\n", |
2503 | GNUNET_i2s (GNUNET_PEER_resolve2 (c->t->peer->id)), c->id); | 2517 | peer2s (c->t->peer), c->id); |
2504 | 2518 | ||
2505 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_POLL); | 2519 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_POLL); |
2506 | msg.header.size = htons (sizeof (msg)); | 2520 | msg.header.size = htons (sizeof (msg)); |
@@ -2685,11 +2699,11 @@ tunnel_change_state (struct MeshTunnel2* t, enum MeshTunnelState state) | |||
2685 | { | 2699 | { |
2686 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2700 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2687 | "Tunnel %s state was %s\n", | 2701 | "Tunnel %s state was %s\n", |
2688 | GNUNET_i2s (GNUNET_PEER_resolve2 (t->peer->id)), | 2702 | peer2s (t->peer), |
2689 | GNUNET_MESH_DEBUG_TS2S (t->state)); | 2703 | GNUNET_MESH_DEBUG_TS2S (t->state)); |
2690 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2704 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2691 | "Tunnel %s state is now %s\n", | 2705 | "Tunnel %s state is now %s\n", |
2692 | GNUNET_i2s (GNUNET_PEER_resolve2 (t->peer->id)), | 2706 | peer2s (t->peer), |
2693 | GNUNET_MESH_DEBUG_TS2S (state)); | 2707 | GNUNET_MESH_DEBUG_TS2S (state)); |
2694 | t->state = state; | 2708 | t->state = state; |
2695 | } | 2709 | } |
@@ -2701,11 +2715,11 @@ connection_change_state (struct MeshConnection* c, | |||
2701 | { | 2715 | { |
2702 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2716 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2703 | "Connection %s[%X] state was %s\n", | 2717 | "Connection %s[%X] state was %s\n", |
2704 | GNUNET_i2s (GNUNET_PEER_resolve2 (c->t->peer->id)), c->id, | 2718 | peer2s (c->t->peer), c->id, |
2705 | GNUNET_MESH_DEBUG_CS2S (c->state)); | 2719 | GNUNET_MESH_DEBUG_CS2S (c->state)); |
2706 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2720 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2707 | "Connection %s[%X] state is now %s\n", | 2721 | "Connection %s[%X] state is now %s\n", |
2708 | GNUNET_i2s (GNUNET_PEER_resolve2 (c->t->peer->id)), c->id, | 2722 | peer2s (c->t->peer), c->id, |
2709 | GNUNET_MESH_DEBUG_CS2S (state)); | 2723 | GNUNET_MESH_DEBUG_CS2S (state)); |
2710 | c->state = state; | 2724 | c->state = state; |
2711 | } | 2725 | } |
@@ -3468,7 +3482,7 @@ connection_keepalive (struct MeshConnection *c, int fwd) | |||
3468 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3482 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3469 | "sending %s keepalive for connection %s[%d]\n", | 3483 | "sending %s keepalive for connection %s[%d]\n", |
3470 | fwd ? "FWD" : "BCK", | 3484 | fwd ? "FWD" : "BCK", |
3471 | GNUNET_i2s (GNUNET_PEER_resolve2 (c->t->peer->id)), | 3485 | peer2s (c->t->peer), |
3472 | c->id); | 3486 | c->id); |
3473 | 3487 | ||
3474 | msg = (struct GNUNET_MESH_ConnectionKeepAlive *) cbuf; | 3488 | msg = (struct GNUNET_MESH_ConnectionKeepAlive *) cbuf; |
@@ -3582,7 +3596,7 @@ connection_send_destroy (struct MeshConnection *c) | |||
3582 | msg.tid = c->t->id; | 3596 | msg.tid = c->t->id; |
3583 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3597 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3584 | " sending tunnel destroy for connection %s[%X]\n", | 3598 | " sending tunnel destroy for connection %s[%X]\n", |
3585 | GNUNET_i2s (GNUNET_PEER_resolve2 (c->t->peer->id)), | 3599 | peer2s (c->t->peer), |
3586 | c->id); | 3600 | c->id); |
3587 | 3601 | ||
3588 | send_prebuilt_message_connection (&msg.header, c, NULL, GNUNET_YES); | 3602 | send_prebuilt_message_connection (&msg.header, c, NULL, GNUNET_YES); |
@@ -3609,7 +3623,7 @@ channel_send_destroy (struct MeshChannel *ch) | |||
3609 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY); | 3623 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY); |
3610 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3624 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3611 | " sending tunnel destroy for channel %s:%X\n", | 3625 | " sending tunnel destroy for channel %s:%X\n", |
3612 | GNUNET_i2s (GNUNET_PEER_resolve2 (ch->t->peer->id)), | 3626 | peer2s (ch->t->peer), |
3613 | ch->gid); | 3627 | ch->gid); |
3614 | 3628 | ||
3615 | if (NULL != ch->root) | 3629 | if (NULL != ch->root) |
@@ -3772,7 +3786,7 @@ connection_destroy (struct MeshConnection *c) | |||
3772 | return; | 3786 | return; |
3773 | 3787 | ||
3774 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "destroying connection %s[%X]\n", | 3788 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "destroying connection %s[%X]\n", |
3775 | GNUNET_i2s (GNUNET_PEER_resolve2 (c->t->peer->id)), | 3789 | peer2s (c->t->peer), |
3776 | c->id); | 3790 | c->id); |
3777 | 3791 | ||
3778 | connection_cancel_queues (c, GNUNET_YES); | 3792 | connection_cancel_queues (c, GNUNET_YES); |
@@ -3800,7 +3814,7 @@ tunnel_destroy (struct MeshTunnel2 *t) | |||
3800 | return; | 3814 | return; |
3801 | 3815 | ||
3802 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "destroying tunnel %s\n", | 3816 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "destroying tunnel %s\n", |
3803 | GNUNET_i2s (GNUNET_PEER_resolve2 (t->peer->id))); | 3817 | peer2s (t->peer); |
3804 | 3818 | ||
3805 | if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (tunnels, &t->id, t)) | 3819 | if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (tunnels, &t->id, t)) |
3806 | GNUNET_break (0); | 3820 | GNUNET_break (0); |
@@ -4051,7 +4065,7 @@ connection_fwd_timeout (void *cls, | |||
4051 | return; | 4065 | return; |
4052 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4066 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4053 | "Connection %s[%X] FWD timed out. Destroying.\n", | 4067 | "Connection %s[%X] FWD timed out. Destroying.\n", |
4054 | GNUNET_i2s(GNUNET_PEER_resolve2 (c->t->peer->id)), | 4068 | peer2s (c->t->peer), |
4055 | c->id); | 4069 | c->id); |
4056 | 4070 | ||
4057 | if (NULL != c->t->channel_head) /* If local, leave TODO review */ | 4071 | if (NULL != c->t->channel_head) /* If local, leave TODO review */ |
@@ -4080,7 +4094,7 @@ connection_bck_timeout (void *cls, | |||
4080 | 4094 | ||
4081 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4095 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4082 | "Connection %s[%X] FWD timed out. Destroying.\n", | 4096 | "Connection %s[%X] FWD timed out. Destroying.\n", |
4083 | GNUNET_i2s(GNUNET_PEER_resolve2 (c->t->peer->id)), | 4097 | peer2s (c->t->peer), |
4084 | c->id); | 4098 | c->id); |
4085 | 4099 | ||
4086 | if (NULL != c->t->channel_head) /* If local, leave TODO review */ | 4100 | if (NULL != c->t->channel_head) /* If local, leave TODO review */ |