2 * Routines for Ethernet header disassembly of FW1 "monitor" files
3 * Copyright 2002,2003, Alfred Koebler <ako@icon.de>
7 * Wireshark - Network traffic analyzer
8 * By Alfred Koebler <ako@icon.de>
9 * Copyright 2002,2003 Alfred Koebler
11 * To use this dissector use the command line option
12 * -o eth.interpret_as_fw1_monitor:TRUE
14 * At the moment the way with the option is the best one.
15 * A automatic way is not possible, because the file format isn't different
18 * With "fw monitor" it is possible to collect packets on several places.
19 * The additional information:
20 * - is it a incoming or outgoing packet
21 * - is it before or after the firewall
22 * i incoming before the firewall
23 * I incoming after the firewall
24 * o outcoming before the firewall
25 * O outcoming after the firewall
26 * - the name of the interface
28 * What's the problem ?
29 * Think about one packet traveling across the firewall.
30 * With wireshark you will see 4 lines in the Top Pane.
31 * To analyze a problem it is helpful to see the additional information
32 * in the protocol tree of the Middle Pane.
34 * The presentation of the summary line is designed in the following way:
35 * Every time the next selected packet in the Top Pane includes a
36 * "new" interface name the name is added to the list in the summary line.
37 * The interface names are listed one after the other.
38 * The position of the interface names didn't change.
40 * And who are the 4 places represented ?
41 * The interface name represents the firewall module of the interface.
42 * On the left side of the interface name is the interface module.
43 * On the right side of the interface name is the "IP" module.
45 * Example for a ping from the firewall to another host:
46 * For the four lines in the Top Pane you will see the according lines
53 * Example for a packet traversing through the Firewall, first through
54 * the inner side firewall module then through the outer side firewall module:
61 * Add new column with summary of FW-1 interface/direction
64 * Additional interpretation of field Chain Position.
65 * Show the chain position in the interface list.
66 * Support for new format of fw monitor file
67 * writen by option -u | -s for UUID/SUUID.
68 * NOTICE: First paket will have UUID == 0 !
70 * This program is free software; you can redistribute it and/or
71 * modify it under the terms of the GNU General Public License
72 * as published by the Free Software Foundation; either version 2
73 * of the License, or (at your option) any later version.
75 * This program is distributed in the hope that it will be useful,
76 * but WITHOUT ANY WARRANTY; without even the implied warranty of
77 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
78 * GNU General Public License for more details.
80 * You should have received a copy of the GNU General Public License
81 * along with this program; if not, write to the Free Software
82 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
92 #include <epan/packet.h>
93 #include <epan/prefs.h>
94 #include <epan/emem.h>
95 #include <epan/etypes.h>
97 /* Place FW1 summary in proto tree */
98 static gboolean fw1_summary_in_tree = TRUE;
99 static gboolean fw1_with_uuid = FALSE;
100 static gboolean fw1_iflist_with_chain = FALSE;
102 /* Initialize the protocol and registered fields */
103 static int proto_fw1 = -1;
104 static int hf_fw1_direction = -1;
105 static int hf_fw1_chain = -1;
106 static int hf_fw1_interface = -1;
107 static int hf_fw1_uuid = -1;
108 static int hf_fw1_type = -1;
109 static int hf_fw1_trailer = -1;
111 /* Initialize the subtree pointers */
112 static gint ett_fw1 = -1;
114 #define ETH_HEADER_SIZE 14
116 #define MAX_INTERFACES 20
117 static char *p_interfaces[MAX_INTERFACES];
118 static int interface_anzahl=0;
125 for (i=0; i<interface_anzahl; i++) {
126 g_free(p_interfaces[i]);
128 interface_anzahl = 0;
132 dissect_fw1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
134 /* Set up structures needed to add the protocol subtree and manage it */
136 proto_tree *volatile fh_tree = NULL;
139 char *interface_name;
140 guint32 iface_len = 10;
142 emem_strbuf_t *header;
145 static const char fw1_header[] = "FW1 Monitor";
147 header = ep_strbuf_new_label(fw1_header);
149 /* Make entries in Protocol column and Info column on summary display */
150 col_set_str(pinfo->cinfo, COL_PROTOCOL, "FW1");
151 col_clear(pinfo->cinfo, COL_INFO);
154 /* g_snprintf(header, sizeof(header), fw1_header); */
156 /* fetch info to local variable */
157 direction = tvb_get_guint8(tvb, 0);
159 if (!fw1_iflist_with_chain)
162 chain = tvb_get_guint8(tvb, 1);
167 interface_name=ep_alloc(iface_len+1);
168 tvb_get_nstringz0(tvb, 2, iface_len+1, interface_name);
170 /* Known interface name - if not, remember it */
172 for (i=0; i<interface_anzahl; i++) {
173 if ( strcmp(p_interfaces[i], interface_name) == 0 ) {
178 if (!found && interface_anzahl < MAX_INTERFACES) {
179 p_interfaces[interface_anzahl] = g_strdup(interface_name);
183 /* display all interfaces always in the same order */
184 for (i=0; i<interface_anzahl; i++) {
185 if ( strcmp(p_interfaces[i], interface_name) == 0 ) {
186 ep_strbuf_append_printf(header, " %c%c %s %c%c",
187 direction == 'i' ? 'i' : (direction == 'O' ? 'O' : ' '),
188 (direction == 'i' || direction == 'O') ? chain : ' ',
190 direction == 'I' ? 'I' : (direction == 'o' ? 'o' : ' '),
191 (direction == 'I' || direction == 'o') ? chain : ' '
194 ep_strbuf_append_printf(header, " %s ", p_interfaces[i]);
198 if (check_col(pinfo->cinfo, COL_IF_DIR))
199 col_add_str(pinfo->cinfo, COL_IF_DIR, header->str + sizeof(fw1_header) + 1);
202 if (!fw1_summary_in_tree)
203 /* Do not show the summary in Protocol Tree */
204 ti = proto_tree_add_protocol_format(tree, proto_fw1, tvb, 0, ETH_HEADER_SIZE, "%s", fw1_header);
206 ti = proto_tree_add_protocol_format(tree, proto_fw1, tvb, 0, ETH_HEADER_SIZE, "%s", header->str);
208 /* create display subtree for the protocol */
209 fh_tree = proto_item_add_subtree(ti, ett_fw1);
211 proto_tree_add_item(fh_tree, hf_fw1_direction, tvb, 0, 1, FALSE);
213 if (fw1_iflist_with_chain)
214 proto_tree_add_item(fh_tree, hf_fw1_chain, tvb, 1, 1, FALSE);
216 proto_tree_add_item(fh_tree, hf_fw1_interface, tvb, 2, iface_len, FALSE);
219 proto_tree_add_item(fh_tree, hf_fw1_uuid, tvb, 8, 4, FALSE);
222 etype = tvb_get_ntohs(tvb, 12);
223 ethertype(etype, tvb, ETH_HEADER_SIZE, pinfo, tree, fh_tree, hf_fw1_type, hf_fw1_trailer, 0);
227 proto_register_fw1(void)
229 static hf_register_info hf[] = {
231 { "Direction", "fw1.direction", FT_STRING, BASE_NONE, NULL, 0x0,
234 { "Chain Position", "fw1.chain", FT_STRING, BASE_NONE, NULL, 0x0,
237 { "Interface", "fw1.interface", FT_STRING, BASE_NONE, NULL, 0x0,
240 { "UUID", "fw1.uuid", FT_UINT32, BASE_DEC, NULL, 0x0,
242 /* registered here but handled in ethertype.c */
244 { "Type", "fw1.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0,
247 /* Setup protocol subtree array */
248 static gint *ett[] = {
251 module_t *fw1_module;
253 /* Register the protocol name and description */
254 proto_fw1 = proto_register_protocol("Checkpoint FW-1", "FW-1", "fw1");
255 /* Required function calls to register the header fields and subtrees used */
256 proto_register_field_array(proto_fw1, hf, array_length(hf));
257 proto_register_subtree_array(ett, array_length(ett));
259 /* Register configuration preferences */
260 fw1_module = prefs_register_protocol(proto_fw1, NULL);
261 prefs_register_bool_preference(fw1_module, "summary_in_tree",
262 "Show FireWall-1 summary in protocol tree",
263 "Whether the FireWall-1 summary line should be shown in the protocol tree",
264 &fw1_summary_in_tree);
265 prefs_register_bool_preference(fw1_module, "with_uuid",
266 "Monitor file includes UUID",
267 "Whether the Firewall-1 monitor file includes UUID information",
269 prefs_register_bool_preference(fw1_module, "iflist_with_chain",
270 "Interface list includes chain position",
271 "Whether the interface list includes the chain position",
272 &fw1_iflist_with_chain);
274 register_dissector("fw1", dissect_fw1, proto_fw1);
276 register_init_routine(fw1_init);