3 * Routines for ITU-T Recommendation H.261 dissection
5 * Copyright 2000, Philips Electronics N.V.
6 * Andreas Sikkema <h323@ramdyne.nl>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 * This dissector tries to dissect the H.261 protocol according to Annex C
29 * of ITU-T Recommendation H.225.0 (02/98)
35 #include <epan/packet.h>
37 #include <epan/rtp_pt.h>
38 #include <epan/iax2_codec_type.h>
40 void proto_register_h261(void);
41 void proto_reg_handoff_h261(void);
43 /* H.261 header fields */
44 static int proto_h261 = -1;
45 static int hf_h261_sbit = -1;
46 static int hf_h261_ebit = -1;
47 static int hf_h261_ibit = -1;
48 static int hf_h261_vbit = -1;
49 static int hf_h261_gobn = -1;
50 static int hf_h261_mbap = -1;
51 static int hf_h261_quant = -1;
52 static int hf_h261_hmvd = -1; /* Mislabeled in a figure in section C.3.1 as HMDV */
53 static int hf_h261_vmvd = -1;
54 static int hf_h261_data = -1;
56 /* H.261 fields defining a sub tree */
57 static gint ett_h261 = -1;
60 dissect_h261( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
62 proto_item *ti = NULL;
63 proto_tree *h261_tree = NULL;
64 unsigned int offset = 0;
65 static const int * bits[] = {
66 /* SBIT 1st octet, 3 bits */
68 /* EBIT 1st octet, 3 bits */
77 col_set_str(pinfo->cinfo, COL_PROTOCOL, "H.261");
79 col_set_str(pinfo->cinfo, COL_INFO, "H.261 message");
82 ti = proto_tree_add_item( tree, proto_h261, tvb, offset, -1, ENC_NA );
83 h261_tree = proto_item_add_subtree( ti, ett_h261 );
85 proto_tree_add_bitmask_list(h261_tree, tvb, offset, 1, bits, ENC_NA);
88 /* GOBN 2nd octet, 4 bits */
89 proto_tree_add_uint( h261_tree, hf_h261_gobn, tvb, offset, 1, tvb_get_guint8( tvb, offset ) >> 4 );
90 /* MBAP 2nd octet, 4 bits, 3rd octet 1 bit */
91 proto_tree_add_uint( h261_tree, hf_h261_mbap, tvb, offset, 1,
92 ( tvb_get_guint8( tvb, offset ) & 15 )
93 + ( tvb_get_guint8( tvb, offset + 1 ) >> 7 ) );
96 /* QUANT 3rd octet, 5 bits (starting at bit 2!) */
97 proto_tree_add_uint( h261_tree, hf_h261_quant, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 124 );
99 /* HMVD 3rd octet 2 bits, 4th octet 3 bits */
100 proto_tree_add_uint( h261_tree, hf_h261_hmvd, tvb, offset, 2,
101 ( ( tvb_get_guint8( tvb, offset ) & 0x03 ) << 3 )
102 + ( tvb_get_guint8( tvb, offset+1 ) >> 5 ) );
105 /* VMVD 4th octet, last 5 bits */
106 proto_tree_add_uint( h261_tree, hf_h261_vmvd, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 31 );
109 /* The rest of the packet is the H.261 stream */
110 proto_tree_add_item( h261_tree, hf_h261_data, tvb, offset, -1, ENC_NA );
115 proto_register_h261(void)
117 static hf_register_info hf[] =
122 "Start bit position",
146 "Intra frame encoded data flag",
158 "Motion vector flag",
182 "Macroblock address predictor",
206 "Horizontal motion vector data",
218 "Vertical motion vector data",
247 proto_h261 = proto_register_protocol("ITU-T Recommendation H.261",
249 proto_register_field_array(proto_h261, hf, array_length(hf));
250 proto_register_subtree_array(ett, array_length(ett));
254 proto_reg_handoff_h261(void)
256 dissector_handle_t h261_handle;
258 h261_handle = create_dissector_handle(dissect_h261, proto_h261);
259 dissector_add_uint("rtp.pt", PT_H261, h261_handle);
260 dissector_add_uint("iax2.codec", AST_FORMAT_H261, h261_handle);
264 * Editor modelines - http://www.wireshark.org/tools/modelines.html
269 * indent-tabs-mode: t
272 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
273 * :indentSize=8:tabSize=8:noTabs=false: