2000-10-19 06:45:11 +00:00
|
|
|
/* packet-h261.c
|
|
|
|
*
|
|
|
|
* Routines for ITU-T Recommendation H.261 dissection
|
2001-06-12 06:32:39 +00:00
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
* $Id: packet-h261.c,v 1.17 2002/08/28 21:00:15 jmayer Exp $
|
|
|
|
*
|
2000-10-19 06:45:11 +00:00
|
|
|
* Copyright 2000, Philips Electronics N.V.
|
|
|
|
* Andreas Sikkema <andreas.sikkema@philips.com>
|
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
2001-05-27 07:37:46 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
2000-10-19 06:45:11 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2000-10-19 06:45:11 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2000-10-19 06:45:11 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2000-10-19 06:45:11 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2000-10-22 07:53:19 +00:00
|
|
|
* This dissector tries to dissect the H.261 protocol according to Annex C
|
2000-10-19 06:45:11 +00:00
|
|
|
* of ITU-T Recommendation H.225.0 (02/98)
|
|
|
|
*
|
|
|
|
* This dissector is called by the RTP dissector
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib.h>
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
2000-10-19 06:45:11 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2000-10-22 07:53:19 +00:00
|
|
|
/* H.261 header fields */
|
2000-10-19 06:45:11 +00:00
|
|
|
static int proto_h261 = -1;
|
|
|
|
static int hf_h261_sbit = -1;
|
|
|
|
static int hf_h261_ebit = -1;
|
|
|
|
static int hf_h261_ibit = -1;
|
|
|
|
static int hf_h261_vbit = -1;
|
|
|
|
static int hf_h261_gobn = -1;
|
|
|
|
static int hf_h261_mbap = -1;
|
|
|
|
static int hf_h261_quant = -1;
|
|
|
|
static int hf_h261_hmvd = -1; /* Mislabeled in a figure in section C.3.1 as HMDV */
|
|
|
|
static int hf_h261_vmvd = -1;
|
|
|
|
static int hf_h261_data = -1;
|
|
|
|
|
2000-10-22 07:53:19 +00:00
|
|
|
/* H.261 fields defining a sub tree */
|
2000-10-19 06:45:11 +00:00
|
|
|
static gint ett_h261 = -1;
|
|
|
|
|
2001-05-27 07:37:46 +00:00
|
|
|
static void
|
2000-10-19 06:45:11 +00:00
|
|
|
dissect_h261( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
|
|
|
|
{
|
|
|
|
proto_item *ti = NULL;
|
|
|
|
proto_tree *h261_tree = NULL;
|
|
|
|
unsigned int offset = 0;
|
|
|
|
|
2001-12-10 00:26:21 +00:00
|
|
|
if ( check_col( pinfo->cinfo, COL_PROTOCOL ) ) {
|
|
|
|
col_set_str( pinfo->cinfo, COL_PROTOCOL, "H.261" );
|
2000-10-19 06:45:11 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-12-10 00:26:21 +00:00
|
|
|
if ( check_col( pinfo->cinfo, COL_INFO) ) {
|
|
|
|
col_set_str( pinfo->cinfo, COL_INFO, "H.261 message");
|
2000-10-19 06:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( tree ) {
|
2002-01-24 09:20:54 +00:00
|
|
|
ti = proto_tree_add_item( tree, proto_h261, tvb, offset, -1, FALSE );
|
2000-10-19 06:45:11 +00:00
|
|
|
h261_tree = proto_item_add_subtree( ti, ett_h261 );
|
|
|
|
/* SBIT 1st octet, 3 bits */
|
|
|
|
proto_tree_add_uint( h261_tree, hf_h261_sbit, tvb, offset, 1, tvb_get_guint8( tvb, offset ) >> 5 );
|
|
|
|
/* EBIT 1st octet, 3 bits */
|
2002-01-29 17:18:06 +00:00
|
|
|
proto_tree_add_uint( h261_tree, hf_h261_ebit, tvb, offset, 1, ( tvb_get_guint8( tvb, offset ) << 3 ) >> 5 );
|
2000-10-19 06:45:11 +00:00
|
|
|
/* I flag, 1 bit */
|
|
|
|
proto_tree_add_boolean( h261_tree, hf_h261_ibit, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 2 );
|
|
|
|
/* V flag, 1 bit */
|
|
|
|
proto_tree_add_boolean( h261_tree, hf_h261_vbit, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 1 );
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
/* GOBN 2nd octet, 4 bits */
|
|
|
|
proto_tree_add_uint( h261_tree, hf_h261_gobn, tvb, offset, 1, tvb_get_guint8( tvb, offset ) >> 4 );
|
|
|
|
/* MBAP 2nd octet, 4 bits, 3rd octet 1 bit */
|
|
|
|
proto_tree_add_uint( h261_tree, hf_h261_mbap, tvb, offset, 1,
|
|
|
|
( tvb_get_guint8( tvb, offset ) & 15 )
|
|
|
|
+ ( tvb_get_guint8( tvb, offset + 1 ) >> 7 ) );
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
/* QUANT 3rd octet, 5 bits (starting at bit 2!) */
|
2002-01-29 17:18:06 +00:00
|
|
|
proto_tree_add_uint( h261_tree, hf_h261_quant, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 124 );
|
|
|
|
/* HMVD 3rd octet 2 bits, 4th octet 3 bits */
|
|
|
|
proto_tree_add_uint( h261_tree, hf_h261_hmvd, tvb, offset, 1,
|
2000-10-19 06:45:11 +00:00
|
|
|
( ( tvb_get_guint8( tvb, offset ) << 4) >> 4 )
|
|
|
|
+ ( tvb_get_guint8( tvb, offset ) >> 5 ) );
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
/* VMVD 4th octet, last 5 bits */
|
2002-01-29 17:18:06 +00:00
|
|
|
proto_tree_add_uint( h261_tree, hf_h261_vmvd, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 31 );
|
2000-10-19 06:45:11 +00:00
|
|
|
offset++;
|
|
|
|
|
|
|
|
/* The rest of the packet is the H.261 stream */
|
2002-02-01 04:34:17 +00:00
|
|
|
proto_tree_add_item( h261_tree, hf_h261_data, tvb, offset, -1, FALSE );
|
2000-10-19 06:45:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_h261(void)
|
|
|
|
{
|
2002-08-28 21:04:11 +00:00
|
|
|
static hf_register_info hf[] =
|
2000-10-19 06:45:11 +00:00
|
|
|
{
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
2000-10-19 06:45:11 +00:00
|
|
|
&hf_h261_sbit,
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
|
|
|
"Start bit position",
|
|
|
|
"h261.sbit",
|
|
|
|
FT_UINT8,
|
|
|
|
BASE_DEC,
|
|
|
|
NULL,
|
2000-10-19 06:45:11 +00:00
|
|
|
0x0,
|
2002-08-28 21:04:11 +00:00
|
|
|
"", HFILL
|
2000-10-19 06:45:11 +00:00
|
|
|
}
|
|
|
|
},
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
2000-10-19 06:45:11 +00:00
|
|
|
&hf_h261_ebit,
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
|
|
|
"End bit position",
|
|
|
|
"h261.ebit",
|
|
|
|
FT_UINT8,
|
|
|
|
BASE_DEC,
|
|
|
|
NULL,
|
2000-10-19 06:45:11 +00:00
|
|
|
0x0,
|
2002-08-28 21:04:11 +00:00
|
|
|
"", HFILL
|
2000-10-19 06:45:11 +00:00
|
|
|
}
|
|
|
|
},
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
2000-10-19 06:45:11 +00:00
|
|
|
&hf_h261_ibit,
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
|
|
|
"Intra frame encoded data flag",
|
|
|
|
"h261.i",
|
|
|
|
FT_BOOLEAN,
|
|
|
|
BASE_NONE,
|
|
|
|
NULL,
|
2000-10-19 06:45:11 +00:00
|
|
|
0x0,
|
2002-08-28 21:04:11 +00:00
|
|
|
"", HFILL
|
2000-10-19 06:45:11 +00:00
|
|
|
}
|
|
|
|
},
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
2000-10-19 06:45:11 +00:00
|
|
|
&hf_h261_vbit,
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
|
|
|
"Motion vector flag",
|
|
|
|
"h261.v",
|
|
|
|
FT_BOOLEAN,
|
|
|
|
BASE_NONE,
|
|
|
|
NULL,
|
2000-10-19 06:45:11 +00:00
|
|
|
0x0,
|
2002-08-28 21:04:11 +00:00
|
|
|
"", HFILL
|
2000-10-19 06:45:11 +00:00
|
|
|
}
|
|
|
|
},
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
2000-10-19 06:45:11 +00:00
|
|
|
&hf_h261_gobn,
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
|
|
|
"GOB Number",
|
|
|
|
"h261.gobn",
|
|
|
|
FT_UINT8,
|
|
|
|
BASE_DEC,
|
|
|
|
NULL,
|
2000-10-19 06:45:11 +00:00
|
|
|
0x0,
|
2002-08-28 21:04:11 +00:00
|
|
|
"", HFILL
|
2000-10-19 06:45:11 +00:00
|
|
|
}
|
|
|
|
},
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
2000-10-19 06:45:11 +00:00
|
|
|
&hf_h261_mbap,
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
|
|
|
"Macroblock address predictor",
|
|
|
|
"h261.mbap",
|
|
|
|
FT_UINT8,
|
|
|
|
BASE_DEC,
|
|
|
|
NULL,
|
2000-10-19 06:45:11 +00:00
|
|
|
0x0,
|
2002-08-28 21:04:11 +00:00
|
|
|
"", HFILL
|
2000-10-19 06:45:11 +00:00
|
|
|
}
|
|
|
|
},
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
2000-10-19 06:45:11 +00:00
|
|
|
&hf_h261_quant,
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
|
|
|
"Quantizer",
|
|
|
|
"h261.quant",
|
|
|
|
FT_UINT8,
|
|
|
|
BASE_DEC,
|
|
|
|
NULL,
|
2000-10-19 06:45:11 +00:00
|
|
|
0x0,
|
2002-08-28 21:04:11 +00:00
|
|
|
"", HFILL
|
2000-10-19 06:45:11 +00:00
|
|
|
}
|
|
|
|
},
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
2000-10-19 06:45:11 +00:00
|
|
|
&hf_h261_hmvd,
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
|
|
|
"Horizontal motion vector data",
|
|
|
|
"h261.hmvd",
|
|
|
|
FT_UINT8,
|
|
|
|
BASE_DEC,
|
|
|
|
NULL,
|
2000-10-19 06:45:11 +00:00
|
|
|
0x0,
|
2002-08-28 21:04:11 +00:00
|
|
|
"", HFILL
|
2000-10-19 06:45:11 +00:00
|
|
|
}
|
|
|
|
},
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
2000-10-19 06:45:11 +00:00
|
|
|
&hf_h261_vmvd,
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
|
|
|
"Vertical motion vector data",
|
|
|
|
"h261.vmvd",
|
|
|
|
FT_UINT8,
|
|
|
|
BASE_DEC,
|
|
|
|
NULL,
|
2000-10-19 06:45:11 +00:00
|
|
|
0x0,
|
2002-08-28 21:04:11 +00:00
|
|
|
"", HFILL
|
2000-10-19 06:45:11 +00:00
|
|
|
}
|
|
|
|
},
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
2000-10-19 06:45:11 +00:00
|
|
|
&hf_h261_data,
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
|
|
|
"H.261 stream",
|
|
|
|
"h261.stream",
|
|
|
|
FT_BYTES,
|
|
|
|
BASE_NONE,
|
|
|
|
NULL,
|
2000-10-19 06:45:11 +00:00
|
|
|
0x0,
|
2002-08-28 21:04:11 +00:00
|
|
|
"", HFILL
|
2000-10-19 06:45:11 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
2002-08-28 21:04:11 +00:00
|
|
|
|
|
|
|
static gint *ett[] =
|
2000-10-19 06:45:11 +00:00
|
|
|
{
|
|
|
|
&ett_h261,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-01-03 06:56:03 +00:00
|
|
|
proto_h261 = proto_register_protocol("ITU-T Recommendation H.261",
|
|
|
|
"H.261", "h261");
|
2000-10-19 06:45:11 +00:00
|
|
|
proto_register_field_array(proto_h261, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2001-05-27 07:37:46 +00:00
|
|
|
|
|
|
|
register_dissector("h261", dissect_h261, proto_h261);
|
2000-10-19 06:45:11 +00:00
|
|
|
}
|