gnunet-transport \
$(WLAN_BIN) \
gnunet-service-transport \
+ gnunet-service-transport-new \
gnunet-transport-list-connections \
gnunet-transport-certificate-creation
$(GN_GLPK) \
$(GN_LIBINTL)
+gnunet_service_transport_new_SOURCES = \
+ gnunet-service-transport-new.c gnunet-service-transport.h \
+ gnunet-service-transport_blacklist.h \
+ gnunet-service-transport_clients.h \
+ gnunet-service-transport_hello.h \
+ gnunet-service-transport_neighbours.h \
+ gnunet-service-transport_plugins.h \
+ gnunet-service-transport_validation.h
+gnunet_service_transport_new_LDADD = \
+ $(top_builddir)/src/hello/libgnunethello.la \
+ $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
+ $(top_builddir)/src/statistics/libgnunetstatistics.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(GN_GLPK) \
+ $(GN_LIBINTL)
+
plugin_LTLIBRARIES = \
libgnunet_plugin_transport_tcp.la \
libgnunet_plugin_transport_udp.la \
--- /dev/null
+/*
+ This file is part of GNUnet.
+ (C) 2010,2011 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 transport/gnunet-service-transport-new.c
+ * @brief
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_statistics_service.h"
+#include "gnunet_transport_service.h"
+#include "gnunet-service-transport.h"
+#include "gnunet-service-transport_blacklist.h"
+#include "gnunet-service-transport_clients.h"
+#include "gnunet-service-transport_hello.h"
+#include "gnunet-service-transport_neighbours.h"
+#include "gnunet-service-transport_plugins.h"
+#include "gnunet-service-transport_validation.h"
+
+/* globals */
+
+/**
+ * Statistics handle.
+ */
+struct GNUNET_STATISTICS_Handle *GST_stats;
+
+/**
+ * Configuration handle.
+ */
+const struct GNUNET_CONFIGURATION_Handle *GST_cfg;
+
+/**
+ * Configuration handle.
+ */
+struct GNUNET_PeerIdentity GST_my_identity;
+
+/**
+ * Our private key.
+ */
+static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key;
+
+/**
+ * Our public key.
+ */
+static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded my_public_key;
+
+/**
+ * Function called when the service shuts down. Unloads our plugins
+ * and cancels pending validations.
+ *
+ * @param cls closure, unused
+ * @param tc task context (unused)
+ */
+static void
+shutdown_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ if (GST_stats != NULL)
+ {
+ GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO);
+ GST_stats = NULL;
+ }
+ if (my_private_key != NULL)
+ {
+ GNUNET_CRYPTO_rsa_key_free (my_private_key);
+ my_private_key = NULL;
+ }
+}
+
+
+/**
+ * Initiate transport service.
+ *
+ * @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)
+{
+#if 0
+ static const struct GNUNET_SERVER_MessageHandler handlers[] = {
+ {NULL, NULL, 0, 0}
+ };
+#endif
+ char *keyfile;
+
+ /* setup globals */
+ GST_cfg = c;
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (c,
+ "GNUNETD",
+ "HOSTKEY", &keyfile))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _
+ ("Transport service is lacking key configuration settings. Exiting.\n"));
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
+ GNUNET_free (keyfile);
+ if (my_private_key == NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Transport service could not access hostkey. Exiting.\n"));
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ GST_stats = GNUNET_STATISTICS_create ("transport", c);
+ GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key);
+ GNUNET_CRYPTO_hash (&my_public_key,
+ sizeof (my_public_key), &GST_my_identity.hashPubKey);
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+ &shutdown_task, NULL);
+}
+
+
+/**
+ * The main function for the transport 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,
+ "transport",
+ GNUNET_SERVICE_OPTION_NONE,
+ &run, NULL)) ? 0 : 1;
+}
+
+/* end of file gnunet-service-transport-new.c */
*
*/
int
-GST_neighbours_handle_pong (const GNUNET_PeerIdentity *sender,
+GST_neighbours_handle_pong (const struct GNUNET_PeerIdentity *sender,
const struct GNUNET_MessageHeader *hdr,
const char *plugin_name,
const void *sender_address,
*
*/
int
-GST_neighbours_handle_connect (const GNUNET_PeerIdentity *sender,
+GST_neighbours_handle_connect (const struct GNUNET_PeerIdentity *sender,
const struct GNUNET_MessageHeader *hdr,
const char *plugin_name,
const void *sender_address,
*
*/
int
-GST_neighbours_handle_disconnect (const GNUNET_PeerIdentity *sender,
+GST_neighbours_handle_disconnect (const struct GNUNET_PeerIdentity *sender,
const struct GNUNET_MessageHeader *hdr,
const char *plugin_name,
const void *sender_address,
#define GNUNET_SERVICE_TRANSPORT_VALIDATION_H
#include "gnunet_statistics_service.h"
-#include "gnunet_transport_validation.h"
#include "gnunet_util_lib.h"
*
*/
int
-GST_validation_handle_ping (const GNUNET_PeerIdentity *sender,
+GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
const struct GNUNET_MessageHeader *hdr,
const char *plugin_name,
const void *sender_address,
*
*/
int
-GST_validation_handle_pong (const GNUNET_PeerIdentity *sender,
+GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
const struct GNUNET_MessageHeader *hdr,
const char *plugin_name,
const void *sender_address,
* is a time in the future if we're currently denying re-validation
*/
typedef void (*GST_ValidationAddressCallback)(void *cls,
- const GNUNET_PeerIdentity *target,
+ const struct GNUNET_PeerIdentity *target,
struct GNUNET_TIME_Absolute last_validated_at,
struct GNUNET_TIME_Absolute validation_block,
const char *plugin_name,
size_t plugin_address_len);
struct GST_ValidationIteratorContext *
-GST_validation_get_addresses (const GNUNET_PeerIdentity *target,
+GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
GST_ValidationAddressCallback cb,
void *cb_cls);