diff options
-rw-r--r-- | src/transport/Makefile.am | 45 | ||||
-rw-r--r-- | src/transport/plugin_transport_udp_broadcasting.c | 4 | ||||
-rw-r--r-- | src/transport/test_plugin_transport.c | 82 |
3 files changed, 109 insertions, 22 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 66331db92..99fe2d936 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -47,6 +47,7 @@ if LINUX | |||
47 | WLAN_BIN_DUMMY = gnunet-helper-transport-wlan-dummy | 47 | WLAN_BIN_DUMMY = gnunet-helper-transport-wlan-dummy |
48 | WLAN_BIN_SENDER = gnunet-transport-wlan-sender | 48 | WLAN_BIN_SENDER = gnunet-transport-wlan-sender |
49 | WLAN_PLUGIN_LA = libgnunet_plugin_transport_wlan.la | 49 | WLAN_PLUGIN_LA = libgnunet_plugin_transport_wlan.la |
50 | WLAN_PLUGIN_TEST = test_plugin_wlan | ||
50 | WLAN_API_TEST = test_transport_api_wlan | 51 | WLAN_API_TEST = test_transport_api_wlan |
51 | WLAN_REL_TEST = test_transport_api_reliability_wlan | 52 | WLAN_REL_TEST = test_transport_api_reliability_wlan |
52 | WLAN_UREL_TEST = test_transport_api_unreliability_wlan | 53 | WLAN_UREL_TEST = test_transport_api_unreliability_wlan |
@@ -295,6 +296,10 @@ check_PROGRAMS = \ | |||
295 | test_transport_testing_restart \ | 296 | test_transport_testing_restart \ |
296 | test_transport_testing \ | 297 | test_transport_testing \ |
297 | test_transport_startonly \ | 298 | test_transport_startonly \ |
299 | test_plugin_tcp \ | ||
300 | test_plugin_udp \ | ||
301 | test_plugin_unix \ | ||
302 | $(WLAN_PLUGIN_TEST) \ | ||
298 | test_transport_api_blacklisting \ | 303 | test_transport_api_blacklisting \ |
299 | test_transport_api_disconnect_tcp \ | 304 | test_transport_api_disconnect_tcp \ |
300 | test_transport_api_bidirectional_connect \ | 305 | test_transport_api_bidirectional_connect \ |
@@ -342,6 +347,10 @@ TESTS = \ | |||
342 | test_transport_testing_restart \ | 347 | test_transport_testing_restart \ |
343 | test_transport_testing \ | 348 | test_transport_testing \ |
344 | test_transport_startonly \ | 349 | test_transport_startonly \ |
350 | test_plugin_tcp \ | ||
351 | test_plugin_udp \ | ||
352 | test_plugin_unix \ | ||
353 | $(WLAN_PLUGIN_TEST) \ | ||
345 | test_transport_api_blacklisting \ | 354 | test_transport_api_blacklisting \ |
346 | test_transport_api_disconnect_tcp \ | 355 | test_transport_api_disconnect_tcp \ |
347 | test_transport_api_bidirectional_connect \ | 356 | test_transport_api_bidirectional_connect \ |
@@ -435,6 +444,42 @@ test_transport_startonly_LDADD = \ | |||
435 | $(top_builddir)/src/util/libgnunetutil.la \ | 444 | $(top_builddir)/src/util/libgnunetutil.la \ |
436 | $(top_builddir)/src/transport/libgnunettransporttesting.la | 445 | $(top_builddir)/src/transport/libgnunettransporttesting.la |
437 | 446 | ||
447 | test_plugin_tcp_SOURCES = \ | ||
448 | test_plugin_transport.c | ||
449 | test_plugin_tcp_LDADD = \ | ||
450 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
451 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
452 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
453 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
454 | $(top_builddir)/src/transport/libgnunettransporttesting.la | ||
455 | |||
456 | test_plugin_udp_SOURCES = \ | ||
457 | test_plugin_transport.c | ||
458 | test_plugin_udp_LDADD = \ | ||
459 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
460 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
461 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
462 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
463 | $(top_builddir)/src/transport/libgnunettransporttesting.la | ||
464 | |||
465 | test_plugin_unix_SOURCES = \ | ||
466 | test_plugin_transport.c | ||
467 | test_plugin_unix_LDADD = \ | ||
468 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
469 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
470 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
471 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
472 | $(top_builddir)/src/transport/libgnunettransporttesting.la | ||
473 | |||
474 | test_plugin_wlan_SOURCES = \ | ||
475 | test_plugin_transport.c | ||
476 | test_plugin_wlan_LDADD = \ | ||
477 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
478 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
479 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
480 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
481 | $(top_builddir)/src/transport/libgnunettransporttesting.la | ||
482 | |||
438 | test_transport_api_tcp_SOURCES = \ | 483 | test_transport_api_tcp_SOURCES = \ |
439 | test_transport_api.c | 484 | test_transport_api.c |
440 | test_transport_api_tcp_LDADD = \ | 485 | test_transport_api_tcp_LDADD = \ |
diff --git a/src/transport/plugin_transport_udp_broadcasting.c b/src/transport/plugin_transport_udp_broadcasting.c index d418e50d9..db6c1fe8c 100644 --- a/src/transport/plugin_transport_udp_broadcasting.c +++ b/src/transport/plugin_transport_udp_broadcasting.c | |||
@@ -228,6 +228,8 @@ prepare_beacon (struct Plugin *plugin, struct UDP_Beacon_Message *msg) | |||
228 | 228 | ||
229 | const struct GNUNET_MessageHeader *hello; | 229 | const struct GNUNET_MessageHeader *hello; |
230 | hello = plugin->env->get_our_hello (); | 230 | hello = plugin->env->get_our_hello (); |
231 | if (NULL == hello) | ||
232 | return 0; | ||
231 | hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); | 233 | hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); |
232 | msg_size = hello_size + sizeof (struct UDP_Beacon_Message); | 234 | msg_size = hello_size + sizeof (struct UDP_Beacon_Message); |
233 | 235 | ||
@@ -258,7 +260,7 @@ udp_ipv4_broadcast_send (void *cls, | |||
258 | sent = 0; | 260 | sent = 0; |
259 | baddr = plugin->ipv4_broadcast_head; | 261 | baddr = plugin->ipv4_broadcast_head; |
260 | /* just IPv4 */ | 262 | /* just IPv4 */ |
261 | while ((baddr != NULL) && (baddr->addrlen == sizeof (struct sockaddr_in))) | 263 | while ((msg_size > 0) && (baddr != NULL) && (baddr->addrlen == sizeof (struct sockaddr_in))) |
262 | { | 264 | { |
263 | struct sockaddr_in *addr = (struct sockaddr_in *) baddr->addr; | 265 | struct sockaddr_in *addr = (struct sockaddr_in *) baddr->addr; |
264 | 266 | ||
diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c index dbd6c6c63..bc7df9880 100644 --- a/src/transport/test_plugin_transport.c +++ b/src/transport/test_plugin_transport.c | |||
@@ -40,7 +40,8 @@ | |||
40 | /** | 40 | /** |
41 | * How long until we give up on transmitting the message? | 41 | * How long until we give up on transmitting the message? |
42 | */ | 42 | */ |
43 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 43 | #define WAIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) |
44 | #define TIMEOUT GNUNET_TIME_relative_multiply (WAIT, 3) | ||
44 | 45 | ||
45 | /** | 46 | /** |
46 | * Our public key. | 47 | * Our public key. |
@@ -68,6 +69,11 @@ const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
68 | struct GNUNET_STATISTICS_Handle *stats; | 69 | struct GNUNET_STATISTICS_Handle *stats; |
69 | 70 | ||
70 | /** | 71 | /** |
72 | * Our HELLO | ||
73 | */ | ||
74 | struct GNUNET_HELLO_Message *hello; | ||
75 | |||
76 | /** | ||
71 | * Number of neighbours we'd like to have. | 77 | * Number of neighbours we'd like to have. |
72 | */ | 78 | */ |
73 | static uint32_t max_connect_per_transport; | 79 | static uint32_t max_connect_per_transport; |
@@ -88,13 +94,27 @@ struct GNUNET_TRANSPORT_PluginFunctions *api; | |||
88 | static GNUNET_SCHEDULER_TaskIdentifier timeout_task; | 94 | static GNUNET_SCHEDULER_TaskIdentifier timeout_task; |
89 | 95 | ||
90 | /** | 96 | /** |
97 | * Timeout task | ||
98 | */ | ||
99 | static GNUNET_SCHEDULER_TaskIdentifier timeout_wait; | ||
100 | |||
101 | /** | ||
91 | * Library name | 102 | * Library name |
92 | */ | 103 | */ |
93 | static char *libname; | 104 | static char *libname; |
94 | 105 | ||
106 | /** | ||
107 | * Plugin addresses head | ||
108 | */ | ||
95 | struct AddressWrapper *head; | 109 | struct AddressWrapper *head; |
110 | |||
111 | /** | ||
112 | * Plugin addresses tail | ||
113 | */ | ||
96 | struct AddressWrapper *tail; | 114 | struct AddressWrapper *tail; |
97 | 115 | ||
116 | unsigned int addresses_reported; | ||
117 | |||
98 | /** | 118 | /** |
99 | * Did the test pass or fail? | 119 | * Did the test pass or fail? |
100 | */ | 120 | */ |
@@ -115,21 +135,13 @@ struct AddressWrapper | |||
115 | static void | 135 | static void |
116 | end () | 136 | end () |
117 | { | 137 | { |
118 | if (NULL != head) | ||
119 | { | ||
120 | |||
121 | } | ||
122 | |||
123 | if (GNUNET_SCHEDULER_NO_TASK != timeout_task) | 138 | if (GNUNET_SCHEDULER_NO_TASK != timeout_task) |
124 | { | 139 | { |
125 | GNUNET_SCHEDULER_cancel (timeout_task); | 140 | GNUNET_SCHEDULER_cancel (timeout_task); |
126 | timeout_task = GNUNET_SCHEDULER_NO_TASK; | 141 | timeout_task = GNUNET_SCHEDULER_NO_TASK; |
127 | } | 142 | } |
128 | |||
129 | if (NULL != api) | 143 | if (NULL != api) |
130 | { | ||
131 | GNUNET_PLUGIN_unload (libname, api); | 144 | GNUNET_PLUGIN_unload (libname, api); |
132 | } | ||
133 | GNUNET_free (libname); | 145 | GNUNET_free (libname); |
134 | libname = NULL; | 146 | libname = NULL; |
135 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); | 147 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); |
@@ -139,13 +151,16 @@ end () | |||
139 | } | 151 | } |
140 | 152 | ||
141 | static void | 153 | static void |
142 | |||
143 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 154 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
144 | { | 155 | { |
145 | struct AddressWrapper *w; | 156 | struct AddressWrapper *w; |
146 | int c = 0; | 157 | int c = 0; |
147 | |||
148 | timeout_task = GNUNET_SCHEDULER_NO_TASK; | 158 | timeout_task = GNUNET_SCHEDULER_NO_TASK; |
159 | if (GNUNET_SCHEDULER_NO_TASK != timeout_wait) | ||
160 | { | ||
161 | GNUNET_SCHEDULER_cancel (timeout_wait); | ||
162 | timeout_wait = GNUNET_SCHEDULER_NO_TASK; | ||
163 | } | ||
149 | if (NULL != libname) | 164 | if (NULL != libname) |
150 | { | 165 | { |
151 | if (NULL != api) | 166 | if (NULL != api) |
@@ -178,10 +193,25 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
178 | ok = 1; | 193 | ok = 1; |
179 | } | 194 | } |
180 | 195 | ||
196 | static void | ||
197 | wait_end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
198 | { | ||
199 | timeout_wait = GNUNET_SCHEDULER_NO_TASK; | ||
200 | if (0 == addresses_reported) | ||
201 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
202 | _("Plugin did not report any addresses, could not check plugin \n")); | ||
203 | end (); | ||
204 | } | ||
205 | |||
181 | 206 | ||
182 | static void | 207 | static void |
183 | end_badly_now () | 208 | end_badly_now () |
184 | { | 209 | { |
210 | if (GNUNET_SCHEDULER_NO_TASK != timeout_wait) | ||
211 | { | ||
212 | GNUNET_SCHEDULER_cancel (timeout_wait); | ||
213 | timeout_wait = GNUNET_SCHEDULER_NO_TASK; | ||
214 | } | ||
185 | if (GNUNET_SCHEDULER_NO_TASK != timeout_task) | 215 | if (GNUNET_SCHEDULER_NO_TASK != timeout_task) |
186 | { | 216 | { |
187 | GNUNET_SCHEDULER_cancel (timeout_task); | 217 | GNUNET_SCHEDULER_cancel (timeout_task); |
@@ -202,7 +232,6 @@ env_receive (void *cls, | |||
202 | uint16_t sender_address_len) | 232 | uint16_t sender_address_len) |
203 | { | 233 | { |
204 | /* do nothing */ | 234 | /* do nothing */ |
205 | GNUNET_break (0); | ||
206 | return GNUNET_TIME_relative_get_zero_(); | 235 | return GNUNET_TIME_relative_get_zero_(); |
207 | } | 236 | } |
208 | 237 | ||
@@ -220,7 +249,8 @@ env_notify_address (void *cls, | |||
220 | 249 | ||
221 | if (GNUNET_YES == add_remove) | 250 | if (GNUNET_YES == add_remove) |
222 | { | 251 | { |
223 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 252 | addresses_reported ++; |
253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
224 | _("Adding address of length %u\n"), addrlen); | 254 | _("Adding address of length %u\n"), addrlen); |
225 | 255 | ||
226 | w = GNUNET_malloc (sizeof (struct AddressWrapper)); | 256 | w = GNUNET_malloc (sizeof (struct AddressWrapper)); |
@@ -271,10 +301,16 @@ env_notify_address (void *cls, | |||
271 | end_badly_now(); | 301 | end_badly_now(); |
272 | return; | 302 | return; |
273 | } | 303 | } |
304 | if (GNUNET_SCHEDULER_NO_TASK != timeout_wait) | ||
305 | { | ||
306 | GNUNET_SCHEDULER_cancel (timeout_wait); | ||
307 | timeout_wait = GNUNET_SCHEDULER_NO_TASK; | ||
308 | } | ||
309 | timeout_wait = GNUNET_SCHEDULER_add_delayed (WAIT, &wait_end, NULL); | ||
274 | } | 310 | } |
275 | else if (GNUNET_NO == add_remove) | 311 | else if (GNUNET_NO == add_remove) |
276 | { | 312 | { |
277 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
278 | _("Removing address of length %u\n"), addrlen); | 314 | _("Removing address of length %u\n"), addrlen); |
279 | 315 | ||
280 | w = head; | 316 | w = head; |
@@ -304,8 +340,9 @@ env_notify_address (void *cls, | |||
304 | { | 340 | { |
305 | GNUNET_break (0); | 341 | GNUNET_break (0); |
306 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 342 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
307 | _("Invalid operation\n")); | 343 | _("Invalid operation: %u \n"), add_remove); |
308 | end_badly_now (); | 344 | end_badly_now (); |
345 | return; | ||
309 | } | 346 | } |
310 | } | 347 | } |
311 | 348 | ||
@@ -315,17 +352,15 @@ env_get_address_type (void *cls, | |||
315 | size_t addrlen) | 352 | size_t addrlen) |
316 | { | 353 | { |
317 | struct GNUNET_ATS_Information ats; | 354 | struct GNUNET_ATS_Information ats; |
318 | ats.type = htonl (0); | 355 | ats.type = htonl (GNUNET_ATS_NETWORK_TYPE); |
319 | ats.value = htonl (0); | 356 | ats.value = htonl (GNUNET_ATS_NET_LOOPBACK); |
320 | return ats; | 357 | return ats; |
321 | } | 358 | } |
322 | 359 | ||
323 | |||
324 | const struct GNUNET_MessageHeader * | 360 | const struct GNUNET_MessageHeader * |
325 | env_get_our_hello (void) | 361 | env_get_our_hello (void) |
326 | { | 362 | { |
327 | GNUNET_break (0); | 363 | return (const struct GNUNET_MessageHeader *) hello; |
328 | return NULL; | ||
329 | } | 364 | } |
330 | 365 | ||
331 | void env_session_end (void *cls, | 366 | void env_session_end (void *cls, |
@@ -409,6 +444,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
409 | GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), | 444 | GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), |
410 | &my_identity.hashPubKey); | 445 | &my_identity.hashPubKey); |
411 | 446 | ||
447 | |||
448 | hello = GNUNET_HELLO_create(&my_public_key, NULL, NULL); | ||
449 | |||
412 | /* load plugins... */ | 450 | /* load plugins... */ |
413 | setup_plugin_environment (); | 451 | setup_plugin_environment (); |
414 | 452 | ||
@@ -431,11 +469,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
431 | if (api == NULL) | 469 | if (api == NULL) |
432 | { | 470 | { |
433 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 471 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
434 | _("Failed to load transport plugin for tcp\n")); | 472 | _("Failed to load transport plugin for %s\n"), plugin); |
435 | end_badly_now (); | 473 | end_badly_now (); |
436 | return; | 474 | return; |
437 | } | 475 | } |
438 | 476 | ||
477 | timeout_wait = GNUNET_SCHEDULER_add_delayed (WAIT, &wait_end, NULL); | ||
478 | |||
439 | /* Check if all functions are implemented */ | 479 | /* Check if all functions are implemented */ |
440 | if (NULL == api->address_pretty_printer) | 480 | if (NULL == api->address_pretty_printer) |
441 | { | 481 | { |