diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/gnunet-service-mesh-new.c | 35 | ||||
-rw-r--r-- | src/mesh/mesh2.h | 24 |
2 files changed, 24 insertions, 35 deletions
diff --git a/src/mesh/gnunet-service-mesh-new.c b/src/mesh/gnunet-service-mesh-new.c index 1eb76232a..697d8275e 100644 --- a/src/mesh/gnunet-service-mesh-new.c +++ b/src/mesh/gnunet-service-mesh-new.c | |||
@@ -307,6 +307,11 @@ struct MeshTunnel | |||
307 | struct MESH_TunnelID id; | 307 | struct MESH_TunnelID id; |
308 | 308 | ||
309 | /** | 309 | /** |
310 | * State of the tunnel. | ||
311 | */ | ||
312 | MeshTunnelState state; | ||
313 | |||
314 | /** | ||
310 | * Local tunnel number ( >= GNUNET_MESH_LOCAL_TUNNEL_ID_CLI or 0 ) | 315 | * Local tunnel number ( >= GNUNET_MESH_LOCAL_TUNNEL_ID_CLI or 0 ) |
311 | */ | 316 | */ |
312 | MESH_TunnelNumber local_tid; | 317 | MESH_TunnelNumber local_tid; |
@@ -1198,29 +1203,21 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
1198 | * Sends a CREATE PATH message for a path to a peer, properly registrating | 1203 | * Sends a CREATE PATH message for a path to a peer, properly registrating |
1199 | * all used resources. | 1204 | * all used resources. |
1200 | * | 1205 | * |
1201 | * @param peer PeerInfo of the final peer for whom this path is being created. | ||
1202 | * @param p Path itself. | ||
1203 | * @param t Tunnel for which the path is created. | 1206 | * @param t Tunnel for which the path is created. |
1204 | */ | 1207 | */ |
1205 | static void | 1208 | static void |
1206 | send_create_path (struct MeshPeerInfo *peer, struct MeshPeerPath *p, | 1209 | send_create_path (struct MeshTunnel *t) |
1207 | struct MeshTunnel *t) | ||
1208 | { | 1210 | { |
1209 | struct MeshPeerInfo *neighbor; | 1211 | struct MeshPeerInfo *neighbor; |
1210 | 1212 | ||
1211 | if (NULL == p) | ||
1212 | { | ||
1213 | GNUNET_break (0); | ||
1214 | return; | ||
1215 | } | ||
1216 | |||
1217 | neighbor = peer_get_short (t->next_hop); | 1213 | neighbor = peer_get_short (t->next_hop); |
1218 | queue_add (t, | 1214 | queue_add (t, |
1219 | GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE, | 1215 | GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE, |
1220 | sizeof (struct GNUNET_MESH_ManipulatePath) + | 1216 | sizeof (struct GNUNET_MESH_ManipulatePath) + |
1221 | (p->length * sizeof (struct GNUNET_PeerIdentity)), | 1217 | (t->path->length * sizeof (struct GNUNET_PeerIdentity)), |
1222 | neighbor, | 1218 | neighbor, |
1223 | t); | 1219 | t); |
1220 | t->state = MESH_TUNNEL_WAITING; | ||
1224 | } | 1221 | } |
1225 | 1222 | ||
1226 | 1223 | ||
@@ -1251,7 +1248,7 @@ send_path_ack (struct MeshTunnel *t) | |||
1251 | 1248 | ||
1252 | 1249 | ||
1253 | /** | 1250 | /** |
1254 | * Try to establish a new connection to this peer in the fiven tunnel. | 1251 | * Try to establish a new connection to this peer in the given tunnel. |
1255 | * If the peer doesn't have any path to it yet, try to get one. | 1252 | * If the peer doesn't have any path to it yet, try to get one. |
1256 | * If the peer already has some path, send a CREATE PATH towards it. | 1253 | * If the peer already has some path, send a CREATE PATH towards it. |
1257 | * | 1254 | * |
@@ -1267,7 +1264,7 @@ peer_connect (struct MeshPeerInfo *peer, struct MeshTunnel *t) | |||
1267 | { | 1264 | { |
1268 | p = peer_get_best_path (peer, t); | 1265 | p = peer_get_best_path (peer, t); |
1269 | tunnel_use_path (t, p); | 1266 | tunnel_use_path (t, p); |
1270 | send_create_path (peer, p, t); | 1267 | send_create_path (t); |
1271 | } | 1268 | } |
1272 | else if (NULL == peer->dhtget) | 1269 | else if (NULL == peer->dhtget) |
1273 | { | 1270 | { |
@@ -1285,6 +1282,7 @@ peer_connect (struct MeshPeerInfo *peer, struct MeshTunnel *t) | |||
1285 | NULL, /* xquery */ | 1282 | NULL, /* xquery */ |
1286 | 0, /* xquery bits */ | 1283 | 0, /* xquery bits */ |
1287 | &dht_get_id_handler, peer); | 1284 | &dht_get_id_handler, peer); |
1285 | t->state = MESH_TUNNEL_SEARCHING; | ||
1288 | } | 1286 | } |
1289 | /* Otherwise, there is no path but the DHT get is already started. */ | 1287 | /* Otherwise, there is no path but the DHT get is already started. */ |
1290 | } | 1288 | } |
@@ -2955,6 +2953,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2955 | return GNUNET_OK; | 2953 | return GNUNET_OK; |
2956 | } | 2954 | } |
2957 | } | 2955 | } |
2956 | t->state = MESH_TUNNEL_WAITING; | ||
2958 | dest_peer_info = | 2957 | dest_peer_info = |
2959 | GNUNET_CONTAINER_multihashmap_get (peers, &pi[size - 1].hashPubKey); | 2958 | GNUNET_CONTAINER_multihashmap_get (peers, &pi[size - 1].hashPubKey); |
2960 | if (NULL == dest_peer_info) | 2959 | if (NULL == dest_peer_info) |
@@ -3029,7 +3028,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3029 | peer_info_add_path (dest_peer_info, path2, GNUNET_NO); | 3028 | peer_info_add_path (dest_peer_info, path2, GNUNET_NO); |
3030 | path2 = path_duplicate (path); | 3029 | path2 = path_duplicate (path); |
3031 | peer_info_add_path_to_origin (orig_peer_info, path2, GNUNET_NO); | 3030 | peer_info_add_path_to_origin (orig_peer_info, path2, GNUNET_NO); |
3032 | send_create_path (dest_peer_info, path, t); | 3031 | send_create_path (t); |
3033 | } | 3032 | } |
3034 | return GNUNET_OK; | 3033 | return GNUNET_OK; |
3035 | } | 3034 | } |
@@ -3593,6 +3592,7 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3593 | { | 3592 | { |
3594 | GNUNET_break (0); | 3593 | GNUNET_break (0); |
3595 | } | 3594 | } |
3595 | t->state = MESH_TUNNEL_READY; | ||
3596 | 3596 | ||
3597 | /* Message for us? */ | 3597 | /* Message for us? */ |
3598 | if (0 == memcmp (&msg->oid, &my_full_id, sizeof (struct GNUNET_PeerIdentity))) | 3598 | if (0 == memcmp (&msg->oid, &my_full_id, sizeof (struct GNUNET_PeerIdentity))) |
@@ -3781,8 +3781,6 @@ path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3781 | * @param type type of the result | 3781 | * @param type type of the result |
3782 | * @param size number of bytes in data | 3782 | * @param size number of bytes in data |
3783 | * @param data pointer to the result data | 3783 | * @param data pointer to the result data |
3784 | * | ||
3785 | * TODO: re-issue the request after certain time? cancel after X results? | ||
3786 | */ | 3784 | */ |
3787 | static void | 3785 | static void |
3788 | dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, | 3786 | dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, |
@@ -3808,7 +3806,8 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
3808 | path_destroy (p); | 3806 | path_destroy (p); |
3809 | for (i = 0; i < peer->ntunnels; i++) | 3807 | for (i = 0; i < peer->ntunnels; i++) |
3810 | { | 3808 | { |
3811 | peer_connect (peer, peer->tunnels[i]); // FIXME add if | 3809 | if (peer->tunnels[i]->state == MESH_TUNNEL_SEARCHING) |
3810 | peer_connect (peer, peer->tunnels[i]); | ||
3812 | } | 3811 | } |
3813 | 3812 | ||
3814 | return; | 3813 | return; |
@@ -3907,7 +3906,7 @@ handle_local_new_client (void *cls, struct GNUNET_SERVER_Client *client, | |||
3907 | 3906 | ||
3908 | /* Create new client structure */ | 3907 | /* Create new client structure */ |
3909 | c = GNUNET_malloc (sizeof (struct MeshClient)); | 3908 | c = GNUNET_malloc (sizeof (struct MeshClient)); |
3910 | c->id = next_client_id++; // overflow not important: just for debug | 3909 | c->id = next_client_id++; /* overflow not important: just for debug */ |
3911 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " CLIENT NEW %u\n", c->id); | 3910 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " CLIENT NEW %u\n", c->id); |
3912 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " client has %u types\n", ntypes); | 3911 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " client has %u types\n", ntypes); |
3913 | c->handle = client; | 3912 | c->handle = client; |
diff --git a/src/mesh/mesh2.h b/src/mesh/mesh2.h index 4b55c3c4e..ec2e14a1f 100644 --- a/src/mesh/mesh2.h +++ b/src/mesh/mesh2.h | |||
@@ -241,44 +241,34 @@ GNUNET_NETWORK_STRUCT_END | |||
241 | /******************************************************************************/ | 241 | /******************************************************************************/ |
242 | 242 | ||
243 | /** | 243 | /** |
244 | * All the states a peer participating in a tunnel can be in. | 244 | * All the states a tunnel can be in. |
245 | */ | 245 | */ |
246 | enum MeshPeerState | 246 | enum MeshTunnelState |
247 | { | 247 | { |
248 | /** | 248 | /** |
249 | * Uninitialized status, should never appear in operation. | 249 | * Uninitialized status, should never appear in operation. |
250 | */ | 250 | */ |
251 | MESH_PEER_INVALID, | 251 | MESH_TUNNEL_NEW, |
252 | |||
253 | /** | ||
254 | * Peer is the root and owner of the tree | ||
255 | */ | ||
256 | MESH_PEER_ROOT, | ||
257 | |||
258 | /** | ||
259 | * Peer only retransmits traffic, is not a final destination | ||
260 | */ | ||
261 | MESH_PEER_RELAY, | ||
262 | 252 | ||
263 | /** | 253 | /** |
264 | * Path to the peer not known yet | 254 | * Path to the peer not known yet |
265 | */ | 255 | */ |
266 | MESH_PEER_SEARCHING, | 256 | MESH_TUNNEL_SEARCHING, |
267 | 257 | ||
268 | /** | 258 | /** |
269 | * Request sent, not yet answered. | 259 | * Request sent, not yet answered. |
270 | */ | 260 | */ |
271 | MESH_PEER_WAITING, | 261 | MESH_TUNNEL_WAITING, |
272 | 262 | ||
273 | /** | 263 | /** |
274 | * Peer connected and ready to accept data | 264 | * Peer connected and ready to accept data |
275 | */ | 265 | */ |
276 | MESH_PEER_READY, | 266 | MESH_TUNNEL_READY, |
277 | 267 | ||
278 | /** | 268 | /** |
279 | * Peer connected previosly but not responding | 269 | * Peer connected previosly but not responding |
280 | */ | 270 | */ |
281 | MESH_PEER_RECONNECTING | 271 | MESH_TUNNEL_RECONNECTING |
282 | }; | 272 | }; |
283 | 273 | ||
284 | 274 | ||