1999-12-09 20:43:38 +00:00
|
|
|
/* plugins.c
|
1999-12-09 20:55:49 +00:00
|
|
|
* plugin routines
|
|
|
|
*
|
2003-09-24 18:35:58 +00:00
|
|
|
* $Id: plugins.c,v 1.77 2003/09/24 18:35:07 guy Exp $
|
1999-12-09 20:43:38 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
2001-08-18 23:21:31 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
1999-12-09 20:55:49 +00:00
|
|
|
* Copyright 1999 Gerald Combs
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
1999-12-09 20:43:38 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
1999-12-09 20:43:38 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
1999-12-09 20:43:38 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2002-07-16 22:50:48 +00:00
|
|
|
#ifdef NEED_SNPRINTF_H
|
|
|
|
# include "snprintf.h"
|
|
|
|
#endif
|
|
|
|
|
2000-01-15 00:23:13 +00:00
|
|
|
#include "plugins.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_PLUGINS
|
1999-12-09 20:43:38 +00:00
|
|
|
|
|
|
|
#include <time.h>
|
2000-01-15 00:23:13 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_DIRENT_H
|
2000-01-04 20:37:18 +00:00
|
|
|
#include <dirent.h>
|
2000-01-15 00:23:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_DIRECT_H
|
|
|
|
#include <direct.h>
|
|
|
|
#endif
|
|
|
|
|
2000-01-04 20:37:18 +00:00
|
|
|
#include <string.h>
|
2000-01-15 00:23:13 +00:00
|
|
|
#include <stdlib.h>
|
2002-08-28 20:41:00 +00:00
|
|
|
#include <errno.h>
|
2000-08-11 13:37:21 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_SYS_STAT_H
|
2000-01-04 21:29:43 +00:00
|
|
|
#include <sys/stat.h>
|
2000-08-11 13:37:21 +00:00
|
|
|
#endif
|
|
|
|
|
2000-01-15 00:23:13 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2000-01-04 21:29:43 +00:00
|
|
|
#include <unistd.h>
|
2000-01-15 00:23:13 +00:00
|
|
|
#endif
|
1999-12-09 20:43:38 +00:00
|
|
|
|
2000-09-28 03:16:29 +00:00
|
|
|
#include "filesystem.h"
|
1999-12-09 20:43:38 +00:00
|
|
|
|
2000-02-07 17:08:27 +00:00
|
|
|
#ifdef PLUGINS_NEED_ADDRESS_TABLE
|
2001-11-04 22:14:43 +00:00
|
|
|
#include "conversation.h"
|
2002-11-16 21:32:06 +00:00
|
|
|
#include "reassemble.h"
|
|
|
|
#include "prefs.h"
|
2001-07-22 10:12:11 +00:00
|
|
|
#include "packet-giop.h"
|
2002-02-22 08:56:48 +00:00
|
|
|
#include "packet-tpkt.h"
|
Make a "tcp_dissect_pdus()" with the standard loop for a TCP segment,
extracting PDUs from it and possibly doing reassembly. Make the COPS,
DNS, DSI, Gryphon, and SCCP dissectors use it.
Add "set_actual_length()", "tcp_dissect_pdus()",
"decode_boolean_bitfield()", "decode_numeric_bitfield()", and
"decode_enumerated_bitfield()" to the list of routines available to
dissectors on platforms where routines in the main program aren't
available to dynamically-loaded code.
Declare routines in "to_str.h" as "extern"; as I remember, that's
necessary to allow the "decode_XXX_bitfield()" routines declared therein
to be made available to plugins as per the above.
Note that new exported routines should be added to the end of the table
if that's the only change being made to the table.
Create a new "plugin_api_decls.h" header file, used to declare both the
"p_" variables and the "p_" structure members in the routine-exporting
mechanism; this reduces the number of places you have to change to
change the list of exported routines.
svn path=/trunk/; revision=5394
2002-05-05 00:16:38 +00:00
|
|
|
#include "packet-tcp.h"
|
2003-03-06 09:01:47 +00:00
|
|
|
#include "tap.h"
|
2003-04-24 21:15:13 +00:00
|
|
|
#include "asn1.h"
|
2003-08-25 21:35:36 +00:00
|
|
|
#include "packet-per.h"
|
2000-03-15 19:09:52 +00:00
|
|
|
#include "plugins/plugin_table.h"
|
2003-08-18 20:17:55 +00:00
|
|
|
static plugin_address_table_t patable = {
|
|
|
|
/* file generated by plugin_gen.py */
|
|
|
|
#include "plugins/Xass-list"
|
|
|
|
};
|
2000-02-07 17:08:27 +00:00
|
|
|
#endif
|
1999-12-09 20:43:38 +00:00
|
|
|
|
|
|
|
/* linked list of all plugins */
|
|
|
|
plugin *plugin_list;
|
Allow plugins to have, instead of "protocol" and "filter_string"
variables and a "dissector" routine, a "plugin_reg_handoff()" routine,
which will act just like the "reg_handoff()" routine of a non-plugin
dissector, registering the dissector with handoff tables.
This lets them plug into both TCP and UDP, or plug into protocols other
than TCP or UDP.
Those new-style plugin are enabled and disabled using the standard
"Edit->Protocols" mechanism (and thus should use
"OLD_CHECK_DISPLAY_AS_DATA()" or "CHECK_DISPLAY_AS_DATA()"); they don't
show up in the list of plugins, aren't enabled or disabled from that
list, and, as they don't have a filter, can't have the filter changed
from that list - instead, they should register preferences for port
numbers and the like if they should be configurable to use different
ports.
Make the Gryphon protocol a new-style plugin.
svn path=/trunk/; revision=2565
2000-11-05 09:05:00 +00:00
|
|
|
|
2000-01-04 20:37:18 +00:00
|
|
|
static gchar *user_plug_dir = NULL;
|
|
|
|
|
2000-08-19 17:53:02 +00:00
|
|
|
#define PLUGINS_DIR_NAME "plugins"
|
|
|
|
|
1999-12-09 20:43:38 +00:00
|
|
|
/*
|
|
|
|
* add a new plugin to the list
|
|
|
|
* returns :
|
|
|
|
* - 0 : OK
|
|
|
|
* - ENOMEM : memory allocation problem
|
|
|
|
* - EEXIST : the same plugin (i.e. name/version) was already registered.
|
|
|
|
*/
|
2001-01-28 21:17:29 +00:00
|
|
|
static int
|
|
|
|
add_plugin(void *handle, gchar *name, gchar *version,
|
|
|
|
void (*reg_handoff)(void))
|
1999-12-09 20:43:38 +00:00
|
|
|
{
|
|
|
|
plugin *new_plug, *pt_plug;
|
|
|
|
|
|
|
|
pt_plug = plugin_list;
|
|
|
|
if (!pt_plug) /* the list is empty */
|
|
|
|
{
|
|
|
|
new_plug = (plugin *)g_malloc(sizeof(plugin));
|
|
|
|
if (new_plug == NULL) return ENOMEM;
|
|
|
|
plugin_list = new_plug;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
/* check if the same name/version is already registered */
|
|
|
|
if (!strcmp(pt_plug->name, name) &&
|
|
|
|
!strcmp(pt_plug->version, version))
|
|
|
|
{
|
|
|
|
return EEXIST;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we found the last plugin in the list */
|
|
|
|
if (pt_plug->next == NULL) break;
|
|
|
|
|
|
|
|
pt_plug = pt_plug->next;
|
|
|
|
}
|
|
|
|
new_plug = (plugin *)g_malloc(sizeof(plugin));
|
|
|
|
if (new_plug == NULL) return ENOMEM;
|
|
|
|
pt_plug->next = new_plug;
|
|
|
|
}
|
|
|
|
|
Allow plugins to have, instead of "protocol" and "filter_string"
variables and a "dissector" routine, a "plugin_reg_handoff()" routine,
which will act just like the "reg_handoff()" routine of a non-plugin
dissector, registering the dissector with handoff tables.
This lets them plug into both TCP and UDP, or plug into protocols other
than TCP or UDP.
Those new-style plugin are enabled and disabled using the standard
"Edit->Protocols" mechanism (and thus should use
"OLD_CHECK_DISPLAY_AS_DATA()" or "CHECK_DISPLAY_AS_DATA()"); they don't
show up in the list of plugins, aren't enabled or disabled from that
list, and, as they don't have a filter, can't have the filter changed
from that list - instead, they should register preferences for port
numbers and the like if they should be configurable to use different
ports.
Make the Gryphon protocol a new-style plugin.
svn path=/trunk/; revision=2565
2000-11-05 09:05:00 +00:00
|
|
|
new_plug->handle = handle;
|
|
|
|
new_plug->name = name;
|
|
|
|
new_plug->version = version;
|
|
|
|
new_plug->reg_handoff = reg_handoff;
|
|
|
|
new_plug->next = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Clean up the dissector registration up a bit - arrange that all plugins
be loaded and their initialization routines called in right after we
call the initialization routines for built-in dissectors, but don't call
their handoff registration routines yet, and then call the handoff
registration routines right after calling the handoff registration
routines for built-in dissectors.
Do all that in "proto_init()", rather than "epan_init()".
That way, we call all dissector registration routines together, and then
call all dissector handoff registration routines together; all the
registration routines are called before any handoff registration
routines, as is required, and, as "proto_init()" is called by
"epan_init()" before "dfilter_init()" is called, all filterable fields
have been registered before "dfilter_init()" is called, and no plugins
have to call "dfilter_init()" themselves to get their fields registered.
Remove pointers to "dfilter_init()" and "dfilter_cleanup()" from the
plugin address table, as plugins shouldn't be calling them any more, and
remove calls to them from plugins.
svn path=/trunk/; revision=2940
2001-01-26 06:14:53 +00:00
|
|
|
/*
|
|
|
|
* XXX - when we remove support for old-style plugins (which we should
|
|
|
|
* probably do eventually, as all plugins should be written as new-style
|
|
|
|
* ones), we may want to have "init_plugins()" merely save a pointer
|
|
|
|
* to the plugin's "init" routine, just as we save a pointer to its
|
|
|
|
* "reg_handoff" routine, and have a "register_all_plugins()" routine
|
|
|
|
* to go through the list of plugins and call all of them.
|
|
|
|
*
|
|
|
|
* Then we'd have "epan_init()", or perhaps even something higher up
|
|
|
|
* in the call tree, call "init_plugins()", and have "proto_init()"
|
|
|
|
* call "register_all_plugins()" right after calling "register_all_protocols()";
|
|
|
|
* this might be a bit cleaner.
|
|
|
|
*/
|
2000-01-04 20:37:18 +00:00
|
|
|
static void
|
|
|
|
plugins_scan_dir(const char *dirname)
|
|
|
|
{
|
2000-08-19 17:53:02 +00:00
|
|
|
#define FILENAME_LEN 1024
|
2003-06-03 02:32:56 +00:00
|
|
|
#if GLIB_MAJOR_VERSION < 2
|
2000-11-29 09:10:03 +00:00
|
|
|
gchar *hack_path; /* pathname used to construct lt_lib_ext */
|
|
|
|
gchar *lt_lib_ext; /* extension for loadable modules */
|
2000-01-04 20:37:18 +00:00
|
|
|
DIR *dir; /* scanned directory */
|
|
|
|
struct dirent *file; /* current file */
|
2003-06-03 02:32:56 +00:00
|
|
|
gchar *name;
|
|
|
|
#else /* GLIB 2 */
|
|
|
|
GDir *dir; /* scanned directory */
|
|
|
|
GError **dummy;
|
|
|
|
const gchar *name;
|
|
|
|
#endif
|
2000-08-19 17:53:02 +00:00
|
|
|
gchar filename[FILENAME_LEN]; /* current file name */
|
2000-01-15 00:23:13 +00:00
|
|
|
GModule *handle; /* handle returned by dlopen */
|
2000-01-04 20:37:18 +00:00
|
|
|
gchar *version;
|
Allow plugins to have, instead of "protocol" and "filter_string"
variables and a "dissector" routine, a "plugin_reg_handoff()" routine,
which will act just like the "reg_handoff()" routine of a non-plugin
dissector, registering the dissector with handoff tables.
This lets them plug into both TCP and UDP, or plug into protocols other
than TCP or UDP.
Those new-style plugin are enabled and disabled using the standard
"Edit->Protocols" mechanism (and thus should use
"OLD_CHECK_DISPLAY_AS_DATA()" or "CHECK_DISPLAY_AS_DATA()"); they don't
show up in the list of plugins, aren't enabled or disabled from that
list, and, as they don't have a filter, can't have the filter changed
from that list - instead, they should register preferences for port
numbers and the like if they should be configurable to use different
ports.
Make the Gryphon protocol a new-style plugin.
svn path=/trunk/; revision=2565
2000-11-05 09:05:00 +00:00
|
|
|
void (*init)(void *);
|
|
|
|
void (*reg_handoff)(void);
|
2000-01-04 20:37:18 +00:00
|
|
|
gchar *dot;
|
|
|
|
int cr;
|
|
|
|
|
2003-06-04 00:11:02 +00:00
|
|
|
#if GLIB_MAJOR_VERSION < 2
|
2000-11-29 09:10:03 +00:00
|
|
|
/*
|
|
|
|
* We find the extension used on this platform for loadable modules
|
|
|
|
* by the sneaky hack of calling "g_module_build_path" to build
|
|
|
|
* the pathname for a module with an empty directory name and
|
|
|
|
* empty module name, and then search for the last "." and use
|
|
|
|
* everything from the last "." on.
|
|
|
|
*/
|
|
|
|
hack_path = g_module_build_path("", "");
|
|
|
|
lt_lib_ext = strrchr(hack_path, '.');
|
|
|
|
if (lt_lib_ext == NULL)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Does this mean there *is* no extension? Assume so.
|
|
|
|
*
|
|
|
|
* XXX - the code below assumes that all loadable modules have
|
|
|
|
* an extension....
|
|
|
|
*/
|
|
|
|
lt_lib_ext = "";
|
|
|
|
}
|
2000-01-04 20:37:18 +00:00
|
|
|
|
|
|
|
if ((dir = opendir(dirname)) != NULL)
|
|
|
|
{
|
|
|
|
while ((file = readdir(dir)) != NULL)
|
|
|
|
{
|
|
|
|
/* don't try to open "." and ".." */
|
|
|
|
if (!(strcmp(file->d_name, "..") &&
|
|
|
|
strcmp(file->d_name, "."))) continue;
|
|
|
|
|
2000-11-29 09:10:03 +00:00
|
|
|
/* skip anything but files with lt_lib_ext */
|
2000-01-04 20:37:18 +00:00
|
|
|
dot = strrchr(file->d_name, '.');
|
2000-11-29 09:10:03 +00:00
|
|
|
if (dot == NULL || strcmp(dot, lt_lib_ext) != 0) continue;
|
2000-01-04 20:37:18 +00:00
|
|
|
|
2000-11-29 09:10:03 +00:00
|
|
|
snprintf(filename, FILENAME_LEN, "%s" G_DIR_SEPARATOR_S "%s",
|
|
|
|
dirname, file->d_name);
|
2000-01-04 20:37:18 +00:00
|
|
|
name = (gchar *)file->d_name;
|
2003-06-03 02:32:56 +00:00
|
|
|
#else /* GLIB 2 */
|
2003-06-04 00:11:02 +00:00
|
|
|
/*
|
|
|
|
* GLib 2.x defines G_MODULE_SUFFIX as the extension used on this
|
|
|
|
* platform for loadable modules.
|
|
|
|
*/
|
2003-06-03 02:32:56 +00:00
|
|
|
dummy = g_malloc(sizeof(GError *));
|
|
|
|
*dummy = NULL;
|
|
|
|
if ((dir = g_dir_open(dirname, 0, dummy)) != NULL)
|
|
|
|
{
|
|
|
|
while ((name = g_dir_read_name(dir)) != NULL)
|
|
|
|
{
|
|
|
|
/* skip anything but files with G_MODULE_SUFFIX */
|
|
|
|
dot = strrchr(name, '.');
|
|
|
|
if (dot == NULL || strcmp(dot+1, G_MODULE_SUFFIX) != 0) continue;
|
|
|
|
|
|
|
|
snprintf(filename, FILENAME_LEN, "%s" G_DIR_SEPARATOR_S "%s",
|
|
|
|
dirname, name);
|
2003-06-04 00:11:02 +00:00
|
|
|
#endif
|
2003-06-03 02:32:56 +00:00
|
|
|
if ((handle = g_module_open(filename, 0)) == NULL)
|
|
|
|
{
|
|
|
|
g_warning("Couldn't load module %s: %s", filename,
|
|
|
|
g_module_error());
|
|
|
|
continue;
|
|
|
|
}
|
2000-01-15 00:23:13 +00:00
|
|
|
if (g_module_symbol(handle, "version", (gpointer*)&version) == FALSE)
|
2000-01-04 20:37:18 +00:00
|
|
|
{
|
2000-08-18 14:22:20 +00:00
|
|
|
g_warning("The plugin %s has no version symbol", name);
|
2000-01-15 00:23:13 +00:00
|
|
|
g_module_close(handle);
|
2000-01-04 20:37:18 +00:00
|
|
|
continue;
|
|
|
|
}
|
Allow plugins to have, instead of "protocol" and "filter_string"
variables and a "dissector" routine, a "plugin_reg_handoff()" routine,
which will act just like the "reg_handoff()" routine of a non-plugin
dissector, registering the dissector with handoff tables.
This lets them plug into both TCP and UDP, or plug into protocols other
than TCP or UDP.
Those new-style plugin are enabled and disabled using the standard
"Edit->Protocols" mechanism (and thus should use
"OLD_CHECK_DISPLAY_AS_DATA()" or "CHECK_DISPLAY_AS_DATA()"); they don't
show up in the list of plugins, aren't enabled or disabled from that
list, and, as they don't have a filter, can't have the filter changed
from that list - instead, they should register preferences for port
numbers and the like if they should be configurable to use different
ports.
Make the Gryphon protocol a new-style plugin.
svn path=/trunk/; revision=2565
2000-11-05 09:05:00 +00:00
|
|
|
|
|
|
|
/*
|
2001-01-28 21:17:29 +00:00
|
|
|
* Old-style dissectors don't have a "plugin_reg_handoff()"
|
|
|
|
* routine; we no longer support them.
|
|
|
|
*
|
|
|
|
* New-style dissectors have one, because, otherwise, there's
|
|
|
|
* no way for them to arrange that they ever be called.
|
Allow plugins to have, instead of "protocol" and "filter_string"
variables and a "dissector" routine, a "plugin_reg_handoff()" routine,
which will act just like the "reg_handoff()" routine of a non-plugin
dissector, registering the dissector with handoff tables.
This lets them plug into both TCP and UDP, or plug into protocols other
than TCP or UDP.
Those new-style plugin are enabled and disabled using the standard
"Edit->Protocols" mechanism (and thus should use
"OLD_CHECK_DISPLAY_AS_DATA()" or "CHECK_DISPLAY_AS_DATA()"); they don't
show up in the list of plugins, aren't enabled or disabled from that
list, and, as they don't have a filter, can't have the filter changed
from that list - instead, they should register preferences for port
numbers and the like if they should be configurable to use different
ports.
Make the Gryphon protocol a new-style plugin.
svn path=/trunk/; revision=2565
2000-11-05 09:05:00 +00:00
|
|
|
*/
|
|
|
|
if (g_module_symbol(handle, "plugin_reg_handoff",
|
|
|
|
(gpointer*)®_handoff))
|
2000-01-04 20:37:18 +00:00
|
|
|
{
|
Allow plugins to have, instead of "protocol" and "filter_string"
variables and a "dissector" routine, a "plugin_reg_handoff()" routine,
which will act just like the "reg_handoff()" routine of a non-plugin
dissector, registering the dissector with handoff tables.
This lets them plug into both TCP and UDP, or plug into protocols other
than TCP or UDP.
Those new-style plugin are enabled and disabled using the standard
"Edit->Protocols" mechanism (and thus should use
"OLD_CHECK_DISPLAY_AS_DATA()" or "CHECK_DISPLAY_AS_DATA()"); they don't
show up in the list of plugins, aren't enabled or disabled from that
list, and, as they don't have a filter, can't have the filter changed
from that list - instead, they should register preferences for port
numbers and the like if they should be configurable to use different
ports.
Make the Gryphon protocol a new-style plugin.
svn path=/trunk/; revision=2565
2000-11-05 09:05:00 +00:00
|
|
|
/*
|
|
|
|
* We require it to have a "plugin_init()" routine.
|
|
|
|
*/
|
|
|
|
if (!g_module_symbol(handle, "plugin_init", (gpointer*)&init))
|
|
|
|
{
|
2002-05-14 10:32:12 +00:00
|
|
|
g_warning("The plugin %s has a plugin_reg_handoff symbol but no plugin_init routine",
|
2002-05-14 10:39:29 +00:00
|
|
|
name);
|
Allow plugins to have, instead of "protocol" and "filter_string"
variables and a "dissector" routine, a "plugin_reg_handoff()" routine,
which will act just like the "reg_handoff()" routine of a non-plugin
dissector, registering the dissector with handoff tables.
This lets them plug into both TCP and UDP, or plug into protocols other
than TCP or UDP.
Those new-style plugin are enabled and disabled using the standard
"Edit->Protocols" mechanism (and thus should use
"OLD_CHECK_DISPLAY_AS_DATA()" or "CHECK_DISPLAY_AS_DATA()"); they don't
show up in the list of plugins, aren't enabled or disabled from that
list, and, as they don't have a filter, can't have the filter changed
from that list - instead, they should register preferences for port
numbers and the like if they should be configurable to use different
ports.
Make the Gryphon protocol a new-style plugin.
svn path=/trunk/; revision=2565
2000-11-05 09:05:00 +00:00
|
|
|
g_module_close(handle);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We have a "plugin_reg_handoff()" routine, so we don't
|
|
|
|
* need the protocol, filter string, or dissector pointer.
|
|
|
|
*/
|
2003-06-03 02:32:56 +00:00
|
|
|
if ((cr = add_plugin(handle, g_strdup(name), version,
|
Allow plugins to have, instead of "protocol" and "filter_string"
variables and a "dissector" routine, a "plugin_reg_handoff()" routine,
which will act just like the "reg_handoff()" routine of a non-plugin
dissector, registering the dissector with handoff tables.
This lets them plug into both TCP and UDP, or plug into protocols other
than TCP or UDP.
Those new-style plugin are enabled and disabled using the standard
"Edit->Protocols" mechanism (and thus should use
"OLD_CHECK_DISPLAY_AS_DATA()" or "CHECK_DISPLAY_AS_DATA()"); they don't
show up in the list of plugins, aren't enabled or disabled from that
list, and, as they don't have a filter, can't have the filter changed
from that list - instead, they should register preferences for port
numbers and the like if they should be configurable to use different
ports.
Make the Gryphon protocol a new-style plugin.
svn path=/trunk/; revision=2565
2000-11-05 09:05:00 +00:00
|
|
|
reg_handoff)))
|
|
|
|
{
|
|
|
|
if (cr == EEXIST)
|
2001-01-28 21:17:29 +00:00
|
|
|
fprintf(stderr, "The plugin %s, version %s\n"
|
Allow plugins to have, instead of "protocol" and "filter_string"
variables and a "dissector" routine, a "plugin_reg_handoff()" routine,
which will act just like the "reg_handoff()" routine of a non-plugin
dissector, registering the dissector with handoff tables.
This lets them plug into both TCP and UDP, or plug into protocols other
than TCP or UDP.
Those new-style plugin are enabled and disabled using the standard
"Edit->Protocols" mechanism (and thus should use
"OLD_CHECK_DISPLAY_AS_DATA()" or "CHECK_DISPLAY_AS_DATA()"); they don't
show up in the list of plugins, aren't enabled or disabled from that
list, and, as they don't have a filter, can't have the filter changed
from that list - instead, they should register preferences for port
numbers and the like if they should be configurable to use different
ports.
Make the Gryphon protocol a new-style plugin.
svn path=/trunk/; revision=2565
2000-11-05 09:05:00 +00:00
|
|
|
"was found in multiple directories\n", name, version);
|
|
|
|
else
|
|
|
|
fprintf(stderr, "Memory allocation problem\n"
|
2001-01-28 21:17:29 +00:00
|
|
|
"when processing plugin %s, version %s\n",
|
Allow plugins to have, instead of "protocol" and "filter_string"
variables and a "dissector" routine, a "plugin_reg_handoff()" routine,
which will act just like the "reg_handoff()" routine of a non-plugin
dissector, registering the dissector with handoff tables.
This lets them plug into both TCP and UDP, or plug into protocols other
than TCP or UDP.
Those new-style plugin are enabled and disabled using the standard
"Edit->Protocols" mechanism (and thus should use
"OLD_CHECK_DISPLAY_AS_DATA()" or "CHECK_DISPLAY_AS_DATA()"); they don't
show up in the list of plugins, aren't enabled or disabled from that
list, and, as they don't have a filter, can't have the filter changed
from that list - instead, they should register preferences for port
numbers and the like if they should be configurable to use different
ports.
Make the Gryphon protocol a new-style plugin.
svn path=/trunk/; revision=2565
2000-11-05 09:05:00 +00:00
|
|
|
name, version);
|
|
|
|
g_module_close(handle);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call its init routine.
|
|
|
|
*/
|
|
|
|
#ifdef PLUGINS_NEED_ADDRESS_TABLE
|
|
|
|
init(&patable);
|
|
|
|
#else
|
|
|
|
init(NULL);
|
|
|
|
#endif
|
2000-01-04 20:37:18 +00:00
|
|
|
}
|
Allow plugins to have, instead of "protocol" and "filter_string"
variables and a "dissector" routine, a "plugin_reg_handoff()" routine,
which will act just like the "reg_handoff()" routine of a non-plugin
dissector, registering the dissector with handoff tables.
This lets them plug into both TCP and UDP, or plug into protocols other
than TCP or UDP.
Those new-style plugin are enabled and disabled using the standard
"Edit->Protocols" mechanism (and thus should use
"OLD_CHECK_DISPLAY_AS_DATA()" or "CHECK_DISPLAY_AS_DATA()"); they don't
show up in the list of plugins, aren't enabled or disabled from that
list, and, as they don't have a filter, can't have the filter changed
from that list - instead, they should register preferences for port
numbers and the like if they should be configurable to use different
ports.
Make the Gryphon protocol a new-style plugin.
svn path=/trunk/; revision=2565
2000-11-05 09:05:00 +00:00
|
|
|
else
|
2000-01-04 20:37:18 +00:00
|
|
|
{
|
2001-01-28 21:17:29 +00:00
|
|
|
/*
|
|
|
|
* This is an old-style dissector; warn that it won't
|
|
|
|
* be used, as those aren't supported.
|
|
|
|
*/
|
|
|
|
fprintf(stderr,
|
|
|
|
"The plugin %s, version %s is an old-style plugin;\n"
|
|
|
|
"Those are no longer supported.\n", name, version);
|
2000-01-04 20:37:18 +00:00
|
|
|
}
|
|
|
|
}
|
2003-06-03 02:32:56 +00:00
|
|
|
#if GLIB_MAJOR_VERSION < 2
|
2000-01-04 20:37:18 +00:00
|
|
|
closedir(dir);
|
|
|
|
}
|
2000-11-29 09:10:03 +00:00
|
|
|
g_free(hack_path);
|
2003-06-03 02:32:56 +00:00
|
|
|
#else /* GLIB 2 */
|
|
|
|
g_dir_close(dir);
|
|
|
|
}
|
|
|
|
g_clear_error(dummy);
|
|
|
|
g_free(dummy);
|
|
|
|
#endif
|
2000-01-04 20:37:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* init plugins
|
|
|
|
*/
|
|
|
|
void
|
Give libethereal its own configuration file, and have that configuration
file, rather than the top-level Ethereal configuration file, check for
"inet_aton()", "inet_pton()", and "inet_ntop()". Then make its
Makefile.am include the appropriate object files if necessary.
Otherwise, they don't get built and put into libethereal, and therefore
attempts to link with anything in libethereal that uses them fail on
platforms that lack ethem, causing the build to fail.
That means a bunch of things need to be fixed to cope with libethereal
having its own "config.h" file; this means removing the include of
"config.h" from some libethereal header files. Move the definitions of
the path names used only by "resolv.c" to "resolv.c" from "resolv.h" (so
"resolv.h" doesn't need "config.h", define HAVE_PLUGINS in the configure
script (so we don't have to include it in "plugins.h" to check whether
HAVE_DLFCN_H is defined).
Unfortunately, stuff outside libethereal needs to know PLUGIN_DIR; for
now, define that in the top-level configuration file, and have Ethereal
and Tethereal pass it as an argument to "epan_init()" - that should be
cleaned up at some point.
Remove from the top-level configure script checks for things used only
in libethereal.
svn path=/trunk/; revision=2498
2000-10-16 23:18:05 +00:00
|
|
|
init_plugins(const char *plugin_dir)
|
2000-01-04 20:37:18 +00:00
|
|
|
{
|
2001-08-18 23:21:31 +00:00
|
|
|
#ifdef WIN32
|
On Windows, use the directory in which the binary resides as the
directory in which global data files are stored. If an installed binary
is being run, that's the correct directory for them; if a build-tree
binary is being run, the "manuf" file will be there, and you can put
other data files there as well, if necessary.
Do the same with plugins, except that, if there's no
"plugins\\{version}" subdirectory of that directory, fall back on the
default installation directory, so you at least have a place where you
can put plugins for use by build-tree binaries. (Should we, instead,
have the Windows build procedure create a subdirectory of the "plugins"
source directory, with the plugin version number as its name, and copy
the plugins there, so you'd use the build-tree plugin binaries?)
Move "test_for_directory()" out of "util.c" and into
"epan/filesystem.c", with the other file system access portability
wrappers and convenience routines. Fix "util.h" not to declare it - or
other routines moved to "epan/filesystem.c" a while ago.
svn path=/trunk/; revision=3858
2001-08-21 06:39:18 +00:00
|
|
|
const char *datafile_dir;
|
2001-08-21 08:16:54 +00:00
|
|
|
char *install_plugin_dir;
|
2001-08-18 23:21:31 +00:00
|
|
|
#endif
|
2000-01-31 19:50:58 +00:00
|
|
|
|
2000-01-04 20:37:18 +00:00
|
|
|
if (plugin_list == NULL) /* ensure init_plugins is only run once */
|
|
|
|
{
|
2001-08-18 23:21:31 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
/*
|
On Windows, use the directory in which the binary resides as the
directory in which global data files are stored. If an installed binary
is being run, that's the correct directory for them; if a build-tree
binary is being run, the "manuf" file will be there, and you can put
other data files there as well, if necessary.
Do the same with plugins, except that, if there's no
"plugins\\{version}" subdirectory of that directory, fall back on the
default installation directory, so you at least have a place where you
can put plugins for use by build-tree binaries. (Should we, instead,
have the Windows build procedure create a subdirectory of the "plugins"
source directory, with the plugin version number as its name, and copy
the plugins there, so you'd use the build-tree plugin binaries?)
Move "test_for_directory()" out of "util.c" and into
"epan/filesystem.c", with the other file system access portability
wrappers and convenience routines. Fix "util.h" not to declare it - or
other routines moved to "epan/filesystem.c" a while ago.
svn path=/trunk/; revision=3858
2001-08-21 06:39:18 +00:00
|
|
|
* On Windows, the data file directory is the installation
|
|
|
|
* directory; the plugins are stored under it.
|
2001-08-18 23:21:31 +00:00
|
|
|
*
|
On Windows, use the directory in which the binary resides as the
directory in which global data files are stored. If an installed binary
is being run, that's the correct directory for them; if a build-tree
binary is being run, the "manuf" file will be there, and you can put
other data files there as well, if necessary.
Do the same with plugins, except that, if there's no
"plugins\\{version}" subdirectory of that directory, fall back on the
default installation directory, so you at least have a place where you
can put plugins for use by build-tree binaries. (Should we, instead,
have the Windows build procedure create a subdirectory of the "plugins"
source directory, with the plugin version number as its name, and copy
the plugins there, so you'd use the build-tree plugin binaries?)
Move "test_for_directory()" out of "util.c" and into
"epan/filesystem.c", with the other file system access portability
wrappers and convenience routines. Fix "util.h" not to declare it - or
other routines moved to "epan/filesystem.c" a while ago.
svn path=/trunk/; revision=3858
2001-08-21 06:39:18 +00:00
|
|
|
* Assume we're running the installed version of Ethereal;
|
|
|
|
* on Windows, the data file directory is the directory
|
|
|
|
* in which the Ethereal binary resides.
|
2001-08-18 23:21:31 +00:00
|
|
|
*/
|
On Windows, use the directory in which the binary resides as the
directory in which global data files are stored. If an installed binary
is being run, that's the correct directory for them; if a build-tree
binary is being run, the "manuf" file will be there, and you can put
other data files there as well, if necessary.
Do the same with plugins, except that, if there's no
"plugins\\{version}" subdirectory of that directory, fall back on the
default installation directory, so you at least have a place where you
can put plugins for use by build-tree binaries. (Should we, instead,
have the Windows build procedure create a subdirectory of the "plugins"
source directory, with the plugin version number as its name, and copy
the plugins there, so you'd use the build-tree plugin binaries?)
Move "test_for_directory()" out of "util.c" and into
"epan/filesystem.c", with the other file system access portability
wrappers and convenience routines. Fix "util.h" not to declare it - or
other routines moved to "epan/filesystem.c" a while ago.
svn path=/trunk/; revision=3858
2001-08-21 06:39:18 +00:00
|
|
|
datafile_dir = get_datafile_dir();
|
2001-08-21 08:16:54 +00:00
|
|
|
install_plugin_dir = g_malloc(strlen(datafile_dir) + strlen("plugins") +
|
On Windows, use the directory in which the binary resides as the
directory in which global data files are stored. If an installed binary
is being run, that's the correct directory for them; if a build-tree
binary is being run, the "manuf" file will be there, and you can put
other data files there as well, if necessary.
Do the same with plugins, except that, if there's no
"plugins\\{version}" subdirectory of that directory, fall back on the
default installation directory, so you at least have a place where you
can put plugins for use by build-tree binaries. (Should we, instead,
have the Windows build procedure create a subdirectory of the "plugins"
source directory, with the plugin version number as its name, and copy
the plugins there, so you'd use the build-tree plugin binaries?)
Move "test_for_directory()" out of "util.c" and into
"epan/filesystem.c", with the other file system access portability
wrappers and convenience routines. Fix "util.h" not to declare it - or
other routines moved to "epan/filesystem.c" a while ago.
svn path=/trunk/; revision=3858
2001-08-21 06:39:18 +00:00
|
|
|
strlen(VERSION) + 3);
|
2001-08-21 08:16:54 +00:00
|
|
|
sprintf(install_plugin_dir, "%s\\plugins\\%s", datafile_dir, VERSION);
|
2001-08-18 23:21:31 +00:00
|
|
|
|
|
|
|
/*
|
On Windows, use the directory in which the binary resides as the
directory in which global data files are stored. If an installed binary
is being run, that's the correct directory for them; if a build-tree
binary is being run, the "manuf" file will be there, and you can put
other data files there as well, if necessary.
Do the same with plugins, except that, if there's no
"plugins\\{version}" subdirectory of that directory, fall back on the
default installation directory, so you at least have a place where you
can put plugins for use by build-tree binaries. (Should we, instead,
have the Windows build procedure create a subdirectory of the "plugins"
source directory, with the plugin version number as its name, and copy
the plugins there, so you'd use the build-tree plugin binaries?)
Move "test_for_directory()" out of "util.c" and into
"epan/filesystem.c", with the other file system access portability
wrappers and convenience routines. Fix "util.h" not to declare it - or
other routines moved to "epan/filesystem.c" a while ago.
svn path=/trunk/; revision=3858
2001-08-21 06:39:18 +00:00
|
|
|
* Make sure that pathname refers to a directory.
|
2001-08-18 23:21:31 +00:00
|
|
|
*/
|
2001-09-14 09:27:35 +00:00
|
|
|
if (test_for_directory(install_plugin_dir) != EISDIR) {
|
2001-08-18 23:21:31 +00:00
|
|
|
/*
|
On Windows, use the directory in which the binary resides as the
directory in which global data files are stored. If an installed binary
is being run, that's the correct directory for them; if a build-tree
binary is being run, the "manuf" file will be there, and you can put
other data files there as well, if necessary.
Do the same with plugins, except that, if there's no
"plugins\\{version}" subdirectory of that directory, fall back on the
default installation directory, so you at least have a place where you
can put plugins for use by build-tree binaries. (Should we, instead,
have the Windows build procedure create a subdirectory of the "plugins"
source directory, with the plugin version number as its name, and copy
the plugins there, so you'd use the build-tree plugin binaries?)
Move "test_for_directory()" out of "util.c" and into
"epan/filesystem.c", with the other file system access portability
wrappers and convenience routines. Fix "util.h" not to declare it - or
other routines moved to "epan/filesystem.c" a while ago.
svn path=/trunk/; revision=3858
2001-08-21 06:39:18 +00:00
|
|
|
* Either it doesn't refer to a directory or it
|
|
|
|
* refers to something that doesn't exist.
|
|
|
|
*
|
|
|
|
* Assume that means we're running, for example,
|
|
|
|
* a version of Ethereal we've built in a source
|
|
|
|
* directory, and fall back on the default
|
|
|
|
* installation directory, so you can put the plugins
|
|
|
|
* somewhere so they can be used with this version
|
|
|
|
* of Ethereal.
|
2001-08-18 23:21:31 +00:00
|
|
|
*
|
On Windows, use the directory in which the binary resides as the
directory in which global data files are stored. If an installed binary
is being run, that's the correct directory for them; if a build-tree
binary is being run, the "manuf" file will be there, and you can put
other data files there as well, if necessary.
Do the same with plugins, except that, if there's no
"plugins\\{version}" subdirectory of that directory, fall back on the
default installation directory, so you at least have a place where you
can put plugins for use by build-tree binaries. (Should we, instead,
have the Windows build procedure create a subdirectory of the "plugins"
source directory, with the plugin version number as its name, and copy
the plugins there, so you'd use the build-tree plugin binaries?)
Move "test_for_directory()" out of "util.c" and into
"epan/filesystem.c", with the other file system access portability
wrappers and convenience routines. Fix "util.h" not to declare it - or
other routines moved to "epan/filesystem.c" a while ago.
svn path=/trunk/; revision=3858
2001-08-21 06:39:18 +00:00
|
|
|
* XXX - should we, instead, have the Windows build
|
|
|
|
* procedure create a subdirectory of the "plugins"
|
|
|
|
* source directory, and copy the plugin DLLs there,
|
|
|
|
* so that you use the plugins from the build tree?
|
2001-08-18 23:21:31 +00:00
|
|
|
*/
|
2001-08-21 08:16:54 +00:00
|
|
|
install_plugin_dir =
|
2001-08-21 09:11:59 +00:00
|
|
|
g_strdup("C:\\Program Files\\Ethereal\\plugins\\" VERSION);
|
2001-08-18 23:21:31 +00:00
|
|
|
}
|
On Windows, use the directory in which the binary resides as the
directory in which global data files are stored. If an installed binary
is being run, that's the correct directory for them; if a build-tree
binary is being run, the "manuf" file will be there, and you can put
other data files there as well, if necessary.
Do the same with plugins, except that, if there's no
"plugins\\{version}" subdirectory of that directory, fall back on the
default installation directory, so you at least have a place where you
can put plugins for use by build-tree binaries. (Should we, instead,
have the Windows build procedure create a subdirectory of the "plugins"
source directory, with the plugin version number as its name, and copy
the plugins there, so you'd use the build-tree plugin binaries?)
Move "test_for_directory()" out of "util.c" and into
"epan/filesystem.c", with the other file system access portability
wrappers and convenience routines. Fix "util.h" not to declare it - or
other routines moved to "epan/filesystem.c" a while ago.
svn path=/trunk/; revision=3858
2001-08-21 06:39:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Scan that directory.
|
|
|
|
*/
|
2001-08-21 08:16:54 +00:00
|
|
|
plugins_scan_dir(install_plugin_dir);
|
2001-08-21 09:11:59 +00:00
|
|
|
g_free(install_plugin_dir);
|
2001-08-18 23:21:31 +00:00
|
|
|
#else
|
|
|
|
/*
|
2002-12-08 22:22:03 +00:00
|
|
|
* Scan the plugin directory.
|
2001-08-18 23:21:31 +00:00
|
|
|
*/
|
2002-12-08 22:22:03 +00:00
|
|
|
plugins_scan_dir(plugin_dir);
|
2001-08-18 23:21:31 +00:00
|
|
|
#endif
|
2000-01-04 20:37:18 +00:00
|
|
|
if (!user_plug_dir)
|
2001-10-24 07:18:39 +00:00
|
|
|
user_plug_dir = get_persconffile_path(PLUGINS_DIR_NAME, FALSE);
|
2000-01-04 20:37:18 +00:00
|
|
|
plugins_scan_dir(user_plug_dir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Clean up the dissector registration up a bit - arrange that all plugins
be loaded and their initialization routines called in right after we
call the initialization routines for built-in dissectors, but don't call
their handoff registration routines yet, and then call the handoff
registration routines right after calling the handoff registration
routines for built-in dissectors.
Do all that in "proto_init()", rather than "epan_init()".
That way, we call all dissector registration routines together, and then
call all dissector handoff registration routines together; all the
registration routines are called before any handoff registration
routines, as is required, and, as "proto_init()" is called by
"epan_init()" before "dfilter_init()" is called, all filterable fields
have been registered before "dfilter_init()" is called, and no plugins
have to call "dfilter_init()" themselves to get their fields registered.
Remove pointers to "dfilter_init()" and "dfilter_cleanup()" from the
plugin address table, as plugins shouldn't be calling them any more, and
remove calls to them from plugins.
svn path=/trunk/; revision=2940
2001-01-26 06:14:53 +00:00
|
|
|
void
|
|
|
|
register_all_plugin_handoffs(void)
|
|
|
|
{
|
2001-01-28 21:17:29 +00:00
|
|
|
plugin *pt_plug;
|
Clean up the dissector registration up a bit - arrange that all plugins
be loaded and their initialization routines called in right after we
call the initialization routines for built-in dissectors, but don't call
their handoff registration routines yet, and then call the handoff
registration routines right after calling the handoff registration
routines for built-in dissectors.
Do all that in "proto_init()", rather than "epan_init()".
That way, we call all dissector registration routines together, and then
call all dissector handoff registration routines together; all the
registration routines are called before any handoff registration
routines, as is required, and, as "proto_init()" is called by
"epan_init()" before "dfilter_init()" is called, all filterable fields
have been registered before "dfilter_init()" is called, and no plugins
have to call "dfilter_init()" themselves to get their fields registered.
Remove pointers to "dfilter_init()" and "dfilter_cleanup()" from the
plugin address table, as plugins shouldn't be calling them any more, and
remove calls to them from plugins.
svn path=/trunk/; revision=2940
2001-01-26 06:14:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For all new-style plugins, call the register-handoff routine.
|
|
|
|
* This is called from "proto_init()"; it must be called after
|
|
|
|
* "register_all_protocols()" and "init_plugins()" are called,
|
|
|
|
* in case one plugin registers itself either with a built-in
|
|
|
|
* dissector or with another plugin; we must first register all
|
|
|
|
* dissectors, whether built-in or plugin, so their dissector tables
|
|
|
|
* are initialized, and only then register all handoffs.
|
|
|
|
*
|
|
|
|
* We treat those protocols as always being enabled; they should
|
|
|
|
* use the standard mechanism for enabling/disabling protocols, not
|
|
|
|
* the plugin-specific mechanism.
|
|
|
|
*/
|
2001-01-28 21:17:29 +00:00
|
|
|
for (pt_plug = plugin_list; pt_plug != NULL; pt_plug = pt_plug->next)
|
Clean up the dissector registration up a bit - arrange that all plugins
be loaded and their initialization routines called in right after we
call the initialization routines for built-in dissectors, but don't call
their handoff registration routines yet, and then call the handoff
registration routines right after calling the handoff registration
routines for built-in dissectors.
Do all that in "proto_init()", rather than "epan_init()".
That way, we call all dissector registration routines together, and then
call all dissector handoff registration routines together; all the
registration routines are called before any handoff registration
routines, as is required, and, as "proto_init()" is called by
"epan_init()" before "dfilter_init()" is called, all filterable fields
have been registered before "dfilter_init()" is called, and no plugins
have to call "dfilter_init()" themselves to get their fields registered.
Remove pointers to "dfilter_init()" and "dfilter_cleanup()" from the
plugin address table, as plugins shouldn't be calling them any more, and
remove calls to them from plugins.
svn path=/trunk/; revision=2940
2001-01-26 06:14:53 +00:00
|
|
|
(pt_plug->reg_handoff)();
|
|
|
|
}
|
1999-12-09 20:43:38 +00:00
|
|
|
#endif
|