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_tcp.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_tcp.c')
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 628a0ff42..e10dd74c1 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -2105,6 +2105,18 @@ libgnunet_plugin_transport_tcp_init (void *cls) | |||
2105 | struct sockaddr **addrs; | 2105 | struct sockaddr **addrs; |
2106 | socklen_t *addrlens; | 2106 | socklen_t *addrlens; |
2107 | 2107 | ||
2108 | if (NULL == env->receive) | ||
2109 | { | ||
2110 | /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully | ||
2111 | initialze the plugin or the API */ | ||
2112 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); | ||
2113 | api->cls = NULL; | ||
2114 | api->address_pretty_printer = &tcp_plugin_address_pretty_printer; | ||
2115 | api->address_to_string = &tcp_address_to_string; | ||
2116 | api->string_to_address = &tcp_string_to_address; | ||
2117 | return api; | ||
2118 | } | ||
2119 | |||
2108 | if (GNUNET_OK != | 2120 | if (GNUNET_OK != |
2109 | GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-tcp", | 2121 | GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-tcp", |
2110 | "MAX_CONNECTIONS", | 2122 | "MAX_CONNECTIONS", |
@@ -2143,8 +2155,6 @@ libgnunet_plugin_transport_tcp_init (void *cls) | |||
2143 | else | 2155 | else |
2144 | service = NULL; | 2156 | service = NULL; |
2145 | 2157 | ||
2146 | |||
2147 | |||
2148 | plugin = GNUNET_malloc (sizeof (struct Plugin)); | 2158 | plugin = GNUNET_malloc (sizeof (struct Plugin)); |
2149 | plugin->sessionmap = GNUNET_CONTAINER_multihashmap_create(max_connections); | 2159 | plugin->sessionmap = GNUNET_CONTAINER_multihashmap_create(max_connections); |
2150 | plugin->max_connections = max_connections; | 2160 | plugin->max_connections = max_connections; |
@@ -2247,9 +2257,13 @@ libgnunet_plugin_transport_tcp_done (void *cls) | |||
2247 | struct Plugin *plugin = api->cls; | 2257 | struct Plugin *plugin = api->cls; |
2248 | struct TCPProbeContext *tcp_probe; | 2258 | struct TCPProbeContext *tcp_probe; |
2249 | 2259 | ||
2260 | if (NULL == plugin) | ||
2261 | { | ||
2262 | GNUNET_free (api); | ||
2263 | return NULL; | ||
2264 | } | ||
2250 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Shutting down TCP plugin\n"); | 2265 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Shutting down TCP plugin\n"); |
2251 | 2266 | ||
2252 | |||
2253 | /* Removing leftover sessions */ | 2267 | /* Removing leftover sessions */ |
2254 | GNUNET_CONTAINER_multihashmap_iterate(plugin->sessionmap, &session_disconnect_it, NULL); | 2268 | GNUNET_CONTAINER_multihashmap_iterate(plugin->sessionmap, &session_disconnect_it, NULL); |
2255 | /* Removing leftover NAT sessions */ | 2269 | /* Removing leftover NAT sessions */ |