Set the eol-style and keywords properties.

Use "tvb_reported_length_remaining()", not "tvb_length_remaining()", in
the loop parsing the packet contents, so we throw an exception on a
short frame (to mark that it *is* a short frame).

Use "tvb_format_text()" for text strings, so we don't have a problem
with non-printable characters.

Use "ether_to_str()" to turn MAC addresses into strings.

Clean up indentation.

svn path=/trunk/; revision=13679
This commit is contained in:
Guy Harris 2005-03-09 10:57:58 +00:00
parent 87c16299db
commit 56f04fe686
1 changed files with 11 additions and 13 deletions

View File

@ -1,16 +1,14 @@
/* packet-dtp.c /* packet-dtp.c
* Routines for the disassembly for Dynamic Trunking Protocol * Routines for the disassembly for Cisco Dynamic Trunking Protocol
* *
* $Id:$ * $Id$
* *
* Ethereal - Network traffic analyzer * Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com> * By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs * Copyright 1998 Gerald Combs
* *
*
* DTP support added by Charlie Lenahan <clenahan@fortresstech.com> * DTP support added by Charlie Lenahan <clenahan@fortresstech.com>
* *
*
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
@ -90,7 +88,7 @@ dissect_dtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree_add_item(dtp_tree, hf_dtp_version, tvb, offset, 1, FALSE); proto_tree_add_item(dtp_tree, hf_dtp_version, tvb, offset, 1, FALSE);
offset += 1; offset += 1;
while (tvb_length_remaining(tvb, offset) ) { while (tvb_reported_length_remaining(tvb, offset) > 0) {
int type, length, valuelength; int type, length, valuelength;
type = tvb_get_ntohs(tvb, offset); type = tvb_get_ntohs(tvb, offset);
@ -128,8 +126,8 @@ dissect_dtp_tlv(tvbuff_t *tvb, int offset, int length,
case TRUNK_NAME_NUM: case TRUNK_NAME_NUM:
if (length > 0) { if (length > 0) {
proto_item_set_text(ti, "Trunk Name: %s", tvb_get_ptr(tvb, offset,length)); proto_item_set_text(ti, "Trunk Name: %s", tvb_format_text(tvb, offset, length - 1));
proto_tree_add_text(tree, tvb, offset, length, "Trunk Name: %s", tvb_get_ptr(tvb, offset,length)); proto_tree_add_text(tree, tvb, offset, length, "Trunk Name: %s", tvb_format_text(tvb, offset, length - 1));
} else { } else {
proto_item_set_text(ti, "Trunk Name: Bad length %u", length); proto_item_set_text(ti, "Trunk Name: Bad length %u", length);
proto_tree_add_text(tree, tvb, offset, length, "Trunk Name: Bad length %u", length); proto_tree_add_text(tree, tvb, offset, length, "Trunk Name: Bad length %u", length);
@ -155,7 +153,7 @@ dissect_dtp_tlv(tvbuff_t *tvb, int offset, int length,
break; break;
case TYPE_3_NUM: case TYPE_3_NUM:
if (length > 0 ) { if (length > 0) {
proto_item_set_text(ti, proto_item_set_text(ti,
"Type 3: 0x%02x", "Type 3: 0x%02x",
tvb_get_guint8(tvb, offset)); tvb_get_guint8(tvb, offset));
@ -177,8 +175,8 @@ dissect_dtp_tlv(tvbuff_t *tvb, int offset, int length,
if (length == 6) { if (length == 6) {
const guint8 *macptr=tvb_get_ptr(tvb,offset,length); const guint8 *macptr=tvb_get_ptr(tvb,offset,length);
proto_item_set_text(ti, "Some MAC: %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x", proto_item_set_text(ti, "Some MAC: %s",
macptr[0], macptr[1], macptr[2], macptr[3], macptr[4], macptr[5]); ether_to_str(macptr)); /* XXX - resolve? */
proto_tree_add_ether(tree, hf_dtp_some_mac, tvb, offset,length,macptr); proto_tree_add_ether(tree, hf_dtp_some_mac, tvb, offset,length,macptr);
} else { } else {
proto_item_set_text(ti, proto_item_set_text(ti,
@ -223,9 +221,9 @@ proto_register_dtp(void)
&ett_dtp_tlv, &ett_dtp_tlv,
}; };
proto_dtp = proto_register_protocol("Dynamic Trunking Protocol", "DTP", "dtp"); proto_dtp = proto_register_protocol("Dynamic Trunking Protocol", "DTP", "dtp");
proto_register_field_array(proto_dtp, hf, array_length(hf)); proto_register_field_array(proto_dtp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett)); proto_register_subtree_array(ett, array_length(ett));
} }
void void