Ethereal-dev: [Ethereal-dev] Correction to previous COTP patch
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
Date: Tue, 17 Aug 2004 20:27:25 +0100
Hello, The previous patch to packet-clnp.c submitted had a bug - duplicate items added to the tree. Revised version below. Many thanks, Matthew Index: packet-clnp.c =================================================================== --- packet-clnp.c (revision 11753) +++ packet-clnp.c (working copy) @@ -77,6 +77,11 @@ static int hf_cotp_srcref = -1; static int hf_cotp_destref = -1; +static int hf_cotp_tpdu_number = -1; +static int hf_cotp_next_tpdu_number = -1; +static int hf_cotp_eot = -1; +static int hf_cotp_eot_extended = -1; + static int hf_cotp_type = -1; static int hf_cotp_segments = -1; static int hf_cotp_segment = -1; @@ -87,6 +92,11 @@ static int hf_cotp_segment_error = -1; static int hf_cotp_reassembled_in = -1; +static const true_false_string fragment_descriptions = { + "Yes", + "No" + }; + static int proto_cltp = -1; static gint ett_cltp = -1; @@ -861,6 +871,7 @@ guint tpdu_nr; guint fragment = 0; guint32 fragment_length = 0; + tvbuff_t *next_tvb; tvbuff_t *reassembled_tvb = NULL; fragment_data *fd_head; @@ -879,7 +890,7 @@ tpdu_nr = tvb_get_guint8(tvb, offset + P_TPDU_NR_234); if ( tpdu_nr & 0x80 ) tpdu_nr = tpdu_nr & 0x7F; - else + else fragment = 1; is_extended = FALSE; is_class_234 = TRUE; @@ -893,6 +904,7 @@ case LI_EXTENDED_DT_WITHOUT_CHECKSUM : tpdu_nr = tvb_get_ntohl(tvb, offset + P_TPDU_NR_234); + if ( tpdu_nr & 0x80000000 ) tpdu_nr = tpdu_nr & 0x7FFFFFFF; else @@ -904,6 +916,7 @@ case LI_NORMAL_DT_CLASS_01 : tpdu_nr = tvb_get_guint8(tvb, offset + P_TPDU_NR_0_1); + if ( tpdu_nr & 0x80 ) tpdu_nr = tpdu_nr & 0x7F; else @@ -959,19 +972,17 @@ if (is_extended) { if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 4, - "TPDU number: 0x%08x (%s)", - tpdu_nr, - (fragment)? "fragment":"complete"); + proto_tree_add_uint(cotp_tree, hf_cotp_tpdu_number, tvb, offset, 4, tpdu_nr); + proto_tree_add_item(cotp_tree, hf_cotp_eot_extended, tvb, offset, 4, TRUE); + } offset += 4; li -= 4; } else { if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 1, - "TPDU number: 0x%02x (%s)", - tpdu_nr, - (fragment)? "fragment":"complete"); + proto_tree_add_uint(cotp_tree, hf_cotp_tpdu_number, tvb, offset, 1, tpdu_nr); + proto_tree_add_item(cotp_tree, hf_cotp_eot, tvb, offset, 1, TRUE); + } offset += 1; li -= 1; @@ -1143,6 +1154,8 @@ if (is_extended) { if (tree) { + proto_tree_add_uint(cotp_tree, hf_cotp_tpdu_number, tvb, offset, 4, tpdu_nr); + proto_tree_add_text(cotp_tree, tvb, offset, 4, "TPDU number: 0x%02x", tpdu_nr); } @@ -1150,6 +1163,7 @@ li -= 4; } else { if (tree) { + proto_tree_add_uint(cotp_tree, hf_cotp_tpdu_number, tvb, offset, 1, tpdu_nr); proto_tree_add_text(cotp_tree, tvb, offset, 1, "TPDU number: 0x%02x", tpdu_nr); } @@ -1213,10 +1227,12 @@ proto_tree_add_text(cotp_tree, tvb, offset + 1, 1, "Credit: %u", cdt); proto_tree_add_uint(cotp_tree, hf_cotp_destref, tvb, offset + 2, 2, dst_ref); - if (li == LI_NORMAL_RJ) + if (li == LI_NORMAL_RJ) { + proto_tree_add_uint(cotp_tree, hf_cotp_next_tpdu_number, tvb, offset +4 , 1, tpdu_nr); proto_tree_add_text(cotp_tree, tvb, offset + 4, 1, "Your TPDU number: 0x%02x", tpdu_nr); - else { + } else { + proto_tree_add_item(cotp_tree, hf_cotp_next_tpdu_number, tvb, offset +4 , 4, TRUE); proto_tree_add_text(cotp_tree, tvb, offset + 4, 4, "Your TPDU number: 0x%02x", tpdu_nr); proto_tree_add_text(cotp_tree, tvb, offset + 8, 2, @@ -1415,9 +1431,8 @@ li -= 2; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 1, - "Your TPDU number: 0x%02x", tpdu_nr); - } + proto_tree_add_uint(cotp_tree, hf_cotp_next_tpdu_number, tvb, offset , 1, tpdu_nr); + } offset += 1; li -= 1; @@ -1456,8 +1471,8 @@ li -= 2; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 4, - "Your TPDU number: 0x%08x", tpdu_nr); + proto_tree_add_uint(cotp_tree, hf_cotp_next_tpdu_number, tvb, offset , 4, tpdu_nr); + } offset += 4; li -= 4; @@ -1553,6 +1568,7 @@ if (is_extended) { if (tree) { + proto_tree_add_uint(cotp_tree, hf_cotp_next_tpdu_number, tvb, offset , 4, tpdu_nr); proto_tree_add_text(cotp_tree, tvb, offset, 4, "Your TPDU number: 0x%08x", tpdu_nr); } @@ -1560,6 +1576,7 @@ li -= 4; } else { if (tree) { + proto_tree_add_uint(cotp_tree, hf_cotp_next_tpdu_number, tvb, offset , 1, tpdu_nr); proto_tree_add_text(cotp_tree, tvb, offset, 1, "Your TPDU number: 0x%02x", tpdu_nr); } @@ -2292,7 +2309,20 @@ { &hf_cotp_type, { "COTP PDU Type", "cotp.type", FT_UINT8, BASE_HEX, VALS(cotp_tpdu_type_abbrev_vals), 0x0, "COTP PDU Type", HFILL}}, - { &hf_cotp_segment_overlap, + { &hf_cotp_tpdu_number, + { "TPDU Number", "cotp.tpdu-number", FT_UINT8, BASE_HEX, NULL, 0x0, + "TPDU number", HFILL}}, + { &hf_cotp_next_tpdu_number, + { "Your TPDU Number", "cotp.next-tpdu-number", FT_UINT8, BASE_HEX, NULL, 0x0, + "Your TPDU number", HFILL}}, + { &hf_cotp_eot, + { "Last data unit", "cotp.eot", FT_BOOLEAN, 8, TFS(&fragment_descriptions), 0x80, + "Is current TPDU the last data unit of a complete DT TPDU sequence?", HFILL}}, + { &hf_cotp_eot_extended, + { "Last data unit", "cotp.eot", FT_BOOLEAN, 32, TFS(&fragment_descriptions), 0x80000000, + "Is current TPDU the last data unit of a complete DT TPDU sequence?", HFILL}}, + + { &hf_cotp_segment_overlap, { "Segment overlap", "cotp.segment.overlap", FT_BOOLEAN, BASE_NONE, NULL, 0x0, "Segment overlaps with other segments", HFILL }}, { &hf_cotp_segment_overlap_conflict, Community Network Services Ltd.. 204-207 Western Docks, Southampton, Hants. SO15 1DA Switchboard : +44 (0)845 6589920 Fax : +44 (0)2380 799602 Help Desk : +44 (0)845 6589930 http://www.cnsonline.net/ Reg. no. 2084279 England ************************************************************* All views or opinions expressed herein are solely those of the author and do not necessarily represent those of Community Network Services Ltd who do not accept liability for any action taken in reliance on the contents of this message (other than where the company has a legal or regulatory obligation to do so) or for the consequences of any computer viruses which may have been transmitted by this E-Mail The E-Mail and any files transmitted with it, are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this message in error please notify the sender and delete the message immediately or alternatively email postmaster@xxxxxxxxxxxxx ***************************************************************
- Follow-Ups:
- Re: [Ethereal-dev] Correction to previous COTP patch
- From: Guy Harris
- Re: [Ethereal-dev] Correction to previous COTP patch
- Prev by Date: Re: [Ethereal-dev] ethereal dump core when trying to decode mapi encrypted data
- Next by Date: [Ethereal-dev] Q931 ethereal code
- Previous by thread: [Ethereal-dev] Glib errors "string not UTF8" when decoding IPX SAP
- Next by thread: Re: [Ethereal-dev] Correction to previous COTP patch
- Index(es):