gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r33137 - in gnunet: . src src/include src/peerstore src/sen


From: gnunet
Subject: [GNUnet-SVN] r33137 - in gnunet: . src src/include src/peerstore src/sensor
Date: Thu, 24 Apr 2014 15:37:25 +0200

Author: otarabai
Date: 2014-04-24 15:37:25 +0200 (Thu, 24 Apr 2014)
New Revision: 33137

Added:
   gnunet/src/include/gnunet_peerstore_service.h
   gnunet/src/peerstore/
   gnunet/src/peerstore/Makefile.am
   gnunet/src/peerstore/gnunet-peerstore.c
   gnunet/src/peerstore/gnunet-service-peerstore.c
   gnunet/src/peerstore/peerstore.conf.in
   gnunet/src/peerstore/peerstore.h
   gnunet/src/peerstore/peerstore_api.c
   gnunet/src/peerstore/test_peerstore_api.c
Modified:
   gnunet/configure.ac
   gnunet/src/Makefile.am
   gnunet/src/sensor/gnunet-service-sensor.c
   gnunet/src/sensor/sensor.h
Log:
PEERSTORE initial commit


Modified: gnunet/configure.ac
===================================================================
--- gnunet/configure.ac 2014-04-23 17:21:27 UTC (rev 33136)
+++ gnunet/configure.ac 2014-04-24 13:37:25 UTC (rev 33137)
@@ -1458,6 +1458,8 @@
 src/peerinfo/Makefile
 src/peerinfo/peerinfo.conf
 src/peerinfo-tool/Makefile
+src/peerstore/Makefile
+src/peerstore/peerstore.conf
 src/postgres/Makefile
 src/psyc/Makefile
 src/psyc/psyc.conf

Modified: gnunet/src/Makefile.am
===================================================================
--- gnunet/src/Makefile.am      2014-04-23 17:21:27 UTC (rev 33136)
+++ gnunet/src/Makefile.am      2014-04-24 13:37:25 UTC (rev 33137)
@@ -10,6 +10,7 @@
  EXPERIMENTATION = experimentation
  SCALARPRODUCT = scalarproduct
  SENSOR = sensor
+ PEERSTORE = peerstore
 endif
 
 if HAVE_EXPERIMENTAL
@@ -23,7 +24,8 @@
   $(SECRETSHARING) \
   $(SCALARPRODUCT) \
   $(EXPERIMENTATION) \
-  $(SENSOR)
+  $(SENSOR) \
+  $(PEERSTORE)
 endif
 
 

Added: gnunet/src/include/gnunet_peerstore_service.h
===================================================================
--- gnunet/src/include/gnunet_peerstore_service.h                               
(rev 0)
+++ gnunet/src/include/gnunet_peerstore_service.h       2014-04-24 13:37:25 UTC 
(rev 33137)
@@ -0,0 +1,48 @@
+/*
+      This file is part of GNUnet
+      (C) 
+
+      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 include/gnunet_peerstore_service.h
+ * @brief API to the peerstore service
+ * @author Omar Tarabai
+ */
+#ifndef GNUNET_PEERSTORE_SERVICE_H
+#define GNUNET_PEERSTORE_SERVICE_H
+
+#include "platform.h"
+#include "gnunet_util_lib.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#if 0                           /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+
+#if 0                           /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Added: gnunet/src/peerstore/Makefile.am
===================================================================
--- gnunet/src/peerstore/Makefile.am                            (rev 0)
+++ gnunet/src/peerstore/Makefile.am    2014-04-24 13:37:25 UTC (rev 33137)
@@ -0,0 +1,59 @@
+AM_CPPFLAGS = -I$(top_srcdir)/src/include
+
+pkgcfgdir= $(pkgdatadir)/config.d/
+
+libexecdir= $(pkglibdir)/libexec/
+
+dist_pkgcfg_DATA = \
+  peerstore.conf
+
+if MINGW
+ WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols 
+endif
+
+if USE_COVERAGE
+  AM_CFLAGS = -fprofile-arcs -ftest-coverage
+endif
+
+bin_PROGRAMS = \
+ gnunet-peerstore 
+
+libexec_PROGRAMS = \
+ gnunet-service-peerstore
+
+lib_LTLIBRARIES = \
+ libgnunetpeerstore.la
+
+gnunet_peerstore_SOURCES = \
+ gnunet-peerstore.c         
+gnunet_peerstore_LDADD = \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  libgnunetpeerstore.la \
+  $(GN_LIBINTL)
+
+gnunet_service_peerstore_SOURCES = \
+ gnunet-service-peerstore.c         
+gnunet_service_peerstore_LDADD = \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(GN_LIBINTL)
+
+libgnunetpeerstore_la_SOURCES = \
+  peerstore_api.c 
+libgnunetpeerstore_la_LIBADD = \
+  $(top_builddir)/src/util/libgnunetutil.la
+libgnunetpeerstore_la_LDFLAGS = \
+  $(GNUNET_LDFLAGS)
+
+check_PROGRAMS = \
+ test_peerstore_api
+
+if ENABLE_TEST_RUN
+AM_TESTS_ENVIRONMENT=export 
GNUNET_PREFIX=$${GNUNET_PREFIX:address@hidden@};export 
PATH=$${GNUNET_PREFIX:address@hidden@}/bin:$$PATH;
+TESTS = $(check_PROGRAMS)
+endif
+
+test_peerstore_api_SOURCES = \
+ test_peerstore_api.c
+test_peerstore_api_LDADD = \
+  $(top_builddir)/src/util/libgnunetutil.la  
+

