2006-08-10 11:18:02 +00:00
|
|
|
/* packet-jpeg.c
|
|
|
|
*
|
|
|
|
* Routines for RFC 2435 JPEG dissection
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright 2006
|
|
|
|
* Erwin Rol <erwin@erwinrol.com>
|
|
|
|
* Copyright 2001,
|
|
|
|
* Francisco Javier Cabello Torres, <fjcabello@vtools.es>
|
|
|
|
*
|
2007-01-02 14:11:35 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
2007-01-02 17:19:25 +00:00
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2006-08-10 11:18:02 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2006-08-10 11:18:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <epan/packet.h>
|
|
|
|
|
|
|
|
#include <epan/rtp_pt.h>
|
|
|
|
|
|
|
|
|
|
|
|
/* JPEG header fields */
|
|
|
|
static int hf_rtp_jpeg_main_hdr = -1;
|
|
|
|
static int hf_rtp_jpeg_main_hdr_ts = -1;
|
|
|
|
static int hf_rtp_jpeg_main_hdr_offs = -1;
|
|
|
|
static int hf_rtp_jpeg_main_hdr_type = -1;
|
|
|
|
static int hf_rtp_jpeg_main_hdr_q = -1;
|
|
|
|
static int hf_rtp_jpeg_main_hdr_width = -1;
|
|
|
|
static int hf_rtp_jpeg_main_hdr_height = -1;
|
|
|
|
|
|
|
|
static int hf_rtp_jpeg_restart_hdr = -1;
|
|
|
|
static int hf_rtp_jpeg_restart_hdr_interval = -1;
|
|
|
|
static int hf_rtp_jpeg_restart_hdr_f = -1;
|
|
|
|
static int hf_rtp_jpeg_restart_hdr_l = -1;
|
|
|
|
static int hf_rtp_jpeg_restart_hdr_count = -1;
|
|
|
|
|
|
|
|
static int hf_rtp_jpeg_qtable_hdr = -1;
|
|
|
|
static int hf_rtp_jpeg_qtable_hdr_mbz = -1;
|
|
|
|
static int hf_rtp_jpeg_qtable_hdr_prec = -1;
|
|
|
|
static int hf_rtp_jpeg_qtable_hdr_length = -1;
|
|
|
|
static int hf_rtp_jpeg_qtable_hdr_data = -1;
|
|
|
|
|
|
|
|
static int hf_rtp_jpeg_payload = -1;
|
|
|
|
|
|
|
|
static int proto_jpeg = -1;
|
|
|
|
|
|
|
|
/* JPEG fields defining a sub tree */
|
|
|
|
static gint ett_jpeg = -1;
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_jpeg( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
|
|
|
|
{
|
|
|
|
proto_item *ti = NULL;
|
|
|
|
proto_tree *jpeg_tree = NULL;
|
|
|
|
proto_tree *main_hdr_tree = NULL;
|
|
|
|
proto_tree *restart_hdr_tree = NULL;
|
|
|
|
proto_tree *qtable_hdr_tree = NULL;
|
2008-02-02 16:41:12 +00:00
|
|
|
guint32 fragment_offset = 0;
|
2006-08-10 11:18:02 +00:00
|
|
|
guint16 len = 0;
|
|
|
|
guint8 type = 0;
|
|
|
|
guint8 q = 0;
|
|
|
|
gint h = 0;
|
|
|
|
gint w = 0;
|
|
|
|
|
|
|
|
unsigned int offset = 0;
|
|
|
|
|
2009-08-09 07:59:51 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "JPEG");
|
2006-08-10 11:18:02 +00:00
|
|
|
|
2009-08-09 07:59:51 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "JPEG message");
|
2006-08-10 11:18:02 +00:00
|
|
|
|
|
|
|
if ( tree ) {
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item( tree, proto_jpeg, tvb, offset, -1, ENC_NA );
|
2006-08-10 11:18:02 +00:00
|
|
|
jpeg_tree = proto_item_add_subtree( ti, ett_jpeg );
|
|
|
|
|
2011-10-04 22:44:31 +00:00
|
|
|
ti = proto_tree_add_item(jpeg_tree, hf_rtp_jpeg_main_hdr, tvb, offset, 8, ENC_NA);
|
2006-08-10 11:18:02 +00:00
|
|
|
main_hdr_tree = proto_item_add_subtree(ti, ett_jpeg);
|
|
|
|
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(main_hdr_tree, hf_rtp_jpeg_main_hdr_ts, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2006-08-10 11:18:02 +00:00
|
|
|
offset += 1;
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(main_hdr_tree, hf_rtp_jpeg_main_hdr_offs, tvb, offset, 3, ENC_BIG_ENDIAN);
|
2008-02-02 16:41:12 +00:00
|
|
|
fragment_offset = tvb_get_ntoh24(tvb, offset);
|
2006-08-10 11:18:02 +00:00
|
|
|
offset += 3;
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(main_hdr_tree, hf_rtp_jpeg_main_hdr_type, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2006-08-10 11:18:02 +00:00
|
|
|
type = tvb_get_guint8(tvb, offset);
|
|
|
|
offset += 1;
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(main_hdr_tree, hf_rtp_jpeg_main_hdr_q, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2006-08-10 11:18:02 +00:00
|
|
|
q = tvb_get_guint8(tvb, offset);
|
|
|
|
offset += 1;
|
|
|
|
w = tvb_get_guint8(tvb, offset) * 8;
|
|
|
|
proto_tree_add_uint(main_hdr_tree, hf_rtp_jpeg_main_hdr_width, tvb, offset, 1, w);
|
|
|
|
offset += 1;
|
|
|
|
h = tvb_get_guint8(tvb, offset) * 8;
|
|
|
|
proto_tree_add_uint(main_hdr_tree, hf_rtp_jpeg_main_hdr_height, tvb, offset, 1, h);
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
if (type >= 64 && type <= 127) {
|
2011-10-04 22:44:31 +00:00
|
|
|
ti = proto_tree_add_item(jpeg_tree, hf_rtp_jpeg_restart_hdr, tvb, offset, 4, ENC_NA);
|
2006-08-10 11:18:02 +00:00
|
|
|
restart_hdr_tree = proto_item_add_subtree(ti, ett_jpeg);
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(restart_hdr_tree, hf_rtp_jpeg_restart_hdr_interval, tvb, offset, 2, ENC_BIG_ENDIAN);
|
2006-08-10 11:18:02 +00:00
|
|
|
offset += 2;
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(restart_hdr_tree, hf_rtp_jpeg_restart_hdr_f, tvb, offset, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(restart_hdr_tree, hf_rtp_jpeg_restart_hdr_l, tvb, offset, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(restart_hdr_tree, hf_rtp_jpeg_restart_hdr_count, tvb, offset, 2, ENC_BIG_ENDIAN);
|
2006-08-10 11:18:02 +00:00
|
|
|
offset += 2;
|
|
|
|
}
|
|
|
|
|
2008-02-02 16:41:12 +00:00
|
|
|
if (q >= 128 && fragment_offset == 0) {
|
2011-10-04 22:44:31 +00:00
|
|
|
ti = proto_tree_add_item(jpeg_tree, hf_rtp_jpeg_qtable_hdr, tvb, offset, -1, ENC_NA);
|
2006-08-10 11:18:02 +00:00
|
|
|
qtable_hdr_tree = proto_item_add_subtree(ti, ett_jpeg);
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(qtable_hdr_tree, hf_rtp_jpeg_qtable_hdr_mbz, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2006-08-10 11:18:02 +00:00
|
|
|
offset += 1;
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(qtable_hdr_tree, hf_rtp_jpeg_qtable_hdr_prec, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2006-08-10 11:18:02 +00:00
|
|
|
offset += 1;
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(qtable_hdr_tree, hf_rtp_jpeg_qtable_hdr_length, tvb, offset, 2, ENC_BIG_ENDIAN);
|
2008-02-02 16:41:12 +00:00
|
|
|
len = tvb_get_ntohs(tvb, offset);
|
2006-08-10 11:18:02 +00:00
|
|
|
offset += 2;
|
|
|
|
if (len > 0) {
|
2011-10-04 22:44:31 +00:00
|
|
|
proto_tree_add_item(qtable_hdr_tree, hf_rtp_jpeg_qtable_hdr_data, tvb, offset, len, ENC_NA);
|
2008-02-02 16:41:12 +00:00
|
|
|
offset += len;
|
2006-08-10 11:18:02 +00:00
|
|
|
}
|
|
|
|
proto_item_set_len(ti, len + 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The rest of the packet is the JPEG data */
|
2011-10-04 22:44:31 +00:00
|
|
|
proto_tree_add_item( jpeg_tree, hf_rtp_jpeg_payload, tvb, offset, -1, ENC_NA );
|
2006-08-10 11:18:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_jpeg(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
static hf_register_info hf[] =
|
|
|
|
{
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_main_hdr, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"Main Header",
|
|
|
|
"jpeg.main_hdr",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_main_hdr_ts, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"Type Specific",
|
|
|
|
"jpeg.main_hdr.ts",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_main_hdr_offs, {
|
2008-12-18 19:08:49 +00:00
|
|
|
"Fragment Offset",
|
2006-08-10 11:18:02 +00:00
|
|
|
"jpeg.main_hdr.offset",
|
|
|
|
FT_UINT24, BASE_DEC, NULL, 0,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_main_hdr_type, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"Type",
|
|
|
|
"jpeg.main_hdr.type",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_main_hdr_q, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"Q",
|
|
|
|
"jpeg.main_hdr.q",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_main_hdr_width, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"Width",
|
|
|
|
"jpeg.main_hdr.width",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_main_hdr_height, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"Height",
|
|
|
|
"jpeg.main_hdr.height",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_restart_hdr, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"Restart Marker Header",
|
|
|
|
"jpeg.restart_hdr",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_restart_hdr_interval, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"Restart Interval",
|
|
|
|
"jpeg.restart_hdr.interval",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_restart_hdr_f, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"F",
|
|
|
|
"jpeg.restart_hdr.f",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x8000,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_restart_hdr_l, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"L",
|
|
|
|
"jpeg.restart_hdr.l",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x4000,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_restart_hdr_count, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"Restart Count",
|
|
|
|
"jpeg.restart_hdr.count",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x3FFF,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_qtable_hdr, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"Quantization Table Header",
|
|
|
|
"jpeg.qtable_hdr",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_qtable_hdr_mbz, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"MBZ",
|
|
|
|
"jpeg.qtable_hdr.mbz",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_qtable_hdr_prec, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"Precision",
|
|
|
|
"jpeg.qtable_hdr.precision",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_qtable_hdr_length, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"Length",
|
|
|
|
"jpeg.qtable_hdr.length",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_qtable_hdr_data, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"Quantization Table Data",
|
|
|
|
"jpeg.qtable_hdr.data",
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
FT_BYTES, BASE_NONE, NULL, 0,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
2011-09-21 23:42:55 +00:00
|
|
|
{ &hf_rtp_jpeg_payload, {
|
2006-08-10 11:18:02 +00:00
|
|
|
"Payload",
|
|
|
|
"jpeg.payload",
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
FT_BYTES, BASE_NONE, NULL, 0,
|
2011-09-21 23:42:55 +00:00
|
|
|
NULL, HFILL
|
2006-08-10 11:18:02 +00:00
|
|
|
}},
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] =
|
|
|
|
{
|
|
|
|
&ett_jpeg,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
proto_jpeg = proto_register_protocol("RFC 2435 JPEG","JPEG","jpeg");
|
|
|
|
proto_register_field_array(proto_jpeg, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_jpeg(void)
|
|
|
|
{
|
|
|
|
dissector_handle_t jpeg_handle;
|
|
|
|
|
|
|
|
jpeg_handle = create_dissector_handle(dissect_jpeg, proto_jpeg);
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("rtp.pt", PT_JPEG, jpeg_handle);
|
2006-08-10 11:18:02 +00:00
|
|
|
}
|