aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-12-02 08:30:29 +0000
committerGuy Harris <guy@alum.mit.edu>2013-12-02 08:30:29 +0000
commit0cc1545d05be6f655c950904b1da776190f3af16 (patch)
treeb82725615b527304bfb2e9e7d9f3b6dfc50ce7fd /epan/tap.c
parentbaf569188ac49ad38912b82d23ff241321cd654f (diff)
Move most of the plugin code from epan to wsutil and remove all
knowledge of particular types of plugins. Instead, let particular types of plugins register with the common plugin code, giving a name and a routine to recognize that type of plugin. In particular applications, only process the relevant plugin types. Add a Makefile.common to the codecs directory. svn path=/trunk/; revision=53710
Diffstat (limited to 'epan/tap.c')
-rw-r--r--epan/tap.c73
1 files changed, 71 insertions, 2 deletions
diff --git a/epan/tap.c b/epan/tap.c
index 7ac5e54bc6..f4036afdb6 100644
--- a/epan/tap.c
+++ b/epan/tap.c
@@ -77,6 +77,77 @@ typedef struct _tap_listener_t {
} tap_listener_t;
static volatile tap_listener_t *tap_listener_queue=NULL;
+#ifdef HAVE_PLUGINS
+
+#include <gmodule.h>
+
+#include <wsutil/plugins.h>
+
+/*
+ * List of tap plugins.
+ */
+typedef struct {
+ void (*register_tap_listener_fn)(void); /* routine to call to register tap listener */
+} tap_plugin;
+
+static GSList *tap_plugins = NULL;
+
+/*
+ * Callback for each plugin found.
+ */
+static gboolean
+check_for_tap_plugin(GModule *handle)
+{
+ gpointer gp;
+ void (*register_tap_listener_fn)(void);
+ tap_plugin *plugin;
+
+ /*
+ * Do we have a register_tap_listener routine?
+ */
+ if (!g_module_symbol(handle, "plugin_register_tap_listener", &gp)) {
+ /* No, so this isn't a tap plugin. */
+ return FALSE;
+ }
+
+ /*
+ * Yes - this plugin includes one or more taps.
+ */
+ register_tap_listener_fn = (void (*)(void))gp;
+
+ /*
+ * Add this one to the list of tap plugins.
+ */
+ plugin = (tap_plugin *)g_malloc(sizeof (tap_plugin));
+ plugin->register_tap_listener_fn = register_tap_listener_fn;
+ tap_plugins = g_slist_append(tap_plugins, plugin);
+ return TRUE;
+}
+
+void
+register_tap_plugin_type(void)
+{
+ add_plugin_type("tap", check_for_tap_plugin);
+}
+
+static void
+register_tap_plugin_listener(gpointer data, gpointer user_data _U_)
+{
+ tap_plugin *plugin = (tap_plugin *)data;
+
+ (plugin->register_tap_listener_fn)();
+}
+
+/*
+ * For all tap plugins, call their register routines.
+ */
+void
+register_all_plugin_tap_listeners(void)
+{
+ g_slist_foreach(tap_plugins, register_tap_plugin_listener, NULL);
+}
+#endif /* HAVE_PLUGINS */
+
/* **********************************************************************
* Init routine only called from epan at application startup
* ********************************************************************** */
@@ -87,8 +158,6 @@ void
tap_init(void)
{
tap_packet_index=0;
-
- return;
}
/* **********************************************************************