diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-10 23:17:45 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-10 23:17:45 +0000 |
commit | 854e1e4d0d1fcfa9812336ebfae76538a9197351 (patch) | |
tree | 83bbf1e3e17cc7400ea85d21e9177bff522b1f11 /src/transport/plugin_transport_http.c | |
parent | da6e72d97f0125825d5348d12b75b39efc7d2b39 (diff) | |
download | gnunet-854e1e4d0d1fcfa9812336ebfae76538a9197351.tar.gz gnunet-854e1e4d0d1fcfa9812336ebfae76538a9197351.zip |
add support for stub-mode for transport plugins
Diffstat (limited to 'src/transport/plugin_transport_http.c')
-rw-r--r-- | src/transport/plugin_transport_http.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index f88ff3388..8e3bd737c 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c | |||
@@ -1373,6 +1373,18 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
1373 | struct Plugin *plugin; | 1373 | struct Plugin *plugin; |
1374 | int res; | 1374 | int res; |
1375 | 1375 | ||
1376 | if (NULL == env->receive) | ||
1377 | { | ||
1378 | /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully | ||
1379 | initialze the plugin or the API */ | ||
1380 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); | ||
1381 | api->cls = NULL; | ||
1382 | api->address_pretty_printer = &http_plugin_address_pretty_printer; | ||
1383 | api->address_to_string = &http_plugin_address_to_string; | ||
1384 | api->string_to_address = NULL; // FIXME! | ||
1385 | return api; | ||
1386 | } | ||
1387 | |||
1376 | plugin = GNUNET_malloc (sizeof (struct Plugin)); | 1388 | plugin = GNUNET_malloc (sizeof (struct Plugin)); |
1377 | plugin->env = env; | 1389 | plugin->env = env; |
1378 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); | 1390 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); |
@@ -1381,6 +1393,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
1381 | api->address_pretty_printer = &http_plugin_address_pretty_printer; | 1393 | api->address_pretty_printer = &http_plugin_address_pretty_printer; |
1382 | api->check_address = &http_plugin_address_suggested; | 1394 | api->check_address = &http_plugin_address_suggested; |
1383 | api->address_to_string = &http_plugin_address_to_string; | 1395 | api->address_to_string = &http_plugin_address_to_string; |
1396 | api->string_to_address = NULL; // FIXME! | ||
1384 | api->get_session = &http_get_session; | 1397 | api->get_session = &http_get_session; |
1385 | api->send = &http_plugin_send; | 1398 | api->send = &http_plugin_send; |
1386 | 1399 | ||
@@ -1452,7 +1465,13 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls) | |||
1452 | { | 1465 | { |
1453 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 1466 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; |
1454 | struct Plugin *plugin = api->cls; | 1467 | struct Plugin *plugin = api->cls; |
1455 | struct Session *s = NULL; | 1468 | struct Session *s; |
1469 | |||
1470 | if (NULL == plugin) | ||
1471 | { | ||
1472 | GNUNET_free (api); | ||
1473 | return NULL; | ||
1474 | } | ||
1456 | 1475 | ||
1457 | /* Stop reporting addresses to transport service */ | 1476 | /* Stop reporting addresses to transport service */ |
1458 | stop_report_addresses (plugin); | 1477 | stop_report_addresses (plugin); |