[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32198 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32198 - gnunet/src/mesh |
Date: |
Tue, 4 Feb 2014 13:36:36 +0100 |
Author: bartpolot
Date: 2014-02-04 13:36:36 +0100 (Tue, 04 Feb 2014)
New Revision: 32198
Modified:
gnunet/src/mesh/Makefile.am
gnunet/src/mesh/gnunet-service-mesh_peer.c
gnunet/src/mesh/gnunet-service-mesh_peer.h
Log:
Use stored hellos to try to establish direct connections to peers with tunnels
Modified: gnunet/src/mesh/Makefile.am
===================================================================
--- gnunet/src/mesh/Makefile.am 2014-02-04 12:36:35 UTC (rev 32197)
+++ gnunet/src/mesh/Makefile.am 2014-02-04 12:36:36 UTC (rev 32198)
@@ -76,6 +76,7 @@
gnunet_service_mesh_CFLAGS = $(AM_CFLAGS)
gnunet_service_mesh_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/transport>/libgnunettransport.la \
$(top_builddir)/src/core/libgnunetcore.la \
$(top_builddir)/src/dht/libgnunetdht.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
@@ -83,6 +84,7 @@
$(top_builddir)/src/block/libgnunetblock.la
gnunet_service_mesh_DEPENDENCIES = \
$(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/transport/libgnunettransport.la \
$(top_builddir)/src/core/libgnunetcore.la \
$(top_builddir)/src/dht/libgnunetdht.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
Modified: gnunet/src/mesh/gnunet-service-mesh_peer.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.c 2014-02-04 12:36:35 UTC (rev
32197)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.c 2014-02-04 12:36:36 UTC (rev
32198)
@@ -22,6 +22,7 @@
#include "platform.h"
#include "gnunet_util_lib.h"
+#include "gnunet_transport_service.h"
#include "gnunet_core_service.h"
#include "gnunet_statistics_service.h"
@@ -163,7 +164,7 @@
/**
* Hello message.
*/
- const struct GNUNET_HELLO_Message* hello;
+ struct GNUNET_HELLO_Message* hello;
};
@@ -206,7 +207,9 @@
*/
static struct GNUNET_CORE_Handle *core_handle;
+static struct GNUNET_TRANSPORT_Handle *transport_handle;
+
/******************************************************************************/
/***************************** CORE CALLBACKS
*********************************/
/******************************************************************************/
@@ -1292,12 +1295,17 @@
NULL, /* Don't notify about all
outbound messages */
GNUNET_NO, /* For header-only out
notification */
core_handlers); /* Register these
handlers */
- if (NULL == core_handle)
+ transport_handle = GNUNET_TRANSPORT_connect (c, &my_full_id,
+ NULL, /* cls */
+ NULL, NULL, NULL); /* Notify callbacks
*/
+
+ if (NULL == core_handle || NULL == transport_handle)
{
GNUNET_break (0);
GNUNET_SCHEDULER_shutdown ();
return;
}
+
}
/**
@@ -1363,6 +1371,24 @@
/**
+ * Try to connect to a peer on transport level.
+ *
+ * @param cls Closure (peer).
+ * @param tc TaskContext.
+ */
+static void
+try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct MeshPeer *peer = cls;
+
+ if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
+ return;
+
+ GNUNET_TRANSPORT_try_connect (transport_handle,
+ GNUNET_PEER_resolve2 (peer->id), NULL, NULL);
+}
+
+/**
* Try to establish a new connection to this peer (in its tunnel).
* If the peer doesn't have any path to it yet, try to get one.
* If the peer already has some path, send a CREATE CONNECTION towards it.
@@ -1375,9 +1401,21 @@
struct MeshTunnel3 *t;
struct MeshPeerPath *p;
struct MeshConnection *c;
+ struct GNUNET_HELLO_Message *hello;
int rerun_search;
LOG (GNUNET_ERROR_TYPE_DEBUG, "peer_connect towards %s\n", GMP_2s (peer));
+
+ /* If we have a current hello, try to connect using it. */
+ hello = GMP_get_hello (peer);
+ if (NULL != hello)
+ {
+ struct GNUNET_MessageHeader *mh;
+
+ mh = GNUNET_HELLO_get_header (hello);
+ GNUNET_TRANSPORT_offer_hello (transport_handle, mh, try_connect, peer);
+ }
+
t = peer->tunnel;
c = NULL;
rerun_search = GNUNET_NO;
@@ -1840,7 +1878,7 @@
* @param hello Hello message.
*/
void
-GMP_set_hello (struct MeshPeer *peer, const struct GNUNET_HELLO_Message *hello)
+GMP_set_hello (struct MeshPeer *peer, struct GNUNET_HELLO_Message *hello)
{
struct GNUNET_TIME_Absolute expiration;
struct GNUNET_TIME_Relative remaining;
@@ -1870,7 +1908,7 @@
*
* @return Hello message.
*/
-const struct GNUNET_HELLO_Message *
+struct GNUNET_HELLO_Message *
GMP_get_hello (struct MeshPeer *peer)
{
struct GNUNET_TIME_Absolute expiration;
Modified: gnunet/src/mesh/gnunet-service-mesh_peer.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.h 2014-02-04 12:36:35 UTC (rev
32197)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.h 2014-02-04 12:36:36 UTC (rev
32198)
@@ -325,7 +325,7 @@
* @param hello Hello message.
*/
void
-GMP_set_hello (struct MeshPeer *peer, const struct GNUNET_HELLO_Message
*hello);
+GMP_set_hello (struct MeshPeer *peer, struct GNUNET_HELLO_Message *hello);
/**
* Get the hello message.
@@ -334,7 +334,7 @@
*
* @return Hello message.
*/
-const struct GNUNET_HELLO_Message *
+struct GNUNET_HELLO_Message *
GMP_get_hello (struct MeshPeer *peer);
/**
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32198 - gnunet/src/mesh,
gnunet <=