aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-02-05 19:02:06 +0000
committerBart Polot <bart@net.in.tum.de>2014-02-05 19:02:06 +0000
commitabe14967d9c053b0f327dd5cc0731d2207b71235 (patch)
tree1fb29eb7353465be609cf1e4b246260724d4f67c
parent84e96af058595217206776bbb357a7e6042427d4 (diff)
downloadgnunet-abe14967d9c053b0f327dd5cc0731d2207b71235.tar.gz
gnunet-abe14967d9c053b0f327dd5cc0731d2207b71235.zip
- use HELLOs from DHT to try_connect on TRANSPORT level
-rw-r--r--src/mesh/gnunet-service-mesh_dht.c9
-rw-r--r--src/mesh/gnunet-service-mesh_peer.c30
-rw-r--r--src/mesh/gnunet-service-mesh_peer.h9
3 files changed, 35 insertions, 13 deletions
diff --git a/src/mesh/gnunet-service-mesh_dht.c b/src/mesh/gnunet-service-mesh_dht.c
index 40aceab3f..a88700cf1 100644
--- a/src/mesh/gnunet-service-mesh_dht.c
+++ b/src/mesh/gnunet-service-mesh_dht.c
@@ -222,16 +222,17 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
222 struct GMD_search_handle *h = cls; 222 struct GMD_search_handle *h = cls;
223 struct GNUNET_HELLO_Message *hello; 223 struct GNUNET_HELLO_Message *hello;
224 struct MeshPeerPath *p; 224 struct MeshPeerPath *p;
225 struct MeshPeer *peer;
225 226
226 LOG (GNUNET_ERROR_TYPE_DEBUG, "Got results!\n");
227 p = path_build_from_dht (get_path, get_path_length, 227 p = path_build_from_dht (get_path, get_path_length,
228 put_path, put_path_length); 228 put_path, put_path_length);
229 peer = GMP_get_short (p->peers[p->length - 1]);
230 LOG (GNUNET_ERROR_TYPE_DEBUG, "Got HELLO for %s\n", GMP_2s (peer));
229 h->callback (h->cls, p); 231 h->callback (h->cls, p);
230 path_destroy (p); 232 path_destroy (p);
231 LOG (GNUNET_ERROR_TYPE_DEBUG, "Got type %u!\n", type);
232 LOG (GNUNET_ERROR_TYPE_DEBUG, "Got size %u!\n", size);
233 hello = (struct GNUNET_HELLO_Message *) data; 233 hello = (struct GNUNET_HELLO_Message *) data;
234 LOG (GNUNET_ERROR_TYPE_DEBUG, "HELLO size %u!\n", GNUNET_HELLO_size (hello)); 234 GMP_set_hello (peer, hello);
235 GMP_try_connect (peer);
235 return; 236 return;
236} 237}
237 238
diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c
index d84d5e6de..d6998c25d 100644
--- a/src/mesh/gnunet-service-mesh_peer.c
+++ b/src/mesh/gnunet-service-mesh_peer.c
@@ -1407,20 +1407,12 @@ GMP_connect (struct MeshPeer *peer)
1407 struct MeshTunnel3 *t; 1407 struct MeshTunnel3 *t;
1408 struct MeshPeerPath *p; 1408 struct MeshPeerPath *p;
1409 struct MeshConnection *c; 1409 struct MeshConnection *c;
1410 struct GNUNET_HELLO_Message *hello;
1411 int rerun_search; 1410 int rerun_search;
1412 1411
1413 LOG (GNUNET_ERROR_TYPE_DEBUG, "peer_connect towards %s\n", GMP_2s (peer)); 1412 LOG (GNUNET_ERROR_TYPE_DEBUG, "peer_connect towards %s\n", GMP_2s (peer));
1414 1413
1415 /* If we have a current hello, try to connect using it. */ 1414 /* If we have a current hello, try to connect using it. */
1416 hello = GMP_get_hello (peer); 1415 GMP_try_connect (peer);
1417 if (NULL != hello)
1418 {
1419 struct GNUNET_MessageHeader *mh;
1420
1421 mh = GNUNET_HELLO_get_header (hello);
1422 GNUNET_TRANSPORT_offer_hello (transport_handle, mh, try_connect, peer);
1423 }
1424 1416
1425 t = peer->tunnel; 1417 t = peer->tunnel;
1426 c = NULL; 1418 c = NULL;
@@ -1942,6 +1934,26 @@ GMP_get_hello (struct MeshPeer *peer)
1942 1934
1943 1935
1944/** 1936/**
1937 * Try to connect to a peer on TRANSPORT level.
1938 *
1939 * @param peer Peer to whom to connect.
1940 */
1941void
1942GMP_try_connect (struct MeshPeer *peer)
1943{
1944 struct GNUNET_HELLO_Message *hello;
1945 struct GNUNET_MessageHeader *mh;
1946
1947 hello = GMP_get_hello (peer);
1948 if (NULL == hello)
1949 return;
1950
1951 mh = GNUNET_HELLO_get_header (hello);
1952 GNUNET_TRANSPORT_offer_hello (transport_handle, mh, try_connect, peer);
1953}
1954
1955
1956/**
1945 * Count the number of known paths toward the peer. 1957 * Count the number of known paths toward the peer.
1946 * 1958 *
1947 * @param peer Peer to get path info. 1959 * @param peer Peer to get path info.
diff --git a/src/mesh/gnunet-service-mesh_peer.h b/src/mesh/gnunet-service-mesh_peer.h
index 234991ade..eb6814894 100644
--- a/src/mesh/gnunet-service-mesh_peer.h
+++ b/src/mesh/gnunet-service-mesh_peer.h
@@ -337,6 +337,15 @@ GMP_set_hello (struct MeshPeer *peer, const struct GNUNET_HELLO_Message *hello);
337struct GNUNET_HELLO_Message * 337struct GNUNET_HELLO_Message *
338GMP_get_hello (struct MeshPeer *peer); 338GMP_get_hello (struct MeshPeer *peer);
339 339
340
341/**
342 * Try to connect to a peer on TRANSPORT level.
343 *
344 * @param peer Peer to whom to connect.
345 */
346void
347GMP_try_connect (struct MeshPeer *peer);
348
340/** 349/**
341 * Count the number of known paths toward the peer. 350 * Count the number of known paths toward the peer.
342 * 351 *