dcerpc-netlogon: maintain netlogon_auth_vars for NetrServerAuthenticateKerberos
[wireshark-sm.git] / epan / dissectors / packet-h263p.c
bloba06f3d5824a161bb5c9a8f076af4563676668f3f
1 /* packet-h263p.c
3 * Routines for RFC-4629-encapsulated H.263 dissection
5 * Copyright 2003 Niklas Ogren <niklas.ogren@7l.se>
6 * Seven Levels Consultants AB
8 * Copyright 2008 Richard van der Hoff, MX Telecom
9 * <richardv@mxtelecom.com>
11 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
13 * Copyright 1998 Gerald Combs
15 * SPDX-License-Identifier: GPL-2.0-or-later
18 #include "config.h"
20 #include <epan/packet.h>
22 #include <epan/prefs.h>
24 #include "packet-h263.h"
26 void proto_reg_handoff_h263P(void);
27 void proto_register_h263P(void);
29 static int proto_h263P;
31 /* H.263 RFC 4629 fields */
32 static int hf_h263P_payload;
33 static int hf_h263P_rr;
34 static int hf_h263P_pbit;
35 static int hf_h263P_vbit;
36 static int hf_h263P_plen;
37 static int hf_h263P_pebit;
38 static int hf_h263P_tid;
39 static int hf_h263P_trun;
40 static int hf_h263P_s;
41 static int hf_h263P_extra_hdr;
42 /* static int hf_h263P_PSC; */
43 /* static int hf_h263P_TR; */
46 /* H.263-1998 fields defining a sub tree */
47 static int ett_h263P;
48 static int ett_h263P_extra_hdr;
49 static int ett_h263P_payload;
50 static int ett_h263P_data;
52 static dissector_handle_t h263P_handle;
54 /* RFC 4629 */
55 static int
56 dissect_h263P( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ )
58 proto_item *ti = NULL;
59 proto_item *data_item = NULL;
60 proto_item *extra_hdr_item = NULL;
61 proto_tree *h263P_tree = NULL;
62 proto_tree *h263P_extr_hdr_tree = NULL;
63 proto_tree *h263P_data_tree = NULL;
64 unsigned int offset = 0;
65 uint16_t data16, plen;
66 uint8_t startcode;
69 tvbuff_t *next_tvb;
72 col_set_str(pinfo->cinfo, COL_PROTOCOL, "H.263 RFC4629 ");
74 if ( tree ) {
75 ti = proto_tree_add_item( tree, proto_h263P, tvb, offset, -1, ENC_NA );
76 h263P_tree = proto_item_add_subtree( ti, ett_h263P );
78 data16 = tvb_get_ntohs(tvb,offset);
79 proto_tree_add_item( h263P_tree, hf_h263P_rr, tvb, offset, 2, ENC_BIG_ENDIAN );
80 proto_tree_add_item( h263P_tree, hf_h263P_pbit, tvb, offset, 2, ENC_BIG_ENDIAN );
81 proto_tree_add_item( h263P_tree, hf_h263P_vbit, tvb, offset, 2, ENC_BIG_ENDIAN );
82 proto_tree_add_item( h263P_tree, hf_h263P_plen, tvb, offset, 2, ENC_BIG_ENDIAN );
83 proto_tree_add_item( h263P_tree, hf_h263P_pebit, tvb, offset, 2, ENC_BIG_ENDIAN );
84 offset = offset +2;
86 * V: 1 bit
88 * Indicates the presence of an 8-bit field containing information
89 * for Video Redundancy Coding (VRC), which follows immediately after
90 * the initial 16 bits of the payload header, if present. For syntax
91 * and semantics of that 8-bit VRC field, see Section 5.2.
94 if ((data16&0x0200)==0x0200){
95 /* V bit = 1
96 * The format of the VRC header extension is as follows:
98 * 0 1 2 3 4 5 6 7
99 * +-+-+-+-+-+-+-+-+
100 * | TID | Trun |S|
101 * +-+-+-+-+-+-+-+-+
103 * TID: 3 bits
105 * Thread ID. Up to 7 threads are allowed. Each frame of H.263+ VRC
106 * data will use as reference information only sync frames or frames
107 * within the same thread. By convention, thread 0 is expected to be
108 * the "canonical" thread, which is the thread from which the sync frame
109 * should ideally be used. In the case of corruption or loss of the
110 * thread 0 representation, a representation of the sync frame with a
111 * higher thread number can be used by the decoder. Lower thread
112 * numbers are expected to contain representations of the sync frames
113 * equal to or better than higher thread numbers in the absence of data
114 * corruption or loss. See [Vredun] for a detailed discussion of VRC.
116 * Trun: 4 bits
118 * Monotonically increasing (modulo 16) 4-bit number counting the packet
119 * number within each thread.
121 * S: 1 bit
123 * A bit that indicates that the packet content is for a sync frame.
126 proto_tree_add_item( h263P_tree, hf_h263P_tid, tvb, offset, 1, ENC_BIG_ENDIAN );
127 proto_tree_add_item( h263P_tree, hf_h263P_trun, tvb, offset, 1, ENC_BIG_ENDIAN );
128 proto_tree_add_item( h263P_tree, hf_h263P_s, tvb, offset, 1, ENC_BIG_ENDIAN );
129 offset++;
132 /* Length, in bytes, of the extra picture header. */
133 plen = (data16 & 0x01f8) >> 3;
134 if (plen != 0){
135 extra_hdr_item = proto_tree_add_item( h263P_tree, hf_h263P_extra_hdr, tvb, offset, plen, ENC_NA );
136 h263P_extr_hdr_tree = proto_item_add_subtree( extra_hdr_item, ett_h263P_extra_hdr );
137 dissect_h263_picture_layer( tvb, pinfo, h263P_extr_hdr_tree, offset, plen, true);
138 offset += plen;
140 if ((data16&0x0400)!=0){
141 /* P bit = 1 */
142 data_item = proto_tree_add_item( h263P_tree, hf_h263P_payload, tvb, offset, -1, ENC_NA );
143 h263P_data_tree = proto_item_add_subtree( data_item, ett_h263P_data );
144 /* Startc code holds bit 17 -23 of the codeword */
145 startcode = tvb_get_uint8(tvb,offset)&0xfe;
146 if (startcode & 0x80){
147 /* All picture, slice, and EOSBS start codes
148 * shall be byte aligned, and GOB and EOS start codes may be byte aligned.
150 switch(startcode){
151 case 0xf8:
152 /* End Of Sub-Bitstream code (EOSBS)
153 * EOSBS codes shall be byte aligned
154 * ( 1111 100. )
156 break;
157 case 0x80:
158 case 0x82:
159 /* Picture Start Code (PSC)
160 * ( 1000 00x.)
162 col_append_str( pinfo->cinfo, COL_INFO, "(PSC) ");
163 dissect_h263_picture_layer( tvb, pinfo, h263P_data_tree, offset, -1, true);
164 break;
165 case 0xfc:
166 case 0xfe:
167 /* End Of Sequence (EOS)
168 * ( 1111 11x. )
170 default:
171 /* Group of Block Start Code (GBSC) or
172 * Slice Start Code (SSC)
174 col_append_str( pinfo->cinfo, COL_INFO, "(GBSC) ");
175 dissect_h263_group_of_blocks_layer( tvb, h263P_data_tree, offset,true);
176 break;
178 }else{
179 /* Error */
181 return tvb_captured_length(tvb);
183 proto_tree_add_item( h263P_tree, hf_h263P_payload, tvb, offset, -1, ENC_NA );
185 return tvb_captured_length(tvb);
188 void
189 proto_reg_handoff_h263P(void)
191 dissector_add_string("rtp_dyn_payload_type","H263-1998", h263P_handle);
192 dissector_add_string("rtp_dyn_payload_type","H263-2000", h263P_handle);
193 dissector_add_uint_range_with_preference("rtp.pt", "", h263P_handle);
197 void
198 proto_register_h263P(void)
200 module_t *h263P_module;
202 static hf_register_info hf[] =
205 &hf_h263P_payload,
207 "H.263 RFC4629 payload",
208 "h263p.payload",
209 FT_NONE,
210 BASE_NONE,
211 NULL,
212 0x0,
213 "The actual H.263 RFC4629 data", HFILL
217 &hf_h263P_rr,
219 "Reserved",
220 "h263p.rr",
221 FT_UINT16,
222 BASE_DEC,
223 NULL,
224 0xf800,
225 "Reserved SHALL be zero", HFILL
229 &hf_h263P_pbit,
231 "P",
232 "h263p.p",
233 FT_BOOLEAN,
235 NULL,
236 0x0400,
237 "Indicates (GOB/Slice) start or (EOS or EOSBS)", HFILL
241 &hf_h263P_vbit,
243 "V",
244 "h263p.v",
245 FT_BOOLEAN,
247 NULL,
248 0x0200,
249 "presence of Video Redundancy Coding (VRC) field", HFILL
253 &hf_h263P_plen,
255 "PLEN",
256 "h263p.plen",
257 FT_UINT16,
258 BASE_DEC,
259 NULL,
260 0x01f8,
261 "Length, in bytes, of the extra picture header", HFILL
265 &hf_h263P_pebit,
267 "PEBIT",
268 "h263p.pebit",
269 FT_UINT16,
270 BASE_DEC,
271 NULL,
272 0x0003,
273 "number of bits that shall be ignored in the last byte of the picture header", HFILL
279 &hf_h263P_tid,
281 "Thread ID",
282 "h263p.tid",
283 FT_UINT8,
284 BASE_DEC,
285 NULL,
286 0xe0,
287 NULL, HFILL
291 &hf_h263P_trun,
293 "Trun",
294 "h263p.trun",
295 FT_UINT8,
296 BASE_DEC,
297 NULL,
298 0x1e,
299 "Monotonically increasing (modulo 16) 4-bit number counting the packet number within each thread", HFILL
303 &hf_h263P_s,
305 "S",
306 "h263p.s",
307 FT_UINT8,
308 BASE_DEC,
309 NULL,
310 0x01,
311 "Indicates that the packet content is for a sync frame", HFILL
315 &hf_h263P_extra_hdr,
317 "Extra picture header",
318 "h263p.extra_hdr",
319 FT_BYTES,
320 BASE_NONE,
321 NULL,
322 0x0,
323 NULL, HFILL
326 #if 0
328 &hf_h263P_PSC,
330 "H.263 PSC",
331 "h263p.PSC",
332 FT_UINT16,
333 BASE_HEX,
334 NULL,
335 0xfc00,
336 "Picture Start Code(PSC)", HFILL
339 #endif
340 #if 0
342 &hf_h263P_TR,
344 "H.263 Temporal Reference",
345 "h263p.tr",
346 FT_UINT16,
347 BASE_HEX,
348 NULL,
349 0x03fc,
350 "Temporal Reference, TR", HFILL
353 #endif
357 static int *ett[] =
359 &ett_h263P,
360 &ett_h263P_extra_hdr,
361 &ett_h263P_payload,
362 &ett_h263P_data,
366 proto_h263P = proto_register_protocol("ITU-T Recommendation H.263 RTP Payload header (RFC4629)",
367 "H.263P", "h263p");
369 proto_register_field_array(proto_h263P, hf, array_length(hf));
370 proto_register_subtree_array(ett, array_length(ett));
372 h263P_module = prefs_register_protocol(proto_h263P, NULL);
374 prefs_register_obsolete_preference(h263P_module, "dynamic.payload.type");
376 h263P_handle = register_dissector("h263P", dissect_h263P, proto_h263P);
380 * Editor modelines - https://www.wireshark.org/tools/modelines.html
382 * Local variables:
383 * c-basic-offset: 4
384 * tab-width: 8
385 * indent-tabs-mode: nil
386 * End:
388 * vi: set shiftwidth=4 tabstop=8 expandtab:
389 * :indentSize=4:tabSize=8:noTabs=true: