/* packet-trmac.c
* Routines for Token-Ring Media Access Control
- * Gilbert Ramirez <gram@xiexie.org>
+ * Gilbert Ramirez <gram@alumni.rice.edu>
*
- * $Id: packet-trmac.c,v 1.27 2001/01/03 06:55:34 guy Exp $
+ * $Id: packet-trmac.c,v 1.37 2002/08/02 23:36:04 jmayer Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* 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
# include "config.h"
#endif
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
#include <string.h>
#include <glib.h>
-#include "packet.h"
+#include <epan/packet.h>
+#include "packet-frame.h"
static int proto_trmac = -1;
static int hf_trmac_mv = -1;
proto_tree *sv_tree;
proto_item *ti;
- u_char errors[6]; /* isolating or non-isolating */
+ guchar errors[6]; /* isolating or non-isolating */
+
+ /* Check the SV length.
+ XXX - Should we do this in each case statement below, e.g. to force
+ an SV length of 6 for the NAUN address? */
+ if (sv_length < 1) {
+ proto_tree_add_protocol_format(tree, proto_malformed, tvb, svoff+0, 1,
+ "Invalid subvector length: %d bytes", sv_length);
+ return sv_length;
+ }
/* this just adds to the clutter on the screen...
proto_tree_add_text(tree, tvb, svoff, 1,
return sv_length;
}
-void
+static void
dissect_trmac(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree *mac_tree = NULL;
guint8 mv_val;
char *mv_text;
- CHECK_DISPLAY_AS_DATA(proto_trmac, tvb, pinfo, tree);
-
- pinfo->current_proto = "TR MAC";
- if (check_col(pinfo->fd, COL_PROTOCOL))
- col_set_str(pinfo->fd, COL_PROTOCOL, "TR MAC");
+ if (check_col(pinfo->cinfo, COL_PROTOCOL))
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "TR MAC");
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_clear(pinfo->cinfo, COL_INFO);
mv_val = tvb_get_guint8(tvb, 3);
/* Interpret the major vector */
mv_text = val_to_str(mv_val, major_vector_vs, "Unknown Major Vector: %d\n");
- if (check_col(pinfo->fd, COL_INFO))
- col_add_str(pinfo->fd, COL_INFO, mv_text);
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_add_str(pinfo->cinfo, COL_INFO, mv_text);
if (tree) {
mv_length = tvb_get_ntohs(tvb, 0);
static hf_register_info hf[] = {
{ &hf_trmac_mv,
{ "Major Vector", "trmac.mvec", FT_UINT8, BASE_HEX, major_vector_vs, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_length,
{ "Total Length", "trmac.length", FT_UINT8, BASE_DEC, NULL, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_srcclass,
{ "Source Class", "trmac.srcclass", FT_UINT8, BASE_HEX, classes_vs, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_dstclass,
{ "Destination Class", "trmac.dstclass", FT_UINT8, BASE_HEX, classes_vs, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_sv,
{ "Sub-Vector", "trmac.svec", FT_UINT8, BASE_HEX, NULL, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_errors_iso,
{ "Isolating Errors", "trmac.errors.iso", FT_UINT16, BASE_DEC, NULL, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_errors_line,
{ "Line Errors", "trmac.errors.line", FT_UINT8, BASE_DEC, NULL, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_errors_internal,
{ "Internal Errors", "trmac.errors.internal", FT_UINT8, BASE_DEC, NULL, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_errors_burst,
{ "Burst Errors", "trmac.errors.burst", FT_UINT8, BASE_DEC, NULL, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_errors_ac,
{ "A/C Errors", "trmac.errors.ac", FT_UINT8, BASE_DEC, NULL, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_errors_abort,
{ "Abort Delimiter Transmitted Errors", "trmac.errors.abort", FT_UINT8, BASE_DEC, NULL, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_errors_noniso,
{ "Non-Isolating Errors", "trmac.errors.noniso", FT_UINT16, BASE_DEC, NULL, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_errors_lost,
{ "Lost Frame Errors", "trmac.errors.lost", FT_UINT8, BASE_DEC, NULL, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_errors_congestion,
{ "Receiver Congestion Errors", "trmac.errors.congestion", FT_UINT8, BASE_DEC, NULL, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_errors_fc,
{ "Frame-Copied Errors", "trmac.errors.fc", FT_UINT8, BASE_DEC, NULL, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_errors_freq,
{ "Frequency Errors", "trmac.errors.freq", FT_UINT8, BASE_DEC, NULL, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_errors_token,
{ "Token Errors", "trmac.errors.token", FT_UINT8, BASE_DEC, NULL, 0x0,
- "" }},
+ "", HFILL }},
{ &hf_trmac_naun,
{ "NAUN", "trmac.naun", FT_ETHER, BASE_DEC, NULL, 0x0,
- "" }},
+ "", HFILL }},
};
static gint *ett[] = {
&ett_tr_mac,
"TR MAC", "trmac");
proto_register_field_array(proto_trmac, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
+
+ register_dissector("trmac", dissect_trmac, proto_trmac);
}