aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-07-19 14:27:50 +0000
committerBart Polot <bart@net.in.tum.de>2013-07-19 14:27:50 +0000
commit836653f6bda35666359b4861490ccbd685b358eb (patch)
tree9f115f61369adaea0e4d3ed4d3c671995b7d6cfa /src/mesh
parent0bf3528ea3b8cac950eee7e3e36b2ae91e3202b0 (diff)
downloadgnunet-836653f6bda35666359b4861490ccbd685b358eb.tar.gz
gnunet-836653f6bda35666359b4861490ccbd685b358eb.zip
- log tunnel state evolution
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c95
1 files changed, 83 insertions, 12 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 6a56f605b..8e4dbb44e 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -837,6 +837,16 @@ tunnel_get (const struct GNUNET_PeerIdentity *oid, MESH_TunnelNumber tid);
837 837
838 838
839/** 839/**
840 * Change the tunnel state.
841 *
842 * @param t Tunnel whose ttate to change.
843 * @param state New state.
844 */
845static void
846tunnel_change_state (struct MeshTunnel *t, enum MeshTunnelState state);
847
848
849/**
840 * Notify a tunnel that a connection has broken that affects at least 850 * Notify a tunnel that a connection has broken that affects at least
841 * some of its peers. 851 * some of its peers.
842 * 852 *
@@ -959,6 +969,45 @@ void
959__mesh_divider______________________________________________________________(); 969__mesh_divider______________________________________________________________();
960 970
961 971
972static const char *
973GNUNET_MESH_DEBUG_S2S (enum MeshTunnelState s)
974{
975 static char buf[128];
976
977 switch (s)
978 {
979 /**
980 * Uninitialized status, should never appear in operation.
981 */
982 case MESH_TUNNEL_NEW: return "MESH_TUNNEL_NEW";
983
984 /**
985 * Path to the peer not known yet
986 */
987 case MESH_TUNNEL_SEARCHING: return "MESH_TUNNEL_SEARCHING";
988
989 /**
990 * Request sent, not yet answered.
991 */
992 case MESH_TUNNEL_WAITING: return "MESH_TUNNEL_WAITING";
993
994 /**
995 * Peer connected and ready to accept data
996 */
997 case MESH_TUNNEL_READY: return "MESH_TUNNEL_READY";
998
999 /**
1000 * Peer connected previosly but not responding
1001 */
1002 case MESH_TUNNEL_RECONNECTING: return "MESH_TUNNEL_RECONNECTING";
1003
1004 default:
1005 sprintf (buf, "%u (UNKNOWN STATE)", s);
1006 return buf;
1007 }
1008}
1009
1010
962/******************************************************************************/ 1011/******************************************************************************/
963/************************ PERIODIC FUNCTIONS ****************************/ 1012/************************ PERIODIC FUNCTIONS ****************************/
964/******************************************************************************/ 1013/******************************************************************************/
@@ -1236,7 +1285,7 @@ send_path_create (struct MeshTunnel *t)
1236 (t->path->length * sizeof (struct GNUNET_PeerIdentity)), 1285 (t->path->length * sizeof (struct GNUNET_PeerIdentity)),
1237 neighbor, 1286 neighbor,
1238 t); 1287 t);
1239 t->state = MESH_TUNNEL_WAITING; 1288 tunnel_change_state (t, MESH_TUNNEL_WAITING);
1240} 1289}
1241 1290
1242 1291
@@ -1248,16 +1297,16 @@ send_path_create (struct MeshTunnel *t)
1248static void 1297static void
1249send_path_ack (struct MeshTunnel *t) 1298send_path_ack (struct MeshTunnel *t)
1250{ 1299{
1251 struct MeshPeerInfo *peer; 1300 struct MeshPeerInfo *neighbor;
1252
1253 peer = peer_get_short (t->prev_hop);
1254 t->state = MESH_TUNNEL_WAITING;
1255 1301
1302 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Send path ack\n");
1303 neighbor = peer_get_short (t->prev_hop);
1256 queue_add (t, 1304 queue_add (t,
1257 GNUNET_MESSAGE_TYPE_MESH_PATH_ACK, 1305 GNUNET_MESSAGE_TYPE_MESH_PATH_ACK,
1258 sizeof (struct GNUNET_MESH_PathACK), 1306 sizeof (struct GNUNET_MESH_PathACK),
1259 peer, 1307 neighbor,
1260 t); 1308 t);
1309 tunnel_change_state (t, MESH_TUNNEL_WAITING);
1261} 1310}
1262 1311
1263 1312
@@ -1574,7 +1623,7 @@ peer_connect (struct MeshPeerInfo *peer, struct MeshTunnel *t)
1574 NULL, /* xquery */ 1623 NULL, /* xquery */
1575 0, /* xquery bits */ 1624 0, /* xquery bits */
1576 &dht_get_id_handler, peer); 1625 &dht_get_id_handler, peer);
1577 t->state = MESH_TUNNEL_SEARCHING; 1626 tunnel_change_state (t, MESH_TUNNEL_SEARCHING);
1578 } 1627 }
1579 else 1628 else
1580 { 1629 {
@@ -2162,6 +2211,28 @@ tunnel_get (const struct GNUNET_PeerIdentity *oid, MESH_TunnelNumber tid)
2162 2211
2163 2212
2164/** 2213/**
2214 * Change the tunnel state.
2215 *
2216 * @param t Tunnel whose ttate to change.
2217 * @param state New state.
2218 */
2219static void
2220tunnel_change_state (struct MeshTunnel *t, enum MeshTunnelState state)
2221{
2222 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2223 "Tunnel %s[%X] state was %s\n",
2224 GNUNET_i2s (GNUNET_PEER_resolve2 (t->id.oid)), t->id.tid,
2225 GNUNET_MESH_DEBUG_S2S (t->state));
2226 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2227 "Tunnel %s[%X] state is now %s\n",
2228 GNUNET_i2s (GNUNET_PEER_resolve2 (t->id.oid)), t->id.tid,
2229 GNUNET_MESH_DEBUG_S2S (state));
2230 t->state = state;
2231}
2232
2233
2234
2235/**
2165 * Add a client to a tunnel, initializing all needed data structures. 2236 * Add a client to a tunnel, initializing all needed data structures.
2166 * 2237 *
2167 * @param t Tunnel to which add the client. 2238 * @param t Tunnel to which add the client.
@@ -3810,7 +3881,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer,
3810 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " nobuffer:%d\n", t->nobuffer); 3881 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " nobuffer:%d\n", t->nobuffer);
3811 } 3882 }
3812 tunnel_reset_timeout (t, GNUNET_YES); 3883 tunnel_reset_timeout (t, GNUNET_YES);
3813 t->state = MESH_TUNNEL_WAITING; 3884 tunnel_change_state (t, MESH_TUNNEL_WAITING);
3814 dest_peer_info = 3885 dest_peer_info =
3815 GNUNET_CONTAINER_multihashmap_get (peers, &pi[size - 1].hashPubKey); 3886 GNUNET_CONTAINER_multihashmap_get (peers, &pi[size - 1].hashPubKey);
3816 if (NULL == dest_peer_info) 3887 if (NULL == dest_peer_info)
@@ -3964,7 +4035,7 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
3964 { 4035 {
3965 GNUNET_break (0); 4036 GNUNET_break (0);
3966 } 4037 }
3967 t->state = MESH_TUNNEL_READY; 4038 tunnel_change_state (t, MESH_TUNNEL_READY);
3968 tunnel_reset_timeout (t, GNUNET_NO); 4039 tunnel_reset_timeout (t, GNUNET_NO);
3969 t->next_fc.last_ack_recv = (NULL == t->client) ? ntohl (msg->ack) : 0; 4040 t->next_fc.last_ack_recv = (NULL == t->client) ? ntohl (msg->ack) : 0;
3970 t->prev_fc.last_ack_sent = ntohl (msg->ack); 4041 t->prev_fc.last_ack_sent = ntohl (msg->ack);
@@ -4170,7 +4241,7 @@ handle_mesh_data (const struct GNUNET_PeerIdentity *peer,
4170 return GNUNET_OK; 4241 return GNUNET_OK;
4171 } 4242 }
4172 if (NULL != c) 4243 if (NULL != c)
4173 t->state = MESH_TUNNEL_READY; 4244 tunnel_change_state (t, MESH_TUNNEL_READY);
4174 tunnel_reset_timeout (t, fwd); 4245 tunnel_reset_timeout (t, fwd);
4175 if (NULL != c) 4246 if (NULL != c)
4176 { 4247 {
@@ -4472,7 +4543,7 @@ handle_mesh_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
4472 4543
4473 fc->last_ack_recv = ack; 4544 fc->last_ack_recv = ack;
4474 peer_unlock_queue (id); 4545 peer_unlock_queue (id);
4475 t->state = MESH_TUNNEL_READY; 4546 tunnel_change_state (t, MESH_TUNNEL_READY);
4476 4547
4477 tunnel_send_ack (t, GNUNET_MESSAGE_TYPE_MESH_ACK, t->next_hop == id); 4548 tunnel_send_ack (t, GNUNET_MESSAGE_TYPE_MESH_ACK, t->next_hop == id);
4478 4549
@@ -4589,7 +4660,7 @@ handle_mesh_keepalive (void *cls, const struct GNUNET_PeerIdentity *peer,
4589 hop = fwd ? t->next_hop : t->prev_hop; 4660 hop = fwd ? t->next_hop : t->prev_hop;
4590 4661
4591 if (NULL != c) 4662 if (NULL != c)
4592 t->state = MESH_TUNNEL_READY; 4663 tunnel_change_state (t, MESH_TUNNEL_READY);
4593 tunnel_reset_timeout (t, fwd); 4664 tunnel_reset_timeout (t, fwd);
4594 if (NULL != c || 0 == hop || myid == hop) 4665 if (NULL != c || 0 == hop || myid == hop)
4595 return GNUNET_OK; 4666 return GNUNET_OK;