}
+/**
+ * Function that will be called for each address the transport
+ * is aware that it might be reachable under. Update our HELLO.
+ *
+ * @param cls name of the plugin (const char*)
+ * @param add_remove should the address added (YES) or removed (NO) from the
+ * set of valid addresses?
+ * @param addr one of the addresses of the host
+ * the specific address format depends on the transport
+ * @param addrlen length of the address
+ */
+static void
+plugin_env_address_change_notification (void *cls,
+ int add_remove,
+ const void *addr,
+ size_t addrlen)
+{
+ const char *plugin_name = cls;
+
+ GST_hello_modify_addresses (add_remove,
+ plugin_name,
+ addr,
+ addrlen);
+}
+
+
/**
* Function called when the service shuts down. Unloads our plugins
* and cancels pending validations.
shutdown_task (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+
+ GST_plugins_unload ();
GST_hello_stop ();
if (GST_peerinfo != NULL)
GNUNET_SCHEDULER_shutdown ();
return;
}
+
+ /* start subsystems */
GST_hello_start (&process_hello_update, NULL);
+ GST_plugins_load (NULL, // FIXME...
+ &plugin_env_address_change_notification,
+ NULL, // FIXME...
+ NULL, // FIXME...
+ NULL); // FIXME...
}
* @author Christian Grothoff
*/
#include "platform.h"
+#include "gnunet-service-transport.h"
+#include "gnunet-service-transport_hello.h"
#include "gnunet-service-transport_plugins.h"
/**
/**
* Head of DLL of all loaded plugins.
*/
-// static struct TransportPlugin *plugins_tail;
+static struct TransportPlugin *plugins_tail;
GNUNET_TRANSPORT_SessionEnd session_end_cb,
GNUNET_TRANSPORT_CostReport cost_cb)
{
-#if 0
struct TransportPlugin *plug;
+ unsigned long long tneigh;
char *libname;
-
- /* load plugins... */
- no_transports = 1;
- if (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (c,
- "TRANSPORT", "PLUGINS", &plugs))
+ char *plugs;
+ char *pos;
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (GST_cfg,
+ "TRANSPORT",
+ "NEIGHBOUR_LIMIT",
+ &tneigh))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Transport service is lacking NEIGHBOUR_LIMIT option.\n"));
+ return;
+ }
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (GST_cfg,
+ "TRANSPORT", "PLUGINS", &plugs))
+ return;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Starting transport plugins `%s'\n"),
+ plugs);
+ for (pos = strtok (plugs, " "); pos != NULL; pos = strtok (NULL, " "))
+ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Starting transport plugins `%s'\n"), plugs);
- pos = strtok (plugs, " ");
- while (pos != NULL)
- {
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Loading `%s' transport plugin\n"), name);
- GNUNET_asprintf (&libname, "libgnunet_plugin_transport_%s", name);
- plug = GNUNET_malloc (sizeof (struct TransportPlugin));
- plug->short_name = GNUNET_strdup (name);
- plug->lib_name = libname;
- plug->env.cfg = cfg;
- plug->env.my_identity = &my_identity;
- plug->env.our_hello = &our_hello;
- plug->env.cls = plug->short_name;
- plug->env.receive = &plugin_env_receive;
- plug->env.notify_address = &plugin_env_notify_address;
- plug->env.session_end = &plugin_env_session_end;
- plug->env.max_connections = max_connect_per_transport;
- plug->env.stats = stats;
- plug->next = plugins;
- plugins = plug;
- plug->api = GNUNET_PLUGIN_load (libname, &plug->env);
- if (plug->api == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Failed to load transport plugin for `%s'\n"), name);
- GNUNET_free (plug->short_name);
- plugins = plug->next;
- GNUNET_free (libname);
- GNUNET_free (plug);
- }
- start_transport (server, pos);
- no_transports = 0;
- pos = strtok (NULL, " ");
- }
- GNUNET_free (plugs);
+ _("Loading `%s' transport plugin\n"), pos);
+ GNUNET_asprintf (&libname,
+ "libgnunet_plugin_transport_%s",
+ pos);
+ plug = GNUNET_malloc (sizeof (struct TransportPlugin));
+ plug->short_name = GNUNET_strdup (pos);
+ plug->lib_name = libname;
+ plug->env.cfg = GST_cfg;
+ plug->env.my_identity = &GST_my_identity;
+ plug->env.get_our_hello = &GST_hello_get;
+ plug->env.cls = plug->short_name;
+ plug->env.receive = recv_cb;
+ plug->env.notify_address = address_cb;
+ plug->env.session_end = session_end_cb;
+ plug->env.max_connections = tneigh;
+ plug->env.stats = GST_stats;
+ GNUNET_CONTAINER_DLL_insert (plugins_head,
+ plugins_tail,
+ plug);
+ plug->api = GNUNET_PLUGIN_load (libname, &plug->env);
+ if (plug->api == NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to load transport plugin for `%s'\n"),
+ pos);
+ GNUNET_CONTAINER_DLL_remove (plugins_head,
+ plugins_tail,
+ plug);
+ GNUNET_free (plug->short_name);
+ GNUNET_free (plug->lib_name);
+ GNUNET_free (plug);
+ }
}
-#endif
+ GNUNET_free (plugs);
}
void
GST_plugins_unload ()
{
-#if 0
- while (NULL != (plug = plugins))
+ struct TransportPlugin *plug;
+
+ while (NULL != (plug = plugins_head))
{
- if (plug->address_update_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (plug->address_update_task);
- plug->address_update_task = GNUNET_SCHEDULER_NO_TASK;
- }
GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api));
GNUNET_free (plug->lib_name);
GNUNET_free (plug->short_name);
- while (NULL != (al = plug->addresses))
- {
- plug->addresses = al->next;
- GNUNET_free (al);
- }
- plugins = plug->next;
+ GNUNET_CONTAINER_DLL_remove (plugins_head,
+ plugins_tail,
+ plug);
GNUNET_free (plug);
}
-#endif
}
struct ieee80211_frame * ieeewlanheader;
struct Radiotap_Send * radioHeader;
struct GNUNET_MessageHeader * msgheader2;
+ const struct GNUNET_MessageHeader *hello;
- hallo_size = GNUNET_HELLO_size(*(plugin->env->our_hello));
+ hello = plugin->env->get_our_hello ();
+ hallo_size = GNUNET_HELLO_size(hello);
GNUNET_assert(sizeof(struct WlanHeader) + hallo_size <= WLAN_MTU);
size = sizeof(struct GNUNET_MessageHeader) + sizeof(struct Radiotap_Send)
+ sizeof(struct ieee80211_frame) + sizeof(struct GNUNET_MessageHeader)
getWlanHeader(ieeewlanheader, &bc_all_mac, plugin, size);
msgheader2 = (struct GNUNET_MessageHeader*) &ieeewlanheader[1];
- msgheader2->size = htons(
- GNUNET_HELLO_size(*(plugin->env->our_hello))
+ msgheader2->size = htons(GNUNET_HELLO_size(hello)
+ sizeof(struct GNUNET_MessageHeader));
msgheader2->type = htons(GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT);
- memcpy(&msgheader2[1], *plugin->env->our_hello, hallo_size);
+ memcpy(&msgheader2[1], hello, hallo_size);
bytes = GNUNET_DISK_file_write(plugin->server_stdin_handle, msgheader, size);