diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-10-12 07:10:07 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-10-12 07:10:07 +0000 |
commit | 93e3a5ea3d6f758e290f0fb24fa613c8c48c8b08 (patch) | |
tree | 8354a3000aa652813443cea37036852c8e7a4203 /src/mesh/gnunet-service-mesh.c | |
parent | ac4befb8c44d653f60924a088f5c6ffd671e13f6 (diff) | |
download | gnunet-93e3a5ea3d6f758e290f0fb24fa613c8c48c8b08.tar.gz gnunet-93e3a5ea3d6f758e290f0fb24fa613c8c48c8b08.zip |
Fixed bugs, added debug messages, extended unicast testcase
Diffstat (limited to 'src/mesh/gnunet-service-mesh.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index dfec4157f..026c8b882 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -1427,6 +1427,8 @@ tunnel_add_path (struct MeshTunnel *t, | |||
1427 | { | 1427 | { |
1428 | GNUNET_assert (0 != own_pos); | 1428 | GNUNET_assert (0 != own_pos); |
1429 | tree_add_path(t->tree, p, NULL); | 1429 | tree_add_path(t->tree, p, NULL); |
1430 | if (NULL == t->tree->me) | ||
1431 | t->tree->me = tree_find_peer(t->tree->root, p->peers[own_pos]); | ||
1430 | } | 1432 | } |
1431 | 1433 | ||
1432 | 1434 | ||
@@ -2243,10 +2245,14 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2243 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 2245 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
2244 | { | 2246 | { |
2245 | struct GNUNET_MESH_PathACK *msg; | 2247 | struct GNUNET_MESH_PathACK *msg; |
2248 | struct GNUNET_PeerIdentity id; | ||
2246 | struct MeshTunnelTreeNode *n; | 2249 | struct MeshTunnelTreeNode *n; |
2247 | struct MeshPeerInfo *peer_info; | 2250 | struct MeshPeerInfo *peer_info; |
2248 | struct MeshTunnel *t; | 2251 | struct MeshTunnel *t; |
2249 | 2252 | ||
2253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2254 | "MESH: Received a path ACK msg [%s]\n", | ||
2255 | GNUNET_i2s(&my_full_id)); | ||
2250 | msg = (struct GNUNET_MESH_PathACK *) message; | 2256 | msg = (struct GNUNET_MESH_PathACK *) message; |
2251 | t = tunnel_get (&msg->oid, msg->tid); | 2257 | t = tunnel_get (&msg->oid, msg->tid); |
2252 | if (NULL == t) | 2258 | if (NULL == t) |
@@ -2258,6 +2264,8 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2258 | /* Message for us? */ | 2264 | /* Message for us? */ |
2259 | if (0 == memcmp (&msg->oid, &my_full_id, sizeof (struct GNUNET_PeerIdentity))) | 2265 | if (0 == memcmp (&msg->oid, &my_full_id, sizeof (struct GNUNET_PeerIdentity))) |
2260 | { | 2266 | { |
2267 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2268 | "MESH: It's for us!\n"); | ||
2261 | if (NULL == t->client) | 2269 | if (NULL == t->client) |
2262 | { | 2270 | { |
2263 | GNUNET_break_op (0); | 2271 | GNUNET_break_op (0); |
@@ -2279,7 +2287,10 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2279 | send_client_peer_connected(t, peer_info->id); | 2287 | send_client_peer_connected(t, peer_info->id); |
2280 | return GNUNET_OK; | 2288 | return GNUNET_OK; |
2281 | } | 2289 | } |
2282 | 2290 | ||
2291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2292 | "MESH: not for us, retransmitting...\n"); | ||
2293 | GNUNET_PEER_resolve(t->tree->me->parent->peer, &id); | ||
2283 | peer_info = peer_info_get (&msg->oid); | 2294 | peer_info = peer_info_get (&msg->oid); |
2284 | if (NULL == peer_info) | 2295 | if (NULL == peer_info) |
2285 | { | 2296 | { |
@@ -2291,8 +2302,7 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2291 | memcpy (msg, message, sizeof (struct GNUNET_MESH_PathACK)); | 2302 | memcpy (msg, message, sizeof (struct GNUNET_MESH_PathACK)); |
2292 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, | 2303 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, |
2293 | GNUNET_TIME_UNIT_FOREVER_REL, | 2304 | GNUNET_TIME_UNIT_FOREVER_REL, |
2294 | path_get_first_hop (t->tree, | 2305 | &id, |
2295 | peer_info->id), | ||
2296 | sizeof (struct GNUNET_MESH_PathACK), | 2306 | sizeof (struct GNUNET_MESH_PathACK), |
2297 | &send_core_data_raw, msg); | 2307 | &send_core_data_raw, msg); |
2298 | return GNUNET_OK; | 2308 | return GNUNET_OK; |
@@ -3303,20 +3313,26 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3303 | struct MeshPeerInfo *peer_info; | 3313 | struct MeshPeerInfo *peer_info; |
3304 | struct MeshPeerPath *path; | 3314 | struct MeshPeerPath *path; |
3305 | 3315 | ||
3316 | #if MESH_DEBUG_CONNECTION | ||
3306 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer connected\n"); | 3317 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer connected\n"); |
3307 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: %s\n", | 3318 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: %s\n", |
3308 | GNUNET_h2s(&my_full_id.hashPubKey)); | 3319 | GNUNET_h2s(&my_full_id.hashPubKey)); |
3320 | #endif | ||
3309 | peer_info = peer_info_get (peer); | 3321 | peer_info = peer_info_get (peer); |
3310 | if (myid == peer_info->id) | 3322 | if (myid == peer_info->id) |
3311 | { | 3323 | { |
3324 | #if MESH_DEBUG_CONNECTION | ||
3312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: (self)\n"); | 3325 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: (self)\n"); |
3326 | #endif | ||
3313 | return; | 3327 | return; |
3314 | } | 3328 | } |
3329 | #if MESH_DEBUG_CONNECTION | ||
3315 | else | 3330 | else |
3316 | { | 3331 | { |
3317 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: %s\n", | 3332 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: %s\n", |
3318 | GNUNET_h2s(&peer->hashPubKey)); | 3333 | GNUNET_h2s(&peer->hashPubKey)); |
3319 | } | 3334 | } |
3335 | #endif | ||
3320 | path = path_new (2); | 3336 | path = path_new (2); |
3321 | path->peers[0] = myid; | 3337 | path->peers[0] = myid; |
3322 | path->peers[1] = peer_info->id; | 3338 | path->peers[1] = peer_info->id; |
@@ -3338,7 +3354,9 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
3338 | struct MeshPeerInfo *pi; | 3354 | struct MeshPeerInfo *pi; |
3339 | unsigned int i; | 3355 | unsigned int i; |
3340 | 3356 | ||
3357 | #if MESH_DEBUG_CONNECTION | ||
3341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer disconnected\n"); | 3358 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer disconnected\n"); |
3359 | #endif | ||
3342 | pi = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); | 3360 | pi = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); |
3343 | if (NULL == pi) | 3361 | if (NULL == pi) |
3344 | { | 3362 | { |
@@ -3350,10 +3368,12 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
3350 | peer_info_cancel_transmission(pi, i); | 3368 | peer_info_cancel_transmission(pi, i); |
3351 | } | 3369 | } |
3352 | path_remove_from_peer (pi, pi->id, myid); | 3370 | path_remove_from_peer (pi, pi->id, myid); |
3371 | #if MESH_DEBUG_CONNECTION | ||
3353 | if (myid == pi->id) | 3372 | if (myid == pi->id) |
3354 | { | 3373 | { |
3355 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: (self)\n"); | 3374 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: (self)\n"); |
3356 | } | 3375 | } |
3376 | #endif | ||
3357 | return; | 3377 | return; |
3358 | } | 3378 | } |
3359 | 3379 | ||