aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-04 12:58:58 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-04 12:58:58 +0000
commit58cc7545c068d1deb7f7085822646313d5271b0f (patch)
tree771ba877b5a6f36e2e297de7c6c6adb17f0c8f9d
parent2b3767b6c7f244f55b9738da102f848eb19f984d (diff)
downloadgnunet-58cc7545c068d1deb7f7085822646313d5271b0f.tar.gz
gnunet-58cc7545c068d1deb7f7085822646313d5271b0f.zip
draft
-rw-r--r--src/transport/Makefile.am17
-rw-r--r--src/transport/gnunet-service-transport-new.c157
-rw-r--r--src/transport/gnunet-service-transport.h1
-rw-r--r--src/transport/gnunet-service-transport_blacklist.h1
-rw-r--r--src/transport/gnunet-service-transport_clients.h1
-rw-r--r--src/transport/gnunet-service-transport_neighbours.h6
-rw-r--r--src/transport/gnunet-service-transport_plugins.h3
-rw-r--r--src/transport/gnunet-service-transport_validation.h9
8 files changed, 183 insertions, 12 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 6a870c6b0..e004d9c00 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -86,6 +86,7 @@ bin_PROGRAMS = \
86 gnunet-transport \ 86 gnunet-transport \
87 $(WLAN_BIN) \ 87 $(WLAN_BIN) \
88 gnunet-service-transport \ 88 gnunet-service-transport \
89 gnunet-service-transport-new \
89 gnunet-transport-list-connections \ 90 gnunet-transport-list-connections \
90 gnunet-transport-certificate-creation 91 gnunet-transport-certificate-creation
91 92
@@ -146,6 +147,22 @@ gnunet_service_transport_LDADD = \
146 $(GN_GLPK) \ 147 $(GN_GLPK) \
147 $(GN_LIBINTL) 148 $(GN_LIBINTL)
148 149
150gnunet_service_transport_new_SOURCES = \
151 gnunet-service-transport-new.c gnunet-service-transport.h \
152 gnunet-service-transport_blacklist.h \
153 gnunet-service-transport_clients.h \
154 gnunet-service-transport_hello.h \
155 gnunet-service-transport_neighbours.h \
156 gnunet-service-transport_plugins.h \
157 gnunet-service-transport_validation.h
158gnunet_service_transport_new_LDADD = \
159 $(top_builddir)/src/hello/libgnunethello.la \
160 $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
161 $(top_builddir)/src/statistics/libgnunetstatistics.la \
162 $(top_builddir)/src/util/libgnunetutil.la \
163 $(GN_GLPK) \
164 $(GN_LIBINTL)
165
149plugin_LTLIBRARIES = \ 166plugin_LTLIBRARIES = \
150 libgnunet_plugin_transport_tcp.la \ 167 libgnunet_plugin_transport_tcp.la \
151 libgnunet_plugin_transport_udp.la \ 168 libgnunet_plugin_transport_udp.la \
diff --git a/src/transport/gnunet-service-transport-new.c b/src/transport/gnunet-service-transport-new.c
new file mode 100644
index 000000000..c039d5963
--- /dev/null
+++ b/src/transport/gnunet-service-transport-new.c
@@ -0,0 +1,157 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010,2011 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/**
22 * @file transport/gnunet-service-transport-new.c
23 * @brief
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_statistics_service.h"
29#include "gnunet_transport_service.h"
30#include "gnunet-service-transport.h"
31#include "gnunet-service-transport_blacklist.h"
32#include "gnunet-service-transport_clients.h"
33#include "gnunet-service-transport_hello.h"
34#include "gnunet-service-transport_neighbours.h"
35#include "gnunet-service-transport_plugins.h"
36#include "gnunet-service-transport_validation.h"
37
38/* globals */
39
40/**
41 * Statistics handle.
42 */
43struct GNUNET_STATISTICS_Handle *GST_stats;
44
45/**
46 * Configuration handle.
47 */
48const struct GNUNET_CONFIGURATION_Handle *GST_cfg;
49
50/**
51 * Configuration handle.
52 */
53struct GNUNET_PeerIdentity GST_my_identity;
54
55/**
56 * Our private key.
57 */
58static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key;
59
60/**
61 * Our public key.
62 */
63static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded my_public_key;
64
65/**
66 * Function called when the service shuts down. Unloads our plugins
67 * and cancels pending validations.
68 *
69 * @param cls closure, unused
70 * @param tc task context (unused)
71 */
72static void
73shutdown_task (void *cls,
74 const struct GNUNET_SCHEDULER_TaskContext *tc)
75{
76 if (GST_stats != NULL)
77 {
78 GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO);
79 GST_stats = NULL;
80 }
81 if (my_private_key != NULL)
82 {
83 GNUNET_CRYPTO_rsa_key_free (my_private_key);
84 my_private_key = NULL;
85 }
86}
87
88
89/**
90 * Initiate transport service.
91 *
92 * @param cls closure
93 * @param server the initialized server
94 * @param c configuration to use
95 */
96static void
97run (void *cls,
98 struct GNUNET_SERVER_Handle *server,
99 const struct GNUNET_CONFIGURATION_Handle *c)
100{
101#if 0
102 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
103 {NULL, NULL, 0, 0}
104 };
105#endif
106 char *keyfile;
107
108 /* setup globals */
109 GST_cfg = c;
110 if (GNUNET_OK !=
111 GNUNET_CONFIGURATION_get_value_filename (c,
112 "GNUNETD",
113 "HOSTKEY", &keyfile))
114 {
115 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
116 _
117 ("Transport service is lacking key configuration settings. Exiting.\n"));
118 GNUNET_SCHEDULER_shutdown ();
119 return;
120 }
121 my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
122 GNUNET_free (keyfile);
123 if (my_private_key == NULL)
124 {
125 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
126 _("Transport service could not access hostkey. Exiting.\n"));
127 GNUNET_SCHEDULER_shutdown ();
128 return;
129 }
130 GST_stats = GNUNET_STATISTICS_create ("transport", c);
131 GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key);
132 GNUNET_CRYPTO_hash (&my_public_key,
133 sizeof (my_public_key), &GST_my_identity.hashPubKey);
134 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
135 &shutdown_task, NULL);
136}
137
138
139/**
140 * The main function for the transport service.
141 *
142 * @param argc number of arguments from the command line
143 * @param argv command line arguments
144 * @return 0 ok, 1 on error
145 */
146int
147main (int argc, char *const *argv)
148{
149 return (GNUNET_OK ==
150 GNUNET_SERVICE_run (argc,
151 argv,
152 "transport",
153 GNUNET_SERVICE_OPTION_NONE,
154 &run, NULL)) ? 0 : 1;
155}
156
157/* end of file gnunet-service-transport-new.c */
diff --git a/src/transport/gnunet-service-transport.h b/src/transport/gnunet-service-transport.h
index 544b60507..8db60d707 100644
--- a/src/transport/gnunet-service-transport.h
+++ b/src/transport/gnunet-service-transport.h
@@ -27,7 +27,6 @@
27#define GNUNET_SERVICE_TRANSPORT_H 27#define GNUNET_SERVICE_TRANSPORT_H
28 28
29#include "gnunet_statistics_service.h" 29#include "gnunet_statistics_service.h"
30#include "gnunet_transport_plugins.h"
31#include "gnunet_transport_service.h" 30#include "gnunet_transport_service.h"
32#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
33 32
diff --git a/src/transport/gnunet-service-transport_blacklist.h b/src/transport/gnunet-service-transport_blacklist.h
index e1674ead3..1d10846ea 100644
--- a/src/transport/gnunet-service-transport_blacklist.h
+++ b/src/transport/gnunet-service-transport_blacklist.h
@@ -27,7 +27,6 @@
27#define GNUNET_SERVICE_TRANSPORT_BLACKLIST_H 27#define GNUNET_SERVICE_TRANSPORT_BLACKLIST_H
28 28
29#include "gnunet_statistics_service.h" 29#include "gnunet_statistics_service.h"
30#include "gnunet_transport_blacklist.h"
31#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
32 31
33/** 32/**
diff --git a/src/transport/gnunet-service-transport_clients.h b/src/transport/gnunet-service-transport_clients.h
index 299d75857..1884ece5d 100644
--- a/src/transport/gnunet-service-transport_clients.h
+++ b/src/transport/gnunet-service-transport_clients.h
@@ -27,7 +27,6 @@
27#define GNUNET_SERVICE_TRANSPORT_CLIENTS_H 27#define GNUNET_SERVICE_TRANSPORT_CLIENTS_H
28 28
29#include "gnunet_statistics_service.h" 29#include "gnunet_statistics_service.h"
30#include "gnunet_transport_clients.h"
31#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
32 31
33 32
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h
index 18134fd33..c627e7e2f 100644
--- a/src/transport/gnunet-service-transport_neighbours.h
+++ b/src/transport/gnunet-service-transport_neighbours.h
@@ -77,7 +77,7 @@ GST_neighbours_iterate (GST_NeighbourIterator cb,
77 * 77 *
78 */ 78 */
79int 79int
80GST_neighbours_handle_pong (const GNUNET_PeerIdentity *sender, 80GST_neighbours_handle_pong (const struct GNUNET_PeerIdentity *sender,
81 const struct GNUNET_MessageHeader *hdr, 81 const struct GNUNET_MessageHeader *hdr,
82 const char *plugin_name, 82 const char *plugin_name,
83 const void *sender_address, 83 const void *sender_address,
@@ -87,7 +87,7 @@ GST_neighbours_handle_pong (const GNUNET_PeerIdentity *sender,
87 * 87 *
88 */ 88 */
89int 89int
90GST_neighbours_handle_connect (const GNUNET_PeerIdentity *sender, 90GST_neighbours_handle_connect (const struct GNUNET_PeerIdentity *sender,
91 const struct GNUNET_MessageHeader *hdr, 91 const struct GNUNET_MessageHeader *hdr,
92 const char *plugin_name, 92 const char *plugin_name,
93 const void *sender_address, 93 const void *sender_address,
@@ -97,7 +97,7 @@ GST_neighbours_handle_connect (const GNUNET_PeerIdentity *sender,
97 * 97 *
98 */ 98 */
99int 99int
100GST_neighbours_handle_disconnect (const GNUNET_PeerIdentity *sender, 100GST_neighbours_handle_disconnect (const struct GNUNET_PeerIdentity *sender,
101 const struct GNUNET_MessageHeader *hdr, 101 const struct GNUNET_MessageHeader *hdr,
102 const char *plugin_name, 102 const char *plugin_name,
103 const void *sender_address, 103 const void *sender_address,
diff --git a/src/transport/gnunet-service-transport_plugins.h b/src/transport/gnunet-service-transport_plugins.h
index ad8746b4c..0d62bbf79 100644
--- a/src/transport/gnunet-service-transport_plugins.h
+++ b/src/transport/gnunet-service-transport_plugins.h
@@ -27,7 +27,8 @@
27#define GNUNET_SERVICE_TRANSPORT_PLUGINS_H 27#define GNUNET_SERVICE_TRANSPORT_PLUGINS_H
28 28
29#include "gnunet_statistics_service.h" 29#include "gnunet_statistics_service.h"
30#include "gnunet_transport_plugins.h" 30#include "gnunet_transport_service.h"
31#include "gnunet_transport_plugin.h"
31#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
32 33
33 34
diff --git a/src/transport/gnunet-service-transport_validation.h b/src/transport/gnunet-service-transport_validation.h
index 374512e47..9768c425e 100644
--- a/src/transport/gnunet-service-transport_validation.h
+++ b/src/transport/gnunet-service-transport_validation.h
@@ -27,7 +27,6 @@
27#define GNUNET_SERVICE_TRANSPORT_VALIDATION_H 27#define GNUNET_SERVICE_TRANSPORT_VALIDATION_H
28 28
29#include "gnunet_statistics_service.h" 29#include "gnunet_statistics_service.h"
30#include "gnunet_transport_validation.h"
31#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
32 31
33 32
@@ -49,7 +48,7 @@ GST_validation_stop (void);
49 * 48 *
50 */ 49 */
51int 50int
52GST_validation_handle_ping (const GNUNET_PeerIdentity *sender, 51GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
53 const struct GNUNET_MessageHeader *hdr, 52 const struct GNUNET_MessageHeader *hdr,
54 const char *plugin_name, 53 const char *plugin_name,
55 const void *sender_address, 54 const void *sender_address,
@@ -59,7 +58,7 @@ GST_validation_handle_ping (const GNUNET_PeerIdentity *sender,
59 * 58 *
60 */ 59 */
61int 60int
62GST_validation_handle_pong (const GNUNET_PeerIdentity *sender, 61GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
63 const struct GNUNET_MessageHeader *hdr, 62 const struct GNUNET_MessageHeader *hdr,
64 const char *plugin_name, 63 const char *plugin_name,
65 const void *sender_address, 64 const void *sender_address,
@@ -84,7 +83,7 @@ struct GST_ValidationIteratorContext;
84 * is a time in the future if we're currently denying re-validation 83 * is a time in the future if we're currently denying re-validation
85 */ 84 */
86typedef void (*GST_ValidationAddressCallback)(void *cls, 85typedef void (*GST_ValidationAddressCallback)(void *cls,
87 const GNUNET_PeerIdentity *target, 86 const struct GNUNET_PeerIdentity *target,
88 struct GNUNET_TIME_Absolute last_validated_at, 87 struct GNUNET_TIME_Absolute last_validated_at,
89 struct GNUNET_TIME_Absolute validation_block, 88 struct GNUNET_TIME_Absolute validation_block,
90 const char *plugin_name, 89 const char *plugin_name,
@@ -92,7 +91,7 @@ typedef void (*GST_ValidationAddressCallback)(void *cls,
92 size_t plugin_address_len); 91 size_t plugin_address_len);
93 92
94struct GST_ValidationIteratorContext * 93struct GST_ValidationIteratorContext *
95GST_validation_get_addresses (const GNUNET_PeerIdentity *target, 94GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
96 GST_ValidationAddressCallback cb, 95 GST_ValidationAddressCallback cb,
97 void *cb_cls); 96 void *cb_cls);
98 97