Added: gnunet/src/peerstore/gnunet-peerstore.c
===================================================================
--- gnunet/src/peerstore/gnunet-peerstore.c                             (rev 0)
+++ gnunet/src/peerstore/gnunet-peerstore.c     2014-04-24 13:37:25 UTC (rev 
33137)
@@ -0,0 +1,88 @@
+/*
+     This file is part of GNUnet.
+     (C)
+
+     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 peerstore/gnunet-peerstore.c
+ * @brief peerstore tool
+ * @author Omar Tarabai
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_peerstore_service.h"
+
+static int ret;
+
+/**
+ * Run on shutdown
+ *
+ * @param cls unused
+ * @param tc scheduler context
+ */
+static void
+shutdown_task (void *cls,
+         const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+}
+
+/**
+ * Main function that will be run by the scheduler.
+ *
+ * @param cls closure
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be 
NULL!)
+ * @param cfg configuration
+ */
+static void
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+                                  &shutdown_task,
+                                  NULL);
+
+  ret = 0;
+}
+
+/**
+ * The main function to peerstore.
+ *
+ * @param argc number of arguments from the command line
+ * @param argv command line arguments
+ * @return 0 ok, 1 on error
+ */
+int
+main (int argc, char *const *argv)
+{
+  static const struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_OPTION_END
+  };
+  return (GNUNET_OK ==
+          GNUNET_PROGRAM_run (argc,
+                              argv,
+                              "gnunet-peerstore [options [value]]",
+                              gettext_noop
+                              ("peerstore"),
+                              options, &run, NULL)) ? ret : 1;
+}
+
+/* end of gnunet-peerstore.c */

Added: gnunet/src/peerstore/gnunet-service-peerstore.c
===================================================================
--- gnunet/src/peerstore/gnunet-service-peerstore.c                             
(rev 0)
+++ gnunet/src/peerstore/gnunet-service-peerstore.c     2014-04-24 13:37:25 UTC 
(rev 33137)
@@ -0,0 +1,117 @@
+/*
+     This file is part of GNUnet.
+     (C) 
+
+     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 peerstore/gnunet-service-peerstore.c
+ * @brief peerstore service implementation
+ * @author Omar Tarabai
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "peerstore.h"
+
+/**
+ * Our configuration.
+ */
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+/**
+ * Task run during shutdown.
+ *
+ * @param cls unused
+ * @param tc unused
+ */
+static void
+shutdown_task (void *cls,
+              const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+}
+
+
+/**
+ * A client disconnected.  Remove all of its data structure entries.
+ *
+ * @param cls closure, NULL
+ * @param client identification of the client
+ */
+static void
+handle_client_disconnect (void *cls,
+                         struct GNUNET_SERVER_Client
+                         * client)
+{
+}
+
+/**
+ * Process statistics requests.
+ *
+ * @param cls closure
+ * @param server the initialized server
+ * @param c configuration to use
+ */
+static void
+run (void *cls,
+     struct GNUNET_SERVER_Handle *server,
+     const struct GNUNET_CONFIGURATION_Handle *c)
+{
+  static const struct GNUNET_SERVER_MessageHandler handlers[] = {
+    {NULL, NULL, 0, 0}
+  };
+  char *database;
+  char *db_lib_name;
+
+  cfg = c;
+  if (GNUNET_OK !=
+        GNUNET_CONFIGURATION_get_value_string (cfg, "peerstore", "DATABASE",
+                                               &database))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n");
+    return;
+  }
+  GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_peerstore_%s", database);
+
+  GNUNET_SERVER_add_handlers (server, handlers);
+  GNUNET_SERVER_disconnect_notify (server, 
+                                  &handle_client_disconnect,
+                                  NULL);
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+                               &shutdown_task,
+                               NULL);
+}
+
+
+/**
+ * The main function for the peerstore service.
+ *
+ * @param argc number of arguments from the command line
+ * @param argv command line arguments
+ * @return 0 ok, 1 on error
+ */
+int
+main (int argc, char *const *argv)
+{
+  return (GNUNET_OK ==
+          GNUNET_SERVICE_run (argc,
+                              argv,
+                              "peerstore",
+                             GNUNET_SERVICE_OPTION_NONE,
+                             &run, NULL)) ? 0 : 1;
+}
+
+/* end of gnunet-service-peerstore.c */

