1999-12-09 20:43:38 +00:00
|
|
|
/* plugins.c
|
1999-12-09 20:55:49 +00:00
|
|
|
* plugin routines
|
|
|
|
*
|
2003-04-08 17:20:05 +00:00
|
|
|
* $Id: plugins.c,v 1.64 2003/04/08 17:20:03 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"
|
2000-03-15 19:09:52 +00:00
|
|
|
#include "plugins/plugin_table.h"
|
Move the table of bit-swapped byte values to "epan/bitswap.c", and
declare it, and define a "BIT_SWAP" macro that uses it, in
"epan/bitswap.h".
Use that macro to bit-swap bytes in the IEEE 802.11 dissector, rather
than the macro that was used (said macro used GCCisms and didn't compile
on Windows).
Make an "init_plugin()" routine to enable a plugin and call its init
routine, and call it from "check_plugin_status()" and
"plugins_enable_cb()", rather than having very similar code in two
places; "patable" is now part of libethereal, and, at least on Windows,
attempts to refer to it from "libui" failed. Make "patable" static to
"epan/plugins.c". (This may still not work, as now "libui" is calling a
routine in "libethereal"; if that fails, perhaps it's time to get rid of
the "enable/disable plugins" stuff completely, as new-style plugins, at
least, register themselves as protocols and should be controllable from
the "Edit->Protocols" window just as built-in dissectors are.)
svn path=/trunk/; revision=2649
2000-11-15 09:37:53 +00:00
|
|
|
static plugin_address_table_t patable;
|
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
|
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 */
|
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 *name;
|
|
|
|
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;
|
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* GLib 2.0 will probably define G_MODULE_SUFFIX as the extension
|
|
|
|
* to use, but that's not checked into the GLib CVS tree yet,
|
|
|
|
* and we can't use it on systems that don't have GLib 2.0.
|
|
|
|
*/
|
|
|
|
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);
|
2002-05-14 10:32:12 +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-04 20:37:18 +00:00
|
|
|
name = (gchar *)file->d_name;
|
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.
|
|
|
|
*/
|
2001-01-28 21:17:29 +00:00
|
|
|
if ((cr = add_plugin(handle, g_strdup(file->d_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
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(dir);
|
|
|
|
}
|
2000-11-29 09:10:03 +00:00
|
|
|
g_free(hack_path);
|
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 */
|
|
|
|
{
|
2000-02-07 17:08:27 +00:00
|
|
|
#ifdef PLUGINS_NEED_ADDRESS_TABLE
|
|
|
|
/* Intialize address table */
|
2000-03-15 19:09:52 +00:00
|
|
|
patable.p_check_col = check_col;
|
2001-01-28 20:26:20 +00:00
|
|
|
patable.p_col_clear = col_clear;
|
2000-03-15 19:09:52 +00:00
|
|
|
patable.p_col_add_fstr = col_add_fstr;
|
2000-11-18 21:41:40 +00:00
|
|
|
patable.p_col_append_fstr = col_append_fstr;
|
2002-01-29 08:44:53 +00:00
|
|
|
patable.p_col_prepend_fstr = col_prepend_fstr;
|
2000-03-15 19:09:52 +00:00
|
|
|
patable.p_col_add_str = col_add_str;
|
|
|
|
patable.p_col_append_str = col_append_str;
|
2001-04-25 08:31:32 +00:00
|
|
|
patable.p_col_set_str = col_set_str;
|
2000-03-15 19:09:52 +00:00
|
|
|
|
2001-11-04 03:37:29 +00:00
|
|
|
patable.p_register_init_routine = register_init_routine;
|
2002-01-05 04:12:17 +00:00
|
|
|
patable.p_register_postseq_cleanup_routine = register_postseq_cleanup_routine;
|
2002-02-20 08:24:52 +00:00
|
|
|
|
2001-11-04 03:37:29 +00:00
|
|
|
patable.p_match_strval = match_strval;
|
|
|
|
patable.p_val_to_str = val_to_str;
|
2000-03-15 19:09:52 +00:00
|
|
|
|
2002-02-20 08:24:52 +00:00
|
|
|
patable.p_conversation_new = conversation_new;
|
|
|
|
patable.p_find_conversation = find_conversation;
|
|
|
|
patable.p_conversation_set_dissector = conversation_set_dissector;
|
|
|
|
|
2000-03-15 19:09:52 +00:00
|
|
|
patable.p_proto_register_protocol = proto_register_protocol;
|
|
|
|
patable.p_proto_register_field_array = proto_register_field_array;
|
|
|
|
patable.p_proto_register_subtree_array = proto_register_subtree_array;
|
|
|
|
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
patable.p_dissector_add = dissector_add;
|
2000-11-13 10:13:26 +00:00
|
|
|
patable.p_dissector_delete = dissector_delete;
|
2001-12-03 10:00:23 +00:00
|
|
|
patable.p_dissector_add_handle = dissector_add_handle;
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
|
|
|
|
patable.p_heur_dissector_add = heur_dissector_add;
|
|
|
|
|
2000-11-18 21:41:40 +00:00
|
|
|
patable.p_register_dissector = register_dissector;
|
|
|
|
patable.p_find_dissector = find_dissector;
|
2001-12-03 04:00:26 +00:00
|
|
|
patable.p_create_dissector_handle = create_dissector_handle;
|
2000-11-18 21:41:40 +00:00
|
|
|
patable.p_call_dissector = call_dissector;
|
Add a mechanism by which a dissector can be registered by name, another
dissector can get a "handle" for that dissector by name and then call
that dissector through the handle.
This allows dissectors that can't be called through a port table or a
heuristic table to be called from other dissectors without directly
referring to the dissector function - dynamically-loaded modules, under
Windows, cannot directly call functions in the main program, and
non-plugin dissectors are in the main program and thus cannot be called
from plugin dissectors unless either
1) a pointer to the dissector is put in the Big Transfer Vector
or
2) some other mechanism for getting a pointer to the dissector
is provided.
This mechanism could also support registering old-style dissectors and
calling them from new-style dissectors without the new-style dissector
having to do the argument translation itself (I didn't add support for
registering old-style dissectors because I'd prefer to have people
tvbuffify their code if they have to register a dissector...).
It could also, in the future, perhaps support
disabling of protocols;
setting "pinfo->current_proto";
inside "call_dissector()" - and inside "{old_}dissector_try_port()" and
"{old_"dissector_try_heuristic()" - allowing a pile of stuff that
currently has to be done in every dissector be done by common code.
(I have some ideas about how to do this, by
having "proto_register_protocol()" take an abbreviation - of the
sort that would be put in, for example, "pinfo->current_proto" -
as an argument;
having the calls to register dissectors take an index returned
by "proto_register_protocol()" as an argument.
The abbreviation could be used elsewhere as well, e.g. in the "Decoding"
tab of the "Edit->Protocols" dialog box, and in a GUI for constructing
protocol filters. Watch this space.)
Make "dissect_sdp()" the first client of this mechanism; it's now static
to "packet-sdp.c", and all dissectors that call it - including the MGCP
plugin - now call it through a dissector handle fetched by
"find_dissector()". (Next step - see if Ethereal can now compile on
Windows as a result of this.)
svn path=/trunk/; revision=2647
2000-11-15 07:07:52 +00:00
|
|
|
|
2002-05-05 00:34:12 +00:00
|
|
|
patable.p_tcp_dissect_pdus = tcp_dissect_pdus;
|
|
|
|
|
Add a Makefile.nmake for the MGCP plugin, and update
"plugins/Makefile.nmake" to build that plugin.
Add to the table of routines callable from plugins
"old_dissector_add()", "old_dissect_data()", and
"proto_is_protocol_enabled()", so that the Gryphon dissector can build
on Windows.
Move the includes of "plugins/plugin_api.h" and "moduleinfo.h" before
all the other includes, except for "config.h", in "plugin-mgcp.c", to
match what the Gryphon dissector does; "plugins_api.h" must be included
before any of the routines whose names it #defines in order for the
plugin to build on Windows. (It still doesn't build on Windows, as
still more routines need to be added to the table of routines callable
from plugins, but tomorrow is another day. Making libethereal a DLL may
obviate the need for that table, *if* all the routines called from a
plugin are in libethereal, as I think routines in a DLL, even a
run-time-loaded DLL, can call routines from another DLL as long as those
routines are exported from the other DLL.)
svn path=/trunk/; revision=2623
2000-11-12 21:20:50 +00:00
|
|
|
patable.p_proto_is_protocol_enabled = proto_is_protocol_enabled;
|
|
|
|
|
2000-11-13 10:13:26 +00:00
|
|
|
patable.p_proto_item_get_len = proto_item_get_len;
|
|
|
|
patable.p_proto_item_set_len = proto_item_set_len;
|
|
|
|
patable.p_proto_item_set_text = proto_item_set_text;
|
2001-08-29 00:51:10 +00:00
|
|
|
patable.p_proto_item_append_text = proto_item_append_text;
|
2000-03-15 19:09:52 +00:00
|
|
|
patable.p_proto_item_add_subtree = proto_item_add_subtree;
|
|
|
|
patable.p_proto_tree_add_item = proto_tree_add_item;
|
|
|
|
patable.p_proto_tree_add_item_hidden = proto_tree_add_item_hidden;
|
2003-04-08 17:20:05 +00:00
|
|
|
patable.p_proto_tree_add_none_format = proto_tree_add_none_format;
|
2000-03-15 19:09:52 +00:00
|
|
|
patable.p_proto_tree_add_protocol_format = proto_tree_add_protocol_format;
|
2000-05-31 18:32:15 +00:00
|
|
|
patable.p_proto_tree_add_bytes = proto_tree_add_bytes;
|
|
|
|
patable.p_proto_tree_add_bytes_hidden = proto_tree_add_bytes_hidden;
|
2000-03-15 19:09:52 +00:00
|
|
|
patable.p_proto_tree_add_bytes_format = proto_tree_add_bytes_format;
|
2000-05-31 18:32:15 +00:00
|
|
|
patable.p_proto_tree_add_time = proto_tree_add_time;
|
|
|
|
patable.p_proto_tree_add_time_hidden = proto_tree_add_time_hidden;
|
2000-03-15 19:09:52 +00:00
|
|
|
patable.p_proto_tree_add_time_format = proto_tree_add_time_format;
|
2000-05-31 18:32:15 +00:00
|
|
|
patable.p_proto_tree_add_ipxnet = proto_tree_add_ipxnet;
|
|
|
|
patable.p_proto_tree_add_ipxnet_hidden = proto_tree_add_ipxnet_hidden;
|
2000-03-15 19:09:52 +00:00
|
|
|
patable.p_proto_tree_add_ipxnet_format = proto_tree_add_ipxnet_format;
|
2000-05-31 18:32:15 +00:00
|
|
|
patable.p_proto_tree_add_ipv4 = proto_tree_add_ipv4;
|
|
|
|
patable.p_proto_tree_add_ipv4_hidden = proto_tree_add_ipv4_hidden;
|
2000-03-15 19:09:52 +00:00
|
|
|
patable.p_proto_tree_add_ipv4_format = proto_tree_add_ipv4_format;
|
2000-05-31 18:32:15 +00:00
|
|
|
patable.p_proto_tree_add_ipv6 = proto_tree_add_ipv6;
|
|
|
|
patable.p_proto_tree_add_ipv6_hidden = proto_tree_add_ipv6_hidden;
|
2000-03-15 19:09:52 +00:00
|
|
|
patable.p_proto_tree_add_ipv6_format = proto_tree_add_ipv6_format;
|
2000-05-31 18:32:15 +00:00
|
|
|
patable.p_proto_tree_add_ether = proto_tree_add_ether;
|
|
|
|
patable.p_proto_tree_add_ether_hidden = proto_tree_add_ether_hidden;
|
2000-03-15 19:09:52 +00:00
|
|
|
patable.p_proto_tree_add_ether_format = proto_tree_add_ether_format;
|
2000-05-31 18:32:15 +00:00
|
|
|
patable.p_proto_tree_add_string = proto_tree_add_string;
|
|
|
|
patable.p_proto_tree_add_string_hidden = proto_tree_add_string_hidden;
|
2000-03-15 19:09:52 +00:00
|
|
|
patable.p_proto_tree_add_string_format = proto_tree_add_string_format;
|
2000-05-31 18:32:15 +00:00
|
|
|
patable.p_proto_tree_add_boolean = proto_tree_add_boolean;
|
|
|
|
patable.p_proto_tree_add_boolean_hidden = proto_tree_add_boolean_hidden;
|
2000-03-15 19:09:52 +00:00
|
|
|
patable.p_proto_tree_add_boolean_format = proto_tree_add_boolean_format;
|
2000-05-31 18:32:15 +00:00
|
|
|
patable.p_proto_tree_add_double = proto_tree_add_double;
|
|
|
|
patable.p_proto_tree_add_double_hidden = proto_tree_add_double_hidden;
|
|
|
|
patable.p_proto_tree_add_double_format = proto_tree_add_double_format;
|
|
|
|
patable.p_proto_tree_add_uint = proto_tree_add_uint;
|
|
|
|
patable.p_proto_tree_add_uint_hidden = proto_tree_add_uint_hidden;
|
2000-03-15 19:09:52 +00:00
|
|
|
patable.p_proto_tree_add_uint_format = proto_tree_add_uint_format;
|
2000-05-31 18:32:15 +00:00
|
|
|
patable.p_proto_tree_add_int = proto_tree_add_int;
|
|
|
|
patable.p_proto_tree_add_int_hidden = proto_tree_add_int_hidden;
|
|
|
|
patable.p_proto_tree_add_int_format = proto_tree_add_int_format;
|
2000-03-15 19:09:52 +00:00
|
|
|
patable.p_proto_tree_add_text = proto_tree_add_text;
|
2000-11-13 08:00:12 +00:00
|
|
|
|
|
|
|
patable.p_tvb_new_subset = tvb_new_subset;
|
2002-02-02 03:42:18 +00:00
|
|
|
patable.p_tvb_set_free_cb = tvb_set_free_cb;
|
|
|
|
patable.p_tvb_set_child_real_data_tvbuff = tvb_set_child_real_data_tvbuff;
|
|
|
|
patable.p_tvb_new_real_data = tvb_new_real_data;
|
2000-11-13 08:00:12 +00:00
|
|
|
|
|
|
|
patable.p_tvb_length = tvb_length;
|
|
|
|
patable.p_tvb_length_remaining = tvb_length_remaining;
|
|
|
|
patable.p_tvb_bytes_exist = tvb_bytes_exist;
|
|
|
|
patable.p_tvb_offset_exists = tvb_offset_exists;
|
|
|
|
patable.p_tvb_reported_length = tvb_reported_length;
|
2001-04-25 08:31:32 +00:00
|
|
|
patable.p_tvb_reported_length_remaining = tvb_reported_length_remaining;
|
2000-11-13 08:00:12 +00:00
|
|
|
|
|
|
|
patable.p_tvb_get_guint8 = tvb_get_guint8;
|
|
|
|
|
|
|
|
patable.p_tvb_get_ntohs = tvb_get_ntohs;
|
|
|
|
patable.p_tvb_get_ntoh24 = tvb_get_ntoh24;
|
|
|
|
patable.p_tvb_get_ntohl = tvb_get_ntohl;
|
|
|
|
|
|
|
|
patable.p_tvb_get_letohs = tvb_get_letohs;
|
|
|
|
patable.p_tvb_get_letoh24 = tvb_get_letoh24;
|
|
|
|
patable.p_tvb_get_letohl = tvb_get_letohl;
|
|
|
|
|
|
|
|
patable.p_tvb_memcpy = tvb_memcpy;
|
|
|
|
patable.p_tvb_memdup = tvb_memdup;
|
|
|
|
|
|
|
|
patable.p_tvb_get_ptr = tvb_get_ptr;
|
|
|
|
|
|
|
|
patable.p_tvb_find_guint8 = tvb_find_guint8;
|
|
|
|
patable.p_tvb_pbrk_guint8 = tvb_pbrk_guint8;
|
|
|
|
|
|
|
|
patable.p_tvb_strnlen = tvb_strnlen;
|
|
|
|
|
|
|
|
patable.p_tvb_format_text = tvb_format_text;
|
|
|
|
|
|
|
|
patable.p_tvb_get_nstringz = tvb_get_nstringz;
|
|
|
|
patable.p_tvb_get_nstringz0 = tvb_get_nstringz0;
|
|
|
|
|
|
|
|
patable.p_tvb_find_line_end = tvb_find_line_end;
|
|
|
|
patable.p_tvb_find_line_end_unquoted = tvb_find_line_end_unquoted;
|
|
|
|
|
|
|
|
patable.p_tvb_strneql = tvb_strneql;
|
|
|
|
patable.p_tvb_strncaseeql = tvb_strncaseeql;
|
|
|
|
|
|
|
|
patable.p_tvb_bytes_to_str = tvb_bytes_to_str;
|
2000-11-13 10:13:26 +00:00
|
|
|
|
2001-01-03 07:53:48 +00:00
|
|
|
patable.p_prefs_register_protocol = prefs_register_protocol;
|
2000-11-13 10:13:26 +00:00
|
|
|
patable.p_prefs_register_uint_preference = prefs_register_uint_preference;
|
|
|
|
patable.p_prefs_register_bool_preference = prefs_register_bool_preference;
|
|
|
|
patable.p_prefs_register_enum_preference = prefs_register_enum_preference;
|
2001-09-04 01:05:41 +00:00
|
|
|
patable.p_prefs_register_string_preference = prefs_register_string_preference;
|
2001-07-22 10:12:11 +00:00
|
|
|
|
|
|
|
patable.p_register_giop_user = register_giop_user;
|
|
|
|
patable.p_is_big_endian = is_big_endian;
|
2002-02-23 02:16:12 +00:00
|
|
|
patable.p_get_CDR_encap_info = get_CDR_encap_info;
|
|
|
|
|
|
|
|
patable.p_get_CDR_any = get_CDR_any;
|
|
|
|
patable.p_get_CDR_boolean = get_CDR_boolean;
|
|
|
|
patable.p_get_CDR_char = get_CDR_char;
|
|
|
|
patable.p_get_CDR_double = get_CDR_double;
|
2001-07-22 10:12:11 +00:00
|
|
|
patable.p_get_CDR_enum = get_CDR_enum;
|
2002-02-23 02:16:12 +00:00
|
|
|
patable.p_get_CDR_fixed = get_CDR_fixed;
|
|
|
|
patable.p_get_CDR_float = get_CDR_float;
|
|
|
|
patable.p_get_CDR_interface = get_CDR_interface;
|
|
|
|
patable.p_get_CDR_long = get_CDR_long;
|
2001-07-22 10:12:11 +00:00
|
|
|
patable.p_get_CDR_object = get_CDR_object;
|
2002-02-23 02:16:12 +00:00
|
|
|
patable.p_get_CDR_octet = get_CDR_octet;
|
|
|
|
patable.p_get_CDR_octet_seq = get_CDR_octet_seq;
|
|
|
|
patable.p_get_CDR_short = get_CDR_short;
|
|
|
|
patable.p_get_CDR_string = get_CDR_string;
|
|
|
|
patable.p_get_CDR_typeCode = get_CDR_typeCode;
|
|
|
|
patable.p_get_CDR_ulong = get_CDR_ulong;
|
|
|
|
patable.p_get_CDR_ushort = get_CDR_ushort;
|
|
|
|
patable.p_get_CDR_wchar = get_CDR_wchar;
|
|
|
|
patable.p_get_CDR_wstring = get_CDR_wstring;
|
2002-02-22 08:56:48 +00:00
|
|
|
|
|
|
|
patable.p_is_tpkt = is_tpkt;
|
|
|
|
patable.p_dissect_tpkt_encap = dissect_tpkt_encap;
|
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
|
|
|
|
|
|
|
patable.p_set_actual_length = set_actual_length;
|
|
|
|
patable.p_decode_boolean_bitfield = decode_boolean_bitfield;
|
|
|
|
patable.p_decode_numeric_bitfield = decode_numeric_bitfield;
|
|
|
|
patable.p_decode_enumerated_bitfield = decode_enumerated_bitfield;
|
2002-07-12 22:52:43 +00:00
|
|
|
patable.p_register_dissector_table = register_dissector_table;
|
|
|
|
patable.p_except_throw = except_throw;
|
|
|
|
patable.p_dissector_try_port = dissector_try_port;
|
2002-08-14 19:18:20 +00:00
|
|
|
|
|
|
|
patable.p_conversation_add_proto_data = conversation_add_proto_data;
|
|
|
|
patable.p_conversation_get_proto_data = conversation_get_proto_data;
|
|
|
|
patable.p_conversation_delete_proto_data = conversation_delete_proto_data;
|
|
|
|
patable.p_p_add_proto_data = p_add_proto_data;
|
|
|
|
patable.p_p_get_proto_data = p_get_proto_data;
|
2002-11-14 18:54:53 +00:00
|
|
|
|
|
|
|
patable.p_ip_to_str = ip_to_str;
|
|
|
|
patable.p_ip6_to_str = ip6_to_str;
|
|
|
|
patable.p_time_secs_to_str = time_secs_to_str;
|
|
|
|
patable.p_time_msecs_to_str = time_msecs_to_str;
|
|
|
|
patable.p_abs_time_to_str = abs_time_to_str;
|
2002-11-16 21:32:06 +00:00
|
|
|
|
2002-11-14 18:54:53 +00:00
|
|
|
patable.p_proto_get_id_by_filter_name = proto_get_id_by_filter_name;
|
|
|
|
patable.p_proto_get_protocol_name = proto_get_protocol_name;
|
|
|
|
patable.p_proto_get_protocol_short_name = proto_get_protocol_short_name;
|
|
|
|
patable.p_proto_get_protocol_filter_name = proto_get_protocol_filter_name;
|
2002-11-16 21:32:06 +00:00
|
|
|
|
|
|
|
patable.p_prefs_register_obsolete_preference = prefs_register_obsolete_preference;
|
|
|
|
|
2002-11-14 18:54:53 +00:00
|
|
|
patable.p_add_new_data_source = add_new_data_source;
|
2002-11-16 21:32:06 +00:00
|
|
|
|
2002-11-14 18:54:53 +00:00
|
|
|
patable.p_fragment_table_init = fragment_table_init;
|
|
|
|
patable.p_reassembled_table_init = reassembled_table_init;
|
|
|
|
patable.p_fragment_add = fragment_add;
|
|
|
|
patable.p_fragment_add_seq = fragment_add_seq;
|
|
|
|
patable.p_fragment_add_seq_check = fragment_add_seq_check;
|
|
|
|
patable.p_fragment_add_seq_next = fragment_add_seq_next;
|
|
|
|
patable.p_fragment_get = fragment_get;
|
|
|
|
patable.p_fragment_set_tot_len = fragment_set_tot_len;
|
|
|
|
patable.p_fragment_get_tot_len = fragment_get_tot_len;
|
|
|
|
patable.p_fragment_set_partial_reassembly = fragment_set_partial_reassembly;
|
|
|
|
patable.p_fragment_delete = fragment_delete;
|
|
|
|
patable.p_show_fragment_tree = show_fragment_tree;
|
|
|
|
patable.p_show_fragment_seq_tree = show_fragment_seq_tree;
|
2003-03-06 09:01:47 +00:00
|
|
|
|
|
|
|
patable.p_register_tap = register_tap;
|
|
|
|
patable.p_tap_queue_packet = tap_queue_packet;
|
|
|
|
|
2000-02-07 17:08:27 +00:00
|
|
|
#endif
|
|
|
|
|
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
|