Ethereal-dev: [Ethereal-dev] [Fwd: [PATCH] Filtering COTP]
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: MEYER Laurent <laurent.meyer@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 15 Apr 2003 11:20:41 +0200
Sorry for the missunderstanding, i have sent this mail to ethereal-cvs in place of thereal-dev Laurent MEYER.
--- Begin Message ---From: MEYER Laurent <laurent.meyer@xxxxxxxxxxxxxxxxxxx>Date: Tue, 15 Apr 2003 10:07:21 +0200Hello, Here is a patch to add filtering capabilities for COTP dissector, Regards. Laurent MEYER--- packet-clnp.c.orig Mon Apr 14 11:03:36 2003 +++ packet-clnp.c Mon Apr 14 14:22:09 2003 @@ -1,7 +1,7 @@ /* packet-clnp.c * Routines for ISO/OSI network and transport protocol packet disassembly * - * $Id: packet-clnp.c,v 1.67 2003/02/25 18:59:47 guy Exp $ + * $Id: packet-clnp.c,v 1.68 2003/03/04 06:47:08 guy Exp $ * Laurent Deniel <laurent.deniel@xxxxxxx> * Ralf Schneider <Ralf.Schneider@xxxxxxxxxxx> * @@ -73,6 +73,10 @@ static int hf_clnp_segment_too_long_segment = -1; static int hf_clnp_segment_error = -1; +static int hf_cotp_srcref = -1; +static int hf_cotp_destref = -1; +static int hf_cotp_type = -1; + static const fragment_items clnp_frag_items = { &ett_clnp_segment, &ett_clnp_segments, @@ -683,7 +687,9 @@ return -1; dst_ref = tvb_get_ntohs(tvb, offset + P_DST_REF); + src_ref = tvb_get_ntohs(tvb, offset + P_SRC_REF); + reason = tvb_get_guint8(tvb, offset + P_REASON_IN_DR); switch(reason) { @@ -709,17 +715,17 @@ col_append_fstr(pinfo->cinfo, COL_INFO, "DR TPDU src-ref: 0x%04x dst-ref: 0x%04x", src_ref, dst_ref); - + if (tree) { ti = proto_tree_add_item(tree, proto_cotp, tvb, offset, li + 1, FALSE); cotp_tree = proto_item_add_subtree(ti, ett_cotp); proto_tree_add_text(cotp_tree, tvb, offset, 1, "Length indicator: %u", li); - proto_tree_add_text(cotp_tree, tvb, offset + 1, 1, - "TPDU code: 0x%x (DR)", tpdu); - proto_tree_add_text(cotp_tree, tvb, offset + 2, 2, + proto_tree_add_uint_format(cotp_tree, hf_cotp_type, tvb, offset + 1, 1, tpdu, + "TPDU code: 0x%x (DR)", tpdu); + proto_tree_add_uint_format(cotp_tree, hf_cotp_destref, tvb, offset + 2, 2, dst_ref, "Destination reference: 0x%04x", dst_ref); - proto_tree_add_text(cotp_tree, tvb, offset + 4, 2, + proto_tree_add_uint_format(cotp_tree, hf_cotp_srcref, tvb, offset + 4, 2, src_ref, "Source reference: 0x%04x", src_ref); proto_tree_add_text(cotp_tree, tvb, offset + 6, 1, "Cause: %s", str); @@ -826,16 +832,16 @@ offset += 1; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 1, + proto_tree_add_uint_format(cotp_tree, hf_cotp_type, tvb, offset, 1, tpdu, "TPDU code: 0x%x (DT)", tpdu); - + } offset += 1; li -= 1; if (is_class_234) { if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 2, + proto_tree_add_uint_format(cotp_tree, hf_cotp_destref, tvb, offset, 2, dst_ref, "Destination reference: 0x%04x", dst_ref); } offset += 2; @@ -955,14 +961,14 @@ offset += 1; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 1, + proto_tree_add_uint_format(cotp_tree, hf_cotp_type, tvb, offset, 1, tpdu, "TPDU code: 0x%x (ED)", tpdu); } offset += 1; li -= 1; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 2, + proto_tree_add_uint_format(cotp_tree, hf_cotp_destref, tvb, offset, 2, dst_ref, "Destination reference: 0x%04x", dst_ref); } offset += 2; @@ -1031,12 +1037,12 @@ cotp_tree = proto_item_add_subtree(ti, ett_cotp); proto_tree_add_text(cotp_tree, tvb, offset, 1, "Length indicator: %u", li); - proto_tree_add_text(cotp_tree, tvb, offset + 1, 1, + proto_tree_add_uint_format(cotp_tree, hf_cotp_type, tvb, offset + 1, 1, tpdu, "TPDU code: 0x%x (RJ)", tpdu); if (li == LI_NORMAL_RJ) proto_tree_add_text(cotp_tree, tvb, offset + 1, 1, "Credit: %u", cdt); - proto_tree_add_text(cotp_tree, tvb, offset + 2, 2, + proto_tree_add_uint_format(cotp_tree, hf_cotp_destref, tvb, offset + 2, 2, dst_ref, "Destination reference: 0x%04x", dst_ref); if (li == LI_NORMAL_RJ) proto_tree_add_text(cotp_tree, tvb, offset + 4, 1, @@ -1070,6 +1076,7 @@ tvbuff_t *next_tvb; src_ref = tvb_get_ntohs(tvb, offset + P_SRC_REF); + class_option = (tvb_get_guint8(tvb, offset + P_CLASS_OPTION) >> 4 ) & 0x0F; if (class_option > 4) return -1; @@ -1081,7 +1088,7 @@ (tpdu == CR_TPDU) ? "CR" : "CC", src_ref, dst_ref); - + if (tree) { ti = proto_tree_add_item(tree, proto_cotp, tvb, offset, li + 1, FALSE); cotp_tree = proto_item_add_subtree(ti, ett_cotp); @@ -1091,7 +1098,7 @@ offset += 1; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 1, + proto_tree_add_uint_format(cotp_tree, hf_cotp_type, tvb, offset, 1, tpdu, "TPDU code: 0x%x (%s)", tpdu, (tpdu == CR_TPDU) ? "CR" : "CC"); } @@ -1099,14 +1106,14 @@ li -= 1; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 2, + proto_tree_add_uint_format(cotp_tree, hf_cotp_destref, tvb, offset, 2, dst_ref, "Destination reference: 0x%04x", dst_ref); } offset += 2; li -= 2; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 2, + proto_tree_add_uint_format(cotp_tree, hf_cotp_srcref, tvb, offset, 2, src_ref, "Source reference: 0x%04x", src_ref); } offset += 2; @@ -1169,21 +1176,21 @@ offset += 1; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 1, + proto_tree_add_uint_format(cotp_tree, hf_cotp_type, tvb, offset, 1, tpdu, "TPDU code: 0x%x (DC)", tpdu); } offset += 1; li -= 1; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 2, + proto_tree_add_uint_format(cotp_tree, hf_cotp_destref, tvb, offset, 2, dst_ref, "Destination reference: 0x%04x", dst_ref); } offset += 2; li -= 2; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 2, + proto_tree_add_uint_format(cotp_tree, hf_cotp_srcref, tvb, offset, 2, src_ref, "Source reference: 0x%04x", src_ref); } offset += 2; @@ -1227,7 +1234,7 @@ offset += 1; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 1, + proto_tree_add_uint_format(cotp_tree, hf_cotp_type, tvb, offset, 1, tpdu, "TPDU code: 0x%x (AK)", tpdu); proto_tree_add_text(cotp_tree, tvb, offset, 1, "Credit: %u", cdt); @@ -1236,7 +1243,7 @@ li -= 1; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 2, + proto_tree_add_uint_format(cotp_tree, hf_cotp_destref, tvb, offset, 2, dst_ref, "Destination reference: 0x%04x", dst_ref); } offset += 2; @@ -1272,14 +1279,14 @@ offset += 1; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 1, + proto_tree_add_uint_format(cotp_tree, hf_cotp_type, tvb, offset, 1, tpdu, "TPDU code: 0x%x (AK)", tpdu); } offset += 1; li -= 1; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 2, + proto_tree_add_uint_format(cotp_tree, hf_cotp_destref, tvb, offset, 2, dst_ref, "Destination reference: 0x%04x", dst_ref); } offset += 2; @@ -1368,14 +1375,14 @@ offset += 1; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 1, + proto_tree_add_uint_format(cotp_tree, hf_cotp_type, tvb, offset, 1, tpdu, "TPDU code: 0x%x (EA)", tpdu); } offset += 1; li -= 1; if (tree) { - proto_tree_add_text(cotp_tree, tvb, offset, 2, + proto_tree_add_uint_format(cotp_tree, hf_cotp_destref, tvb, offset, 2, dst_ref, "Destination reference: 0x%04x", dst_ref); } offset += 2; @@ -1444,9 +1451,9 @@ cotp_tree = proto_item_add_subtree(ti, ett_cotp); proto_tree_add_text(cotp_tree, tvb, offset, 1, "Length indicator: %u", li); - proto_tree_add_text(cotp_tree, tvb, offset + 1, 1, + proto_tree_add_uint_format(cotp_tree, hf_cotp_type, tvb, offset + 1, 1, tpdu, "TPDU code: 0x%x (ER)", tpdu); - proto_tree_add_text(cotp_tree, tvb, offset + 2, 2, + proto_tree_add_uint_format(cotp_tree, hf_cotp_destref, tvb, offset + 2, 2, dst_ref, "Destination reference: 0x%04x", dst_ref); proto_tree_add_text(cotp_tree, tvb, offset + 4, 1, "Reject cause: %s", str); @@ -1477,7 +1484,7 @@ offset += 1; if (tree) { - proto_tree_add_text(cltp_tree, tvb, offset, 1, + proto_tree_add_uint_format(cltp_tree, hf_cotp_type, tvb, offset, 1, tpdu, "TPDU code: 0x%x (UD)", tpdu); } offset += 1; @@ -1863,14 +1870,14 @@ offset = cnf_hdr_len; - /* If clnp_reassemble is on, and this is a segment, we have all the + /* If clnp_reassemble is on, this is a segment, we have all the * data in the segment, and the checksum is valid, then just add the * segment to the hashtable. */ save_fragmented = pinfo->fragmented; if (clnp_reassemble && (cnf_type & CNF_SEG_OK) && ((cnf_type & CNF_MORE_SEGS) || segment_offset != 0) && - (tvb_reported_length(tvb) <= tvb_length(tvb)) && + tvb_bytes_exist(tvb, offset, segment_length - cnf_hdr_len) && cksum_status != CKSUM_NOT_OK) { fd_head = fragment_add(tvb, offset, pinfo, du_id, clnp_segment_table, segment_offset, segment_length - cnf_hdr_len, @@ -2105,16 +2112,23 @@ void proto_register_cotp(void) { - /* static hf_register_info hf[] = { - { &variable, - { "Name", "cotp.abbreviation", TYPE, VALS_POINTER }}, - };*/ + static hf_register_info hf[] = { + { &hf_cotp_srcref, + { "Source address reference", "cotp.srcref", FT_UINT16, BASE_HEX, NULL, 0x0, + "Source address reference", HFILL}}, + { &hf_cotp_destref, + { "Destination address reference", "cotp.destref", FT_UINT16, BASE_HEX, NULL, 0x0, + "Destination address reference", HFILL}}, + { &hf_cotp_type, + { "COTP PDU Type ", "cotp.type", FT_UINT8, BASE_HEX, NULL, 0x0, + "COTP PDU Type ", HFILL}}, + }; static gint *ett[] = { &ett_cotp, }; proto_cotp = proto_register_protocol(PROTO_STRING_COTP, "COTP", "cotp"); - /* proto_register_field_array(proto_cotp, hf, array_length(hf));*/ + proto_register_field_array(proto_cotp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); /* subdissector code in inactive subset */
--- End Message ---
- Follow-Ups:
- Re: [Ethereal-dev] [Fwd: [PATCH] Filtering COTP]
- From: Guy Harris
- Re: [Ethereal-dev] [Fwd: [PATCH] Filtering COTP]
- Prev by Date: [Ethereal-dev] Crash when using "Per packet information"
- Next by Date: Re: [Ethereal-dev] Crash when using "Per packet information"
- Previous by thread: Re: [Ethereal-dev] Crash when using "Per packet information"
- Next by thread: Re: [Ethereal-dev] [Fwd: [PATCH] Filtering COTP]
- Index(es):