diff options
-rw-r--r-- | plugins.c | 56 | ||||
-rw-r--r-- | plugins/Makefile.am | 3 | ||||
-rw-r--r-- | plugins/plugin_api.c | 158 | ||||
-rw-r--r-- | plugins/plugin_api.h | 131 | ||||
-rw-r--r-- | plugins/plugin_table.h | 99 |
5 files changed, 212 insertions, 235 deletions
@@ -1,7 +1,7 @@ /* plugins.c * plugin routines * - * $Id: plugins.c,v 1.10 2000/02/09 19:37:47 gram Exp $ + * $Id: plugins.c,v 1.11 2000/03/15 19:09:23 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -58,9 +58,8 @@ #include "util.h" #ifdef PLUGINS_NEED_ADDRESS_TABLE -#include "plugins/plugin_api.h" +#include "plugins/plugin_table.h" plugin_address_table_t patable; -extern int hf_text_only; #endif /* linked list of all plugins */ @@ -450,28 +449,37 @@ init_plugins() { #ifdef PLUGINS_NEED_ADDRESS_TABLE -#ifdef pi -#undef pi -#endif /* Intialize address table */ - patable.check_col = check_col; - patable.col_add_fstr = col_add_fstr; - patable.col_append_fstr = col_append_str; - patable.col_add_str = col_add_str; - patable.col_append_str = col_append_str; - - patable.dfilter_init = dfilter_init; - patable.dfilter_cleanup = dfilter_cleanup; - - patable.pi = π - - patable.proto_register_protocol = proto_register_protocol; - patable.proto_register_field_array = proto_register_field_array; - patable.proto_register_subtree_array = proto_register_subtree_array; - - patable.proto_item_add_subtree = proto_item_add_subtree; - patable._proto_tree_add_item_value = _proto_tree_add_item_value; - patable.hf_text_only = hf_text_only; + patable.p_check_col = check_col; + patable.p_col_add_fstr = col_add_fstr; + patable.p_col_append_fstr = col_append_str; + patable.p_col_add_str = col_add_str; + patable.p_col_append_str = col_append_str; + + patable.p_dfilter_init = dfilter_init; + patable.p_dfilter_cleanup = dfilter_cleanup; + + patable.p_pi = π + + 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; + + 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; + patable.p_proto_tree_add_protocol_format = proto_tree_add_protocol_format; + patable.p_proto_tree_add_bytes_format = proto_tree_add_bytes_format; + patable.p_proto_tree_add_time_format = proto_tree_add_time_format; + patable.p_proto_tree_add_ipxnet_format = proto_tree_add_ipxnet_format; + patable.p_proto_tree_add_ipv4_format = proto_tree_add_ipv4_format; + patable.p_proto_tree_add_ipv6_format = proto_tree_add_ipv6_format; + patable.p_proto_tree_add_ether_format = proto_tree_add_ether_format; + patable.p_proto_tree_add_string_format = proto_tree_add_string_format; + patable.p_proto_tree_add_boolean_format = proto_tree_add_boolean_format; + patable.p_proto_tree_add_uint_format = proto_tree_add_uint_format; + patable.p_proto_tree_add_text = proto_tree_add_text; + patable.p_proto_tree_add_notext = proto_tree_add_notext; #endif plugins_scan_dir(std_plug_dir); diff --git a/plugins/Makefile.am b/plugins/Makefile.am index db536189e6..e31f0b99b9 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am # Automake file for Ethereal # -# $Id: Makefile.am,v 1.4 2000/03/03 12:00:49 gram Exp $ +# $Id: Makefile.am,v 1.5 2000/03/15 19:09:16 guy Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs <gerald@zing.org> @@ -29,4 +29,5 @@ plugindir = @PLUGIN_DIR@ EXTRA_DIST = \ plugin_api.c \ plugin_api.h \ + plugin_table.h \ Makefile.nmake diff --git a/plugins/plugin_api.c b/plugins/plugin_api.c index 4262c7ca58..4da934b3af 100644 --- a/plugins/plugin_api.c +++ b/plugins/plugin_api.c @@ -1,7 +1,7 @@ /* plugin_api.c * Routines for Ethereal plugins. * - * $Id: plugin_api.c,v 1.4 2000/02/12 11:24:24 guy Exp $ + * $Id: plugin_api.c,v 1.5 2000/03/15 19:09:16 guy Exp $ * * Ethereal - Network traffic analyzer * Copyright 2000 by Gilbert Ramirez <gram@xiexie.org> @@ -31,139 +31,35 @@ #include "plugin_api.h" -static plugin_address_table_t *patable = NULL; packet_info *p_pi = NULL; - -#ifdef pi -#undef pi -#endif - void plugin_address_table_init(plugin_address_table_t *pat) { - patable = pat; - p_pi = pat->pi; -} - -gint -check_col(frame_data* fd, gint col) -{ - return patable->check_col(fd, col); -} - -/*void col_add_fstr(frame_data*, gint, gchar*, ...); -void col_append_fstr(frame_data*, gint, gchar*, ...);*/ - -void -col_add_str(frame_data* fd, gint col, const gchar* str) -{ - patable->col_add_str(fd, col, str); -} - -void -col_append_str(frame_data* fd, gint col, gchar* str) -{ - patable->col_append_str(fd, col, str); -} - -void -dfilter_init(void) -{ - patable->dfilter_init(); -} - -void -dfilter_cleanup(void) -{ - patable->dfilter_cleanup(); -} - -int -proto_register_protocol(char* name, char* abbrev) -{ - return patable->proto_register_protocol(name, abbrev); -} - -void -proto_register_field_array(int parent, hf_register_info* hf, int num_records) -{ - patable->proto_register_field_array(parent, hf, num_records); -} - -void -proto_register_subtree_array(int** indices, int num_indices) -{ - patable->proto_register_subtree_array(indices, num_indices); -} - -proto_tree * -proto_item_add_subtree(proto_item* pi, gint idx) -{ - return patable->proto_item_add_subtree(pi, idx); -} - -proto_item * -proto_tree_add_item(proto_tree *tree, int hfindex, gint start, gint length, ...) -{ - proto_item *pi; - va_list ap; - - va_start(ap, length); - pi = patable->_proto_tree_add_item_value(tree, hfindex, start, length, 0, 1, ap); - va_end(ap); - - return pi; -} - -proto_item * -proto_tree_add_item_hidden(proto_tree *tree, int hfindex, gint start, gint length, ...) -{ - proto_item *pi; - va_list ap; - - va_start(ap, length); - pi = patable->_proto_tree_add_item_value(tree, hfindex, start, length, 0, 0, ap); - va_end(ap); - - return pi; -} - -proto_item * -proto_tree_add_item_format(proto_tree *tree, int hfindex, gint start, gint length, ...) -{ - proto_item *pi; - va_list ap; - - va_start(ap, length); - pi = patable->_proto_tree_add_item_value(tree, hfindex, start, length, 1, 1, ap); - va_end(ap); - - return pi; -} - -proto_item * -proto_tree_add_notext(proto_tree *tree, gint start, gint length, ...) -{ - proto_item *pi; - va_list ap; - - va_start(ap, length); - pi = patable->_proto_tree_add_item_value(tree, patable->hf_text_only, start, length, 0, 1, ap); - va_end(ap); - - return pi; -} - -proto_item * -proto_tree_add_text(proto_tree *tree, gint start, gint length, ...) -{ - proto_item *pi; - va_list ap; - - va_start(ap, length); - pi = patable->_proto_tree_add_item_value(tree, patable->hf_text_only, start, length, 1, 1, ap); - va_end(ap); - - return pi; + p_pi = pat->p_pi; + p_check_col = pat->p_check_col; + p_col_add_fstr = pat->p_col_add_fstr; + p_col_append_fstr = pat->p_col_append_fstr; + p_col_add_str = pat->p_col_add_str; + p_col_append_str = pat->p_col_append_str; + p_dfilter_init = pat->p_dfilter_init; + p_dfilter_cleanup = pat->p_dfilter_cleanup; + p_proto_register_protocol = pat->p_proto_register_protocol; + p_proto_register_field_array = pat->p_proto_register_field_array; + p_proto_register_subtree_array = pat->p_proto_register_subtree_array; + p_proto_item_add_subtree = pat->p_proto_item_add_subtree; + p_proto_tree_add_item = pat->p_proto_tree_add_item; + p_proto_tree_add_item_hidden = pat->p_proto_tree_add_item_hidden; + p_proto_tree_add_protocol_format = pat->p_proto_tree_add_protocol_format; + p_proto_tree_add_bytes_format = pat->p_proto_tree_add_bytes_format; + p_proto_tree_add_time_format = pat->p_proto_tree_add_time_format; + p_proto_tree_add_ipxnet_format = pat->p_proto_tree_add_ipxnet_format; + p_proto_tree_add_ipv4_format = pat->p_proto_tree_add_ipv4_format; + p_proto_tree_add_ipv6_format = pat->p_proto_tree_add_ipv6_format; + p_proto_tree_add_ether_format = pat->p_proto_tree_add_ether_format; + p_proto_tree_add_string_format = pat->p_proto_tree_add_string_format; + p_proto_tree_add_boolean_format = pat->p_proto_tree_add_boolean_format; + p_proto_tree_add_uint_format = pat->p_proto_tree_add_uint_format; + p_proto_tree_add_text = pat->p_proto_tree_add_text; + p_proto_tree_add_notext = pat->p_proto_tree_add_notext; } diff --git a/plugins/plugin_api.h b/plugins/plugin_api.h index d66fb94133..13082a02fd 100644 --- a/plugins/plugin_api.h +++ b/plugins/plugin_api.h @@ -1,7 +1,7 @@ /* plugin_api.h * Routines for Ethereal plugins. * - * $Id: plugin_api.h,v 1.2 2000/02/07 17:23:47 gram Exp $ + * $Id: plugin_api.h,v 1.3 2000/03/15 19:09:16 guy Exp $ * * Ethereal - Network traffic analyzer * Copyright 2000 by Gilbert Ramirez <gram@xiexie.org> @@ -23,96 +23,69 @@ * */ -#ifndef __PACKET_H__ -#include "packet.h" -#endif - #ifdef PLUGINS_NEED_ADDRESS_TABLE #define DLLEXPORT __declspec(dllexport) -/* Some OSes (Win32) have DLLs that cannot reference symbols in the parent executable. - So, the executable needs to provide a table of pointers for the DLL plugin to use. */ - -/* Typedefs to make our plugin_address_table_t struct look prettier */ -typedef gint (*addr_check_col)(frame_data*, gint); -typedef void (*addr_col_add_fstr)(frame_data*, gint, gchar*, ...); -typedef void (*addr_col_append_fstr)(frame_data*, gint, gchar*, ...); -typedef void (*addr_col_add_str)(frame_data*, gint, const gchar*); -typedef void (*addr_col_append_str)(frame_data*, gint, gchar*); - -typedef void (*addr_dfilter_init)(void); -typedef void (*addr_dfilter_cleanup)(void); - -typedef int (*addr_proto_register_protocol)(char*, char*); -typedef void (*addr_proto_register_field_array)(int, hf_register_info*, int); -typedef void (*addr_proto_register_subtree_array)(int**, int); +/* Some OSes (Win32) have DLLs that cannot reference symbols in the parent + executable, so the executable needs to provide a collection of pointers + to those functions for the DLL plugin to use. */ + +/* #defines for those functions that call through pointers. + #defined in this fashion so that the declaration of the functions, + from the system header files, turn into declarations of pointers + to functions, and the calls to it in plugins, in the plugins, turn + into calls through the pointers. */ +#define check_col (*p_check_col) +#define col_add_fstr (*p_col_add_fstr) +#define col_append_fstr (*p_col_append_fstr) +#define col_add_str (*p_col_add_str) +#define col_append_str (*p_col_append_str) + +#define dfilter_init (*p_dfilter_init) +#define dfilter_cleanup (*p_dfilter_cleanup) + +#define proto_register_protocol (*p_proto_register_protocol) +#define proto_register_field_array (*p_proto_register_field_array) +#define proto_register_subtree_array (*p_proto_register_subtree_array) + +#define proto_item_add_subtree (*p_proto_item_add_subtree) +#define proto_tree_add_item (*p_proto_tree_add_item) +#define proto_tree_add_item_hidden (*p_proto_tree_add_item_hidden) +#define proto_tree_add_protocol_format (*p_proto_tree_add_protocol_format) +#define proto_tree_add_bytes_format (*p_proto_tree_add_bytes_format) +#define proto_tree_add_time_format (*p_proto_tree_add_time_format) +#define proto_tree_add_ipxnet_format (*p_proto_tree_add_ipxnet_format) +#define proto_tree_add_ipv4_format (*p_proto_tree_add_ipv4_format) +#define proto_tree_add_ipv6_format (*p_proto_tree_add_ipv6_format) +#define proto_tree_add_ether_format (*p_proto_tree_add_ether_format) +#define proto_tree_add_string_format (*p_proto_tree_add_string_format) +#define proto_tree_add_boolean_format (*p_proto_tree_add_boolean_format) +#define proto_tree_add_uint_format (*p_proto_tree_add_uint_format) +#define proto_tree_add_text (*p_proto_tree_add_text) +#define proto_tree_add_notext (*p_proto_tree_add_notext) -typedef proto_tree* (*addr_proto_item_add_subtree)(proto_item*, gint); -typedef proto_item* (*addr_proto_tree_add_item)(proto_tree*, int, gint, gint, ...); -typedef proto_item* (*addr_proto_tree_add_item_hidden)(proto_tree*, int, gint, gint, ...); -typedef proto_item* (*addr_proto_tree_add_item_format)(proto_tree*, int, gint, gint, ...); -typedef proto_item* (*addr_proto_tree_add_notext)(proto_tree*, gint, gint, ...); -typedef proto_item* (*addr_proto_tree_add_item_value)(proto_tree*, int, gint, gint, int, int, - va_list); -extern packet_info *p_pi; +#define pi (*p_pi) -typedef struct { +#else - addr_check_col check_col; - addr_col_add_fstr col_add_fstr; - addr_col_append_fstr col_append_fstr; - addr_col_add_str col_add_str; - addr_col_append_str col_append_str; +/* ! PLUGINS_NEED_ADDRESS_TABLE */ +#define DLLEXPORT - addr_dfilter_init dfilter_init; - addr_dfilter_cleanup dfilter_cleanup; +#endif - packet_info *pi; +#ifndef __PACKET_H__ +#include "packet.h" +#endif - addr_proto_register_protocol proto_register_protocol; - addr_proto_register_field_array proto_register_field_array; - addr_proto_register_subtree_array proto_register_subtree_array; +#include "dfilter.h" - addr_proto_item_add_subtree proto_item_add_subtree; - addr_proto_tree_add_item_value _proto_tree_add_item_value; - int hf_text_only; -} plugin_address_table_t; +#include "plugin_table.h" +#ifdef PLUGINS_NEED_ADDRESS_TABLE /* The parent executable will send us the pointer to a filled in - plugin_address_table_t struct, and we keep a copy of that pointer - so that we can use functions in the parent executable. */ + plugin_address_table_t struct, and we copy the pointers from + that table so that we can use functions from the parent executable. */ void plugin_address_table_init(plugin_address_table_t*); - -/* Wrapper functions that use plugin_address_table_t */ -gint check_col(frame_data*, gint); -void col_add_fstr(frame_data*, gint, gchar*, ...); -void col_append_fstr(frame_data*, gint, gchar*, ...); -void col_add_str(frame_data*, gint, const gchar*); -void col_append_str(frame_data*, gint, gchar*); - -void dfilter_init(void); -void dfilter_cleanup(void); - -int proto_register_protocol(char*, char*); -void proto_register_field_array(int, hf_register_info*, int); -void proto_register_subtree_array(int**, int); - -proto_tree* proto_item_add_subtree(proto_item*, gint); -proto_item* proto_tree_add_item(proto_tree*, int, gint, gint, ...); -proto_item* proto_tree_add_item_hidden(proto_tree*, int, gint, gint, ...); -proto_item* proto_tree_add_item_format(proto_tree*, int, gint, gint, ...); -proto_item* proto_tree_add_notext(proto_tree*, gint, gint, ...); -proto_item* proto_tree_add_text(proto_tree*, gint, gint, ...); - -#define pi (*p_pi) - - #else - -/* ! PLUGINS_NEED_ACCESS_TABLE */ -#define DLLEXPORT -typedef void plugin_address_table_t; -#define plugin_address_table_init(x) ; - +#define plugin_address_table_init(x) ; #endif - diff --git a/plugins/plugin_table.h b/plugins/plugin_table.h new file mode 100644 index 0000000000..533560d5d7 --- /dev/null +++ b/plugins/plugin_table.h @@ -0,0 +1,99 @@ +/* plugin_table.h + * Table of exported addresses for Ethereal plugins. + * + * $Id: plugin_table.h,v 1.1 2000/03/15 19:09:52 guy Exp $ + * + * Ethereal - Network traffic analyzer + * Copyright 2000 by Gilbert Ramirez <gram@xiexie.org> + * + * + * 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. + * + * 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. + * + * 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 PLUGINS_NEED_ADDRESS_TABLE + +/* Some OSes (Win32) have DLLs that cannot reference symbols in the parent + executable, so the executable needs to provide a collection of pointers + to those functions for the DLL plugin to use. */ + +/* Typedefs to make our plugin_address_table_t struct look prettier */ +typedef gint (*addr_check_col)(frame_data*, gint); +typedef void (*addr_col_add_fstr)(frame_data*, gint, gchar*, ...); +typedef void (*addr_col_append_fstr)(frame_data*, gint, gchar*, ...); +typedef void (*addr_col_add_str)(frame_data*, gint, const gchar*); +typedef void (*addr_col_append_str)(frame_data*, gint, gchar*); + +typedef void (*addr_dfilter_init)(void); +typedef void (*addr_dfilter_cleanup)(void); + +typedef int (*addr_proto_register_protocol)(char*, char*); +typedef void (*addr_proto_register_field_array)(int, hf_register_info*, int); +typedef void (*addr_proto_register_subtree_array)(int**, int); + +typedef proto_tree* (*addr_proto_item_add_subtree)(proto_item*, gint); +typedef proto_item* (*addr_proto_tree_add_item)(proto_tree*, int, gint, gint, ...); +typedef proto_item* (*addr_proto_tree_add_item_hidden)(proto_tree*, int, gint, gint, ...); +typedef proto_item* (*addr_proto_tree_add_protocol_format)(proto_tree*, int, gint, gint, const char*, ...); +typedef proto_item* (*addr_proto_tree_add_bytes_format)(proto_tree*, int, gint, gint, const guint8*, const char*, ...); +typedef proto_item* (*addr_proto_tree_add_time_format)(proto_tree*, int, gint, gint, struct timeval*, const char*, ...); +typedef proto_item* (*addr_proto_tree_add_ipxnet_format)(proto_tree*, int, gint, gint, guint32, const char*, ...); +typedef proto_item* (*addr_proto_tree_add_ipv4_format)(proto_tree*, int, gint, gint, guint32, const char*, ...); +typedef proto_item* (*addr_proto_tree_add_ipv6_format)(proto_tree*, int, gint, gint, guint8*, const char*, ...); +typedef proto_item* (*addr_proto_tree_add_ether_format)(proto_tree*, int, gint, gint, guint8*, const char*, ...); +typedef proto_item* (*addr_proto_tree_add_string_format)(proto_tree*, int, gint, gint, const char*, const char*, ...); +typedef proto_item* (*addr_proto_tree_add_boolean_format)(proto_tree*, int, gint, gint, guint32, const char*, ...); +typedef proto_item* (*addr_proto_tree_add_uint_format)(proto_tree*, int, gint, gint, guint32, const char*, ...); +typedef proto_item* (*addr_proto_tree_add_text)(proto_tree*, gint, gint, const char*, ...); +typedef proto_item* (*addr_proto_tree_add_notext)(proto_tree*, gint, gint); + +typedef struct { + addr_check_col p_check_col; + addr_col_add_fstr p_col_add_fstr; + addr_col_append_fstr p_col_append_fstr; + addr_col_add_str p_col_add_str; + addr_col_append_str p_col_append_str; + + addr_dfilter_init p_dfilter_init; + addr_dfilter_cleanup p_dfilter_cleanup; + + packet_info *p_pi; + + addr_proto_register_protocol p_proto_register_protocol; + addr_proto_register_field_array p_proto_register_field_array; + addr_proto_register_subtree_array p_proto_register_subtree_array; + + addr_proto_item_add_subtree p_proto_item_add_subtree; + addr_proto_tree_add_item p_proto_tree_add_item; + addr_proto_tree_add_item_hidden p_proto_tree_add_item_hidden; + addr_proto_tree_add_protocol_format p_proto_tree_add_protocol_format; + addr_proto_tree_add_bytes_format p_proto_tree_add_bytes_format; + addr_proto_tree_add_time_format p_proto_tree_add_time_format; + addr_proto_tree_add_ipxnet_format p_proto_tree_add_ipxnet_format; + addr_proto_tree_add_ipv4_format p_proto_tree_add_ipv4_format; + addr_proto_tree_add_ipv6_format p_proto_tree_add_ipv6_format; + addr_proto_tree_add_ether_format p_proto_tree_add_ether_format; + addr_proto_tree_add_string_format p_proto_tree_add_string_format; + addr_proto_tree_add_boolean_format p_proto_tree_add_boolean_format; + addr_proto_tree_add_uint_format p_proto_tree_add_uint_format; + addr_proto_tree_add_text p_proto_tree_add_text; + addr_proto_tree_add_notext p_proto_tree_add_notext; +} plugin_address_table_t; + +#else /* ! PLUGINS_NEED_ACCESS_TABLE */ + +typedef void plugin_address_table_t; + +#endif |