3 * Routines for ITU-T Recommendation H.261 dissection
5 * Copyright 2000, Philips Electronics N.V.
6 * Andreas Sikkema <andreas.sikkema@philips.com>
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@zing.org>
10 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 * This dissector tries to dissect the H.261 protocol according to Annex C
30 * of ITU-T Recommendation H.225.0 (02/98)
32 * This dissector is called by the RTP dissector
43 #ifdef HAVE_SYS_TYPES_H
44 # include <sys/types.h>
47 #ifdef HAVE_NETINET_IN_H
48 # include <netinet/in.h>
54 #include "packet-h261.h"
56 /* H.261 header fields */
57 static int proto_h261 = -1;
58 static int hf_h261_sbit = -1;
59 static int hf_h261_ebit = -1;
60 static int hf_h261_ibit = -1;
61 static int hf_h261_vbit = -1;
62 static int hf_h261_gobn = -1;
63 static int hf_h261_mbap = -1;
64 static int hf_h261_quant = -1;
65 static int hf_h261_hmvd = -1; /* Mislabeled in a figure in section C.3.1 as HMDV */
66 static int hf_h261_vmvd = -1;
67 static int hf_h261_data = -1;
69 /* H.261 fields defining a sub tree */
70 static gint ett_h261 = -1;
73 dissect_h261( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
75 proto_item *ti = NULL;
76 proto_tree *h261_tree = NULL;
77 unsigned int offset = 0;
79 if ( check_col( pinfo->fd, COL_PROTOCOL ) ) {
80 col_set_str( pinfo->fd, COL_PROTOCOL, "H.261" );
83 if ( check_col( pinfo->fd, COL_INFO) ) {
84 col_set_str( pinfo->fd, COL_INFO, "H.261 message");
88 /* Using fd->pkt_len here instead of END_OF_FRAME. This variable is changed in dissect_rtp()! */
89 ti = proto_tree_add_item( tree, proto_h261, tvb, offset, tvb_length( tvb ), FALSE );
90 h261_tree = proto_item_add_subtree( ti, ett_h261 );
91 /* SBIT 1st octet, 3 bits */
92 proto_tree_add_uint( h261_tree, hf_h261_sbit, tvb, offset, 1, tvb_get_guint8( tvb, offset ) >> 5 );
93 /* EBIT 1st octet, 3 bits */
94 proto_tree_add_item( h261_tree, hf_h261_ebit, tvb, offset, 1, ( tvb_get_guint8( tvb, offset ) << 3 ) >> 5 );
96 proto_tree_add_boolean( h261_tree, hf_h261_ibit, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 2 );
98 proto_tree_add_boolean( h261_tree, hf_h261_vbit, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 1 );
101 /* GOBN 2nd octet, 4 bits */
102 proto_tree_add_uint( h261_tree, hf_h261_gobn, tvb, offset, 1, tvb_get_guint8( tvb, offset ) >> 4 );
103 /* MBAP 2nd octet, 4 bits, 3rd octet 1 bit */
104 proto_tree_add_uint( h261_tree, hf_h261_mbap, tvb, offset, 1,
105 ( tvb_get_guint8( tvb, offset ) & 15 )
106 + ( tvb_get_guint8( tvb, offset + 1 ) >> 7 ) );
109 /* QUANT 3rd octet, 5 bits (starting at bit 2!) */
110 proto_tree_add_uint( h261_tree, hf_h261_mbap, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 124 );
111 /* HMDV 3rd octet 2 bits, 4th octet 3 bits */
112 proto_tree_add_uint( h261_tree, hf_h261_mbap, tvb, offset, 1,
113 ( ( tvb_get_guint8( tvb, offset ) << 4) >> 4 )
114 + ( tvb_get_guint8( tvb, offset ) >> 5 ) );
117 /* VMVD 4th octet, last 5 bits */
118 proto_tree_add_uint( h261_tree, hf_h261_mbap, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 31 );
121 /* The rest of the packet is the H.261 stream */
122 proto_tree_add_bytes( h261_tree, hf_h261_data, tvb, offset, tvb_length_remaining( tvb, offset ), tvb_get_ptr( tvb, offset, tvb_length_remaining( tvb, offset ) ) );
127 proto_register_h261(void)
129 static hf_register_info hf[] =
134 "Start bit position",
158 "Intra frame encoded data flag",
170 "Motion vector flag",
194 "Macroblock address predictor",
218 "Horizontal motion vctor data",
230 "Vertical motion vector data",
259 proto_h261 = proto_register_protocol("ITU-T Recommendation H.261",
261 proto_register_field_array(proto_h261, hf, array_length(hf));
262 proto_register_subtree_array(ett, array_length(ett));