HACK: 2nd try to match RowsetProperties
[wireshark-wip.git] / epan / dissectors / packet-h261.c
blob397b36b4d6edf84fd8639c348aeffba466aa3270
1 /* packet-h261.c
3 * Routines for ITU-T Recommendation H.261 dissection
5 * $Id$
7 * Copyright 2000, Philips Electronics N.V.
8 * Andreas Sikkema <h323@ramdyne.nl>
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 * This dissector tries to dissect the H.261 protocol according to Annex C
31 * of ITU-T Recommendation H.225.0 (02/98)
35 #include "config.h"
37 #include <glib.h>
38 #include <epan/packet.h>
40 #include <epan/rtp_pt.h>
41 #include <epan/iax2_codec_type.h>
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;
59 static void
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;
66 col_set_str(pinfo->cinfo, COL_PROTOCOL, "H.261");
68 col_set_str(pinfo->cinfo, COL_INFO, "H.261 message");
70 if ( tree ) {
71 ti = proto_tree_add_item( tree, proto_h261, tvb, offset, -1, ENC_NA );
72 h261_tree = proto_item_add_subtree( ti, ett_h261 );
73 /* SBIT 1st octet, 3 bits */
74 proto_tree_add_uint( h261_tree, hf_h261_sbit, tvb, offset, 1, tvb_get_guint8( tvb, offset ) >> 5 );
75 /* EBIT 1st octet, 3 bits */
76 proto_tree_add_uint( h261_tree, hf_h261_ebit, tvb, offset, 1, ( tvb_get_guint8( tvb, offset ) >> 2 ) & 7 );
77 /* I flag, 1 bit */
78 proto_tree_add_boolean( h261_tree, hf_h261_ibit, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 2 );
79 /* V flag, 1 bit */
80 proto_tree_add_boolean( h261_tree, hf_h261_vbit, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 1 );
81 offset++;
83 /* GOBN 2nd octet, 4 bits */
84 proto_tree_add_uint( h261_tree, hf_h261_gobn, tvb, offset, 1, tvb_get_guint8( tvb, offset ) >> 4 );
85 /* MBAP 2nd octet, 4 bits, 3rd octet 1 bit */
86 proto_tree_add_uint( h261_tree, hf_h261_mbap, tvb, offset, 1,
87 ( tvb_get_guint8( tvb, offset ) & 15 )
88 + ( tvb_get_guint8( tvb, offset + 1 ) >> 7 ) );
89 offset++;
91 /* QUANT 3rd octet, 5 bits (starting at bit 2!) */
92 proto_tree_add_uint( h261_tree, hf_h261_quant, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 124 );
94 /* HMVD 3rd octet 2 bits, 4th octet 3 bits */
95 proto_tree_add_uint( h261_tree, hf_h261_hmvd, tvb, offset, 2,
96 ( ( tvb_get_guint8( tvb, offset ) & 0x03 ) << 3 )
97 + ( tvb_get_guint8( tvb, offset+1 ) >> 5 ) );
98 offset++;
100 /* VMVD 4th octet, last 5 bits */
101 proto_tree_add_uint( h261_tree, hf_h261_vmvd, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 31 );
102 offset++;
104 /* The rest of the packet is the H.261 stream */
105 proto_tree_add_item( h261_tree, hf_h261_data, tvb, offset, -1, ENC_NA );
109 void
110 proto_register_h261(void)
112 static hf_register_info hf[] =
115 &hf_h261_sbit,
117 "Start bit position",
118 "h261.sbit",
119 FT_UINT8,
120 BASE_DEC,
121 NULL,
122 0x0,
123 NULL, HFILL
127 &hf_h261_ebit,
129 "End bit position",
130 "h261.ebit",
131 FT_UINT8,
132 BASE_DEC,
133 NULL,
134 0x0,
135 NULL, HFILL
139 &hf_h261_ibit,
141 "Intra frame encoded data flag",
142 "h261.i",
143 FT_BOOLEAN,
144 BASE_NONE,
145 NULL,
146 0x0,
147 NULL, HFILL
151 &hf_h261_vbit,
153 "Motion vector flag",
154 "h261.v",
155 FT_BOOLEAN,
156 BASE_NONE,
157 NULL,
158 0x0,
159 NULL, HFILL
163 &hf_h261_gobn,
165 "GOB Number",
166 "h261.gobn",
167 FT_UINT8,
168 BASE_DEC,
169 NULL,
170 0x0,
171 NULL, HFILL
175 &hf_h261_mbap,
177 "Macroblock address predictor",
178 "h261.mbap",
179 FT_UINT8,
180 BASE_DEC,
181 NULL,
182 0x0,
183 NULL, HFILL
187 &hf_h261_quant,
189 "Quantizer",
190 "h261.quant",
191 FT_UINT8,
192 BASE_DEC,
193 NULL,
194 0x0,
195 NULL, HFILL
199 &hf_h261_hmvd,
201 "Horizontal motion vector data",
202 "h261.hmvd",
203 FT_UINT8,
204 BASE_DEC,
205 NULL,
206 0x0,
207 NULL, HFILL
211 &hf_h261_vmvd,
213 "Vertical motion vector data",
214 "h261.vmvd",
215 FT_UINT8,
216 BASE_DEC,
217 NULL,
218 0x0,
219 NULL, HFILL
223 &hf_h261_data,
225 "H.261 stream",
226 "h261.stream",
227 FT_BYTES,
228 BASE_NONE,
229 NULL,
230 0x0,
231 NULL, HFILL
236 static gint *ett[] =
238 &ett_h261,
242 proto_h261 = proto_register_protocol("ITU-T Recommendation H.261",
243 "H.261", "h261");
244 proto_register_field_array(proto_h261, hf, array_length(hf));
245 proto_register_subtree_array(ett, array_length(ett));
248 void
249 proto_reg_handoff_h261(void)
251 dissector_handle_t h261_handle;
253 h261_handle = create_dissector_handle(dissect_h261, proto_h261);
254 dissector_add_uint("rtp.pt", PT_H261, h261_handle);
255 dissector_add_uint("iax2.codec", AST_FORMAT_H261, h261_handle);