[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32192 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32192 - gnunet/src/mesh |
Date: |
Tue, 4 Feb 2014 13:36:31 +0100 |
Author: bartpolot
Date: 2014-02-04 13:36:31 +0100 (Tue, 04 Feb 2014)
New Revision: 32192
Added:
gnunet/src/mesh/gnunet-service-mesh_hello.c
gnunet/src/mesh/gnunet-service-mesh_hello.h
Modified:
gnunet/src/mesh/Makefile.am
gnunet/src/mesh/gnunet-service-mesh.c
Log:
- add hello subsystem to get hellos for known peers
Modified: gnunet/src/mesh/Makefile.am
===================================================================
--- gnunet/src/mesh/Makefile.am 2014-02-04 12:36:30 UTC (rev 32191)
+++ gnunet/src/mesh/Makefile.am 2014-02-04 12:36:31 UTC (rev 32192)
@@ -69,6 +69,7 @@
gnunet-service-mesh_local.c gnunet-service-mesh_local.h \
gnunet-service-mesh_peer.c gnunet-service-mesh_peer.h \
gnunet-service-mesh_dht.c gnunet-service-mesh_dht.h \
+ gnunet-service-mesh_hello.c gnunet-service-mesh_hello.h \
mesh_path.c mesh_path.h \
mesh_common.c \
gnunet-service-mesh.c
@@ -78,12 +79,14 @@
$(top_builddir)/src/core/libgnunetcore.la \
$(top_builddir)/src/dht/libgnunetdht.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
+ $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
$(top_builddir)/src/block/libgnunetblock.la
gnunet_service_mesh_DEPENDENCIES = \
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/core/libgnunetcore.la \
$(top_builddir)/src/dht/libgnunetdht.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
+ $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
$(top_builddir)/src/block/libgnunetblock.la
if LINUX
gnunet_service_mesh_LDFLAGS = -lrt
Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c 2014-02-04 12:36:30 UTC (rev
32191)
+++ gnunet/src/mesh/gnunet-service-mesh.c 2014-02-04 12:36:31 UTC (rev
32192)
@@ -52,6 +52,7 @@
#include "gnunet-service-mesh_tunnel.h"
#include "gnunet-service-mesh_dht.h"
#include "gnunet-service-mesh_peer.h"
+#include "gnunet-service-mesh_hello.h"
/******************************************************************************/
@@ -107,6 +108,7 @@
shutting_down = GNUNET_YES;
GML_shutdown ();
+ GMH_shutdown ();
GMD_shutdown ();
GMC_shutdown ();
GMT_shutdown ();
@@ -146,6 +148,7 @@
GNUNET_i2s (&my_full_id));
GML_init (server); /* Local clients */
+ GMH_shutdown (c); /* Hellos */
GMC_init (c); /* Connections */
GMP_init (c); /* Peers */
GMD_init (c); /* DHT */
Added: gnunet/src/mesh/gnunet-service-mesh_hello.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_hello.c (rev 0)
+++ gnunet/src/mesh/gnunet-service-mesh_hello.c 2014-02-04 12:36:31 UTC (rev
32192)
@@ -0,0 +1,159 @@
+/*
+ This file is part of GNUnet.
+ (C) 2014 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "platform.h"
+#include "gnunet_util_lib.h"
+
+#include "gnunet_statistics_service.h"
+#include "gnunet_peerinfo_service.h"
+
+#include "mesh_protocol.h"
+#include "mesh_path.h"
+
+#include "gnunet-service-mesh_hello.h"
+#include "gnunet-service-mesh_peer.h"
+
+#define LOG(level, ...) GNUNET_log_from(level,"mesh-hll",__VA_ARGS__)
+
+
+/******************************************************************************/
+/******************************** STRUCTS
**********************************/
+/******************************************************************************/
+
+
+
+/******************************************************************************/
+/******************************* GLOBALS
***********************************/
+/******************************************************************************/
+
+/**
+ * Global handle to the statistics service.
+ */
+extern struct GNUNET_STATISTICS_Handle *stats;
+
+/**
+ * Local peer own ID (memory efficient handle).
+ */
+extern GNUNET_PEER_Id myid;
+
+/**
+ * Local peer own ID (full value).
+ */
+extern struct GNUNET_PeerIdentity my_full_id;
+
+
+/**
+ * Don't try to recover tunnels if shutting down.
+ */
+extern int shutting_down;
+
+
+/**
+ * Hello message of local peer.
+ */
+const struct GNUNET_HELLO_Message *mine;
+
+/**
+ * Handle to peerinfo service.
+ */
+static struct GNUNET_PEERINFO_Handle *peerinfo;
+
+/**
+ * Iterator context.
+ */
+struct GNUNET_PEERINFO_NotifyContext* nc;
+
+
+/******************************************************************************/
+/******************************** STATIC
***********************************/
+/******************************************************************************/
+
+/**
+ * Process each hello message received from peerinfo.
+ *
+ * @param cls the 'struct GetUriContext'
+ * @param peer identity of the peer
+ * @param hello addresses of the peer
+ * @param err_msg error message
+ */
+static void
+got_hello (void *cls, const struct GNUNET_PeerIdentity *id,
+ const struct GNUNET_HELLO_Message *hello,
+ const char *err_msg)
+{
+ struct MeshPeer *peer;
+
+ if (NULL == id)
+ LOG (GNUNET_ERROR_TYPE_ERROR, "not a valid id\n");
+
+ peer = GMP_get (id);
+ GMP_set_hello (peer, hello);
+}
+
+
+/******************************************************************************/
+/******************************** API
***********************************/
+/******************************************************************************/
+
+
+void
+GMH_init (const struct GNUNET_CONFIGURATION_Handle *c)
+{
+ GNUNET_assert (NULL != nc);
+ peerinfo = GNUNET_PEERINFO_connect (c);
+ nc = GNUNET_PEERINFO_notify (c, GNUNET_NO, &got_hello, NULL);
+}
+
+
+void
+GMH_shutdown ()
+{
+ if (NULL != nc)
+ {
+ GNUNET_PEERINFO_notify_cancel (nc);
+ nc = NULL;
+ }
+ if (NULL != peerinfo)
+ {
+ GNUNET_PEERINFO_disconnect (peerinfo);
+ peerinfo = NULL;
+ }
+}
+
+
+const struct GNUNET_HELLO_Message *
+GMH_get_mine (void)
+{
+ return mine;
+}
+
+
+const struct GNUNET_HELLO_Message *
+GMH_get (const struct GNUNET_PeerIdentity *id)
+{
+ return GMP_get_hello (GMP_get (id));
+}
+
+void
+GMH_2s ()
+{
+}
+
+
Added: gnunet/src/mesh/gnunet-service-mesh_hello.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_hello.h (rev 0)
+++ gnunet/src/mesh/gnunet-service-mesh_hello.h 2014-02-04 12:36:31 UTC (rev
32192)
@@ -0,0 +1,61 @@
+/*
+ This file is part of GNUnet.
+ (C) 2014 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file mesh/gnunet-service-mesh_hello.h
+ * @brief mesh service; dealing with hello messages
+ * @author Bartlomiej Polot
+ *
+ * All functions in this file should use the prefix GMH (Gnunet Mesh Hello)
+ */
+
+#ifndef GNUNET_SERVICE_MESH_HELLO_H
+#define GNUNET_SERVICE_MESH_HELLO_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#if 0 /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+#include "platform.h"
+#include "gnunet_util_lib.h"
+
+
+void
+GMH_init (const struct GNUNET_CONFIGURATION_Handle *c);
+
+void
+GMH_shutdown ();
+
+
+
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+/* ifndef GNUNET_MESH_SERVICE_HELLO_H */
+#endif
+/* end of gnunet-mesh-service_hello.h */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32192 - gnunet/src/mesh,
gnunet <=