aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gryphon/packet-gryphon.c41
-rw-r--r--plugins/plugin_api.c147
-rw-r--r--plugins/plugin_api.h96
3 files changed, 265 insertions, 19 deletions
diff --git a/plugins/gryphon/packet-gryphon.c b/plugins/gryphon/packet-gryphon.c
index e019b0ad08..e741cf9aec 100644
--- a/plugins/gryphon/packet-gryphon.c
+++ b/plugins/gryphon/packet-gryphon.c
@@ -1,7 +1,7 @@
/* packet-gryphon.c
* Routines for Gryphon protocol packet disassembly
*
- * $Id: packet-gryphon.c,v 1.4 2000/01/08 19:37:11 gram Exp $
+ * $Id: packet-gryphon.c,v 1.5 2000/02/07 17:08:27 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Steve Limkemann <stevelim@dgtech.com>
@@ -29,6 +29,8 @@
#include "config.h"
#endif
+#include "plugins/plugin_api.h"
+
#include "moduleinfo.h"
#ifdef HAVE_SYS_TYPES_H
@@ -37,6 +39,7 @@
#include <string.h>
#include <ctype.h>
+#include <time.h>
#include <glib.h>
#ifdef HAVE_NETINET_IN_H
@@ -46,10 +49,14 @@
#include "dfilter.h"
#include "packet-gryphon.h"
-const gchar version[] = VERSION;
-const gchar desc[] = "DG Gryphon Protocol";
-const gchar protocol[] = "tcp";
-const gchar filter_string[] = "tcp.port == 7000";
+DLLEXPORT const gchar version[] = VERSION;
+DLLEXPORT const gchar desc[] = "DG Gryphon Protocol";
+DLLEXPORT const gchar protocol[] = "tcp";
+DLLEXPORT const gchar filter_string[] = "tcp.port == 7000";
+
+#ifndef G_HAVE_GINT64
+#error "Sorry, this won't compile without 64-bit integer support"
+#endif
static int proto_gryphon = -1;
@@ -78,14 +85,10 @@ static gint ett_gryphon_pgm_list = -1;
static gint ett_gryphon_pgm_status = -1;
static gint ett_gryphon_pgm_options = -1;
-#define gryphon_LTX_desc desc
-#define gryphon_LTX_dissector dissector
-#define gryphon_LTX_filter_string filter_string
-#define gryphon_LTX_proto_init proto_init
-#define gryphon_LTX_protocol protocol
-#define gryphon_LTX_version version
-void dissector(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+
+DLLEXPORT void
+dissector(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
proto_tree *gryphon_tree, *header_tree, *body_tree;
@@ -647,15 +650,15 @@ resp_time (int src, const u_char **data, const u_char *dataend, int *offset, int
{
int hours, minutes, seconds, fraction;
union {
- unsigned int lng[2];
- unsigned long long int lnglng;
+ unsigned int lng[2];
+ unsigned gint64 lnglng;
} ts;
unsigned int timestamp;
unsigned char date[45];
-
+
ts.lng[1] = pntohl ((unsigned int *)(*data));
ts.lng[0] = pntohl ((unsigned int *)((*data)+4));
- timestamp = ts.lnglng / 100000LL;
+ timestamp = ts.lnglng / 100000L;
strncpy (date, ctime((time_t*)&timestamp), sizeof(date));
date[strlen(date)-1] = 0x00;
proto_tree_add_text(pt, *offset, 8, "Date/Time: %s", date);
@@ -1517,8 +1520,8 @@ blm_mode (int src, const u_char **data, const u_char *dataend, int *offset, int
BUMP (*offset, *data, 4);
}
-void
-proto_init(void)
+DLLEXPORT void
+plugin_init(plugin_address_table_t *pat)
{
static hf_register_info hf[] = {
{ &hf_gryph_src,
@@ -1560,7 +1563,7 @@ proto_init(void)
&ett_gryphon_pgm_status,
&ett_gryphon_pgm_options,
};
-
+ plugin_address_table_init(pat);
dfilter_cleanup();
proto_gryphon = proto_register_protocol("DG Gryphon Protocol", "gryphon");
proto_register_field_array(proto_gryphon, hf, array_length(hf));
diff --git a/plugins/plugin_api.c b/plugins/plugin_api.c
new file mode 100644
index 0000000000..50627a5648
--- /dev/null
+++ b/plugins/plugin_api.c
@@ -0,0 +1,147 @@
+/* plugin_api.c
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdarg.h>
+
+#include "plugin_api.h"
+
+static plugin_address_table_t *patable = NULL;
+packet_info *p_pi;
+
+
+#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)
+{
+ 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;
+}
diff --git a/plugins/plugin_api.h b/plugins/plugin_api.h
new file mode 100644
index 0000000000..781456d867
--- /dev/null
+++ b/plugins/plugin_api.h
@@ -0,0 +1,96 @@
+/* plugin_api.h
+ */
+
+#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);
+
+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;
+
+typedef struct {
+
+ 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;
+
+ addr_dfilter_init dfilter_init;
+ addr_dfilter_cleanup dfilter_cleanup;
+
+ packet_info *pi;
+
+ 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;
+
+ 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;
+
+/* 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. */
+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) ;
+
+#endif
+