/**
* Function that should be called by the transport plugin
- * whenever a message is received.
+ * whenever a message is received. If this field is "NULL",
+ * the plugin should load in 'stub' mode and NOT fully
+ * initialize and instead only return an API with the
+ * 'address_pretty_printer', 'address_to_string' and
+ * 'string_to_address' functions.
*/
GNUNET_TRANSPORT_PluginReceiveCallback receive;
struct Plugin *plugin;
int res;
+ if (NULL == env->receive)
+ {
+ /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully
+ initialze the plugin or the API */
+ api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
+ api->cls = NULL;
+ api->address_pretty_printer = &http_plugin_address_pretty_printer;
+ api->address_to_string = &http_plugin_address_to_string;
+ api->string_to_address = NULL; // FIXME!
+ return api;
+ }
+
plugin = GNUNET_malloc (sizeof (struct Plugin));
plugin->env = env;
api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
api->address_pretty_printer = &http_plugin_address_pretty_printer;
api->check_address = &http_plugin_address_suggested;
api->address_to_string = &http_plugin_address_to_string;
+ api->string_to_address = NULL; // FIXME!
api->get_session = &http_get_session;
api->send = &http_plugin_send;
{
struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
struct Plugin *plugin = api->cls;
- struct Session *s = NULL;
+ struct Session *s;
+
+ if (NULL == plugin)
+ {
+ GNUNET_free (api);
+ return NULL;
+ }
/* Stop reporting addresses to transport service */
stop_report_addresses (plugin);
struct sockaddr **addrs;
socklen_t *addrlens;
+ if (NULL == env->receive)
+ {
+ /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully
+ initialze the plugin or the API */
+ api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
+ api->cls = NULL;
+ api->address_pretty_printer = &tcp_plugin_address_pretty_printer;
+ api->address_to_string = &tcp_address_to_string;
+ api->string_to_address = &tcp_string_to_address;
+ return api;
+ }
+
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-tcp",
"MAX_CONNECTIONS",
else
service = NULL;
-
-
plugin = GNUNET_malloc (sizeof (struct Plugin));
plugin->sessionmap = GNUNET_CONTAINER_multihashmap_create(max_connections);
plugin->max_connections = max_connections;
struct Plugin *plugin = api->cls;
struct TCPProbeContext *tcp_probe;
+ if (NULL == plugin)
+ {
+ GNUNET_free (api);
+ return NULL;
+ }
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Shutting down TCP plugin\n");
-
/* Removing leftover sessions */
GNUNET_CONTAINER_multihashmap_iterate(plugin->sessionmap, &session_disconnect_it, NULL);
/* Removing leftover NAT sessions */
int res;
+ if (NULL == env->receive)
+ {
+ /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully
+ initialze the plugin or the API */
+ api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
+ api->cls = NULL;
+ api->address_pretty_printer = &udp_plugin_address_pretty_printer;
+ api->address_to_string = &udp_address_to_string;
+ api->string_to_address = NULL; // FIXME!
+ return api;
+ }
+
/* Get port number */
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-udp", "PORT",
api->disconnect = &udp_disconnect;
api->address_pretty_printer = &udp_plugin_address_pretty_printer;
api->address_to_string = &udp_address_to_string;
+ api->string_to_address = NULL; // FIXME!
api->check_address = &udp_plugin_check_address;
api->get_session = &udp_plugin_get_session;
api->send = &udp_plugin_send;
return api;
}
-int heap_cleanup_iterator (void *cls,
- struct GNUNET_CONTAINER_HeapNode *
- node, void *element,
- GNUNET_CONTAINER_HeapCostType
- cost)
+
+static int
+heap_cleanup_iterator (void *cls,
+ struct GNUNET_CONTAINER_HeapNode *
+ node, void *element,
+ GNUNET_CONTAINER_HeapCostType
+ cost)
{
struct DefragContext * d_ctx = element;
* returns the udp transport API.
*
* @param cls our 'struct GNUNET_TRANSPORT_PluginEnvironment'
- * @return our 'struct GNUNET_TRANSPORT_PluginFunctions'
+ * @return NULL
*/
void *
libgnunet_plugin_transport_udp_done (void *cls)
{
struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
struct Plugin *plugin = api->cls;
+
+ if (NULL == plugin)
+ {
+ GNUNET_free (api);
+ return NULL;
+ }
+
stop_broadcast (plugin);
if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK)
struct Plugin *plugin;
int sockets_created;
+ if (NULL == env->receive)
+ {
+ /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully
+ initialze the plugin or the API */
+ api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
+ api->cls = NULL;
+ api->address_pretty_printer = &unix_plugin_address_pretty_printer;
+ api->address_to_string = &unix_address_to_string;
+ api->string_to_address = NULL; // FIXME!
+ return api;
+ }
+
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-unix", "PORT",
&port))
struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
struct Plugin *plugin = api->cls;
+ if (NULL == plugin)
+ {
+ GNUNET_free (api);
+ return NULL;
+ }
unix_transport_server_stop (plugin);
GNUNET_CONTAINER_multihashmap_iterate (plugin->session_map, &get_session_delete_it, plugin);
}
}
+
+
/**
* Exit point from the plugin.
* @param cls pointer to the api struct
{
struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
struct Plugin *plugin = api->cls;
- struct MacEndpoint *endpoint = plugin->mac_head;
+ struct MacEndpoint *endpoint;
struct MacEndpoint *endpoint_next;
+ if (NULL == plugin)
+ {
+ GNUNET_free (api);
+ return NULL;
+ }
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"libgnunet_plugin_transport_wlan_done started\n");
wlan_transport_stop_wlan_helper (plugin);
GNUNET_assert (cls != NULL);
//free sessions
+ endpoint = plugin->mac_head;
while (endpoint != NULL)
{
endpoint_next = endpoint->next;
return NULL;
}
+
/**
* Entry point for the plugin.
*
void *
libgnunet_plugin_transport_wlan_init (void *cls)
{
- //struct GNUNET_SERVICE_Context *service;
struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
struct GNUNET_TRANSPORT_PluginFunctions *api;
struct Plugin *plugin;
- GNUNET_assert (cls != NULL);
+ if (NULL == env->receive)
+ {
+ /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully
+ initialze the plugin or the API */
+ api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
+ api->cls = NULL;
+ api->address_pretty_printer = &wlan_plugin_address_pretty_printer;
+ api->address_to_string = &wlan_plugin_address_to_string;
+ api->string_to_address = NULL; // FIXME!
+ return api;
+ }
plugin = GNUNET_malloc (sizeof (struct Plugin));
plugin->env = env;
return api;
}
+
+
+
/* end of plugin_transport_wlan.c */