3 * Top-most dissector. Decides dissector based on Wiretap Encapsulation Type.
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 2000 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 #include <epan/packet.h>
37 #include <epan/timestamp.h>
38 #include "packet-frame.h"
39 #include <epan/prefs.h>
41 #include <epan/expert.h>
42 #include <epan/crypt/md5.h>
45 #include "color_filters.h"
48 int proto_pkt_comment = -1;
49 int hf_frame_arrival_time = -1;
50 int hf_frame_shift_offset = -1;
51 int hf_frame_arrival_time_epoch = -1;
52 static int hf_frame_time_invalid = -1;
53 static int hf_frame_time_delta = -1;
54 static int hf_frame_time_delta_displayed = -1;
55 static int hf_frame_time_relative = -1;
56 static int hf_frame_time_reference = -1;
57 int hf_frame_number = -1;
58 int hf_frame_len = -1;
59 int hf_frame_capture_len = -1;
60 static int hf_frame_p2p_dir = -1;
61 static int hf_frame_file_off = -1;
62 static int hf_frame_md5_hash = -1;
63 static int hf_frame_marked = -1;
64 static int hf_frame_ignored = -1;
65 static int hf_link_number = -1;
66 static int hf_frame_protocols = -1;
67 static int hf_frame_color_filter_name = -1;
68 static int hf_frame_color_filter_text = -1;
69 static int hf_frame_interface_id = -1;
70 static int hf_comments_text = -1;
72 static int proto_short = -1;
73 int proto_malformed = -1;
74 static int proto_unreassembled = -1;
76 static gint ett_frame = -1;
77 static gint ett_comments = -1;
79 static int frame_tap = -1;
81 static dissector_handle_t data_handle;
82 static dissector_handle_t docsis_handle;
85 static gboolean show_file_off = FALSE;
86 static gboolean force_docsis_encap = FALSE;
87 static gboolean generate_md5_hash = FALSE;
88 static gboolean generate_epoch_time = TRUE;
89 static gboolean generate_bits_field = TRUE;
91 static const value_string p2p_dirs[] = {
92 { P2P_DIR_UNKNOWN, "Unknown" },
93 { P2P_DIR_SENT, "Sent" },
94 { P2P_DIR_RECV, "Received" },
98 dissector_table_t wtap_encap_dissector_table;
100 static GSList *frame_end_routines = NULL;
103 * Routine used to register frame end routine. The routine should only
104 * be registered when the dissector is used in the frame, not in the
105 * proto_register_XXX function.
108 register_frame_end_routine(void (*func)(void))
110 frame_end_routines = g_slist_append(frame_end_routines, (gpointer)func);
113 typedef void (*void_func_t)(void);
116 call_frame_end_routine(gpointer routine, gpointer dummy _U_)
118 void_func_t func = (void_func_t)routine;
123 dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
125 proto_item *volatile ti = NULL, *comment_item;
126 guint cap_len = 0, frame_len = 0;
127 proto_tree *volatile tree;
128 proto_tree *comments_tree;
130 const gchar *cap_plurality, *frame_plurality;
134 pinfo->current_proto = "Frame";
136 if (pinfo->pseudo_header != NULL) {
137 switch (pinfo->fd->lnk_t) {
139 case WTAP_ENCAP_WFLEET_HDLC:
140 case WTAP_ENCAP_CHDLC_WITH_PHDR:
141 case WTAP_ENCAP_PPP_WITH_PHDR:
142 case WTAP_ENCAP_SDLC:
143 case WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR:
144 pinfo->p2p_dir = pinfo->pseudo_header->p2p.sent ?
145 P2P_DIR_SENT : P2P_DIR_RECV;
148 case WTAP_ENCAP_BLUETOOTH_HCI:
149 pinfo->p2p_dir = pinfo->pseudo_header->bthci.sent;
152 case WTAP_ENCAP_LAPB:
153 case WTAP_ENCAP_FRELAY_WITH_PHDR:
155 (pinfo->pseudo_header->x25.flags & FROM_DCE) ?
156 P2P_DIR_RECV : P2P_DIR_SENT;
159 case WTAP_ENCAP_ISDN:
160 case WTAP_ENCAP_V5_EF:
161 case WTAP_ENCAP_DPNSS:
162 case WTAP_ENCAP_BACNET_MS_TP_WITH_PHDR:
163 pinfo->p2p_dir = pinfo->pseudo_header->isdn.uton ?
164 P2P_DIR_SENT : P2P_DIR_RECV;
167 case WTAP_ENCAP_LINUX_LAPD:
168 pinfo->p2p_dir = (pinfo->pseudo_header->lapd.pkttype == 3 ||
169 pinfo->pseudo_header->lapd.pkttype == 4) ?
170 P2P_DIR_SENT : P2P_DIR_RECV;
173 case WTAP_ENCAP_MTP2_WITH_PHDR:
174 pinfo->p2p_dir = pinfo->pseudo_header->mtp2.sent ?
175 P2P_DIR_SENT : P2P_DIR_RECV;
176 pinfo->link_number = pinfo->pseudo_header->mtp2.link_number;
177 pinfo->annex_a_used = pinfo->pseudo_header->mtp2.annex_a_used;
180 case WTAP_ENCAP_GSM_UM:
181 pinfo->p2p_dir = pinfo->pseudo_header->gsm_um.uplink ?
182 P2P_DIR_SENT : P2P_DIR_RECV;
188 if(pinfo->fd->opt_comment){
189 item = proto_tree_add_item(tree, proto_pkt_comment, tvb, 0, -1, ENC_NA);
190 comments_tree = proto_item_add_subtree(item, ett_comments);
191 comment_item = proto_tree_add_string_format(comments_tree, hf_comments_text, tvb, 0, -1,
192 pinfo->fd->opt_comment, "%s",
193 pinfo->fd->opt_comment);
194 expert_add_info_format(pinfo, comment_item, PI_COMMENTS_GROUP, PI_COMMENT,
195 "%s", pinfo->fd->opt_comment);
200 /* if FRAME is not referenced from any filters we dont need to worry about
201 generating any tree items. */
202 if(!proto_field_is_referenced(tree, proto_frame)) {
204 if(pinfo->fd->flags.has_ts) {
205 if(pinfo->fd->abs_ts.nsecs < 0 || pinfo->fd->abs_ts.nsecs >= 1000000000)
206 expert_add_info_format(pinfo, NULL, PI_MALFORMED, PI_WARN,
207 "Arrival Time: Fractional second out of range (0-1000000000)");
211 gboolean old_visible;
213 /* Put in frame header information. */
214 cap_len = tvb_length(tvb);
215 frame_len = tvb_reported_length(tvb);
217 cap_plurality = plurality(cap_len, "", "s");
218 frame_plurality = plurality(frame_len, "", "s");
220 ti = proto_tree_add_protocol_format(tree, proto_frame, tvb, 0, -1,
221 "Frame %u: %u byte%s on wire",
222 pinfo->fd->num, frame_len, frame_plurality);
223 if (generate_bits_field)
224 proto_item_append_text(ti, " (%u bits)", frame_len * 8);
225 proto_item_append_text(ti, ", %u byte%s captured",
226 cap_len, cap_plurality);
227 if (generate_bits_field) {
228 proto_item_append_text(ti, " (%u bits)",
231 if (pinfo->fd->flags.has_if_id) {
232 proto_item_append_text(ti, " on interface %u",
233 pinfo->fd->interface_id);
236 fh_tree = proto_item_add_subtree(ti, ett_frame);
238 if (pinfo->fd->flags.has_if_id)
239 proto_tree_add_uint(fh_tree, hf_frame_interface_id, tvb, 0, 0, pinfo->fd->interface_id);
241 if (pinfo->fd->flags.has_ts) {
242 proto_tree_add_time(fh_tree, hf_frame_arrival_time, tvb,
243 0, 0, &(pinfo->fd->abs_ts));
244 if(pinfo->fd->abs_ts.nsecs < 0 || pinfo->fd->abs_ts.nsecs >= 1000000000) {
245 item = proto_tree_add_none_format(fh_tree, hf_frame_time_invalid, tvb,
246 0, 0, "Arrival Time: Fractional second %09ld is invalid, the valid range is 0-1000000000", (long) pinfo->fd->abs_ts.nsecs);
247 PROTO_ITEM_SET_GENERATED(item);
248 expert_add_info_format(pinfo, item, PI_MALFORMED, PI_WARN, "Arrival Time: Fractional second out of range (0-1000000000)");
250 item = proto_tree_add_time(fh_tree, hf_frame_shift_offset, tvb,
251 0, 0, &(pinfo->fd->shift_offset));
252 PROTO_ITEM_SET_GENERATED(item);
254 if(generate_epoch_time) {
255 proto_tree_add_time(fh_tree, hf_frame_arrival_time_epoch, tvb,
256 0, 0, &(pinfo->fd->abs_ts));
259 item = proto_tree_add_time(fh_tree, hf_frame_time_delta, tvb,
260 0, 0, &(pinfo->fd->del_cap_ts));
261 PROTO_ITEM_SET_GENERATED(item);
263 item = proto_tree_add_time(fh_tree, hf_frame_time_delta_displayed, tvb,
264 0, 0, &(pinfo->fd->del_dis_ts));
265 PROTO_ITEM_SET_GENERATED(item);
267 item = proto_tree_add_time(fh_tree, hf_frame_time_relative, tvb,
268 0, 0, &(pinfo->fd->rel_ts));
269 PROTO_ITEM_SET_GENERATED(item);
271 if(pinfo->fd->flags.ref_time){
272 ti = proto_tree_add_item(fh_tree, hf_frame_time_reference, tvb, 0, 0, ENC_NA);
273 PROTO_ITEM_SET_GENERATED(ti);
277 proto_tree_add_uint(fh_tree, hf_frame_number, tvb,
278 0, 0, pinfo->fd->num);
280 proto_tree_add_uint_format(fh_tree, hf_frame_len, tvb,
281 0, 0, frame_len, "Frame Length: %u byte%s (%u bits)",
282 frame_len, frame_plurality, frame_len * 8);
284 proto_tree_add_uint_format(fh_tree, hf_frame_capture_len, tvb,
285 0, 0, cap_len, "Capture Length: %u byte%s (%u bits)",
286 cap_len, cap_plurality, cap_len * 8);
288 if (generate_md5_hash) {
291 md5_byte_t digest[16];
292 gchar *digest_string;
294 cp = tvb_get_ptr(tvb, 0, cap_len);
297 md5_append(&md_ctx, cp, cap_len);
298 md5_finish(&md_ctx, digest);
300 digest_string = bytestring_to_str(digest, 16, '\0');
301 ti = proto_tree_add_string(fh_tree, hf_frame_md5_hash, tvb, 0, 0, digest_string);
302 PROTO_ITEM_SET_GENERATED(ti);
305 ti = proto_tree_add_boolean(fh_tree, hf_frame_marked, tvb, 0, 0,pinfo->fd->flags.marked);
306 PROTO_ITEM_SET_GENERATED(ti);
308 ti = proto_tree_add_boolean(fh_tree, hf_frame_ignored, tvb, 0, 0,pinfo->fd->flags.ignored);
309 PROTO_ITEM_SET_GENERATED(ti);
311 if(proto_field_is_referenced(tree, hf_frame_protocols)) {
312 /* we are going to be using proto_item_append_string() on
313 * hf_frame_protocols, and we must therefore disable the
314 * TRY_TO_FAKE_THIS_ITEM() optimisation for the tree by
315 * setting it as visible.
317 * See proto.h for details.
319 old_visible = proto_tree_set_visible(fh_tree, TRUE);
320 ti = proto_tree_add_string(fh_tree, hf_frame_protocols, tvb, 0, 0, "");
321 PROTO_ITEM_SET_GENERATED(ti);
322 proto_tree_set_visible(fh_tree, old_visible);
324 pinfo->layer_names = g_string_new("");
327 pinfo->layer_names = NULL;
329 /* Check for existences of P2P pseudo header */
330 if (pinfo->p2p_dir != P2P_DIR_UNKNOWN) {
331 proto_tree_add_int(fh_tree, hf_frame_p2p_dir, tvb,
332 0, 0, pinfo->p2p_dir);
335 /* Check for existences of MTP2 link number */
336 if ((pinfo->pseudo_header != NULL ) && (pinfo->fd->lnk_t == WTAP_ENCAP_MTP2_WITH_PHDR)) {
337 proto_tree_add_uint(fh_tree, hf_link_number, tvb,
338 0, 0, pinfo->link_number);
342 proto_tree_add_int64_format(fh_tree, hf_frame_file_off, tvb,
343 0, 0, pinfo->fd->file_off,
344 "File Offset: %" G_GINT64_MODIFIER "d (0x%" G_GINT64_MODIFIER "x)",
345 pinfo->fd->file_off, pinfo->fd->file_off);
348 if(pinfo->fd->color_filter != NULL) {
349 const color_filter_t *color_filter = pinfo->fd->color_filter;
350 item = proto_tree_add_string(fh_tree, hf_frame_color_filter_name, tvb,
351 0, 0, color_filter->filter_name);
352 PROTO_ITEM_SET_GENERATED(item);
353 item = proto_tree_add_string(fh_tree, hf_frame_color_filter_text, tvb,
354 0, 0, color_filter->filter_text);
355 PROTO_ITEM_SET_GENERATED(item);
359 if (pinfo->fd->flags.ignored) {
360 /* Ignored package, stop handling here */
361 col_set_str(pinfo->cinfo, COL_INFO, "<Ignored>");
362 proto_tree_add_text (tree, tvb, 0, -1, "This frame is marked as ignored");
366 /* Portable Exception Handling to trap Wireshark specific exceptions like BoundsError exceptions */
369 /* Win32: Visual-C Structured Exception Handling (SEH) to trap hardware exceptions like memory access violations */
370 /* (a running debugger will be called before the except part below) */
373 if ((force_docsis_encap) && (docsis_handle)) {
374 call_dissector(docsis_handle, tvb, pinfo, parent_tree);
376 if (!dissector_try_uint(wtap_encap_dissector_table, pinfo->fd->lnk_t,
377 tvb, pinfo, parent_tree)) {
379 col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNKNOWN");
380 col_add_fstr(pinfo->cinfo, COL_INFO, "WTAP_ENCAP = %d",
382 call_dissector(data_handle,tvb, pinfo, parent_tree);
386 } __except(EXCEPTION_EXECUTE_HANDLER /* handle all exceptions */) {
387 switch(GetExceptionCode()) {
388 case(STATUS_ACCESS_VIOLATION):
389 show_exception(tvb, pinfo, parent_tree, DissectorError,
390 "STATUS_ACCESS_VIOLATION: dissector accessed an invalid memory address");
392 case(STATUS_INTEGER_DIVIDE_BY_ZERO):
393 show_exception(tvb, pinfo, parent_tree, DissectorError,
394 "STATUS_INTEGER_DIVIDE_BY_ZERO: dissector tried an integer division by zero");
396 case(STATUS_STACK_OVERFLOW):
397 show_exception(tvb, pinfo, parent_tree, DissectorError,
398 "STATUS_STACK_OVERFLOW: dissector overflowed the stack (e.g. endless loop)");
399 /* XXX - this will have probably corrupted the stack, which makes problems later in the exception code */
401 /* XXX - add other hardware exception codes as required */
403 show_exception(tvb, pinfo, parent_tree, DissectorError,
404 g_strdup_printf("dissector caused an unknown exception: 0x%x", GetExceptionCode()));
409 CATCH(OutOfMemoryError) {
413 show_exception(tvb, pinfo, parent_tree, EXCEPT_CODE, GET_MESSAGE);
417 if (tree && pinfo->layer_names) {
418 proto_item_append_string(ti, pinfo->layer_names->str);
419 g_string_free(pinfo->layer_names, TRUE);
420 pinfo->layer_names = NULL;
423 /* Call postdissectors if we have any (while trying to avoid another
426 if (have_postdissector()) {
429 /* Win32: Visual-C Structured Exception Handling (SEH) to trap hardware exceptions like memory access violations */
430 /* (a running debugger will be called before the except part below) */
433 call_all_postdissectors(tvb, pinfo, parent_tree);
435 } __except(EXCEPTION_EXECUTE_HANDLER /* handle all exceptions */) {
436 switch(GetExceptionCode()) {
437 case(STATUS_ACCESS_VIOLATION):
438 show_exception(tvb, pinfo, parent_tree, DissectorError,
439 "STATUS_ACCESS_VIOLATION: dissector accessed an invalid memory address");
441 case(STATUS_INTEGER_DIVIDE_BY_ZERO):
442 show_exception(tvb, pinfo, parent_tree, DissectorError,
443 "STATUS_INTEGER_DIVIDE_BY_ZERO: dissector tried an integer division by zero");
445 case(STATUS_STACK_OVERFLOW):
446 show_exception(tvb, pinfo, parent_tree, DissectorError,
447 "STATUS_STACK_OVERFLOW: dissector overflowed the stack (e.g. endless loop)");
448 /* XXX - this will have probably corrupted the stack, which makes problems later in the exception code */
450 /* XXX - add other hardware exception codes as required */
452 show_exception(tvb, pinfo, parent_tree, DissectorError,
453 g_strdup_printf("dissector caused an unknown exception: 0x%x", GetExceptionCode()));
458 CATCH(OutOfMemoryError) {
462 show_exception(tvb, pinfo, parent_tree, EXCEPT_CODE, GET_MESSAGE);
467 tap_queue_packet(frame_tap, pinfo, NULL);
470 if (frame_end_routines) {
471 g_slist_foreach(frame_end_routines, &call_frame_end_routine, NULL);
472 g_slist_free(frame_end_routines);
473 frame_end_routines = NULL;
478 show_exception(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
479 unsigned long exception, const char *exception_message)
481 static const char dissector_error_nomsg[] =
482 "Dissector writer didn't bother saying what the error was";
488 case ScsiBoundsError:
489 col_append_str(pinfo->cinfo, COL_INFO, "[SCSI transfer limited due to allocation_length too small]");
490 /*item =*/ proto_tree_add_protocol_format(tree, proto_short, tvb, 0, 0,
491 "SCSI transfer limited due to allocation_length too small: %s truncated]", pinfo->current_proto);
492 /* Don't record ScsiBoundsError exceptions as expert events - they merely
493 * reflect a normal SCSI condition.
494 * (any case where it's caused by something else is a bug). */
495 /* expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "Packet size limited");*/
499 col_append_str(pinfo->cinfo, COL_INFO, "[Packet size limited during capture]");
500 /*item =*/ proto_tree_add_protocol_format(tree, proto_short, tvb, 0, 0,
501 "[Packet size limited during capture: %s truncated]", pinfo->current_proto);
502 /* Don't record BoundsError exceptions as expert events - they merely
503 * reflect a capture done with a snapshot length too short to capture
505 * (any case where it's caused by something else is a bug). */
506 /* expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "Packet size limited");*/
509 case ReportedBoundsError:
510 show_reported_bounds_error(tvb, pinfo, tree);
514 col_append_fstr(pinfo->cinfo, COL_INFO,
515 "[Dissector bug, protocol %s: %s]",
516 pinfo->current_proto,
517 exception_message == NULL ?
518 dissector_error_nomsg : exception_message);
519 item = proto_tree_add_protocol_format(tree, proto_malformed, tvb, 0, 0,
520 "[Dissector bug, protocol %s: %s]",
521 pinfo->current_proto,
522 exception_message == NULL ?
523 dissector_error_nomsg : exception_message);
524 g_warning("Dissector bug, protocol %s, in packet %u: %s",
525 pinfo->current_proto, pinfo->fd->num,
526 exception_message == NULL ?
527 dissector_error_nomsg : exception_message);
528 expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR,
530 exception_message == NULL ?
531 dissector_error_nomsg : exception_message);
535 /* XXX - we want to know, if an unknown exception passed until here, don't we? */
536 g_assert_not_reached();
541 show_reported_bounds_error(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
545 if (pinfo->fragmented) {
547 * We were dissecting an unreassembled fragmented
548 * packet when the exception was thrown, so the
549 * problem isn't that the dissector expected
550 * something but it wasn't in the packet, the
551 * problem is that the dissector expected something
552 * but it wasn't in the fragment we dissected.
554 col_append_fstr(pinfo->cinfo, COL_INFO,
555 "[Unreassembled Packet%s] ",
556 pinfo->noreassembly_reason);
557 item = proto_tree_add_protocol_format(tree, proto_unreassembled,
558 tvb, 0, 0, "[Unreassembled Packet%s: %s]",
559 pinfo->noreassembly_reason, pinfo->current_proto);
560 expert_add_info_format(pinfo, item, PI_REASSEMBLE, PI_WARN, "Unreassembled Packet (Exception occurred)");
562 col_append_str(pinfo->cinfo, COL_INFO,
563 "[Malformed Packet]");
564 item = proto_tree_add_protocol_format(tree, proto_malformed,
565 tvb, 0, 0, "[Malformed Packet: %s]", pinfo->current_proto);
566 expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "Malformed Packet (Exception occurred)");
571 proto_register_frame(void)
573 static hf_register_info hf[] = {
574 { &hf_frame_arrival_time,
575 { "Arrival Time", "frame.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0,
576 "Absolute time when this frame was captured", HFILL }},
578 { &hf_frame_shift_offset,
579 { "Time shift for this packet","frame.offset_shift", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
580 "Time shift applied to this packet", HFILL }},
582 { &hf_frame_arrival_time_epoch,
583 { "Epoch Time", "frame.time_epoch", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
584 "Epoch time when this frame was captured", HFILL }},
586 { &hf_frame_time_invalid,
587 { "Arrival Timestamp invalid", "frame.time_invalid", FT_NONE, BASE_NONE, NULL, 0x0,
588 "The timestamp from the capture is out of the valid range", HFILL }},
590 { &hf_frame_time_delta,
591 { "Time delta from previous captured frame", "frame.time_delta", FT_RELATIVE_TIME, BASE_NONE, NULL,
595 { &hf_frame_time_delta_displayed,
596 { "Time delta from previous displayed frame", "frame.time_delta_displayed", FT_RELATIVE_TIME, BASE_NONE, NULL,
600 { &hf_frame_time_relative,
601 { "Time since reference or first frame", "frame.time_relative", FT_RELATIVE_TIME, BASE_NONE, NULL,
603 "Time relative to time reference or first frame", HFILL }},
605 { &hf_frame_time_reference,
606 { "This is a Time Reference frame", "frame.ref_time", FT_NONE, BASE_NONE, NULL, 0x0,
607 "This frame is a Time Reference frame", HFILL }},
610 { "Frame Number", "frame.number", FT_UINT32, BASE_DEC, NULL, 0x0,
614 { "Frame length on the wire", "frame.len", FT_UINT32, BASE_DEC, NULL, 0x0,
617 { &hf_frame_capture_len,
618 { "Frame length stored into the capture file", "frame.cap_len", FT_UINT32, BASE_DEC, NULL, 0x0,
621 { &hf_frame_md5_hash,
622 { "Frame MD5 Hash", "frame.md5_hash", FT_STRING, BASE_NONE, NULL, 0x0,
626 { "Point-to-Point Direction", "frame.p2p_dir", FT_INT8, BASE_DEC, VALS(p2p_dirs), 0x0,
630 { "Link Number", "frame.link_nr", FT_UINT16, BASE_DEC, NULL, 0x0,
633 { &hf_frame_file_off,
634 { "File Offset", "frame.file_off", FT_INT64, BASE_DEC, NULL, 0x0,
638 { "Frame is marked", "frame.marked", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
639 "Frame is marked in the GUI", HFILL }},
642 { "Frame is ignored", "frame.ignored", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
643 "Frame is ignored by the dissectors", HFILL }},
645 { &hf_frame_protocols,
646 { "Protocols in frame", "frame.protocols", FT_STRING, BASE_NONE, NULL, 0x0,
647 "Protocols carried by this frame", HFILL }},
649 { &hf_frame_color_filter_name,
650 { "Coloring Rule Name", "frame.coloring_rule.name", FT_STRING, BASE_NONE, NULL, 0x0,
651 "The frame matched the coloring rule with this name", HFILL }},
653 { &hf_frame_color_filter_text,
654 { "Coloring Rule String", "frame.coloring_rule.string", FT_STRING, BASE_NONE, NULL, 0x0,
655 "The frame matched this coloring rule string", HFILL }},
657 { &hf_frame_interface_id,
658 { "Interface id", "frame.interface_id", FT_UINT32, BASE_DEC, NULL, 0x0,
662 { "Comment", "comment", FT_STRING, BASE_NONE, NULL, 0x0,
665 static gint *ett[] = {
669 module_t *frame_module;
671 wtap_encap_dissector_table = register_dissector_table("wtap_encap",
672 "Wiretap encapsulation type", FT_UINT32, BASE_DEC);
674 proto_frame = proto_register_protocol("Frame", "Frame", "frame");
675 proto_pkt_comment = proto_register_protocol("Packet comments", "Pkt_Comment", "pkt_comment");
676 proto_register_field_array(proto_frame, hf, array_length(hf));
677 proto_register_subtree_array(ett, array_length(ett));
678 register_dissector("frame",dissect_frame,proto_frame);
680 /* You can't disable dissection of "Frame", as that would be
681 tantamount to not doing any dissection whatsoever. */
682 proto_set_cant_toggle(proto_frame);
684 proto_short = proto_register_protocol("Short Frame", "Short frame", "short");
685 proto_malformed = proto_register_protocol("Malformed Packet",
686 "Malformed packet", "malformed");
687 proto_unreassembled = proto_register_protocol(
688 "Unreassembled Fragmented Packet",
689 "Unreassembled fragmented packet", "unreassembled");
691 /* "Short Frame", "Malformed Packet", and "Unreassembled Fragmented
692 Packet" aren't really protocols, they're error indications;
693 disabling them makes no sense. */
694 proto_set_cant_toggle(proto_short);
695 proto_set_cant_toggle(proto_malformed);
696 proto_set_cant_toggle(proto_unreassembled);
698 /* Our preferences */
699 frame_module = prefs_register_protocol(proto_frame, NULL);
700 prefs_register_bool_preference(frame_module, "show_file_off",
701 "Show File Offset", "Show offset of frame in capture file", &show_file_off);
702 prefs_register_bool_preference(frame_module, "force_docsis_encap",
703 "Treat all frames as DOCSIS frames", "Treat all frames as DOCSIS Frames", &force_docsis_encap);
704 prefs_register_bool_preference(frame_module, "generate_md5_hash",
705 "Generate an MD5 hash of each frame",
706 "Whether or not MD5 hashes should be generated for each frame, useful for finding duplicate frames.",
708 prefs_register_bool_preference(frame_module, "generate_epoch_time",
709 "Generate an epoch time entry for each frame",
710 "Whether or not an Epoch time entry should be generated for each frame.",
711 &generate_epoch_time);
712 prefs_register_bool_preference(frame_module, "generate_bits_field",
713 "Show the number of bits in the frame",
714 "Whether or not the number of bits in the frame should be shown.",
715 &generate_bits_field);
717 frame_tap=register_tap("frame");
721 proto_reg_handoff_frame(void)
723 data_handle = find_dissector("data");
724 docsis_handle = find_dissector("docsis");