aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_wlan.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-03-10 23:17:45 +0000
committerChristian Grothoff <christian@grothoff.org>2012-03-10 23:17:45 +0000
commit854e1e4d0d1fcfa9812336ebfae76538a9197351 (patch)
tree83bbf1e3e17cc7400ea85d21e9177bff522b1f11 /src/transport/plugin_transport_wlan.c
parentda6e72d97f0125825d5348d12b75b39efc7d2b39 (diff)
downloadgnunet-854e1e4d0d1fcfa9812336ebfae76538a9197351.tar.gz
gnunet-854e1e4d0d1fcfa9812336ebfae76538a9197351.zip
add support for stub-mode for transport plugins
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r--src/transport/plugin_transport_wlan.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 7aebad93a..084fc611c 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -3080,6 +3080,8 @@ wlan_process_helper (void *cls, void *client,
3080 } 3080 }
3081} 3081}
3082 3082
3083
3084
3083/** 3085/**
3084 * Exit point from the plugin. 3086 * Exit point from the plugin.
3085 * @param cls pointer to the api struct 3087 * @param cls pointer to the api struct
@@ -3091,15 +3093,21 @@ libgnunet_plugin_transport_wlan_done (void *cls)
3091{ 3093{
3092 struct GNUNET_TRANSPORT_PluginFunctions *api = cls; 3094 struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
3093 struct Plugin *plugin = api->cls; 3095 struct Plugin *plugin = api->cls;
3094 struct MacEndpoint *endpoint = plugin->mac_head; 3096 struct MacEndpoint *endpoint;
3095 struct MacEndpoint *endpoint_next; 3097 struct MacEndpoint *endpoint_next;
3096 3098
3099 if (NULL == plugin)
3100 {
3101 GNUNET_free (api);
3102 return NULL;
3103 }
3097 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 3104 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
3098 "libgnunet_plugin_transport_wlan_done started\n"); 3105 "libgnunet_plugin_transport_wlan_done started\n");
3099 wlan_transport_stop_wlan_helper (plugin); 3106 wlan_transport_stop_wlan_helper (plugin);
3100 3107
3101 GNUNET_assert (cls != NULL); 3108 GNUNET_assert (cls != NULL);
3102 //free sessions 3109 //free sessions
3110 endpoint = plugin->mac_head;
3103 while (endpoint != NULL) 3111 while (endpoint != NULL)
3104 { 3112 {
3105 endpoint_next = endpoint->next; 3113 endpoint_next = endpoint->next;
@@ -3121,6 +3129,7 @@ libgnunet_plugin_transport_wlan_done (void *cls)
3121 return NULL; 3129 return NULL;
3122} 3130}
3123 3131
3132
3124/** 3133/**
3125 * Entry point for the plugin. 3134 * Entry point for the plugin.
3126 * 3135 *
@@ -3130,12 +3139,21 @@ libgnunet_plugin_transport_wlan_done (void *cls)
3130void * 3139void *
3131libgnunet_plugin_transport_wlan_init (void *cls) 3140libgnunet_plugin_transport_wlan_init (void *cls)
3132{ 3141{
3133 //struct GNUNET_SERVICE_Context *service;
3134 struct GNUNET_TRANSPORT_PluginEnvironment *env = cls; 3142 struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
3135 struct GNUNET_TRANSPORT_PluginFunctions *api; 3143 struct GNUNET_TRANSPORT_PluginFunctions *api;
3136 struct Plugin *plugin; 3144 struct Plugin *plugin;
3137 3145
3138 GNUNET_assert (cls != NULL); 3146 if (NULL == env->receive)
3147 {
3148 /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully
3149 initialze the plugin or the API */
3150 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
3151 api->cls = NULL;
3152 api->address_pretty_printer = &wlan_plugin_address_pretty_printer;
3153 api->address_to_string = &wlan_plugin_address_to_string;
3154 api->string_to_address = NULL; // FIXME!
3155 return api;
3156 }
3139 3157
3140 plugin = GNUNET_malloc (sizeof (struct Plugin)); 3158 plugin = GNUNET_malloc (sizeof (struct Plugin));
3141 plugin->env = env; 3159 plugin->env = env;
@@ -3199,4 +3217,7 @@ libgnunet_plugin_transport_wlan_init (void *cls)
3199 return api; 3217 return api;
3200} 3218}
3201 3219
3220
3221
3222
3202/* end of plugin_transport_wlan.c */ 3223/* end of plugin_transport_wlan.c */