2 * Routines for Ethernet header disassembly of FW1 "monitor" files
3 * Copyright 2002,2003, Alfred Koebler <ako@icon.de>
4 * Copyright 2018, Alfred Koebler <Alfred.Koebler2002ATgmx.de>
6 * Wireshark - Network traffic analyzer
7 * By Alfred Koebler <ako@icon.de>
8 * By Alfred Koebler <Alfred.Koebler2002ATgmx.de>
9 * Copyright 2002,2003,2018 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 * e before VPN encryption
27 * E after VPN encryption
28 * - the name of the interface
30 * What's the problem ?
31 * Think about one packet traveling across the firewall.
32 * With wireshark you will see 4 lines in the Top Pane.
33 * To analyze a problem it is helpful to see the additional information
34 * in the protocol tree of the Middle Pane.
36 * The presentation of the summary line is designed in the following way:
37 * Every time the next selected packet in the Top Pane includes a
38 * "new" interface name the name is added to the list in the summary line.
39 * The interface names are listed one after the other.
40 * The position of the interface names didn't change.
42 * And who are the 4 places represented ?
43 * The interface name represents the firewall module of the interface.
44 * On the left side of the interface name is the interface module.
45 * On the right side of the interface name is the "IP" module.
47 * Example for a ping from the firewall to another host:
48 * For the four lines in the Top Pane you will see the according lines
55 * Example for a packet traversing through the Firewall, first through
56 * the inner side firewall module then through the outer side firewall module:
63 * Add new column with summary of FW-1 interface/direction
66 * Additional interpretation of field Chain Position.
67 * Show the chain position in the interface list.
68 * Support for new format of fw monitor file
69 * written by option -u | -s for UUID/SUUID.
70 * NOTICE: First paket will have UUID == 0 !
72 * SPDX-License-Identifier: GPL-2.0-or-later
75 * added inspection points "e" and "E"
81 #include <epan/packet.h>
82 #include <epan/prefs.h>
83 #include <epan/etypes.h>
85 void proto_register_fw1(void);
86 void proto_reg_handoff_fw1(void);
88 /* Place FW1 summary in proto tree */
89 static bool fw1_summary_in_tree
= true;
90 static bool fw1_with_uuid
;
91 static bool fw1_iflist_with_chain
;
93 static dissector_handle_t ethertype_handle
;
95 /* Initialize the protocol and registered fields */
97 static int hf_fw1_direction
;
98 static int hf_fw1_chain
;
99 static int hf_fw1_interface
;
100 static int hf_fw1_uuid
;
101 static int hf_fw1_type
;
102 static int hf_fw1_trailer
;
104 /* Initialize the subtree pointers */
107 #define ETH_HEADER_SIZE 14
109 #define MAX_INTERFACES 20
110 static char *p_interfaces
[MAX_INTERFACES
];
111 static int interface_anzahl
=0;
116 interface_anzahl
= 0;
120 dissect_fw1(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
122 /* Set up structures needed to add the protocol subtree and manage it */
124 proto_tree
*fh_tree
= NULL
;
127 char *interface_name
;
128 uint32_t iface_len
= 10;
129 wmem_strbuf_t
*header
;
132 static const char fw1_header
[] = "FW1 Monitor";
133 ethertype_data_t ethertype_data
;
135 header
= wmem_strbuf_create(pinfo
->pool
);
136 wmem_strbuf_append(header
, fw1_header
);
138 /* Make entries in Protocol column and Info column on summary display */
139 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "FW1");
140 col_clear(pinfo
->cinfo
, COL_INFO
);
142 /* fetch info to local variable */
143 direction
= tvb_get_uint8(tvb
, 0);
145 if (!fw1_iflist_with_chain
)
148 chain
= tvb_get_uint8(tvb
, 1);
153 interface_name
=tvb_get_stringzpad(pinfo
->pool
, tvb
, 2, iface_len
, ENC_ASCII
|ENC_NA
);
155 /* Known interface name - if not, remember it */
157 for (i
=0; i
<interface_anzahl
; i
++) {
158 if ( strcmp(p_interfaces
[i
], interface_name
) == 0 ) {
163 if (!found
&& interface_anzahl
< MAX_INTERFACES
) {
164 p_interfaces
[interface_anzahl
] = wmem_strdup(wmem_file_scope(), interface_name
);
168 /* display all interfaces always in the same order */
169 for (i
=0; i
<interface_anzahl
; i
++) {
170 if ( strcmp(p_interfaces
[i
], interface_name
) == 0 ) {
171 wmem_strbuf_append_printf(header
, " %c%c %s %c%c",
172 direction
== 'i' ? 'i' : (direction
== 'O' ? 'O' : (direction
== 'E' ? 'E' : ' ') ),
173 (direction
== 'i' || direction
== 'O' || direction
== 'E') ? chain
: ' ',
175 direction
== 'I' ? 'I' : (direction
== 'o' ? 'o' : (direction
== 'e' ? 'e' : ' ') ),
176 (direction
== 'I' || direction
== 'o' || direction
== 'e') ? chain
: ' '
179 wmem_strbuf_append_printf(header
, " %s ", p_interfaces
[i
]);
183 col_add_str(pinfo
->cinfo
, COL_IF_DIR
, wmem_strbuf_get_str(header
) + sizeof(fw1_header
) + 1);
186 if (!fw1_summary_in_tree
)
187 /* Do not show the summary in Protocol Tree */
188 ti
= proto_tree_add_protocol_format(tree
, proto_fw1
, tvb
, 0, ETH_HEADER_SIZE
, "%s", fw1_header
);
190 ti
= proto_tree_add_protocol_format(tree
, proto_fw1
, tvb
, 0, ETH_HEADER_SIZE
, "%s", wmem_strbuf_get_str(header
));
192 /* create display subtree for the protocol */
193 fh_tree
= proto_item_add_subtree(ti
, ett_fw1
);
195 proto_tree_add_item(fh_tree
, hf_fw1_direction
, tvb
, 0, 1, ENC_ASCII
);
197 if (fw1_iflist_with_chain
)
198 proto_tree_add_item(fh_tree
, hf_fw1_chain
, tvb
, 1, 1, ENC_ASCII
);
200 proto_tree_add_item(fh_tree
, hf_fw1_interface
, tvb
, 2, iface_len
, ENC_ASCII
);
203 proto_tree_add_item(fh_tree
, hf_fw1_uuid
, tvb
, 8, 4, ENC_BIG_ENDIAN
);
206 ethertype_data
.etype
= tvb_get_ntohs(tvb
, 12);
207 proto_tree_add_uint(fh_tree
, hf_fw1_type
, tvb
, 12, 2, ethertype_data
.etype
);
209 ethertype_data
.payload_offset
= ETH_HEADER_SIZE
;
210 ethertype_data
.fh_tree
= fh_tree
;
211 ethertype_data
.trailer_id
= hf_fw1_trailer
;
212 ethertype_data
.fcs_len
= 0;
214 call_dissector_with_data(ethertype_handle
, tvb
, pinfo
, tree
, ðertype_data
);
215 return tvb_captured_length(tvb
);
219 proto_register_fw1(void)
221 static hf_register_info hf
[] = {
223 { "Direction", "fw1.direction", FT_STRING
, BASE_NONE
, NULL
, 0x0,
227 { "Chain Position", "fw1.chain", FT_STRING
, BASE_NONE
, NULL
, 0x0,
231 { "Interface", "fw1.interface", FT_STRING
, BASE_NONE
, NULL
, 0x0,
235 { "UUID", "fw1.uuid", FT_UINT32
, BASE_DEC
, NULL
, 0x0,
238 /* registered here but handled in ethertype.c */
240 { "Type", "fw1.type", FT_UINT16
, BASE_HEX
, VALS(etype_vals
), 0x0,
244 { "Trailer", "fw1.trailer", FT_BYTES
, BASE_NONE
, NULL
, 0x0,
248 /* Setup protocol subtree array */
249 static int *ett
[] = {
252 module_t
*fw1_module
;
255 /* Register the protocol name and description */
256 proto_fw1
= proto_register_protocol("Checkpoint FW-1", "FW-1", "fw1");
257 /* Required function calls to register the header fields and subtrees used */
258 proto_register_field_array(proto_fw1
, hf
, array_length(hf
));
259 proto_register_subtree_array(ett
, array_length(ett
));
261 /* Register configuration preferences */
262 fw1_module
= prefs_register_protocol(proto_fw1
, NULL
);
263 prefs_register_bool_preference(fw1_module
, "summary_in_tree",
264 "Show FireWall-1 summary in protocol tree",
265 "Whether the FireWall-1 summary line should be shown in the protocol tree",
266 &fw1_summary_in_tree
);
267 prefs_register_bool_preference(fw1_module
, "with_uuid",
268 "Monitor file includes UUID",
269 "Whether the Firewall-1 monitor file includes UUID information",
271 prefs_register_bool_preference(fw1_module
, "iflist_with_chain",
272 "Interface list includes chain position",
273 "Whether the interface list includes the chain position",
274 &fw1_iflist_with_chain
);
276 register_dissector("fw1", dissect_fw1
, proto_fw1
);
278 for (i
=0; i
<MAX_INTERFACES
; i
++) {
279 p_interfaces
[i
] = NULL
;
281 register_init_routine(fw1_init
);
285 proto_reg_handoff_fw1(void)
287 ethertype_handle
= find_dissector_add_dependency("ethertype", proto_fw1
);
291 * Editor modelines - https://www.wireshark.org/tools/modelines.html
296 * indent-tabs-mode: nil
299 * ex: set shiftwidth=2 tabstop=8 expandtab:
300 * :indentSize=2:tabSize=8:noTabs=true: