2002-08-08 09:28:11 +00:00
|
|
|
/* packet-fw1.c
|
|
|
|
* Routines for Ethernet header disassembly of FW1 "monitor" files
|
2003-08-16 00:29:15 +00:00
|
|
|
* Copyright 2002,2003, Alfred Koebler <ako@icon.de>
|
2002-08-08 09:28:11 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
2003-08-16 00:29:15 +00:00
|
|
|
* By Alfred Koebler <ako@icon.de>
|
|
|
|
* Copyright 2002,2003 Alfred Koebler
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2002-08-08 09:28:11 +00:00
|
|
|
* To use this dissector use the command line option
|
2002-08-08 09:33:26 +00:00
|
|
|
* -o eth.interpret_as_fw1_monitor:TRUE
|
2002-08-08 09:28:11 +00:00
|
|
|
*
|
|
|
|
* At the moment the way with the option is the best one.
|
|
|
|
* A automatic way is not possible, because the file format isn't different
|
|
|
|
* to the snoop file.
|
|
|
|
*
|
|
|
|
* With "fw monitor" it is possible to collect packets on several places.
|
|
|
|
* The additional information:
|
|
|
|
* - is it a incoming or outgoing packet
|
|
|
|
* - is it before or after the firewall
|
|
|
|
* i incoming before the firewall
|
|
|
|
* I incoming after the firewall
|
|
|
|
* o outcoming before the firewall
|
|
|
|
* O outcoming after the firewall
|
|
|
|
* - the name of the interface
|
|
|
|
*
|
|
|
|
* What's the problem ?
|
|
|
|
* Think about one packet traveling across the firewall.
|
2006-05-21 04:49:01 +00:00
|
|
|
* With wireshark you will see 4 lines in the Top Pane.
|
2002-08-08 09:28:11 +00:00
|
|
|
* To analyze a problem it is helpful to see the additional information
|
|
|
|
* in the protocol tree of the Middle Pane.
|
|
|
|
*
|
|
|
|
* The presentation of the summary line is designed in the following way:
|
|
|
|
* Every time the next selected packet in the Top Pane includes a
|
|
|
|
* "new" interface name the name is added to the list in the summary line.
|
|
|
|
* The interface names are listed one after the other.
|
|
|
|
* The position of the interface names didn't change.
|
|
|
|
*
|
|
|
|
* And who are the 4 places represented ?
|
|
|
|
* The interface name represents the firewall module of the interface.
|
|
|
|
* On the left side of the interface name is the interface module.
|
|
|
|
* On the right side of the interface name is the "IP" module.
|
|
|
|
*
|
|
|
|
* Example for a ping from the firewall to another host:
|
|
|
|
* For the four lines in the Top Pane you will see the according lines
|
|
|
|
* in the Middle Pane:
|
|
|
|
* El90x1 o
|
2002-08-28 21:04:11 +00:00
|
|
|
* O El90x1
|
|
|
|
* i El90x1
|
2002-08-08 09:28:11 +00:00
|
|
|
* El90x1 I
|
|
|
|
*
|
|
|
|
* Example for a packet traversing through the Firewall, first through
|
|
|
|
* the inner side firewall module then through the outer side firewall module:
|
|
|
|
* i El90x1 El90x2
|
|
|
|
* El90x1 I El90x2
|
|
|
|
* El90x1 o E190x2
|
|
|
|
* El90x1 E190x2 O
|
|
|
|
*
|
2002-12-10 00:12:59 +00:00
|
|
|
* 9.12.2002
|
|
|
|
* Add new column with summary of FW-1 interface/direction
|
2002-08-08 09:28:11 +00:00
|
|
|
*
|
2003-08-16 00:29:15 +00:00
|
|
|
* 11.8.2003
|
|
|
|
* Additional interpretation of field Chain Position.
|
|
|
|
* Show the chain position in the interface list.
|
2006-07-07 00:45:54 +00:00
|
|
|
* Support for new format of fw monitor file
|
2003-08-16 00:29:15 +00:00
|
|
|
* writen by option -u | -s for UUID/SUUID.
|
|
|
|
* NOTICE: First paket will have UUID == 0 !
|
|
|
|
*
|
2002-08-08 09:28:11 +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 21:04:11 +00:00
|
|
|
*
|
2002-08-08 09:28:11 +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 21:04:11 +00:00
|
|
|
*
|
2002-08-08 09:28:11 +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
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2002-08-08 09:28:11 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2002-08-08 09:28:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
2004-09-27 22:55:15 +00:00
|
|
|
#include <epan/prefs.h>
|
2005-09-17 00:02:31 +00:00
|
|
|
#include <epan/etypes.h>
|
2002-08-08 09:28:11 +00:00
|
|
|
|
2013-12-14 12:45:57 +00:00
|
|
|
void proto_register_fw1(void);
|
|
|
|
void proto_reg_handoff_fw1(void);
|
|
|
|
|
2002-08-08 09:28:11 +00:00
|
|
|
/* Place FW1 summary in proto tree */
|
|
|
|
static gboolean fw1_summary_in_tree = TRUE;
|
2003-08-16 00:29:15 +00:00
|
|
|
static gboolean fw1_with_uuid = FALSE;
|
|
|
|
static gboolean fw1_iflist_with_chain = FALSE;
|
2002-08-08 09:28:11 +00:00
|
|
|
|
2013-11-20 02:28:14 +00:00
|
|
|
static dissector_handle_t ethertype_handle;
|
|
|
|
|
2002-08-08 09:28:11 +00:00
|
|
|
/* Initialize the protocol and registered fields */
|
|
|
|
static int proto_fw1 = -1;
|
|
|
|
static int hf_fw1_direction = -1;
|
2003-08-16 00:29:15 +00:00
|
|
|
static int hf_fw1_chain = -1;
|
2002-08-08 09:28:11 +00:00
|
|
|
static int hf_fw1_interface = -1;
|
2003-08-16 00:29:15 +00:00
|
|
|
static int hf_fw1_uuid = -1;
|
2002-08-08 09:28:11 +00:00
|
|
|
static int hf_fw1_type = -1;
|
|
|
|
static int hf_fw1_trailer = -1;
|
|
|
|
|
|
|
|
/* Initialize the subtree pointers */
|
|
|
|
static gint ett_fw1 = -1;
|
|
|
|
|
2010-12-14 01:50:31 +00:00
|
|
|
#define ETH_HEADER_SIZE 14
|
2002-08-08 09:28:11 +00:00
|
|
|
|
2010-12-14 01:50:31 +00:00
|
|
|
#define MAX_INTERFACES 20
|
2012-08-14 17:58:41 +00:00
|
|
|
static gchar *p_interfaces[MAX_INTERFACES];
|
2010-12-14 01:50:31 +00:00
|
|
|
static int interface_anzahl=0;
|
2004-01-06 22:05:37 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
fw1_init(void)
|
|
|
|
{
|
|
|
|
interface_anzahl = 0;
|
|
|
|
}
|
|
|
|
|
2015-11-10 04:01:28 +00:00
|
|
|
static int
|
|
|
|
dissect_fw1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
2002-08-08 09:28:11 +00:00
|
|
|
{
|
|
|
|
/* Set up structures needed to add the protocol subtree and manage it */
|
2002-08-28 21:04:11 +00:00
|
|
|
proto_item *ti;
|
2015-10-26 01:03:36 +00:00
|
|
|
proto_tree *fh_tree = NULL;
|
2010-12-14 01:50:31 +00:00
|
|
|
char direction;
|
|
|
|
char chain;
|
|
|
|
char *interface_name;
|
|
|
|
guint32 iface_len = 10;
|
2013-09-15 09:12:01 +00:00
|
|
|
wmem_strbuf_t *header;
|
2010-12-14 01:50:31 +00:00
|
|
|
int i;
|
|
|
|
gboolean found;
|
|
|
|
static const char fw1_header[] = "FW1 Monitor";
|
2013-11-20 02:28:14 +00:00
|
|
|
ethertype_data_t ethertype_data;
|
2002-12-10 00:12:59 +00:00
|
|
|
|
2017-02-25 03:11:22 +00:00
|
|
|
header = wmem_strbuf_new_label(wmem_packet_scope());
|
2013-09-15 09:12:01 +00:00
|
|
|
wmem_strbuf_append(header, fw1_header);
|
2005-08-27 00:25:32 +00:00
|
|
|
|
2002-08-08 09:28:11 +00:00
|
|
|
/* Make entries in Protocol column and Info column on summary display */
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "FW1");
|
2009-08-09 07:36:13 +00:00
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2002-08-08 09:28:11 +00:00
|
|
|
|
2002-12-10 00:12:59 +00:00
|
|
|
/* fetch info to local variable */
|
2005-02-03 23:42:06 +00:00
|
|
|
direction = tvb_get_guint8(tvb, 0);
|
2003-08-16 00:29:15 +00:00
|
|
|
|
2005-02-03 23:42:06 +00:00
|
|
|
if (!fw1_iflist_with_chain)
|
2010-12-14 01:50:31 +00:00
|
|
|
chain = ' ';
|
2005-02-03 23:42:06 +00:00
|
|
|
else
|
2010-12-14 01:50:31 +00:00
|
|
|
chain = tvb_get_guint8(tvb, 1);
|
2005-02-03 23:42:06 +00:00
|
|
|
|
|
|
|
if (fw1_with_uuid)
|
2010-12-14 01:50:31 +00:00
|
|
|
iface_len = 6;
|
2006-07-07 00:45:54 +00:00
|
|
|
|
2014-04-12 22:26:34 +00:00
|
|
|
interface_name=tvb_get_stringzpad(wmem_packet_scope(), tvb, 2, iface_len, ENC_ASCII|ENC_NA);
|
2002-12-10 00:12:59 +00:00
|
|
|
|
|
|
|
/* Known interface name - if not, remember it */
|
2004-01-06 21:11:04 +00:00
|
|
|
found=FALSE;
|
2004-01-06 22:05:37 +00:00
|
|
|
for (i=0; i<interface_anzahl; i++) {
|
2002-12-10 00:12:59 +00:00
|
|
|
if ( strcmp(p_interfaces[i], interface_name) == 0 ) {
|
2004-01-06 21:11:04 +00:00
|
|
|
found=TRUE;
|
2005-02-03 23:42:06 +00:00
|
|
|
break;
|
2002-08-08 09:28:11 +00:00
|
|
|
}
|
2002-12-10 00:12:59 +00:00
|
|
|
}
|
2004-01-06 21:11:04 +00:00
|
|
|
if (!found && interface_anzahl < MAX_INTERFACES) {
|
2013-09-15 09:12:01 +00:00
|
|
|
p_interfaces[interface_anzahl] = wmem_strdup(wmem_file_scope(), interface_name);
|
2002-12-10 00:12:59 +00:00
|
|
|
interface_anzahl++;
|
|
|
|
}
|
2005-02-03 23:42:06 +00:00
|
|
|
|
2002-12-10 00:12:59 +00:00
|
|
|
/* display all interfaces always in the same order */
|
|
|
|
for (i=0; i<interface_anzahl; i++) {
|
2005-02-03 23:42:06 +00:00
|
|
|
if ( strcmp(p_interfaces[i], interface_name) == 0 ) {
|
2013-09-15 09:12:01 +00:00
|
|
|
wmem_strbuf_append_printf(header, " %c%c %s %c%c",
|
|
|
|
direction == 'i' ? 'i' : (direction == 'O' ? 'O' : ' '),
|
|
|
|
(direction == 'i' || direction == 'O') ? chain : ' ',
|
|
|
|
p_interfaces[i],
|
|
|
|
direction == 'I' ? 'I' : (direction == 'o' ? 'o' : ' '),
|
|
|
|
(direction == 'I' || direction == 'o') ? chain : ' '
|
2010-12-14 01:50:31 +00:00
|
|
|
);
|
2003-08-16 00:29:15 +00:00
|
|
|
} else {
|
2013-09-15 09:12:01 +00:00
|
|
|
wmem_strbuf_append_printf(header, " %s ", p_interfaces[i]);
|
2003-08-16 00:29:15 +00:00
|
|
|
}
|
2002-12-10 00:12:59 +00:00
|
|
|
}
|
2002-08-08 09:28:11 +00:00
|
|
|
|
2013-09-15 09:12:01 +00:00
|
|
|
col_add_str(pinfo->cinfo, COL_IF_DIR, wmem_strbuf_get_str(header) + sizeof(fw1_header) + 1);
|
2002-12-10 00:12:59 +00:00
|
|
|
|
2005-03-05 20:36:03 +00:00
|
|
|
if (tree) {
|
|
|
|
if (!fw1_summary_in_tree)
|
|
|
|
/* Do not show the summary in Protocol Tree */
|
2006-07-07 00:45:54 +00:00
|
|
|
ti = proto_tree_add_protocol_format(tree, proto_fw1, tvb, 0, ETH_HEADER_SIZE, "%s", fw1_header);
|
2005-03-05 20:36:03 +00:00
|
|
|
else
|
2013-09-15 09:12:01 +00:00
|
|
|
ti = proto_tree_add_protocol_format(tree, proto_fw1, tvb, 0, ETH_HEADER_SIZE, "%s", wmem_strbuf_get_str(header));
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2005-03-05 20:36:03 +00:00
|
|
|
/* create display subtree for the protocol */
|
|
|
|
fh_tree = proto_item_add_subtree(ti, ett_fw1);
|
2002-08-08 09:28:11 +00:00
|
|
|
|
2011-10-15 18:46:26 +00:00
|
|
|
proto_tree_add_item(fh_tree, hf_fw1_direction, tvb, 0, 1, ENC_ASCII|ENC_NA);
|
2002-08-08 09:28:11 +00:00
|
|
|
|
2005-03-05 20:36:03 +00:00
|
|
|
if (fw1_iflist_with_chain)
|
2011-10-15 18:46:26 +00:00
|
|
|
proto_tree_add_item(fh_tree, hf_fw1_chain, tvb, 1, 1, ENC_ASCII|ENC_NA);
|
2005-02-03 23:42:06 +00:00
|
|
|
|
2011-10-15 18:46:26 +00:00
|
|
|
proto_tree_add_item(fh_tree, hf_fw1_interface, tvb, 2, iface_len, ENC_ASCII|ENC_NA);
|
2006-07-07 00:45:54 +00:00
|
|
|
|
|
|
|
if (fw1_with_uuid)
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(fh_tree, hf_fw1_uuid, tvb, 8, 4, ENC_BIG_ENDIAN);
|
2005-03-05 20:36:03 +00:00
|
|
|
}
|
2005-02-03 23:42:06 +00:00
|
|
|
|
2013-11-20 02:28:14 +00:00
|
|
|
ethertype_data.etype = tvb_get_ntohs(tvb, 12);
|
|
|
|
ethertype_data.offset_after_ethertype = ETH_HEADER_SIZE;
|
|
|
|
ethertype_data.fh_tree = fh_tree;
|
|
|
|
ethertype_data.etype_id = hf_fw1_type;
|
|
|
|
ethertype_data.trailer_id = hf_fw1_trailer;
|
|
|
|
ethertype_data.fcs_len = 0;
|
|
|
|
|
|
|
|
call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, ðertype_data);
|
2015-11-10 04:01:28 +00:00
|
|
|
return tvb_captured_length(tvb);
|
2002-08-08 09:28:11 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-08-08 09:28:11 +00:00
|
|
|
void
|
|
|
|
proto_register_fw1(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
2010-12-14 01:50:31 +00:00
|
|
|
{ &hf_fw1_direction,
|
2012-05-03 19:31:03 +00:00
|
|
|
{ "Direction", "fw1.direction", FT_STRING, BASE_NONE, NULL, 0x0,
|
2010-12-14 01:50:31 +00:00
|
|
|
NULL, HFILL }},
|
2012-05-03 19:31:03 +00:00
|
|
|
|
2010-12-14 01:50:31 +00:00
|
|
|
{ &hf_fw1_chain,
|
2012-05-03 19:31:03 +00:00
|
|
|
{ "Chain Position", "fw1.chain", FT_STRING, BASE_NONE, NULL, 0x0,
|
2010-12-14 01:50:31 +00:00
|
|
|
NULL, HFILL }},
|
2012-05-03 19:31:03 +00:00
|
|
|
|
2010-12-14 01:50:31 +00:00
|
|
|
{ &hf_fw1_interface,
|
2012-05-03 19:31:03 +00:00
|
|
|
{ "Interface", "fw1.interface", FT_STRING, BASE_NONE, NULL, 0x0,
|
2010-12-14 01:50:31 +00:00
|
|
|
NULL, HFILL }},
|
2012-05-03 19:31:03 +00:00
|
|
|
|
2010-12-14 01:50:31 +00:00
|
|
|
{ &hf_fw1_uuid,
|
|
|
|
{ "UUID", "fw1.uuid", FT_UINT32, BASE_DEC, NULL, 0x0,
|
|
|
|
NULL, HFILL }},
|
2012-05-03 19:31:03 +00:00
|
|
|
|
2010-12-14 01:50:31 +00:00
|
|
|
/* registered here but handled in ethertype.c */
|
|
|
|
{ &hf_fw1_type,
|
2012-05-03 19:31:03 +00:00
|
|
|
{ "Type", "fw1.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0,
|
2010-12-14 01:50:31 +00:00
|
|
|
NULL, HFILL }},
|
2013-01-29 14:18:04 +00:00
|
|
|
|
|
|
|
{ &hf_fw1_trailer,
|
|
|
|
{ "Trailer", "fw1.trailer", FT_BYTES, BASE_NONE, NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
}
|
2002-08-08 09:28:11 +00:00
|
|
|
};
|
|
|
|
/* Setup protocol subtree array */
|
|
|
|
static gint *ett[] = {
|
2010-12-14 01:50:31 +00:00
|
|
|
&ett_fw1,
|
2002-08-08 09:28:11 +00:00
|
|
|
};
|
|
|
|
module_t *fw1_module;
|
2010-12-14 01:50:31 +00:00
|
|
|
int i;
|
2002-08-08 09:28:11 +00:00
|
|
|
|
|
|
|
/* 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);
|
2002-08-08 09:33:26 +00:00
|
|
|
prefs_register_bool_preference(fw1_module, "summary_in_tree",
|
2010-12-14 01:50:31 +00:00
|
|
|
"Show FireWall-1 summary in protocol tree",
|
|
|
|
"Whether the FireWall-1 summary line should be shown in the protocol tree",
|
|
|
|
&fw1_summary_in_tree);
|
2003-08-16 00:29:15 +00:00
|
|
|
prefs_register_bool_preference(fw1_module, "with_uuid",
|
2010-12-14 01:50:31 +00:00
|
|
|
"Monitor file includes UUID",
|
|
|
|
"Whether the Firewall-1 monitor file includes UUID information",
|
|
|
|
&fw1_with_uuid);
|
2003-08-16 00:29:15 +00:00
|
|
|
prefs_register_bool_preference(fw1_module, "iflist_with_chain",
|
2010-12-14 01:50:31 +00:00
|
|
|
"Interface list includes chain position",
|
|
|
|
"Whether the interface list includes the chain position",
|
|
|
|
&fw1_iflist_with_chain);
|
2002-08-08 09:28:11 +00:00
|
|
|
|
2015-12-09 04:04:01 +00:00
|
|
|
register_dissector("fw1", dissect_fw1, proto_fw1);
|
2004-01-06 22:05:37 +00:00
|
|
|
|
2012-08-14 17:58:41 +00:00
|
|
|
for (i=0; i<MAX_INTERFACES; i++) {
|
2010-12-14 01:50:31 +00:00
|
|
|
p_interfaces[i] = NULL;
|
|
|
|
}
|
2004-01-06 22:05:37 +00:00
|
|
|
register_init_routine(fw1_init);
|
2002-08-08 09:28:11 +00:00
|
|
|
}
|
2013-11-20 02:28:14 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_fw1(void)
|
|
|
|
{
|
2016-03-16 13:02:52 +00:00
|
|
|
ethertype_handle = find_dissector_add_dependency("ethertype", proto_fw1);
|
2013-12-14 12:45:57 +00:00
|
|
|
}
|
2014-09-29 18:07:49 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 2
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=2 tabstop=8 expandtab:
|
|
|
|
* :indentSize=2:tabSize=8:noTabs=true:
|
|
|
|
*/
|