3 * Routines for RFC2190-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
19 * This dissector tries to dissect the H.263 protocol according to
20 * RFC 2190, https://www.ietf.org/rfc/rfc2190
25 #include <epan/packet.h>
27 #include <epan/rtp_pt.h>
28 #include <epan/iax2_codec_type.h>
30 #include "packet-h263.h"
32 void proto_register_rfc2190(void);
33 void proto_reg_handoff_rfc2190(void);
35 /* H.263 header fields */
36 static int proto_rfc2190
;
39 static int hf_rfc2190_ftype
;
40 static int hf_rfc2190_pbframes
;
41 static int hf_rfc2190_sbit
;
42 static int hf_rfc2190_ebit
;
43 static int hf_rfc2190_srcformat
;
44 static int hf_rfc2190_picture_coding_type_modeA
;
45 static int hf_rfc2190_unrestricted_motion_vector_modeA
;
46 static int hf_rfc2190_syntax_based_arithmetic_modeA
;
47 static int hf_rfc2190_advanced_prediction_modeA
;
48 static int hf_rfc2190_r_modeA
;
49 static int hf_rfc2190_rr
;
50 static int hf_rfc2190_dbq
;
51 static int hf_rfc2190_trb
;
52 static int hf_rfc2190_tr
;
53 /* Additional fields for Mode B or C header */
54 static int hf_rfc2190_picture_coding_type_modeB
;
55 static int hf_rfc2190_unrestricted_motion_vector_modeB
;
56 static int hf_rfc2190_syntax_based_arithmetic_modeB
;
57 static int hf_rfc2190_advanced_prediction_modeB
;
58 static int hf_rfc2190_r_modeB
;
59 static int hf_rfc2190_quant
;
60 static int hf_rfc2190_gobn
;
61 static int hf_rfc2190_mba
;
62 static int hf_rfc2190_hmv1
;
63 static int hf_rfc2190_vmv1
;
64 static int hf_rfc2190_hmv2
;
65 static int hf_rfc2190_vmv2
;
67 static int ett_rfc2190
;
68 static dissector_handle_t h263_handle
;
69 static dissector_handle_t rfc2190_handle
;
73 dissect_rfc2190( tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
75 proto_item
*ti
= NULL
;
76 proto_tree
*rfc2190_tree
= NULL
;
78 unsigned int rfc2190_version
= 0;
82 rfc2190_version
= (tvb_get_uint8( tvb
, offset
) & 0xc0 ) >> 6;
84 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "H.263 ");
86 /* Three formats (mode A, mode B and mode C) are defined for H.263
87 * payload header. In mode A, an H.263 payload header of four bytes is
88 * present before actual compressed H.263 video bitstream in a packet.
89 * It allows fragmentation at GOB boundaries. In mode B, an eight byte
90 * H.263 payload header is used and each packet starts at MB boundaries
91 * without the PB-frames option. Finally, a twelve byte H.263 payload
92 * header is defined in mode C to support fragmentation at MB boundaries
93 * for frames that are coded with the PB-frames option.
95 if( rfc2190_version
== 0x00) {
96 col_append_str( pinfo
->cinfo
, COL_INFO
, "MODE A ");
99 else if( rfc2190_version
== 0x02) {
100 col_append_str( pinfo
->cinfo
, COL_INFO
, "MODE B ");
103 else if( rfc2190_version
== 0x03) {
104 col_append_str( pinfo
->cinfo
, COL_INFO
, "MODE C ");
109 ti
= proto_tree_add_item( tree
, proto_rfc2190
, tvb
, offset
, hdr_len
, ENC_NA
);
110 rfc2190_tree
= proto_item_add_subtree( ti
, ett_rfc2190
);
112 /* FBIT 1st octet, 1 bit */
113 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_ftype
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
114 /* PBIT 1st octet, 1 bit */
115 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_pbframes
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
116 /* SBIT 1st octet, 3 bits */
117 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_sbit
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
118 /* EBIT 1st octet, 3 bits */
119 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_ebit
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
122 /* SRC 2nd octet, 3 bits */
123 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_srcformat
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
125 if(rfc2190_version
== 0x00) { /* MODE A */
127 proto_tree_add_item(rfc2190_tree
, hf_rfc2190_picture_coding_type_modeA
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
129 proto_tree_add_item(rfc2190_tree
, hf_rfc2190_unrestricted_motion_vector_modeA
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
131 proto_tree_add_item(rfc2190_tree
, hf_rfc2190_syntax_based_arithmetic_modeA
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
133 proto_tree_add_item(rfc2190_tree
, hf_rfc2190_advanced_prediction_modeA
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
135 /* Reserved 2nd octet, 1 bit + 3rd octet 3 bits */
136 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_r_modeA
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
140 /* DBQ 3 octet, 2 bits */
141 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_dbq
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
142 /* TRB 3 octet, 3 bits */
143 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_trb
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
146 /* TR 4 octet, 8 bits */
147 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_tr
, tvb
, offset
, 1, ENC_NA
);
151 } else { /* MODE B or MODE C */
152 /* QUANT 2 octet, 5 bits */
153 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_quant
, tvb
, offset
, 1, ENC_NA
);
157 /* GOBN 3 octet, 5 bits */
158 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_gobn
, tvb
, offset
, 1, ENC_NA
);
159 /* MBA 3 octet, 3 bits + 4 octet 6 bits */
160 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_mba
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
164 /* Reserved 4th octet, 2 bits */
165 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_r_modeB
, tvb
, offset
, 1, ENC_NA
);
170 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_picture_coding_type_modeB
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
172 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_unrestricted_motion_vector_modeB
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
174 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_syntax_based_arithmetic_modeB
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
176 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_advanced_prediction_modeB
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
178 /* HMV1 5th octet, 4 bits + 6th octet 3 bits*/
179 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_hmv1
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
183 /* VMV1 6th octet, 5 bits + 7th octet 2 bits*/
184 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_vmv1
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
188 /* HMV2 7th octet, 6 bits + 8th octet 1 bit*/
189 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_hmv2
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
193 /* VMV2 8th octet, 7 bits*/
194 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_vmv2
, tvb
, offset
, 1, ENC_NA
);
198 if(rfc2190_version
== 0x03) { /* MODE C */
199 /* Reserved 9th to 11th octet, 8 + 8 + 3 bits */
200 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_rr
, tvb
, offset
, 3, ENC_BIG_ENDIAN
);
204 /* DBQ 11th octet, 2 bits */
205 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_dbq
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
206 /* TRB 11th octet, 3 bits */
207 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_trb
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
211 /* TR 12th octet, 8 bits */
212 proto_tree_add_item( rfc2190_tree
, hf_rfc2190_tr
, tvb
, offset
, 1, ENC_NA
);
216 } /* end not mode a */
218 switch(rfc2190_version
) {
219 case 0x00: /* MODE A */
222 case 0x01: /* MODE B */
225 case 0x02: /* MODE C */
232 /* The rest of the packet is the H.263 stream */
233 next_tvb
= tvb_new_subset_remaining( tvb
, offset
);
234 call_dissector(h263_handle
,next_tvb
,pinfo
,tree
);
235 return tvb_captured_length(tvb
);
239 proto_reg_handoff_rfc2190(void)
241 dissector_add_uint("rtp.pt", PT_H263
, rfc2190_handle
);
242 dissector_add_uint("iax2.codec", AST_FORMAT_H263
, rfc2190_handle
);
244 h263_handle
= find_dissector_add_dependency("h263data", proto_rfc2190
);
249 proto_register_rfc2190(void)
251 static hf_register_info hf
[] = {
261 "Indicates the mode of the payload header (MODE A or B/C)", HFILL
265 &hf_rfc2190_pbframes
,
273 "Optional PB-frames mode as defined by H.263 (MODE C)", HFILL
279 "Start bit position",
285 "Start bit position specifies number of most significant bits that shall be ignored in the first data byte.", HFILL
297 "End bit position specifies number of least significant bits that shall be ignored in the last data byte.", HFILL
301 &hf_rfc2190_srcformat
,
307 VALS(h263_srcformat_vals
),
309 "Source format specifies the resolution of the current picture.", HFILL
313 &hf_rfc2190_picture_coding_type_modeA
,
316 "rfc2190.picture_coding_type",
321 "Picture coding type, intra-coded (false) or inter-coded (true)", HFILL
325 &hf_rfc2190_unrestricted_motion_vector_modeA
,
328 "rfc2190.unrestricted_motion_vector",
333 "Unrestricted Motion Vector option for current picture", HFILL
337 &hf_rfc2190_syntax_based_arithmetic_modeA
,
339 "Syntax-based arithmetic coding",
340 "rfc2190.syntax_based_arithmetic",
345 "Syntax-based Arithmetic Coding option for current picture", HFILL
349 &hf_rfc2190_advanced_prediction_modeA
,
351 "Advanced prediction option",
352 "rfc2190.advanced_prediction",
357 "Advanced Prediction option for current picture", HFILL
361 &hf_rfc2190_picture_coding_type_modeB
,
364 "rfc2190.picture_coding_type",
369 "Picture coding type, intra-coded (false) or inter-coded (true)", HFILL
373 &hf_rfc2190_unrestricted_motion_vector_modeB
,
376 "rfc2190.unrestricted_motion_vector",
381 "Unrestricted Motion Vector option for current picture", HFILL
385 &hf_rfc2190_syntax_based_arithmetic_modeB
,
387 "Syntax-based arithmetic coding",
388 "rfc2190.syntax_based_arithmetic",
393 "Syntax-based Arithmetic Coding option for current picture", HFILL
397 &hf_rfc2190_advanced_prediction_modeB
,
399 "Advanced prediction option",
400 "rfc2190.advanced_prediction",
405 "Advanced Prediction option for current picture", HFILL
411 "Differential quantization parameter",
417 "Differential quantization parameter used to calculate quantizer for the B frame based on quantizer for the P frame, when PB-frames option is used.", HFILL
423 "Temporal Reference for B frames",
429 "Temporal Reference for the B frame as defined by H.263", HFILL
435 "Temporal Reference for P frames",
441 "Temporal Reference for the P frame as defined by H.263", HFILL
453 "Quantization value for the first MB coded at the starting of the packet.", HFILL
465 "GOB number in effect at the start of the packet.", HFILL
471 "Macroblock address",
477 "The address within the GOB of the first MB in the packet, counting from zero in scan order.", HFILL
483 "Horizontal motion vector 1",
489 "Horizontal motion vector predictor for the first MB in this packet", HFILL
495 "Vertical motion vector 1",
501 "Vertical motion vector predictor for the first MB in this packet", HFILL
507 "Horizontal motion vector 2",
513 "Horizontal motion vector predictor for block number 3 in the first MB in this packet when four motion vectors are used with the advanced prediction option.", HFILL
519 "Vertical motion vector 2",
525 "Vertical motion vector predictor for block number 3 in the first MB in this packet when four motion vectors are used with the advanced prediction option.", HFILL
537 "Reserved field that should contain zeroes", HFILL
549 "Reserved field that should contain zeroes", HFILL
561 "Reserved field that should contain zeroes", HFILL
566 static int *ett
[] = {
570 proto_register_subtree_array(ett
, array_length(ett
));
572 proto_rfc2190
= proto_register_protocol("H.263 RTP Payload header (RFC2190)",
573 "H.263 (RFC2190)", "rfc2190");
575 proto_register_field_array(proto_rfc2190
, hf
, array_length(hf
));
576 rfc2190_handle
= register_dissector("rfc2190", dissect_rfc2190
, proto_rfc2190
);
580 * Editor modelines - https://www.wireshark.org/tools/modelines.html
585 * indent-tabs-mode: nil
588 * vi: set shiftwidth=4 tabstop=8 expandtab:
589 * :indentSize=4:tabSize=8:noTabs=true: