Ethereal-dev: [Ethereal-dev] [patch] h245 dissector fix
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Jeff Snyder <jeff@xxxxxxxxxxxxx>
Date: Fri, 19 Aug 2005 11:21:45 +0100
Hi, I've fixed the h245 dissector to handle multiple commands in a single PDU, which used to work in the pre-asn2eth h245 dissector. I've also bumped up the maximum number for messages per packet from 5 to 15, since it seems to be fairly common for packets to have 5 or more messages. Please find the diff attached. Thanks, Jeff -- Jeff Snyder <jeff@xxxxxxxxxxxxx> http://www.mxtelecom.com
diff -ur --exclude Entries ethereal/asn1/h245/packet-h245-template.c ethereal2/asn1/h245/packet-h245-template.c --- ethereal/asn1/h245/packet-h245-template.c 2005-08-19 10:59:11.474658728 +0100 +++ ethereal2/asn1/h245/packet-h245-template.c 2005-08-18 18:45:44.000000000 +0100 @@ -2,7 +2,7 @@ * Routines for h245 packet dissection * Copyright 2004, Anders Broman <anders.broman@xxxxxxxxxxxx> * - * $Id: packet-h245-template.c,v 1.1.1.2 2005/08/15 14:45:15 jeff Exp $ + * $Id: packet-h245-template.c,v 1.2 2005/08/18 17:45:44 jeff Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@xxxxxxxxxxxx> @@ -57,6 +57,13 @@ #define PSNAME "h245" #define PFNAME "h245" +/* + * We assuming a certain maximum number of messaages per packet. + * we have to keep the pi_arr data for more than one packet at a time + * becase of the tap queueing. + */ +#define H245_MAX_MESSAGES_PER_PACKET 15 + static dissector_handle_t rtp_handle=NULL; static dissector_handle_t rtcp_handle=NULL; static dissector_table_t nsp_object_dissector_table; @@ -72,7 +79,7 @@ static int h245_tap = -1; static int ett_h245 = -1; static int h245dg_tap = -1; -static h245_packet_info pi_arr[5]; /* We assuming a maximum of 5 H245 messaages per packet */ +static h245_packet_info pi_arr[H245_MAX_MESSAGES_PER_PACKET]; static int pi_current=0; h245_packet_info *h245_pi=NULL; @@ -234,18 +241,11 @@ static void dissect_h245(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - pi_current++; - if(pi_current==5){ - pi_current=0; - } - h245_pi=&pi_arr[pi_current]; - - reset_h245_packet_info(h245_pi); - h245_pi->msg_type = H245_OTHER; - + /* + * MultimediaSystemControlMessage_handle is the handle for + * dissect_h245_h245, so we don't want to do any h245_pi or tap stuff here. + */ dissect_tpkt_encap(tvb, pinfo, parent_tree, h245_reassembly, MultimediaSystemControlMessage_handle); - - tap_queue_packet(h245_tap, pinfo, h245_pi); } static void @@ -255,23 +255,23 @@ proto_tree *tr; guint32 offset=0; - pi_current++; - if(pi_current==5){ - pi_current=0; - } - h245_pi=&pi_arr[pi_current]; - - reset_h245_packet_info(h245_pi); - h245_pi->msg_type = H245_OTHER; - if (check_col(pinfo->cinfo, COL_PROTOCOL)){ col_set_str(pinfo->cinfo, COL_PROTOCOL, "H.245"); } it=proto_tree_add_protocol_format(parent_tree, proto_h245, tvb, 0, tvb_length(tvb), "H.245"); tr=proto_item_add_subtree(it, ett_h245); - dissect_h245_MultimediaSystemControlMessage(tvb, offset, pinfo ,tr, hf_h245_pdu_type); - tap_queue_packet(h245dg_tap, pinfo, h245_pi); + + /* assume that whilst there is more tvb data, there are more h245 commands */ + while ( tvb_length_remaining( tvb, offset>>3 )>0 ){ + if(++pi_current==H245_MAX_MESSAGES_PER_PACKET) { + pi_current=0; + } + h245_pi=&pi_arr[pi_current]; + offset = dissect_h245_MultimediaSystemControlMessage(tvb, offset, pinfo ,tr, hf_h245_pdu_type); + tap_queue_packet(h245dg_tap, pinfo, h245_pi); + offset = (offset+0x07) & 0xfffffff8; + } } int diff -ur --exclude Entries ethereal/epan/dissectors/packet-h245.c ethereal2/epan/dissectors/packet-h245.c --- ethereal/epan/dissectors/packet-h245.c 2005-08-19 10:59:40.662221544 +0100 +++ ethereal2/epan/dissectors/packet-h245.c 2005-08-19 11:01:43.733511864 +0100 @@ -1,6 +1,6 @@ /* Do not modify this file. */ /* It is created automatically by the ASN.1 to Ethereal dissector compiler */ -/* .\packet-h245.c */ +/* ./packet-h245.c */ /* ../../tools/asn2eth.py -X -e -p h245 -c h245.cnf -s packet-h245-template h245.asn */ /* Input file: packet-h245-template.c */ @@ -9,7 +9,7 @@ * Routines for h245 packet dissection * Copyright 2004, Anders Broman <anders.broman@xxxxxxxxxxxx> * - * $Id: packet-h245.c,v 1.1.1.3 2005/08/15 14:45:17 jeff Exp $ + * $Id: packet-h245.c,v 1.2 2005/08/18 17:45:44 jeff Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@xxxxxxxxxxxx> @@ -64,6 +64,13 @@ #define PSNAME "h245" #define PFNAME "h245" +/* + * We assuming a certain maximum number of messaages per packet. + * we have to keep the pi_arr data for more than one packet at a time + * becase of the tap queueing. + */ +#define H245_MAX_MESSAGES_PER_PACKET 15 + static dissector_handle_t rtp_handle=NULL; static dissector_handle_t rtcp_handle=NULL; static dissector_table_t nsp_object_dissector_table; @@ -79,7 +86,7 @@ static int h245_tap = -1; static int ett_h245 = -1; static int h245dg_tap = -1; -static h245_packet_info pi_arr[5]; /* We assuming a maximum of 5 H245 messaages per packet */ +static h245_packet_info pi_arr[H245_MAX_MESSAGES_PER_PACKET]; static int pi_current=0; h245_packet_info *h245_pi=NULL; @@ -16861,18 +16868,11 @@ static void dissect_h245(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - pi_current++; - if(pi_current==5){ - pi_current=0; - } - h245_pi=&pi_arr[pi_current]; - - reset_h245_packet_info(h245_pi); - h245_pi->msg_type = H245_OTHER; - + /* + * MultimediaSystemControlMessage_handle is the handle for + * dissect_h245_h245, so we don't want to do any h245_pi or tap stuff here. + */ dissect_tpkt_encap(tvb, pinfo, parent_tree, h245_reassembly, MultimediaSystemControlMessage_handle); - - tap_queue_packet(h245_tap, pinfo, h245_pi); } static void @@ -16882,23 +16882,23 @@ proto_tree *tr; guint32 offset=0; - pi_current++; - if(pi_current==5){ - pi_current=0; - } - h245_pi=&pi_arr[pi_current]; - - reset_h245_packet_info(h245_pi); - h245_pi->msg_type = H245_OTHER; - if (check_col(pinfo->cinfo, COL_PROTOCOL)){ col_set_str(pinfo->cinfo, COL_PROTOCOL, "H.245"); } it=proto_tree_add_protocol_format(parent_tree, proto_h245, tvb, 0, tvb_length(tvb), "H.245"); tr=proto_item_add_subtree(it, ett_h245); - dissect_h245_MultimediaSystemControlMessage(tvb, offset, pinfo ,tr, hf_h245_pdu_type); - tap_queue_packet(h245dg_tap, pinfo, h245_pi); + + /* assume that whilst there is more tvb data, there are more h245 commands */ + while ( tvb_length_remaining( tvb, offset>>3 )>0 ){ + if(++pi_current==H245_MAX_MESSAGES_PER_PACKET) { + pi_current=0; + } + h245_pi=&pi_arr[pi_current]; + offset = dissect_h245_MultimediaSystemControlMessage(tvb, offset, pinfo ,tr, hf_h245_pdu_type); + tap_queue_packet(h245dg_tap, pinfo, h245_pi); + offset = (offset+0x07) & 0xfffffff8; + } } int
- Follow-Ups:
- [Ethereal-dev] Re: h245 dissector fix
- From: ronnie sahlberg
- [Ethereal-dev] Re: h245 dissector fix
- Prev by Date: Re: [Ethereal-dev] API for registering "-z" args and "Statistics" menu item split off from main tapping API
- Next by Date: [Ethereal-dev] buildbot failure in Fedora Core 4 (IA32)
- Previous by thread: Re: [Ethereal-dev] API for registering "-z" args and "Statistics" menu item split off from main tapping API
- Next by thread: [Ethereal-dev] Re: h245 dissector fix
- Index(es):