gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r16370 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r16370 - gnunet/src/transport
Date: Thu, 4 Aug 2011 14:58:58 +0200

Author: grothoff
Date: 2011-08-04 14:58:58 +0200 (Thu, 04 Aug 2011)
New Revision: 16370

Added:
   gnunet/src/transport/gnunet-service-transport-new.c
Modified:
   gnunet/src/transport/Makefile.am
   gnunet/src/transport/gnunet-service-transport.h
   gnunet/src/transport/gnunet-service-transport_blacklist.h
   gnunet/src/transport/gnunet-service-transport_clients.h
   gnunet/src/transport/gnunet-service-transport_neighbours.h
   gnunet/src/transport/gnunet-service-transport_plugins.h
   gnunet/src/transport/gnunet-service-transport_validation.h
Log:
draft

Modified: gnunet/src/transport/Makefile.am
===================================================================
--- gnunet/src/transport/Makefile.am    2011-08-04 12:21:21 UTC (rev 16369)
+++ gnunet/src/transport/Makefile.am    2011-08-04 12:58:58 UTC (rev 16370)
@@ -86,6 +86,7 @@
  gnunet-transport \
  $(WLAN_BIN) \
  gnunet-service-transport \
+ gnunet-service-transport-new \
  gnunet-transport-list-connections \
  gnunet-transport-certificate-creation
 
@@ -146,6 +147,22 @@
   $(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 \

Added: gnunet/src/transport/gnunet-service-transport-new.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport-new.c                         
(rev 0)
+++ gnunet/src/transport/gnunet-service-transport-new.c 2011-08-04 12:58:58 UTC 
(rev 16370)
@@ -0,0 +1,157 @@
+/*
+     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 */

Modified: gnunet/src/transport/gnunet-service-transport.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport.h     2011-08-04 12:21:21 UTC 
(rev 16369)
+++ gnunet/src/transport/gnunet-service-transport.h     2011-08-04 12:58:58 UTC 
(rev 16370)
@@ -27,7 +27,6 @@
 #define GNUNET_SERVICE_TRANSPORT_H
 
 #include "gnunet_statistics_service.h"
-#include "gnunet_transport_plugins.h"
 #include "gnunet_transport_service.h"
 #include "gnunet_util_lib.h"
 

Modified: gnunet/src/transport/gnunet-service-transport_blacklist.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_blacklist.h   2011-08-04 
12:21:21 UTC (rev 16369)
+++ gnunet/src/transport/gnunet-service-transport_blacklist.h   2011-08-04 
12:58:58 UTC (rev 16370)
@@ -27,7 +27,6 @@
 #define GNUNET_SERVICE_TRANSPORT_BLACKLIST_H
 
 #include "gnunet_statistics_service.h"
-#include "gnunet_transport_blacklist.h"
 #include "gnunet_util_lib.h"
 
 /**

Modified: gnunet/src/transport/gnunet-service-transport_clients.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.h     2011-08-04 
12:21:21 UTC (rev 16369)
+++ gnunet/src/transport/gnunet-service-transport_clients.h     2011-08-04 
12:58:58 UTC (rev 16370)
@@ -27,7 +27,6 @@
 #define GNUNET_SERVICE_TRANSPORT_CLIENTS_H
 
 #include "gnunet_statistics_service.h"
-#include "gnunet_transport_clients.h"
 #include "gnunet_util_lib.h"
 
 

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.h  2011-08-04 
12:21:21 UTC (rev 16369)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.h  2011-08-04 
12:58:58 UTC (rev 16370)
@@ -77,7 +77,7 @@
  *
  */
 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,
@@ -87,7 +87,7 @@
  *
  */
 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,
@@ -97,7 +97,7 @@
  *
  */
 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,

Modified: gnunet/src/transport/gnunet-service-transport_plugins.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_plugins.h     2011-08-04 
12:21:21 UTC (rev 16369)
+++ gnunet/src/transport/gnunet-service-transport_plugins.h     2011-08-04 
12:58:58 UTC (rev 16370)
@@ -27,7 +27,8 @@
 #define GNUNET_SERVICE_TRANSPORT_PLUGINS_H
 
 #include "gnunet_statistics_service.h"
-#include "gnunet_transport_plugins.h"
+#include "gnunet_transport_service.h"
+#include "gnunet_transport_plugin.h"
 #include "gnunet_util_lib.h"
 
 

Modified: gnunet/src/transport/gnunet-service-transport_validation.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_validation.h  2011-08-04 
12:21:21 UTC (rev 16369)
+++ gnunet/src/transport/gnunet-service-transport_validation.h  2011-08-04 
12:58:58 UTC (rev 16370)
@@ -27,7 +27,6 @@
 #define GNUNET_SERVICE_TRANSPORT_VALIDATION_H
 
 #include "gnunet_statistics_service.h"
-#include "gnunet_transport_validation.h"
 #include "gnunet_util_lib.h"
 
 
@@ -49,7 +48,7 @@
  *
  */
 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,
@@ -59,7 +58,7 @@
  *
  */
 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,
@@ -84,7 +83,7 @@
  *                          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,
@@ -92,7 +91,7 @@
                                              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);
 




reply via email to

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