diff options
author | Guy Harris <guy@alum.mit.edu> | 2004-01-31 09:48:26 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2004-01-31 09:48:26 +0000 |
commit | d4857dc7060547a22e644221a6a20a3a85d9b2fd (patch) | |
tree | a69295256c9c611d4fe5c88a550bc9df5793afcc | |
parent | c979950fc6df3a04d269ff63cb995f6d3b7f810f (diff) | |
download | wireshark-d4857dc7060547a22e644221a6a20a3a85d9b2fd.tar.gz wireshark-d4857dc7060547a22e644221a6a20a3a85d9b2fd.tar.bz2 wireshark-d4857dc7060547a22e644221a6a20a3a85d9b2fd.zip |
Add to the _rtp_info structure a "info_all_data_present" boolean, which
is TRUE if all the RTP raw data is present in the tvbuff and FALSE
otherwise. If it's not all present, also set "info_data_len" to 0 and
"info_data" to NULL.
In the RTP Analysis "Save Payload..." operation, check the
"info_all_data_present" flag and fail if it's not set, and use
"rtpinfo->info_data" and "rtpinfo->info_payload_offset" to get at the
payload, rather than using "cfile.pd", as the latter doesn't necessarily
refer to the current frame data.
Note that the RTP Streams save operation should also check the
"info_all_data_present" flag.
svn path=/trunk/; revision=9920
-rw-r--r-- | gtk/rtp_analysis.c | 44 | ||||
-rw-r--r-- | gtk/rtp_stream.c | 4 | ||||
-rw-r--r-- | packet-rtp.c | 56 | ||||
-rw-r--r-- | packet-rtp.h | 3 |
4 files changed, 82 insertions, 25 deletions
diff --git a/gtk/rtp_analysis.c b/gtk/rtp_analysis.c index b075519a16..c549a96b28 100644 --- a/gtk/rtp_analysis.c +++ b/gtk/rtp_analysis.c @@ -1,7 +1,7 @@ /* rtp_analysis.c * RTP analysis addition for ethereal * - * $Id: rtp_analysis.c,v 1.30 2004/01/31 03:22:42 guy Exp $ + * $Id: rtp_analysis.c,v 1.31 2004/01/31 09:48:26 guy Exp $ * * Copyright 2003, Alcatel Business Systems * By Lars Ruoff <lars.ruoff@gmx.net> @@ -119,6 +119,7 @@ typedef enum { TAP_RTP_WRONG_CODEC, TAP_RTP_WRONG_LENGTH, TAP_RTP_PADDING_ERROR, + TAP_RTP_SHORT_FRAME, TAP_RTP_FILE_OPEN_ERROR, TAP_RTP_NO_DATA } error_type_t; @@ -585,7 +586,7 @@ static int rtp_packet_save_payload(tap_rtp_save_info_t *saveinfo, packet_info *pinfo, struct _rtp_info *rtpinfo) { guint i; - guint8 *data; + const guint8 *data; gint16 tmp; /* is this the first packet we got in this direction? */ @@ -639,10 +640,18 @@ static int rtp_packet_save_payload(tap_rtp_save_info_t *saveinfo, /* ulaw? */ if (rtpinfo->info_payload_type == PT_PCMU) { - /* we put the pointer at the beggining of the RTP data, that is - * at the end of the current frame minus the length of the - * padding count minus length of the RTP data */ - data = cfile.pd + (pinfo->fd->pkt_len - rtpinfo->info_payload_len); + if (!rtpinfo->info_all_data_present) { + /* Not all the data was captured. */ + saveinfo->saved = FALSE; + saveinfo->error_type = TAP_RTP_SHORT_FRAME; + return 0; + } + + /* we put the pointer at the beginning of the RTP + * payload, that is, at the beginning of the RTP data + * plus the offset of the payload from the beginning + * of the RTP data */ + data = rtpinfo->info_data + rtpinfo->info_payload_offset; for(i=0; i < (rtpinfo->info_payload_len - rtpinfo->info_padding_count); i++, data++) { tmp = (gint16 )ulaw2linear((unsigned char)*data); fwrite(&tmp, 2, 1, saveinfo->fp); @@ -655,7 +664,18 @@ static int rtp_packet_save_payload(tap_rtp_save_info_t *saveinfo, /* alaw? */ else if (rtpinfo->info_payload_type == PT_PCMA) { - data = cfile.pd + (pinfo->fd->pkt_len - rtpinfo->info_payload_len); + if (!rtpinfo->info_all_data_present) { + /* Not all the data was captured. */ + saveinfo->saved = FALSE; + saveinfo->error_type = TAP_RTP_SHORT_FRAME; + return 0; + } + + /* we put the pointer at the beginning of the RTP + * payload, that is, at the beginning of the RTP data + * plus the offset of the payload from the beginning + * of the RTP data */ + data = rtpinfo->info_data + rtpinfo->info_payload_offset; for(i=0; i < (rtpinfo->info_payload_len - rtpinfo->info_padding_count); i++, data++) { tmp = (gint16 )alaw2linear((unsigned char)*data); fwrite(&tmp, 2, 1, saveinfo->fp); @@ -1429,6 +1449,10 @@ static void save_voice_as_ok_cb(GtkWidget *ok_bt _U_, gpointer fs _U_) (user_data->reversed.saveinfo.error_type == TAP_RTP_PADDING_ERROR)) simple_dialog(ESD_TYPE_ERROR | ESD_TYPE_MODAL, ESD_BTN_OK, "Can't save in a file: RTP data with padding!"); + else if ((user_data->forward.saveinfo.error_type == TAP_RTP_SHORT_FRAME) || + (user_data->reversed.saveinfo.error_type == TAP_RTP_SHORT_FRAME)) + simple_dialog(ESD_TYPE_ERROR | ESD_TYPE_MODAL, ESD_BTN_OK, + "Can't save in a file: Not all data in all packets was captured!"); else simple_dialog(ESD_TYPE_ERROR | ESD_TYPE_MODAL, ESD_BTN_OK, "Can't save in a file: File I/O problem!"); @@ -1446,6 +1470,9 @@ static void save_voice_as_ok_cb(GtkWidget *ok_bt _U_, gpointer fs _U_) else if (user_data->forward.saveinfo.error_type == TAP_RTP_PADDING_ERROR) simple_dialog(ESD_TYPE_ERROR | ESD_TYPE_MODAL, ESD_BTN_OK, "Can't save forward direction in a file: RTP data with padding!"); + else if (user_data->forward.saveinfo.error_type == TAP_RTP_SHORT_FRAME) + simple_dialog(ESD_TYPE_ERROR | ESD_TYPE_MODAL, ESD_BTN_OK, + "Can't save forward direction in a file: Not all data in all packets was captured!"); else simple_dialog(ESD_TYPE_ERROR | ESD_TYPE_MODAL, ESD_BTN_OK, "Can't save forward direction in a file: File I/O problem!"); @@ -1463,6 +1490,9 @@ static void save_voice_as_ok_cb(GtkWidget *ok_bt _U_, gpointer fs _U_) else if (user_data->reversed.saveinfo.error_type == TAP_RTP_PADDING_ERROR) simple_dialog(ESD_TYPE_ERROR | ESD_TYPE_MODAL, ESD_BTN_OK, "Can't save reversed direction in a file: RTP data with padding!"); + else if (user_data->forward.saveinfo.error_type == TAP_RTP_SHORT_FRAME) + simple_dialog(ESD_TYPE_ERROR | ESD_TYPE_MODAL, ESD_BTN_OK, + "Can't save reversed direction in a file: Not all data in all packets was captured!"); else if (user_data->reversed.saveinfo.error_type == TAP_RTP_NO_DATA) simple_dialog(ESD_TYPE_ERROR | ESD_TYPE_MODAL, ESD_BTN_OK, "Can't save reversed direction in a file: No RTP data!"); diff --git a/gtk/rtp_stream.c b/gtk/rtp_stream.c index a6628f1430..df73005518 100644 --- a/gtk/rtp_stream.c +++ b/gtk/rtp_stream.c @@ -1,7 +1,7 @@ /* rtp_stream.c * RTP streams summary addition for ethereal * - * $Id: rtp_stream.c,v 1.10 2004/01/31 03:22:42 guy Exp $ + * $Id: rtp_stream.c,v 1.11 2004/01/31 09:48:26 guy Exp $ * * Copyright 2003, Alcatel Business Systems * By Lars Ruoff <lars.ruoff@gmx.net> @@ -240,6 +240,8 @@ int rtpstream_packet(rtpstream_tapinfo_t *tapinfo _U_, packet_info *pinfo, epan_ } else if (tapinfo->mode == TAP_SAVE) { if (rtp_stream_info_cmp(&tmp_strinfo, tapinfo->filter_stream_fwd)==0) { + /* XXX - what if rtpinfo->info_all_data_present is + FALSE, so that we don't *have* all the data? */ sample.header.rec_time = (pinfo->fd->abs_usecs + 1000000 - tapinfo->filter_stream_fwd->start_usec)/1000 + (pinfo->fd->abs_secs - tapinfo->filter_stream_fwd->start_sec - 1)*1000; diff --git a/packet-rtp.c b/packet-rtp.c index 813676da81..9786853800 100644 --- a/packet-rtp.c +++ b/packet-rtp.c @@ -6,7 +6,7 @@ * Copyright 2000, Philips Electronics N.V. * Written by Andreas Sikkema <andreas.sikkema@philips.com> * - * $Id: packet-rtp.c,v 1.43 2003/11/20 23:34:29 guy Exp $ + * $Id: packet-rtp.c,v 1.44 2004/01/31 09:48:25 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -299,6 +299,7 @@ dissect_rtp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ) unsigned int i = 0; unsigned int hdr_extension= 0; unsigned int padding_count; + gint length, reported_length; int data_len; unsigned int offset = 0; guint16 seq_num; @@ -357,17 +358,39 @@ dissect_rtp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ) rtp_info.info_seq_num = seq_num; rtp_info.info_timestamp = timestamp; rtp_info.info_sync_src = sync_src; - rtp_info.info_data_len = tvb_reported_length_remaining( tvb, offset ); /* - * Save the pointer to raw rtp data (header + payload incl. padding) - * That should be safe because the "epan_dissect_t" constructed for the packet - * has not yet been freed when the taps are called. - * (destroying the "epan_dissect_t" will end up freeing all the tvbuffs - * and hence invalidating pointers to their data). - * See "add_packet_to_packet_list()" for details. - */ - rtp_info.info_data = tvb_get_ptr(tvb, 0, -1); + * Do we have all the data? + */ + length = tvb_length_remaining(tvb, offset); + reported_length = tvb_reported_length_remaining(tvb, offset); + if (reported_length >= 0 && length >= reported_length) { + /* + * Yes. + */ + rtp_info.info_all_data_present = TRUE; + rtp_info.info_data_len = reported_length; + + /* + * Save the pointer to raw rtp data (header + payload incl. + * padding). + * That should be safe because the "epan_dissect_t" + * constructed for the packet has not yet been freed when + * the taps are called. + * (Destroying the "epan_dissect_t" will end up freeing + * all the tvbuffs and hence invalidating pointers to + * their data.) + * See "add_packet_to_packet_list()" for details. + */ + rtp_info.info_data = tvb_get_ptr(tvb, 0, -1); + } else { + /* + * No - packet was cut short at capture time. + */ + rtp_info.info_all_data_present = FALSE; + rtp_info.info_data_len = 0; + rtp_info.info_data = NULL; + } if ( check_col( pinfo->cinfo, COL_PROTOCOL ) ) { col_set_str( pinfo->cinfo, COL_PROTOCOL, "RTP" ); @@ -445,12 +468,13 @@ dissect_rtp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ) offset, 2, hdr_extension); offset += 2; if ( hdr_extension > 0 ) { - if ( tree ) { ti = proto_tree_add_text(rtp_tree, tvb, offset, csrc_count * 4, "Header extensions"); - /* I'm re-using the old tree variable here - from the CSRC list!*/ - rtp_csrc_tree = proto_item_add_subtree( ti, - ett_hdr_ext ); - } + if ( tree ) { + ti = proto_tree_add_text(rtp_tree, tvb, offset, csrc_count * 4, "Header extensions"); + /* I'm re-using the old tree variable here + from the CSRC list!*/ + rtp_csrc_tree = proto_item_add_subtree( ti, + ett_hdr_ext ); + } for (i = 0; i < hdr_extension; i++ ) { if ( tree ) proto_tree_add_uint( rtp_csrc_tree, hf_rtp_hdr_ext, tvb, offset, 4, tvb_get_ntohl( tvb, offset ) ); offset += 4; diff --git a/packet-rtp.h b/packet-rtp.h index 2eaa495842..ee5b1bda27 100644 --- a/packet-rtp.h +++ b/packet-rtp.h @@ -3,7 +3,7 @@ * Routines for RTP dissection * RTP = Real time Transport Protocol * - * $Id: packet-rtp.h,v 1.10 2003/11/20 23:34:30 guy Exp $ + * $Id: packet-rtp.h,v 1.11 2004/01/31 09:48:25 guy Exp $ * * Copyright 2000, Philips Electronics N.V. * Written by Andreas Sikkema <andreas.sikkema@philips.com> @@ -36,6 +36,7 @@ struct _rtp_info { guint32 info_timestamp; guint32 info_sync_src; guint info_data_len; /* length of raw rtp data as reported */ + gboolean info_all_data_present; /* FALSE if data is cut off */ guint info_payload_offset; /* start of payload relative to info_data */ guint info_payload_len; /* length of payload (incl padding) */ const guint8* info_data; /* pointer to raw rtp data */ |