Ethereal-dev: [ak@xxxxxxxxxxxx: Re: [Ethereal-dev] FW1 monitor dissector patch]
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Alfred Koebler <ak@xxxxxxxxxxxx>
Date: Fri, 28 Jun 2002 17:18:27 +0200
Hallo,
> > Well, that has a record length of 0x0000010c, or 268, and a packet data
> > length of 0x000000f3, or 243, in the first packet; snoop just puts
> > padding there, but I wouldn't be surprised if FW1 puts some extra
> > information there, just as Shomiti Surveyor does.
> >
> > So, while it might be possible to guess which type of file it is based
> > on the size of the extra stuff hidden in the padding, I don't have the
> > Shomiti documentation to know for sure whether Shomiti, in any Surveyor
> > release, stuck exactly 24 bytes of extra information in the padding.
>
> OK - I have to look to see for a deterministic way to detect
> a FW1 monitor file.
So far as I can determine there is no deterministic way that the file
is a FW1 monitor file.
The format is exactly a snoop format.
There is no info in the padding area.
So the only way without heuristic behaviour of packet-eth.c is to use
a Switch in Edit-Preferences-Protocols-Ethernet.
Here is the patch with the additional Preference in packet-eth.c.
To patch:
cd <path with ethereal-0.9.4 directory>
patch -p0 < ethereal-0.9.4-fw1.patch
./configure && make && make install
To start ethereal with interpretation of FW1 monitor file:
ethereal -o eth.eth_interpret_as_fw_monitor:TRUE -r FILE
or in ~/.ethereal/preferences
As this is the first time I contribute code to ethereal - what are the next steps ?
diff -Naur ethereal-0.9.4/packet-fw1.c ethereal-0.9.4-fw1/packet-fw1.c
--- ethereal-0.9.4/packet-fw1.c Thu Jun 27 12:12:34 2002
+++ ethereal-0.9.4-fw1/packet-fw1.c Thu Jun 27 12:19:00 2002
@@ -0,0 +1,210 @@
+/* packet-fw1.c
+ * Routines for Ethernet header disassembly of FW1 "monitor" files
+ * Copyright 2002, Alfred Koebler <ak@xxxxxxxxxxxx>
+ *
+ * $Id: README.developer,v 1.49 2002/03/02 07:56:16 guy Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Alfred Koebler <ak@xxxxxxxxxxxx>
+ * Copyright 2002 I.Consult
+ *
+ * To use this dissector use the command line option
+ * -o eth.eth_interpret_as_fw1_monitor:TRUE
+ *
+ * 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 HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <string.h>
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+
+#include <glib.h>
+#include <epan/packet.h>
+#include "prefs.h"
+#include "packet-fw1.h"
+#include "packet-eth.h"
+#include "etypes.h"
+
+/* Place FW1 summary in proto tree */
+static gboolean fw1_summary_in_tree = TRUE;
+
+/* Initialize the protocol and registered fields */
+static int proto_fw1 = -1;
+static int hf_fw1_direction = -1;
+static int hf_fw1_interface = -1;
+static int hf_fw1_type = -1;
+static int hf_fw1_trailer = -1;
+
+/* Initialize the subtree pointers */
+static gint ett_fw1 = -1;
+
+#define TYPE_ETHER 0x0
+#define TYPE_TR 0x1
+#define TYPE_FDDI 0x2
+#define TYPE_ATM 0x3
+
+#define ETH_HEADER_SIZE 14
+
+static dissector_handle_t eth_handle;
+
+void
+capture_fw1(const u_char *pd, int offset, int len, packet_counts *ld)
+{
+
+ if (!BYTES_ARE_IN_FRAME(offset, len, ETH_HEADER_SIZE)) {
+ ld->other++;
+ return;
+ }
+
+ capture_eth(pd, offset, len, ld);
+}
+
+void
+dissect_fw1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ /* Set up structures needed to add the protocol subtree and manage it */
+ proto_item *ti;
+ proto_tree *volatile fh_tree = NULL;
+ char direction[3];
+ char interface[20];
+ guint16 etype;
+ char header[1000];
+ char *p_header;
+ int i;
+ int found;
+
+ #define MAX_INTERFACES 20
+ static char *p_interfaces[MAX_INTERFACES];
+ static int interface_anzahl=0;
+
+ /* Make entries in Protocol column and Info column on summary display */
+ if (check_col(pinfo->cinfo, COL_PROTOCOL))
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "FW1");
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_clear(pinfo->cinfo, COL_INFO);
+
+ etype = tvb_get_ntohs(tvb, 12);
+
+ if (tree) {
+ sprintf(header, "FW1 Monitor");
+
+ /* fetch info to local variable */
+ direction[0] = tvb_get_guint8(tvb, 0);
+ direction[1] = 0;
+ tvb_get_nstringz0(tvb, 2, 10, interface);
+
+ if (fw1_summary_in_tree) {
+ /* Known interface name - if not, remember it */
+ found=1;
+ for (i=0; i<interface_anzahl && i<MAX_INTERFACES; i++) {
+ if ( strcmp(p_interfaces[i], interface) == 0 ) {
+ found=0;
+ }
+ }
+ if (found == 1 ) {
+ p_interfaces[interface_anzahl] = strdup(interface);
+ interface_anzahl++;
+ }
+ /* display all interfaces always in the same order */
+ for (i=0; i<interface_anzahl; i++) {
+ found=1;
+ if ( strcmp(p_interfaces[i], interface) == 0 ) {
+ found=0;
+ }
+ p_header = header + strlen(header);
+ sprintf(p_header, " %c %s %c",
+ found==0 ? (direction[0]=='i' ? 'i' : (direction[0]=='O' ? 'O' : ' ')) : ' ',
+ p_interfaces[i],
+ found==0 ? (direction[0]=='I' ? 'I' : (direction[0]=='o' ? 'o' : ' ')) : ' '
+ );
+ }
+ } else {
+ /* without FW1 summary delete all remembered names of interfaces */
+ for (i=0; i<interface_anzahl && i<MAX_INTERFACES; i++) {
+ free(p_interfaces[i]);
+ }
+ interface_anzahl = 0;
+ }
+
+ ti = proto_tree_add_protocol_format(tree, proto_fw1, tvb, 0, ETH_HEADER_SIZE, header);
+
+ /* create display subtree for the protocol */
+ fh_tree = proto_item_add_subtree(ti, ett_fw1);
+
+ proto_tree_add_item(fh_tree, hf_fw1_direction, tvb, 0, 1, FALSE);
+
+ proto_tree_add_string_format(fh_tree, hf_fw1_interface,
+ tvb, 2, 10,
+ interface, "Interface: %s", interface);
+ }
+ ethertype(etype, tvb, ETH_HEADER_SIZE, pinfo, tree, fh_tree, hf_fw1_type,
+ hf_fw1_trailer);
+}
+
+void
+proto_register_fw1(void)
+{
+ static hf_register_info hf[] = {
+ { &hf_fw1_direction,
+ { "Direction", "fw1.direction", FT_STRING, BASE_NONE, NULL, 0x0,
+ "Direction", HFILL }},
+ { &hf_fw1_interface,
+ { "Interface", "fw1.interface", FT_STRING, BASE_NONE, NULL, 0x0,
+ "Interface", HFILL }},
+ /* registered here but handled in ethertype.c */
+ { &hf_fw1_type,
+ { "Type", "fw1.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0,
+ "", HFILL }},
+ };
+ /* Setup protocol subtree array */
+ static gint *ett[] = {
+ &ett_fw1,
+ };
+ module_t *fw1_module;
+
+ /* Register the protocol name and description */
+ proto_fw1 = proto_register_protocol("Checkpoint FW-1", "FW-1", "fw1");
+ /* Required function calls to register the header fields and subtrees used */
+ proto_register_field_array(proto_fw1, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
+
+ /* Register configuration preferences */
+ fw1_module = prefs_register_protocol(proto_fw1, NULL);
+ prefs_register_bool_preference(fw1_module, "fw1_summary_in_tree",
+ "Show FW1 summary in protocol tree",
+"Whether the FW1 summary line should be shown in the protocol tree",
+ &fw1_summary_in_tree);
+
+ register_dissector("fw1", dissect_fw1, proto_fw1);
+}
+
+void
+proto_reg_handoff_fw1(void)
+{
+ /*
+ * Get handles for the Ethernet dissectors.
+ */
+ eth_handle = find_dissector("eth");
+}
diff -Naur ethereal-0.9.4/packet-fw1.h ethereal-0.9.4-fw1/packet-fw1.h
--- ethereal-0.9.4/packet-fw1.h Thu Jun 27 12:12:41 2002
+++ ethereal-0.9.4-fw1/packet-fw1.h Wed Jun 26 21:21:21 2002
@@ -0,0 +1,29 @@
+/* packet-fw1.h
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@xxxxxxxxxxxx>
+ * Copyright 1998 Gerald Combs
+ *
+ * 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.
+ */
+
+#ifndef __PACKET_FW1_H__
+#define __PACKET_FW1_H__
+
+void capture_fw1(const u_char *, int, int, packet_counts *);
+
+void dissect_fw1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
+
+#endif
diff -Naur ethereal-0.9.4/packet-eth.c ethereal-0.9.4-fw1/packet-eth.c
--- ethereal-0.9.4/packet-eth.c Sat May 11 18:23:28 2002
+++ ethereal-0.9.4-fw1/packet-eth.c Thu Jun 27 12:20:22 2002
@@ -32,6 +32,7 @@
#include <glib.h>
#include <epan/packet.h>
+#include "prefs.h"
#include "etypes.h"
#include <epan/resolv.h>
#include "packet-eth.h"
@@ -39,6 +40,10 @@
#include "packet-ipx.h"
#include "packet-isl.h"
#include "packet-llc.h"
+#include "packet-fw1.h"
+
+/* Interpret capture file as FW1 monitor file */
+static gboolean eth_interpret_as_fw1_monitor = FALSE;
/* protocols and header fields */
static int proto_eth = -1;
@@ -53,6 +58,7 @@
static gint ett_ether2 = -1;
static dissector_handle_t isl_handle;
+static dissector_handle_t fw1_handle;
#define ETH_HEADER_SIZE 14
@@ -212,6 +218,11 @@
dissect_802_3(etype, is_802_2, tvb, ETH_HEADER_SIZE, pinfo, tree, fh_tree,
hf_eth_len, hf_eth_trailer);
} else {
+ if ( eth_interpret_as_fw1_monitor ) {
+ call_dissector(fw1_handle, tvb, pinfo, tree);
+ return;
+ }
+
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO, "Ethernet II");
if (tree) {
@@ -266,11 +277,19 @@
&ett_ieee8023,
&ett_ether2,
};
+ module_t *eth_module;
proto_eth = proto_register_protocol("Ethernet", "Ethernet", "eth");
proto_register_field_array(proto_eth, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
+ /* Register configuration preferences */
+ eth_module = prefs_register_protocol(proto_eth, NULL);
+ prefs_register_bool_preference(eth_module, "eth_interpret_as_fw1_monitor",
+ "Interpret as FW1 monitor file",
+"Whether the capture file should be interpreted as FW1 monitor file",
+ ð_interpret_as_fw1_monitor);
+
register_dissector("eth", dissect_eth, proto_eth);
}
@@ -283,6 +302,7 @@
* Get a handle for the ISL dissector.
*/
isl_handle = find_dissector("isl");
+ fw1_handle = find_dissector("fw1");
eth_handle = find_dissector("eth");
dissector_add("wtap_encap", WTAP_ENCAP_ETHERNET, eth_handle);
diff -Naur ethereal-0.9.4/Makefile.am ethereal-0.9.4-fw1/Makefile.am
--- ethereal-0.9.4/Makefile.am Sat May 18 04:42:04 2002
+++ ethereal-0.9.4-fw1/Makefile.am Wed Jun 26 21:19:11 2002
@@ -134,6 +134,7 @@
packet-fr.c \
packet-frame.c \
packet-ftp.c \
+ packet-fw1.c \
packet-giop.c \
packet-gmrp.c \
packet-gnutella.c \
@@ -383,6 +384,7 @@
packet-eth.h \
packet-fddi.h \
packet-frame.h \
+ packet-fw1.h \
packet-giop.h \
packet-gnutella.h \
packet-hclnfsd.h \
diff -Naur ethereal-0.9.4/Makefile.nmake ethereal-0.9.4-fw1/Makefile.nmake
--- ethereal-0.9.4/Makefile.nmake Sat May 18 04:42:04 2002
+++ ethereal-0.9.4-fw1/Makefile.nmake Wed Jun 26 21:19:50 2002
@@ -85,6 +85,7 @@
packet-fr.c \
packet-frame.c \
packet-ftp.c \
+ packet-fw1.c \
packet-giop.c \
packet-gmrp.c \
packet-gnutella.c \
Greetings
Alfred Koebler
---
I.CONSULT Beratungsgesellschaft mbH web: www.icon-sult.de
Dipl. Ing. Alfred Koebler email: ak@xxxxxxxxxxxx
CCSA/CCSE-2000, CCSA/CCSE-NG, CCSI, ACA
Breitwiesenstr. 6 Fon: +49 711 787808-13
70565 Stuttgart Fax: +49 711 787808-11
PGP Fingerprint = 0C15 BB1B 7E87 19F6 EDCC 539D AB04 BEB7 3409 9A09
Publickey: http://www.pca.dfn.de/dfnpca/pgpkserv/ - KeyID: ak@xxxxxxxxxxxx
X509/Certificate Fingerprint = 5E:2C:CF:46:91:96:0D:BD:B0:52:8C:E2:BE:3B:D7:60
Attachment:
pgp5mM5D3Ydvb.pgp
Description: PGP signature
- Prev by Date: [Ethereal-dev] Missing noinst headers from top level Makefile.am
- Next by Date: Re: [Ethereal-dev] Missing noinst headers from top level Makefile.am
- Previous by thread: Re: [Ethereal-dev] Missing noinst headers from top level Makefile.am
- Next by thread: [Ethereal-dev] patch for packet-sctp.c
- Index(es):