Added: gnunet/src/peerstore/peerstore.conf.in
===================================================================
--- gnunet/src/peerstore/peerstore.conf.in                              (rev 0)
+++ gnunet/src/peerstore/peerstore.conf.in      2014-04-24 13:37:25 UTC (rev 
33137)
@@ -0,0 +1,8 @@
+[peerstore]
+BINARY = gnunet-service-peerstore
+UNIXPATH = /tmp/gnunet-service-peerstore.sock
+HOME = $SERVICEHOME
+# PORT = 2106
address@hidden@ PORT = 2088
+DATABASE = file
+

Added: gnunet/src/peerstore/peerstore.h
===================================================================
--- gnunet/src/peerstore/peerstore.h                            (rev 0)
+++ gnunet/src/peerstore/peerstore.h    2014-04-24 13:37:25 UTC (rev 33137)
@@ -0,0 +1,32 @@
+/*
+      This file is part of GNUnet
+      (C) 2012-2013 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 peerstore/peerstore.h
+ * @brief IPC messages
+ * @author Omar Tarabai
+ */
+
+#include "gnunet_peerstore_service.h"
+
+
+GNUNET_NETWORK_STRUCT_BEGIN
+
+
+GNUNET_NETWORK_STRUCT_END

Added: gnunet/src/peerstore/peerstore_api.c
===================================================================
--- gnunet/src/peerstore/peerstore_api.c                                (rev 0)
+++ gnunet/src/peerstore/peerstore_api.c        2014-04-24 13:37:25 UTC (rev 
33137)
@@ -0,0 +1,47 @@
+/*
+     This file is part of GNUnet.
+     (C) 
+
+     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 peerstore/peerstore_api.c
+ * @brief API for peerstore
+ * @author Omar Tarabai
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "peerstore.h"
+
+#define LOG(kind,...) GNUNET_log_from (kind, "peerstore-api",__VA_ARGS__)
+
+/******************************************************************************/
+/************************      DATA STRUCTURES     
****************************/
+/******************************************************************************/
+
+
+/******************************************************************************/
+/***********************         DECLARATIONS         
*************************/
+/******************************************************************************/
+
+
+/******************************************************************************/
+/*******************         CONNECTION FUNCTIONS         
*********************/
+/******************************************************************************/
+
+
+/* end of peerstore_api.c */

Added: gnunet/src/peerstore/test_peerstore_api.c
===================================================================
--- gnunet/src/peerstore/test_peerstore_api.c                           (rev 0)
+++ gnunet/src/peerstore/test_peerstore_api.c   2014-04-24 13:37:25 UTC (rev 
33137)
@@ -0,0 +1,84 @@
+/*
+     This file is part of GNUnet.
+     (C)
+
+     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 peerstore/test_peerstore_api.c
+ * @brief testcase for peerstore_api.c
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_peerstore_service.h"
+
+
+static int ok = 1;
+
+
+static void
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  ok = 0;
+}
+
+
+static int
+check ()
+{
+  char *const argv[] = { "test-peerstore-api", NULL };
+  struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_OPTION_END
+  };
+  struct GNUNET_OS_Process *proc;
+  char *path = GNUNET_OS_get_libexec_binary_path ( "gnunet-service-peerstore");
+  if (NULL == path)
+  {
+               fprintf (stderr, "Service executable not found `%s'\n", 
"gnunet-service-peerstore");
+               return -1;
+  }
+
+  proc = GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
+      NULL, NULL, path, "gnunet-service-peerstore", NULL);
+
+  GNUNET_free (path);
+  GNUNET_assert (NULL != proc);
+  GNUNET_PROGRAM_run (1, argv, "test-peerstore-api", "nohelp",
+                      options, &run, &ok);
+  if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
+    {
+      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
+      ok = 1;
+    }
+  GNUNET_OS_process_wait (proc);
+  GNUNET_OS_process_destroy (proc);
+  return ok;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+  GNUNET_log_setup ("test_statistics_api", 
+                   "WARNING",
+                   NULL);
+  return check ();
+}
+
+/* end of test_peerstore_api.c */

Modified: gnunet/src/sensor/gnunet-service-sensor.c
===================================================================
--- gnunet/src/sensor/gnunet-service-sensor.c   2014-04-23 17:21:27 UTC (rev 
33136)
+++ gnunet/src/sensor/gnunet-service-sensor.c   2014-04-24 13:37:25 UTC (rev 
33137)
@@ -21,7 +21,7 @@
 /**
  * @file sensor/gnunet-service-sensor.c
  * @brief sensor service implementation
- * @author Christian Grothoff
+ * @author Omar Tarabai
  */
 #include "platform.h"
 #include "gnunet_util_lib.h"

Modified: gnunet/src/sensor/sensor.h
===================================================================
--- gnunet/src/sensor/sensor.h  2014-04-23 17:21:27 UTC (rev 33136)
+++ gnunet/src/sensor/sensor.h  2014-04-24 13:37:25 UTC (rev 33137)
@@ -19,7 +19,7 @@
  */
 /**
  * @file sensor/sensor.h
- * @brief example IPC messages between SENSOR API and GNS service
+ * @brief IPC messages
  * @author Omar Tarabai
  */
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]