aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--src/Makefile.am4
-rw-r--r--src/include/gnunet_peerstore_service.h48
-rw-r--r--src/peerstore/Makefile.am59
-rw-r--r--src/peerstore/gnunet-peerstore.c88
-rw-r--r--src/peerstore/gnunet-service-peerstore.c117
-rw-r--r--src/peerstore/peerstore.conf.in8
-rw-r--r--src/peerstore/peerstore.h32
-rw-r--r--src/peerstore/peerstore_api.c47
-rw-r--r--src/peerstore/test_peerstore_api.c84
-rw-r--r--src/sensor/gnunet-service-sensor.c2
-rw-r--r--src/sensor/sensor.h2
12 files changed, 490 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 105950a0e..968625b22 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1458,6 +1458,8 @@ src/nse/nse.conf
1458src/peerinfo/Makefile 1458src/peerinfo/Makefile
1459src/peerinfo/peerinfo.conf 1459src/peerinfo/peerinfo.conf
1460src/peerinfo-tool/Makefile 1460src/peerinfo-tool/Makefile
1461src/peerstore/Makefile
1462src/peerstore/peerstore.conf
1461src/postgres/Makefile 1463src/postgres/Makefile
1462src/psyc/Makefile 1464src/psyc/Makefile
1463src/psyc/psyc.conf 1465src/psyc/psyc.conf
diff --git a/src/Makefile.am b/src/Makefile.am
index c2b4856fb..4b63933b8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,6 +10,7 @@ if HAVE_TESTING
10 EXPERIMENTATION = experimentation 10 EXPERIMENTATION = experimentation
11 SCALARPRODUCT = scalarproduct 11 SCALARPRODUCT = scalarproduct
12 SENSOR = sensor 12 SENSOR = sensor
13 PEERSTORE = peerstore
13endif 14endif
14 15
15if HAVE_EXPERIMENTAL 16if HAVE_EXPERIMENTAL
@@ -23,7 +24,8 @@ if HAVE_EXPERIMENTAL
23 $(SECRETSHARING) \ 24 $(SECRETSHARING) \
24 $(SCALARPRODUCT) \ 25 $(SCALARPRODUCT) \
25 $(EXPERIMENTATION) \ 26 $(EXPERIMENTATION) \
26 $(SENSOR) 27 $(SENSOR) \
28 $(PEERSTORE)
27endif 29endif
28 30
29 31
diff --git a/src/include/gnunet_peerstore_service.h b/src/include/gnunet_peerstore_service.h
new file mode 100644
index 000000000..e8a05100b
--- /dev/null
+++ b/src/include/gnunet_peerstore_service.h
@@ -0,0 +1,48 @@
1/*
2 This file is part of GNUnet
3 (C)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 */
20
21/**
22 * @file include/gnunet_peerstore_service.h
23 * @brief API to the peerstore service
24 * @author Omar Tarabai
25 */
26#ifndef GNUNET_PEERSTORE_SERVICE_H
27#define GNUNET_PEERSTORE_SERVICE_H
28
29#include "platform.h"
30#include "gnunet_util_lib.h"
31
32#ifdef __cplusplus
33extern "C"
34{
35#if 0 /* keep Emacsens' auto-indent happy */
36}
37#endif
38#endif
39
40
41#if 0 /* keep Emacsens' auto-indent happy */
42{
43#endif
44#ifdef __cplusplus
45}
46#endif
47
48#endif
diff --git a/src/peerstore/Makefile.am b/src/peerstore/Makefile.am
new file mode 100644
index 000000000..0b111cc50
--- /dev/null
+++ b/src/peerstore/Makefile.am
@@ -0,0 +1,59 @@
1AM_CPPFLAGS = -I$(top_srcdir)/src/include
2
3pkgcfgdir= $(pkgdatadir)/config.d/
4
5libexecdir= $(pkglibdir)/libexec/
6
7dist_pkgcfg_DATA = \
8 peerstore.conf
9
10if MINGW
11 WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols
12endif
13
14if USE_COVERAGE
15 AM_CFLAGS = -fprofile-arcs -ftest-coverage
16endif
17
18bin_PROGRAMS = \
19 gnunet-peerstore
20
21libexec_PROGRAMS = \
22 gnunet-service-peerstore
23
24lib_LTLIBRARIES = \
25 libgnunetpeerstore.la
26
27gnunet_peerstore_SOURCES = \
28 gnunet-peerstore.c
29gnunet_peerstore_LDADD = \
30 $(top_builddir)/src/util/libgnunetutil.la \
31 libgnunetpeerstore.la \
32 $(GN_LIBINTL)
33
34gnunet_service_peerstore_SOURCES = \
35 gnunet-service-peerstore.c
36gnunet_service_peerstore_LDADD = \
37 $(top_builddir)/src/util/libgnunetutil.la \
38 $(GN_LIBINTL)
39
40libgnunetpeerstore_la_SOURCES = \
41 peerstore_api.c
42libgnunetpeerstore_la_LIBADD = \
43 $(top_builddir)/src/util/libgnunetutil.la
44libgnunetpeerstore_la_LDFLAGS = \
45 $(GNUNET_LDFLAGS)
46
47check_PROGRAMS = \
48 test_peerstore_api
49
50if ENABLE_TEST_RUN
51AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;
52TESTS = $(check_PROGRAMS)
53endif
54
55test_peerstore_api_SOURCES = \
56 test_peerstore_api.c
57test_peerstore_api_LDADD = \
58 $(top_builddir)/src/util/libgnunetutil.la
59
diff --git a/src/peerstore/gnunet-peerstore.c b/src/peerstore/gnunet-peerstore.c
new file mode 100644
index 000000000..21b480204
--- /dev/null
+++ b/src/peerstore/gnunet-peerstore.c
@@ -0,0 +1,88 @@
1/*
2 This file is part of GNUnet.
3 (C)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file peerstore/gnunet-peerstore.c
23 * @brief peerstore tool
24 * @author Omar Tarabai
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_peerstore_service.h"
29
30static int ret;
31
32/**
33 * Run on shutdown
34 *
35 * @param cls unused
36 * @param tc scheduler context
37 */
38static void
39shutdown_task (void *cls,
40 const struct GNUNET_SCHEDULER_TaskContext *tc)
41{
42}
43
44/**
45 * Main function that will be run by the scheduler.
46 *
47 * @param cls closure
48 * @param args remaining command-line arguments
49 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
50 * @param cfg configuration
51 */
52static void
53run (void *cls,
54 char *const *args,
55 const char *cfgfile,
56 const struct GNUNET_CONFIGURATION_Handle *cfg)
57{
58
59 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
60 &shutdown_task,
61 NULL);
62
63 ret = 0;
64}
65
66/**
67 * The main function to peerstore.
68 *
69 * @param argc number of arguments from the command line
70 * @param argv command line arguments
71 * @return 0 ok, 1 on error
72 */
73int
74main (int argc, char *const *argv)
75{
76 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
77 GNUNET_GETOPT_OPTION_END
78 };
79 return (GNUNET_OK ==
80 GNUNET_PROGRAM_run (argc,
81 argv,
82 "gnunet-peerstore [options [value]]",
83 gettext_noop
84 ("peerstore"),
85 options, &run, NULL)) ? ret : 1;
86}
87
88/* end of gnunet-peerstore.c */
diff --git a/src/peerstore/gnunet-service-peerstore.c b/src/peerstore/gnunet-service-peerstore.c
new file mode 100644
index 000000000..2c54b6d0c
--- /dev/null
+++ b/src/peerstore/gnunet-service-peerstore.c
@@ -0,0 +1,117 @@
1/*
2 This file is part of GNUnet.
3 (C)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file peerstore/gnunet-service-peerstore.c
23 * @brief peerstore service implementation
24 * @author Omar Tarabai
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "peerstore.h"
29
30/**
31 * Our configuration.
32 */
33static const struct GNUNET_CONFIGURATION_Handle *cfg;
34
35/**
36 * Task run during shutdown.
37 *
38 * @param cls unused
39 * @param tc unused
40 */
41static void
42shutdown_task (void *cls,
43 const struct GNUNET_SCHEDULER_TaskContext *tc)
44{
45}
46
47
48/**
49 * A client disconnected. Remove all of its data structure entries.
50 *
51 * @param cls closure, NULL
52 * @param client identification of the client
53 */
54static void
55handle_client_disconnect (void *cls,
56 struct GNUNET_SERVER_Client
57 * client)
58{
59}
60
61/**
62 * Process statistics requests.
63 *
64 * @param cls closure
65 * @param server the initialized server
66 * @param c configuration to use
67 */
68static void
69run (void *cls,
70 struct GNUNET_SERVER_Handle *server,
71 const struct GNUNET_CONFIGURATION_Handle *c)
72{
73 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
74 {NULL, NULL, 0, 0}
75 };
76 char *database;
77 char *db_lib_name;
78
79 cfg = c;
80 if (GNUNET_OK !=
81 GNUNET_CONFIGURATION_get_value_string (cfg, "peerstore", "DATABASE",
82 &database))
83 {
84 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n");
85 return;
86 }
87 GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_peerstore_%s", database);
88
89 GNUNET_SERVER_add_handlers (server, handlers);
90 GNUNET_SERVER_disconnect_notify (server,
91 &handle_client_disconnect,
92 NULL);
93 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
94 &shutdown_task,
95 NULL);
96}
97
98
99/**
100 * The main function for the peerstore service.
101 *
102 * @param argc number of arguments from the command line
103 * @param argv command line arguments
104 * @return 0 ok, 1 on error
105 */
106int
107main (int argc, char *const *argv)
108{
109 return (GNUNET_OK ==
110 GNUNET_SERVICE_run (argc,
111 argv,
112 "peerstore",
113 GNUNET_SERVICE_OPTION_NONE,
114 &run, NULL)) ? 0 : 1;
115}
116
117/* end of gnunet-service-peerstore.c */
diff --git a/src/peerstore/peerstore.conf.in b/src/peerstore/peerstore.conf.in
new file mode 100644
index 000000000..50e0f867f
--- /dev/null
+++ b/src/peerstore/peerstore.conf.in
@@ -0,0 +1,8 @@
1[peerstore]
2BINARY = gnunet-service-peerstore
3UNIXPATH = /tmp/gnunet-service-peerstore.sock
4HOME = $SERVICEHOME
5# PORT = 2106
6@UNIXONLY@ PORT = 2088
7DATABASE = file
8
diff --git a/src/peerstore/peerstore.h b/src/peerstore/peerstore.h
new file mode 100644
index 000000000..ffc13da2a
--- /dev/null
+++ b/src/peerstore/peerstore.h
@@ -0,0 +1,32 @@
1/*
2 This file is part of GNUnet
3 (C) 2012-2013 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 */
20/**
21 * @file peerstore/peerstore.h
22 * @brief IPC messages
23 * @author Omar Tarabai
24 */
25
26#include "gnunet_peerstore_service.h"
27
28
29GNUNET_NETWORK_STRUCT_BEGIN
30
31
32GNUNET_NETWORK_STRUCT_END
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c
new file mode 100644
index 000000000..02c8d69df
--- /dev/null
+++ b/src/peerstore/peerstore_api.c
@@ -0,0 +1,47 @@
1/*
2 This file is part of GNUnet.
3 (C)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file peerstore/peerstore_api.c
23 * @brief API for peerstore
24 * @author Omar Tarabai
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "peerstore.h"
29
30#define LOG(kind,...) GNUNET_log_from (kind, "peerstore-api",__VA_ARGS__)
31
32/******************************************************************************/
33/************************ DATA STRUCTURES ****************************/
34/******************************************************************************/
35
36
37/******************************************************************************/
38/*********************** DECLARATIONS *************************/
39/******************************************************************************/
40
41
42/******************************************************************************/
43/******************* CONNECTION FUNCTIONS *********************/
44/******************************************************************************/
45
46
47/* end of peerstore_api.c */
diff --git a/src/peerstore/test_peerstore_api.c b/src/peerstore/test_peerstore_api.c
new file mode 100644
index 000000000..8bb973f74
--- /dev/null
+++ b/src/peerstore/test_peerstore_api.c
@@ -0,0 +1,84 @@
1/*
2 This file is part of GNUnet.
3 (C)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20/**
21 * @file peerstore/test_peerstore_api.c
22 * @brief testcase for peerstore_api.c
23 */
24#include "platform.h"
25#include "gnunet_util_lib.h"
26#include "gnunet_peerstore_service.h"
27
28
29static int ok = 1;
30
31
32static void
33run (void *cls,
34 char *const *args,
35 const char *cfgfile,
36 const struct GNUNET_CONFIGURATION_Handle *cfg)
37{
38 ok = 0;
39}
40
41
42static int
43check ()
44{
45 char *const argv[] = { "test-peerstore-api", NULL };
46 struct GNUNET_GETOPT_CommandLineOption options[] = {
47 GNUNET_GETOPT_OPTION_END
48 };
49 struct GNUNET_OS_Process *proc;
50 char *path = GNUNET_OS_get_libexec_binary_path ( "gnunet-service-peerstore");
51 if (NULL == path)
52 {
53 fprintf (stderr, "Service executable not found `%s'\n", "gnunet-service-peerstore");
54 return -1;
55 }
56
57 proc = GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
58 NULL, NULL, path, "gnunet-service-peerstore", NULL);
59
60 GNUNET_free (path);
61 GNUNET_assert (NULL != proc);
62 GNUNET_PROGRAM_run (1, argv, "test-peerstore-api", "nohelp",
63 options, &run, &ok);
64 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
65 {
66 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
67 ok = 1;
68 }
69 GNUNET_OS_process_wait (proc);
70 GNUNET_OS_process_destroy (proc);
71 return ok;
72}
73
74
75int
76main (int argc, char *argv[])
77{
78 GNUNET_log_setup ("test_statistics_api",
79 "WARNING",
80 NULL);
81 return check ();
82}
83
84/* end of test_peerstore_api.c */
diff --git a/src/sensor/gnunet-service-sensor.c b/src/sensor/gnunet-service-sensor.c
index eaf117b21..2f7ffaa0a 100644
--- a/src/sensor/gnunet-service-sensor.c
+++ b/src/sensor/gnunet-service-sensor.c
@@ -21,7 +21,7 @@
21/** 21/**
22 * @file sensor/gnunet-service-sensor.c 22 * @file sensor/gnunet-service-sensor.c
23 * @brief sensor service implementation 23 * @brief sensor service implementation
24 * @author Christian Grothoff 24 * @author Omar Tarabai
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
diff --git a/src/sensor/sensor.h b/src/sensor/sensor.h
index 014eb5214..a505d47d3 100644
--- a/src/sensor/sensor.h
+++ b/src/sensor/sensor.h
@@ -19,7 +19,7 @@
19 */ 19 */
20/** 20/**
21 * @file sensor/sensor.h 21 * @file sensor/sensor.h
22 * @brief example IPC messages between SENSOR API and GNS service 22 * @brief IPC messages
23 * @author Omar Tarabai 23 * @author Omar Tarabai
24 */ 24 */
25 25