From b1a71d135c08eac25e42f53a6ede7e9b518c3eaa Mon Sep 17 00:00:00 2001 From: Sree Harsha Totakura Date: Tue, 12 Jun 2012 20:23:00 +0000 Subject: testbed service build system --- configure.ac | 1 + src/testbed/Makefile.am | 12 ++++ src/testbed/gnunet-service-testbed.c | 122 +++++++++++++++++++++++++++++++++++ src/testbed/testbed.conf | 0 src/testbed/testbed.conf.in | 12 ++++ src/testbed/testbed.h | 4 +- 6 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 src/testbed/gnunet-service-testbed.c delete mode 100644 src/testbed/testbed.conf create mode 100644 src/testbed/testbed.conf.in diff --git a/configure.ac b/configure.ac index de4817a0c..ececc8e71 100644 --- a/configure.ac +++ b/configure.ac @@ -1091,6 +1091,7 @@ src/statistics/statistics.conf src/stream/Makefile src/template/Makefile src/testbed/Makefile +src/testbed/testbed.conf src/testing/Makefile src/testing_old/Makefile src/topology/Makefile diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am index a1b290e1b..3f613b0d6 100644 --- a/src/testbed/Makefile.am +++ b/src/testbed/Makefile.am @@ -11,6 +11,18 @@ endif pkgcfgdir= $(pkgdatadir)/config.d/ +pkgcfg_DATA = \ + testbed.conf + +bin_PROGRAMS = \ + gnunet-service-testbed + +gnunet_service_testbed_SOURCES = \ + gnunet-service-testbed.c +gnunet_service_testbed_LDADD = $(XLIB) \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(LTLIBINTL) + dist_pkgcfg_DATA = \ testbed.conf diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c new file mode 100644 index 000000000..58639384e --- /dev/null +++ b/src/testbed/gnunet-service-testbed.c @@ -0,0 +1,122 @@ +/* + This file is part of GNUnet. + (C) 2012 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 2, 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 testbed/gnunet-service-testbed.c + * @brief implementation of the TESTBED service + * @author Sree Harsha Totakura + */ + +#include "platform.h" +#include "gnunet_service_lib.h" +#include "gnunet_server_lib.h" + +#include "testbed.h" + + +#define LOG(kind,...) \ + GNUNET_log (kind, __VA_ARGS__) + + +/** + * Message handler for GNUNET_MESSAGE_TYPE_TESTBED_INIT messages + * + * @param cls NULL + * @param client identification of the client + * @param message the actual message + */ +static void +handle_init (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) +{ + GNUNET_break (0); +} + + +/** + * Callback for client disconnect + * + * @param cls NULL + * @param client the client which has disconnected + */ +static void +client_disconnect_cb (void *cls, struct GNUNET_SERVER_Client *client) +{ + GNUNET_break (0); +} + + +/** + * Task to clean up and shutdown nicely + * + * @param cls NULL + * @param tc the TaskContext from scheduler + */ +static void +shutdown_task (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + GNUNET_break (0); +} + + +/** + * Testbed setup + * + * @param cls closure + * @param server the initialized server + * @param cfg configuration to use + */ +static void +testbed_run (void *cls, + struct GNUNET_SERVER_Handle * server, + const struct GNUNET_CONFIGURATION_Handle *cfg) +{ + static const struct GNUNET_SERVER_MessageHandler message_handlers[] = + { + {&handle_init, NULL, GNUNET_MESSAGE_TYPE_TESTBED_INIT, 0}, + {NULL} + }; + GNUNET_SERVER_add_handlers (server, + message_handlers); + GNUNET_SERVER_disconnect_notify (server, + &client_disconnect_cb, + NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, + &shutdown_task, + NULL); +} + + +/** + * The starting point of execution + */ +int main (int argc, char *const *argv) +{ + return + (GNUNET_OK == + GNUNET_SERVICE_run (argc, + argv, + "testbed", + GNUNET_SERVICE_OPTION_NONE, + &testbed_run, + NULL)) ? 0 : 1; +} diff --git a/src/testbed/testbed.conf b/src/testbed/testbed.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/testbed/testbed.conf.in b/src/testbed/testbed.conf.in new file mode 100644 index 000000000..2f658fddd --- /dev/null +++ b/src/testbed/testbed.conf.in @@ -0,0 +1,12 @@ +[testbed] +AUTOSTART = NO +@UNIXONLY@ PORT = 2101 +HOSTNAME = localhost +HOME = $SERVICEHOME +CONFIG = $DEFAULTCONFIG +BINARY = gnunet-service-testbed +ACCEPT_FROM = 127.0.0.1; +ACCEPT_FROM6 = ::1; +UNIXPATH = /tmp/gnunet-service-testbed.sock +UNIX_MATCH_UID = YES +UNIX_MATCH_GID = YES diff --git a/src/testbed/testbed.h b/src/testbed/testbed.h index 703ca0308..3c096399a 100644 --- a/src/testbed/testbed.h +++ b/src/testbed/testbed.h @@ -566,9 +566,9 @@ struct GNUNET_TESTBED_PeerConfigurationInformationMessage struct GNUNET_MessageHeader header; /** - * Peer identity of the peer that was created. + * Peer number of the peer that was created. */ - uint32_t peer_id GNUNET_PACKED; + uint32_t peer_number GNUNET_PACKED; /** * Operation ID of the operation that created this event. -- cgit v1.2.3