aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/transport/Makefile.am6
-rw-r--r--src/transport/gnunet-service-transport-new.c52
-rw-r--r--src/transport/gnunet-service-transport.h9
-rw-r--r--src/transport/gnunet-service-transport_clients.c62
-rw-r--r--src/transport/gnunet-service-transport_clients.h12
-rw-r--r--src/transport/gnunet-service-transport_hello.c358
-rw-r--r--src/transport/gnunet-service-transport_hello.h42
-rw-r--r--src/transport/gnunet-service-transport_plugins.c94
-rw-r--r--src/transport/gnunet-service-transport_plugins.h31
9 files changed, 652 insertions, 14 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index e004d9c00..5c8a997a9 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -150,10 +150,10 @@ gnunet_service_transport_LDADD = \
150gnunet_service_transport_new_SOURCES = \ 150gnunet_service_transport_new_SOURCES = \
151 gnunet-service-transport-new.c gnunet-service-transport.h \ 151 gnunet-service-transport-new.c gnunet-service-transport.h \
152 gnunet-service-transport_blacklist.h \ 152 gnunet-service-transport_blacklist.h \
153 gnunet-service-transport_clients.h \ 153 gnunet-service-transport_clients.h gnunet-service-transport_clients.c \
154 gnunet-service-transport_hello.h \ 154 gnunet-service-transport_hello.h gnunet-service-transport_hello.c \
155 gnunet-service-transport_neighbours.h \ 155 gnunet-service-transport_neighbours.h \
156 gnunet-service-transport_plugins.h \ 156 gnunet-service-transport_plugins.h gnunet-service-transport_plugins.c \
157 gnunet-service-transport_validation.h 157 gnunet-service-transport_validation.h
158gnunet_service_transport_new_LDADD = \ 158gnunet_service_transport_new_LDADD = \
159 $(top_builddir)/src/hello/libgnunethello.la \ 159 $(top_builddir)/src/hello/libgnunethello.la \
diff --git a/src/transport/gnunet-service-transport-new.c b/src/transport/gnunet-service-transport-new.c
index c039d5963..bade1cf5a 100644
--- a/src/transport/gnunet-service-transport-new.c
+++ b/src/transport/gnunet-service-transport-new.c
@@ -27,6 +27,7 @@
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_statistics_service.h" 28#include "gnunet_statistics_service.h"
29#include "gnunet_transport_service.h" 29#include "gnunet_transport_service.h"
30#include "gnunet_peerinfo_service.h"
30#include "gnunet-service-transport.h" 31#include "gnunet-service-transport.h"
31#include "gnunet-service-transport_blacklist.h" 32#include "gnunet-service-transport_blacklist.h"
32#include "gnunet-service-transport_clients.h" 33#include "gnunet-service-transport_clients.h"
@@ -53,14 +54,39 @@ const struct GNUNET_CONFIGURATION_Handle *GST_cfg;
53struct GNUNET_PeerIdentity GST_my_identity; 54struct GNUNET_PeerIdentity GST_my_identity;
54 55
55/** 56/**
57 * Handle to peerinfo service.
58 */
59struct GNUNET_PEERINFO_Handle *GST_peerinfo;
60
61/**
62 * Our public key.
63 */
64struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded GST_my_public_key;
65
66/**
56 * Our private key. 67 * Our private key.
57 */ 68 */
58static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key; 69static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key;
59 70
71
60/** 72/**
61 * Our public key. 73 * My HELLO has changed. Tell everyone who should know.
74 *
75 * @param cls unused
76 * @param hello new HELLO
62 */ 77 */
63static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded my_public_key; 78static void
79process_hello_update (void *cls,
80 const struct GNUNET_MessageHeader *hello)
81{
82 GST_clients_broadcast (hello);
83#if 0
84 GNUNET_CONTAINER_multihashmap_iterate (neighbours,
85 &transmit_our_hello_if_pong,
86 NULL);
87#endif
88}
89
64 90
65/** 91/**
66 * Function called when the service shuts down. Unloads our plugins 92 * Function called when the service shuts down. Unloads our plugins
@@ -73,6 +99,13 @@ static void
73shutdown_task (void *cls, 99shutdown_task (void *cls,
74 const struct GNUNET_SCHEDULER_TaskContext *tc) 100 const struct GNUNET_SCHEDULER_TaskContext *tc)
75{ 101{
102 GST_hello_stop ();
103
104 if (GST_peerinfo != NULL)
105 {
106 GNUNET_PEERINFO_disconnect (GST_peerinfo);
107 GST_peerinfo = NULL;
108 }
76 if (GST_stats != NULL) 109 if (GST_stats != NULL)
77 { 110 {
78 GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO); 111 GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO);
@@ -128,11 +161,20 @@ run (void *cls,
128 return; 161 return;
129 } 162 }
130 GST_stats = GNUNET_STATISTICS_create ("transport", c); 163 GST_stats = GNUNET_STATISTICS_create ("transport", c);
131 GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); 164 GST_peerinfo = GNUNET_PEERINFO_connect (c);
132 GNUNET_CRYPTO_hash (&my_public_key, 165 GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &GST_my_public_key);
133 sizeof (my_public_key), &GST_my_identity.hashPubKey); 166 GNUNET_CRYPTO_hash (&GST_my_public_key,
167 sizeof (GST_my_public_key), &GST_my_identity.hashPubKey);
134 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 168 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
135 &shutdown_task, NULL); 169 &shutdown_task, NULL);
170 if (GST_peerinfo == NULL)
171 {
172 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
173 _("Could not access PEERINFO service. Exiting.\n"));
174 GNUNET_SCHEDULER_shutdown ();
175 return;
176 }
177 GST_hello_start (&process_hello_update, NULL);
136} 178}
137 179
138 180
diff --git a/src/transport/gnunet-service-transport.h b/src/transport/gnunet-service-transport.h
index 8db60d707..d6eda464a 100644
--- a/src/transport/gnunet-service-transport.h
+++ b/src/transport/gnunet-service-transport.h
@@ -45,6 +45,15 @@ extern const struct GNUNET_CONFIGURATION_Handle *GST_cfg;
45 */ 45 */
46extern struct GNUNET_PeerIdentity GST_my_identity; 46extern struct GNUNET_PeerIdentity GST_my_identity;
47 47
48/**
49 * Handle to peerinfo service.
50 */
51extern struct GNUNET_PEERINFO_Handle *GST_peerinfo;
52
53/**
54 * Our public key.
55 */
56extern struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded GST_my_public_key;
48 57
49#endif 58#endif
50/* end of file gnunet-service-transport_plugins.h */ 59/* end of file gnunet-service-transport_plugins.h */
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c
new file mode 100644
index 000000000..9fe367c16
--- /dev/null
+++ b/src/transport/gnunet-service-transport_clients.c
@@ -0,0 +1,62 @@
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_clients.c
23 * @brief plugin management API
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "gnunet-service-transport_clients.h"
28
29
30/**
31 * Start handling requests from clients.
32 *
33 * @param server server used to accept clients from.
34 */
35void
36GST_clients_start (struct GNUNET_SERVER_Handle *server)
37{
38}
39
40
41/**
42 * Stop processing clients.
43 */
44void
45GST_clients_stop ()
46{
47}
48
49
50/**
51 * Broadcast the given message to all of our clients.
52 *
53 * @param msg message to broadcast
54 */
55void
56GST_clients_broadcast (const struct GNUNET_MessageHeader *msg)
57{
58
59}
60
61
62/* end of file gnunet-service-transport_clients.c */
diff --git a/src/transport/gnunet-service-transport_clients.h b/src/transport/gnunet-service-transport_clients.h
index 1884ece5d..aa696b1ab 100644
--- a/src/transport/gnunet-service-transport_clients.h
+++ b/src/transport/gnunet-service-transport_clients.h
@@ -31,19 +31,29 @@
31 31
32 32
33/** 33/**
34 * Start handling requests from clients.
34 * 35 *
36 * @param server server used to accept clients from.
35 */ 37 */
36void 38void
37GST_clients_start (struct GNUNET_SERVER_Handle *server); 39GST_clients_start (struct GNUNET_SERVER_Handle *server);
38 40
39 41
40/** 42/**
41 * 43 * Stop processing clients.
42 */ 44 */
43void 45void
44GST_clients_stop (void); 46GST_clients_stop (void);
45 47
46 48
49/**
50 * Broadcast the given message to all of our clients.
51 *
52 * @param msg message to broadcast
53 */
54void
55GST_clients_broadcast (const struct GNUNET_MessageHeader *msg);
56
47 57
48 58
49#endif 59#endif
diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c
new file mode 100644
index 000000000..cf7459769
--- /dev/null
+++ b/src/transport/gnunet-service-transport_hello.c
@@ -0,0 +1,358 @@
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_hello.c
23 * @brief hello management implementation
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "gnunet_hello_lib.h"
28#include "gnunet_peerinfo_service.h"
29#include "gnunet_statistics_service.h"
30#include "gnunet-service-transport_hello.h"
31#include "gnunet-service-transport.h"
32#include "gnunet-service-transport_plugins.h"
33
34/**
35 * After how long do we expire an address in a HELLO that we just
36 * validated? This value is also used for our own addresses when we
37 * create a HELLO.
38 */
39#define HELLO_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 12)
40
41/**
42 * How often do we refresh our HELLO (due to expiration concerns)?
43 */
44#define HELLO_REFRESH_PERIOD GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 6)
45
46
47/**
48 * Entry in linked list of network addresses for ourselves. Also
49 * includes a cached signature for 'struct TransportPongMessage's.
50 */
51struct OwnAddressList
52{
53 /**
54 * This is a doubly-linked list.
55 */
56 struct OwnAddressList *next;
57
58 /**
59 * This is a doubly-linked list.
60 */
61 struct OwnAddressList *prev;
62
63 /**
64 * Name of the plugin.
65 */
66 char *plugin_name;
67
68 /**
69 * How long until the current signature expires? (ZERO if the
70 * signature was never created).
71 */
72 struct GNUNET_TIME_Absolute pong_sig_expires;
73
74 /**
75 * Signature for a 'struct TransportPongMessage' for this address.
76 */
77 struct GNUNET_CRYPTO_RsaSignature pong_signature;
78
79 /**
80 * Length of addr.
81 */
82 size_t addrlen;
83
84};
85
86
87/**
88 * Our HELLO message.
89 */
90static struct GNUNET_HELLO_Message *our_hello;
91
92/**
93 * Function to call on HELLO changes.
94 */
95static GST_HelloCallback hello_cb;
96
97/**
98 * Closure for 'hello_cb'.
99 */
100static void *hello_cb_cls;
101
102/**
103 * Head of my addresses.
104 */
105struct OwnAddressList *oal_head;
106
107/**
108 * Tail of my addresses.
109 */
110struct OwnAddressList *oal_tail;
111
112/**
113 * Identifier of 'refresh_hello' task.
114 */
115static GNUNET_SCHEDULER_TaskIdentifier hello_task;
116
117
118/**
119 * Closure for 'address_generator'.
120 */
121struct GeneratorContext
122{
123 /**
124 * Where are we in the DLL?
125 */
126 struct OwnAddressList *addr_pos;
127
128 /**
129 * When do addresses expire?
130 */
131 struct GNUNET_TIME_Absolute expiration;
132};
133
134
135/**
136 * Add an address from the 'OwnAddressList' to the buffer.
137 *
138 * @param cls the 'struct GeneratorContext'
139 * @param max maximum number of bytes left
140 * @param buf where to write the address
141 */
142static size_t
143address_generator (void *cls, size_t max, void *buf)
144{
145 struct GeneratorContext *gc = cls;
146 size_t ret;
147
148 if (NULL == gc->addr_pos)
149 return 0;
150 ret = GNUNET_HELLO_add_address (gc->addr_pos->plugin_name,
151 gc->expiration,
152 &gc->addr_pos[1],
153 gc->addr_pos->addrlen,
154 buf, max);
155 gc->addr_pos = gc->addr_pos->next;
156 return ret;
157}
158
159
160/**
161 * Construct our HELLO message from all of the addresses of
162 * all of the transports.
163 *
164 * @param cls unused
165 * @param tc scheduler context
166 */
167static void
168refresh_hello_task (void *cls,
169 const struct GNUNET_SCHEDULER_TaskContext *tc)
170{
171 struct GeneratorContext gc;
172
173 hello_task = GNUNET_SCHEDULER_NO_TASK;
174 gc.addr_pos = oal_head;
175 gc.expiration = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION);
176 GNUNET_free (our_hello);
177 our_hello = GNUNET_HELLO_create (&GST_my_public_key,
178 &address_generator,
179 &gc);
180#if DEBUG_TRANSPORT
181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
182 "Refreshed my `%s', new size is %d\n", "HELLO",
183 GNUNET_HELLO_size(our_hello));
184#endif
185 GNUNET_STATISTICS_update (GST_stats,
186 gettext_noop ("# refreshed my HELLO"),
187 1,
188 GNUNET_NO);
189 if (NULL != hello_cb)
190 hello_cb (hello_cb_cls, GST_hello_get());
191 GNUNET_PEERINFO_add_peer (GST_peerinfo, our_hello);
192 hello_task
193 = GNUNET_SCHEDULER_add_delayed (HELLO_REFRESH_PERIOD,
194 &refresh_hello_task,
195 NULL);
196
197}
198
199
200/**
201 * Schedule task to refresh hello (unless such a
202 * task exists already).
203 */
204static void
205refresh_hello ()
206{
207 if (hello_task != GNUNET_SCHEDULER_NO_TASK)
208 GNUNET_SCHEDULER_cancel (hello_task);
209 hello_task
210 = GNUNET_SCHEDULER_add_now (&refresh_hello_task,
211 NULL);
212}
213
214
215/**
216 * Initialize the HELLO module.
217 *
218 * @param cb function to call whenever our HELLO changes
219 * @param cb_cls closure for cb
220 */
221void
222GST_hello_start (GST_HelloCallback cb,
223 void *cb_cls)
224{
225 hello_cb = cb;
226 hello_cb_cls = cb_cls;
227 our_hello = GNUNET_HELLO_create (&GST_my_public_key,
228 NULL, NULL);
229 refresh_hello ();
230}
231
232
233/**
234 * Shutdown the HELLO module.
235 */
236void
237GST_hello_stop ()
238{
239 hello_cb = NULL;
240 hello_cb_cls = NULL;
241 if (GNUNET_SCHEDULER_NO_TASK != hello_task)
242 {
243 GNUNET_SCHEDULER_cancel (hello_task);
244 hello_task = GNUNET_SCHEDULER_NO_TASK;
245 }
246 if (NULL != our_hello)
247 {
248 GNUNET_free (our_hello);
249 our_hello = NULL;
250 }
251}
252
253
254/**
255 * Obtain this peers HELLO message.
256 *
257 * @return our HELLO message
258 */
259const struct GNUNET_MessageHeader *
260GST_hello_get ()
261{
262 return (struct GNUNET_MessageHeader*) our_hello;
263}
264
265
266/**
267 * Add or remove an address from this peer's HELLO message.
268 *
269 * @param addremove GNUNET_YES to add, GNUNET_NO to remove
270 * @param plugin_name name of the plugin for which this is an address
271 * @param plugin_address address in a plugin-specific format
272 * @param plugin_address_len number of bytes in plugin_address
273 */
274void
275GST_hello_modify_addresses (int addremove,
276 const char *plugin_name,
277 const void *plugin_address,
278 size_t plugin_address_len)
279{
280 struct OwnAddressList *al;
281
282#if DEBUG_TRANSPORT
283 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
284 (add_remove == GNUNET_YES)
285 ? "Adding `%s':%s to the set of our addresses\n"
286 : "Removing `%s':%s from the set of our addresses\n",
287 GST_plugins_a2s (plugin_name,
288 addr, addrlen),
289 p->short_name);
290#endif
291 GNUNET_assert (plugin_address != NULL);
292 if (GNUNET_NO == addremove)
293 {
294 for (al = oal_head; al != NULL; al = al->next)
295 if ( (plugin_address_len == al->addrlen) &&
296 (0 == strcmp (al->plugin_name, plugin_name)) &&
297 (0 == memcmp (plugin_address, &al[1], plugin_address_len)) )
298 {
299 GNUNET_CONTAINER_DLL_remove (oal_head,
300 oal_tail,
301 al);
302 GNUNET_free (al->plugin_name);
303 GNUNET_free (al);
304 refresh_hello ();
305 return;
306 }
307 /* address to be removed not found!? */
308 GNUNET_break (0);
309 return;
310 }
311 al = GNUNET_malloc (sizeof (struct OwnAddressList) + plugin_address_len);
312 GNUNET_CONTAINER_DLL_insert (oal_head,
313 oal_tail,
314 al);
315 al->plugin_name = GNUNET_strdup (plugin_name);
316 al->addrlen = plugin_address_len;
317 memcpy (&al[1], plugin_address, plugin_address_len);
318 refresh_hello ();
319}
320
321
322/**
323 * Test if a particular address is one of ours.
324 *
325 * @param plugin_name name of the plugin for which this is an address
326 * @param plugin_address address in a plugin-specific format
327 * @param plugin_address_len number of bytes in plugin_address
328 * @param sig location where to cache PONG signatures for this address [set]
329 * @param sig_expiration how long until the current 'sig' expires?
330 * (ZERO if sig was never created) [set]
331 * @return GNUNET_YES if this is one of our addresses,
332 * GNUNET_NO if not
333 */
334int
335GST_hello_test_address (const char *plugin_name,
336 const void *plugin_address,
337 size_t plugin_address_len,
338 struct GNUNET_CRYPTO_RsaSignature **sig,
339 struct GNUNET_TIME_Absolute **sig_expiration)
340{
341 struct OwnAddressList *al;
342
343 for (al = oal_head; al != NULL; al = al->next)
344 if ( (plugin_address_len == al->addrlen) &&
345 (0 == strcmp (al->plugin_name, plugin_name)) &&
346 (0 == memcmp (plugin_address, &al[1], plugin_address_len)) )
347 {
348 *sig = &al->pong_signature;
349 *sig_expiration = &al->pong_sig_expires;
350 return GNUNET_YES;
351 }
352 *sig = NULL;
353 *sig_expiration = NULL;
354 return GNUNET_NO;
355}
356
357
358/* end of file gnunet-service-transport_hello.c */
diff --git a/src/transport/gnunet-service-transport_hello.h b/src/transport/gnunet-service-transport_hello.h
index 75fef07ae..d34162841 100644
--- a/src/transport/gnunet-service-transport_hello.h
+++ b/src/transport/gnunet-service-transport_hello.h
@@ -32,25 +32,49 @@
32 32
33 33
34/** 34/**
35 * Signature of a function to call whenever our hello changes.
35 * 36 *
37 * @param cls closure
38 * @param hello updated HELLO
36 */ 39 */
37void 40typedef void (*GST_HelloCallback)(void *cls,
38GST_hello_start (void); 41 const struct GNUNET_MessageHeader *hello);
42
39 43
40/** 44/**
45 * Initialize the HELLO module.
41 * 46 *
47 * @param cb function to call whenever our HELLO changes
48 * @param cb_cls closure for cb
49 */
50void
51GST_hello_start (GST_HelloCallback cb,
52 void *cb_cls);
53
54
55/**
56 * Shutdown the HELLO module.
42 */ 57 */
43void 58void
44GST_hello_stop (void); 59GST_hello_stop (void);
45 60
61
46/** 62/**
63 * Obtain this peers HELLO message.
47 * 64 *
65 * @return our HELLO message
48 */ 66 */
49const struct GNUNET_MessageHeader * 67const struct GNUNET_MessageHeader *
50GST_hello_get (void); 68GST_hello_get (void);
51 69
70
52/** 71/**
72 * Add or remove an address from this peer's HELLO message.
53 * 73 *
74 * @param addremove GNUNET_YES to add, GNUNET_NO to remove
75 * @param plugin_name name of the plugin for which this is an address
76 * @param plugin_address address in a plugin-specific format
77 * @param plugin_address_len number of bytes in plugin_address
54 */ 78 */
55void 79void
56GST_hello_modify_addresses (int addremove, 80GST_hello_modify_addresses (int addremove,
@@ -58,13 +82,25 @@ GST_hello_modify_addresses (int addremove,
58 const void *plugin_address, 82 const void *plugin_address,
59 size_t plugin_address_len); 83 size_t plugin_address_len);
60 84
85
61/** 86/**
87 * Test if a particular address is one of ours.
62 * 88 *
89 * @param plugin_name name of the plugin for which this is an address
90 * @param plugin_address address in a plugin-specific format
91 * @param plugin_address_len number of bytes in plugin_address
92 * @param sig location where to cache PONG signatures for this address [set]
93 * @param sig_expiration how long until the current 'sig' expires?
94 * (ZERO if sig was never created) [set]
95 * @return GNUNET_YES if this is one of our addresses,
96 * GNUNET_NO if not
63 */ 97 */
64int 98int
65GST_hello_test_address (const char *plugin_name, 99GST_hello_test_address (const char *plugin_name,
66 const void *plugin_address, 100 const void *plugin_address,
67 size_t plugin_address_len); 101 size_t plugin_address_len,
102 struct GNUNET_CRYPTO_RsaSignature **sig,
103 struct GNUNET_TIME_Absolute **sig_expiration);
68 104
69 105
70#endif 106#endif
diff --git a/src/transport/gnunet-service-transport_plugins.c b/src/transport/gnunet-service-transport_plugins.c
new file mode 100644
index 000000000..0db7120fd
--- /dev/null
+++ b/src/transport/gnunet-service-transport_plugins.c
@@ -0,0 +1,94 @@
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_plugins.c
23 * @brief plugin management
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "gnunet-service-transport_plugins.h"
28
29
30/**
31 * Load and initialize all plugins. The respective functions will be
32 * invoked by the plugins when the respective events happen. The
33 * closure will be set to a 'const char*' containing the name of the
34 * plugin that caused the call.
35 *
36 * @param recv_cb function to call when data is received
37 * @param address_cb function to call when our public addresses changed
38 * @param traffic_cb function to call for flow control
39 * @param session_end_cb function to call when a session was terminated
40 * @param cost_cb function to call about ATS cost changes
41 * @return GNUNET_OK on success
42 */
43int
44GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb,
45 GNUNET_TRANSPORT_AddressNotification address_cb,
46 GNUNET_TRANSPORT_TrafficReport traffic_cb,
47 GNUNET_TRANSPORT_SessionEnd session_end_cb,
48 GNUNET_TRANSPORT_CostReport cost_cb)
49{
50 return GNUNET_SYSERR;
51}
52
53
54/**
55 * Unload all plugins
56 */
57void
58GST_plugins_unload ()
59{
60}
61
62
63/**
64 * Obtain the plugin API based on a plugin name.
65 *
66 * @param name name of the plugin
67 * @return the plugin's API, NULL if the plugin is not loaded
68 */
69struct GNUNET_TRANSPORT_PluginFunctions *
70GST_plugins_find (const char *name)
71{
72 return NULL;
73}
74
75
76/**
77 * Convert a given address to a human-readable format. Note that the
78 * return value will be overwritten on the next call to this function.
79 *
80 * @param name plugin name
81 * @param addr binary address in plugin-specific format
82 * @param addrlen number of bytes in 'addr'
83 * @return statically allocated (!) human-readable address
84 */
85const char *
86GST_plugins_a2s (const char *name,
87 const void *addr,
88 size_t addrlen)
89{
90 return "FIXME";
91}
92
93
94/* end of file gnunet-service-transport_plugins.c */
diff --git a/src/transport/gnunet-service-transport_plugins.h b/src/transport/gnunet-service-transport_plugins.h
index 0d62bbf79..3ad09b7f6 100644
--- a/src/transport/gnunet-service-transport_plugins.h
+++ b/src/transport/gnunet-service-transport_plugins.h
@@ -33,7 +33,17 @@
33 33
34 34
35/** 35/**
36 * Load and initialize all plugins. The respective functions will be
37 * invoked by the plugins when the respective events happen. The
38 * closure will be set to a 'const char*' containing the name of the
39 * plugin that caused the call.
36 * 40 *
41 * @param recv_cb function to call when data is received
42 * @param address_cb function to call when our public addresses changed
43 * @param traffic_cb function to call for flow control
44 * @param session_end_cb function to call when a session was terminated
45 * @param cost_cb function to call about ATS cost changes
46 * @return GNUNET_OK on success
37 */ 47 */
38int 48int
39GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, 49GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb,
@@ -44,19 +54,36 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb,
44 54
45 55
46/** 56/**
47 * 57 * Unload all plugins
48 */ 58 */
49int 59void
50GST_plugins_unload (void); 60GST_plugins_unload (void);
51 61
52 62
53/** 63/**
64 * Obtain the plugin API based on a plugin name.
54 * 65 *
66 * @param name name of the plugin
67 * @return the plugin's API, NULL if the plugin is not loaded
55 */ 68 */
56struct GNUNET_TRANSPORT_PluginFunctions * 69struct GNUNET_TRANSPORT_PluginFunctions *
57GST_plugins_find (const char *name); 70GST_plugins_find (const char *name);
58 71
59 72
73/**
74 * Convert a given address to a human-readable format. Note that the
75 * return value will be overwritten on the next call to this function.
76 *
77 * @param name plugin name
78 * @param addr binary address in plugin-specific format
79 * @param addrlen number of bytes in 'addr'
80 * @return statically allocated (!) human-readable address
81 */
82const char *
83GST_plugins_a2s (const char *name,
84 const void *addr,
85 size_t addrlen);
86
60 87
61#endif 88#endif
62/* end of file gnunet-service-transport_plugins.h */ 89/* end of file gnunet-service-transport_plugins.h */