Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-h261.c
blobfb18379447e6b66f59a78dedcb46896b98d5a24e
1 /* packet-h261.c
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)
21 #include "config.h"
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 static dissector_handle_t h261_handle;
33 /* H.261 header fields */
34 static int proto_h261;
35 static int hf_h261_sbit;
36 static int hf_h261_ebit;
37 static int hf_h261_ibit;
38 static int hf_h261_vbit;
39 static int hf_h261_gobn;
40 static int hf_h261_mbap;
41 static int hf_h261_quant;
42 static int hf_h261_hmvd; /* Mislabeled in a figure in section C.3.1 as HMDV */
43 static int hf_h261_vmvd;
44 static int hf_h261_data;
46 /* H.261 fields defining a sub tree */
47 static int ett_h261;
49 static int
50 dissect_h261( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ )
52 proto_item *ti = NULL;
53 proto_tree *h261_tree = NULL;
54 unsigned int offset = 0;
55 static int * const bits[] = {
56 /* SBIT 1st octet, 3 bits */
57 &hf_h261_sbit,
58 /* EBIT 1st octet, 3 bits */
59 &hf_h261_ebit,
60 /* I flag, 1 bit */
61 &hf_h261_ibit,
62 /* V flag, 1 bit */
63 &hf_h261_vbit,
64 NULL
67 col_set_str(pinfo->cinfo, COL_PROTOCOL, "H.261");
69 col_set_str(pinfo->cinfo, COL_INFO, "H.261 message");
71 ti = proto_tree_add_item( tree, proto_h261, tvb, offset, -1, ENC_NA);
72 h261_tree = proto_item_add_subtree( ti, ett_h261 );
74 proto_tree_add_bitmask_list(h261_tree, tvb, offset, 1, bits, ENC_NA);
75 offset++;
77 /* GOBN 2nd octet, 4 bits */
78 proto_tree_add_item( h261_tree, hf_h261_gobn, tvb, offset, 1, ENC_NA);
79 /* MBAP 2nd octet, 4 bits, 3rd octet 1 bit */
80 proto_tree_add_item( h261_tree, hf_h261_mbap, tvb, offset, 2, ENC_BIG_ENDIAN);
81 offset++;
83 /* QUANT 3rd octet, 5 bits (starting at bit 2!) */
84 proto_tree_add_item( h261_tree, hf_h261_quant, tvb, offset, 1, ENC_NA);
86 /* HMVD 3rd octet 2 bits, 4th octet 3 bits */
87 proto_tree_add_item( h261_tree, hf_h261_hmvd, tvb, offset, 2, ENC_BIG_ENDIAN);
88 offset++;
90 /* VMVD 4th octet, last 5 bits */
91 proto_tree_add_item( h261_tree, hf_h261_vmvd, tvb, offset, 1, ENC_NA);
92 offset++;
94 /* The rest of the packet is the H.261 stream */
95 proto_tree_add_item( h261_tree, hf_h261_data, tvb, offset, -1, ENC_NA);
97 return tvb_captured_length(tvb);
100 void
101 proto_register_h261(void)
103 static hf_register_info hf[] =
106 &hf_h261_sbit,
108 "Start bit position",
109 "h261.sbit",
110 FT_UINT8,
111 BASE_DEC,
112 NULL,
113 0xe0,
114 NULL, HFILL
118 &hf_h261_ebit,
120 "End bit position",
121 "h261.ebit",
122 FT_UINT8,
123 BASE_DEC,
124 NULL,
125 0x1c,
126 NULL, HFILL
130 &hf_h261_ibit,
132 "Intra frame encoded data flag",
133 "h261.i",
134 FT_BOOLEAN,
136 NULL,
137 0x02,
138 NULL, HFILL
142 &hf_h261_vbit,
144 "Motion vector flag",
145 "h261.v",
146 FT_BOOLEAN,
148 NULL,
149 0x01,
150 NULL, HFILL
154 &hf_h261_gobn,
156 "GOB Number",
157 "h261.gobn",
158 FT_UINT8,
159 BASE_DEC,
160 NULL,
161 0xF0,
162 NULL, HFILL
166 &hf_h261_mbap,
168 "Macroblock address predictor",
169 "h261.mbap",
170 FT_UINT16,
171 BASE_DEC,
172 NULL,
173 0x0F80,
174 NULL, HFILL
178 &hf_h261_quant,
180 "Quantizer",
181 "h261.quant",
182 FT_UINT8,
183 BASE_DEC,
184 NULL,
185 0x7C,
186 NULL, HFILL
190 &hf_h261_hmvd,
192 "Horizontal motion vector data",
193 "h261.hmvd",
194 FT_UINT16,
195 BASE_DEC,
196 NULL,
197 0x03E0,
198 NULL, HFILL
202 &hf_h261_vmvd,
204 "Vertical motion vector data",
205 "h261.vmvd",
206 FT_UINT8,
207 BASE_DEC,
208 NULL,
209 0x0,
210 NULL, HFILL
214 &hf_h261_data,
216 "H.261 stream",
217 "h261.stream",
218 FT_BYTES,
219 BASE_NONE,
220 NULL,
221 0x0,
222 NULL, HFILL
227 static int *ett[] =
229 &ett_h261,
233 proto_h261 = proto_register_protocol("ITU-T Recommendation H.261",
234 "H.261", "h261");
235 proto_register_field_array(proto_h261, hf, array_length(hf));
236 proto_register_subtree_array(ett, array_length(ett));
238 h261_handle = register_dissector("h261", dissect_h261, proto_h261);
241 void
242 proto_reg_handoff_h261(void)
244 dissector_add_uint("rtp.pt", PT_H261, h261_handle);
245 dissector_add_uint("iax2.codec", AST_FORMAT_H261, h261_handle);
249 * Editor modelines - https://www.wireshark.org/tools/modelines.html
251 * Local variables:
252 * c-basic-offset: 8
253 * tab-width: 8
254 * indent-tabs-mode: t
255 * End:
257 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
258 * :indentSize=8:tabSize=8:noTabs=false: