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 * SPDX-License-Identifier: GPL-2.0-or-later
16 * This dissector tries to dissect the H.261 protocol according to Annex C
17 * of ITU-T Recommendation H.225.0 (02/98)
23 #include <epan/packet.h>
25 #include <epan/rtp_pt.h>
26 #include <epan/iax2_codec_type.h>
28 void proto_register_h261(void);
29 void proto_reg_handoff_h261(void);
31 /* H.261 header fields */
32 static int proto_h261 = -1;
33 static int hf_h261_sbit = -1;
34 static int hf_h261_ebit = -1;
35 static int hf_h261_ibit = -1;
36 static int hf_h261_vbit = -1;
37 static int hf_h261_gobn = -1;
38 static int hf_h261_mbap = -1;
39 static int hf_h261_quant = -1;
40 static int hf_h261_hmvd = -1; /* Mislabeled in a figure in section C.3.1 as HMDV */
41 static int hf_h261_vmvd = -1;
42 static int hf_h261_data = -1;
44 /* H.261 fields defining a sub tree */
45 static gint ett_h261 = -1;
48 dissect_h261( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ )
50 proto_item *ti = NULL;
51 proto_tree *h261_tree = NULL;
52 unsigned int offset = 0;
53 static const int * bits[] = {
54 /* SBIT 1st octet, 3 bits */
56 /* EBIT 1st octet, 3 bits */
65 col_set_str(pinfo->cinfo, COL_PROTOCOL, "H.261");
67 col_set_str(pinfo->cinfo, COL_INFO, "H.261 message");
70 ti = proto_tree_add_item( tree, proto_h261, tvb, offset, -1, ENC_NA );
71 h261_tree = proto_item_add_subtree( ti, ett_h261 );
73 proto_tree_add_bitmask_list(h261_tree, tvb, offset, 1, bits, ENC_NA);
76 /* GOBN 2nd octet, 4 bits */
77 proto_tree_add_item( h261_tree, hf_h261_gobn, tvb, offset, 1, ENC_NA);
78 /* MBAP 2nd octet, 4 bits, 3rd octet 1 bit */
79 proto_tree_add_item( h261_tree, hf_h261_mbap, tvb, offset, 1, ENC_BIG_ENDIAN);
82 /* QUANT 3rd octet, 5 bits (starting at bit 2!) */
83 proto_tree_add_item( h261_tree, hf_h261_quant, tvb, offset, 1, ENC_NA );
85 /* HMVD 3rd octet 2 bits, 4th octet 3 bits */
86 proto_tree_add_item( h261_tree, hf_h261_hmvd, tvb, offset, 2, ENC_BIG_ENDIAN);
89 /* VMVD 4th octet, last 5 bits */
90 proto_tree_add_item( h261_tree, hf_h261_vmvd, tvb, offset, 1, 0x1F );
93 /* The rest of the packet is the H.261 stream */
94 proto_tree_add_item( h261_tree, hf_h261_data, tvb, offset, -1, ENC_NA );
96 return tvb_captured_length(tvb);
100 proto_register_h261(void)
102 static hf_register_info hf[] =
107 "Start bit position",
131 "Intra frame encoded data flag",
143 "Motion vector flag",
167 "Macroblock address predictor",
191 "Horizontal motion vector data",
203 "Vertical motion vector data",
232 proto_h261 = proto_register_protocol("ITU-T Recommendation H.261",
234 proto_register_field_array(proto_h261, hf, array_length(hf));
235 proto_register_subtree_array(ett, array_length(ett));
239 proto_reg_handoff_h261(void)
241 dissector_handle_t h261_handle;
243 h261_handle = create_dissector_handle(dissect_h261, proto_h261);
244 dissector_add_uint("rtp.pt", PT_H261, h261_handle);
245 dissector_add_uint("iax2.codec", AST_FORMAT_H261, h261_handle);
249 * Editor modelines - http://www.wireshark.org/tools/modelines.html
254 * indent-tabs-mode: t
257 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
258 * :indentSize=8:tabSize=8:noTabs=false: