2 * Routines for MPEG2 (ISO/ISO 13818-1) Program Map Table (PMT) dissection
3 * Copyright 2012, Guy Martin <gmsoft@tuxicoman.be>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include <epan/packet.h>
29 #include <epan/dissectors/packet-mpeg-sect.h>
31 #include "packet-mpeg-descriptor.h"
33 void proto_register_mpeg_pmt(void);
34 void proto_reg_handoff_mpeg_pmt(void);
36 static int proto_mpeg_pmt = -1;
37 static int hf_mpeg_pmt_program_number = -1;
38 static int hf_mpeg_pmt_reserved1 = -1;
39 static int hf_mpeg_pmt_version_number = -1;
40 static int hf_mpeg_pmt_current_next_indicator = -1;
41 static int hf_mpeg_pmt_section_number = -1;
42 static int hf_mpeg_pmt_last_section_number = -1;
43 static int hf_mpeg_pmt_reserved2 = -1;
44 static int hf_mpeg_pmt_pcr_pid = -1;
45 static int hf_mpeg_pmt_reserved3 = -1;
46 static int hf_mpeg_pmt_program_info_length = -1;
49 static int hf_mpeg_pmt_stream_type = -1;
50 static int hf_mpeg_pmt_stream_reserved1 = -1;
51 static int hf_mpeg_pmt_stream_elementary_pid = -1;
52 static int hf_mpeg_pmt_stream_reserved2 = -1;
53 static int hf_mpeg_pmt_stream_es_info_length = -1;
55 static gint ett_mpeg_pmt = -1;
56 static gint ett_mpeg_pmt_stream = -1;
58 #define MPEG_PMT_RESERVED1_MASK 0xC0
59 #define MPEG_PMT_VERSION_NUMBER_MASK 0x3E
60 #define MPEG_PMT_CURRENT_NEXT_INDICATOR_MASK 0x01
62 #define MPEG_PMT_RESERVED2_MASK 0xE000
63 #define MPEG_PMT_PCR_PID_MASK 0x1FFF
64 #define MPEG_PMT_RESERVED3_MASK 0xF000
65 #define MPEG_PMT_PROGRAM_INFO_LENGTH_MASK 0x0FFF
67 #define MPEG_PMT_STREAM_RESERVED1_MASK 0xE000
68 #define MPEG_PMT_STREAM_ELEMENTARY_PID_MASK 0x1FFF
70 #define MPEG_PMT_STREAM_RESERVED2_MASK 0xF000
71 #define MPEG_PMT_STREAM_ES_INFO_LENGTH_MASK 0x0FFF
74 static const value_string mpeg_pmt_cur_next_vals[] = {
76 { 0x0, "Not yet applicable" },
77 { 0x1, "Currently applicable" },
83 static const value_string mpeg_pmt_stream_type_vals[] = {
84 { 0x00, "ITU-T | ISO/IEC Reserved" },
85 { 0x01, "ISO/IEC 11172 Video" },
86 { 0x02, "ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or ISO/IEC 11172-2 constrained parameter video stream" },
87 { 0x03, "ISO/IEC 11172 Audio" },
88 { 0x04, "ISO/IEC 13818-3 Audio" },
89 { 0x05, "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private_sections" },
90 { 0x06, "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing private data" },
91 { 0x07, "ISO/IEC 13522 MHEG" },
92 { 0x08, "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A DSM-CC" },
93 { 0x09, "ITU-T Rec. H.222.1" },
94 { 0x0A, "ISO/IEC 13818-6 type A" },
95 { 0x0B, "ISO/IEC 13818-6 type B" },
96 { 0x0C, "ISO/IEC 13818-6 type C" },
97 { 0x0D, "ISO/IEC 13818-6 type D" },
98 { 0x0E, "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 auxiliary" },
99 { 0x0F, "ISO/IEC 13818-7 Audio with ADTS transport syntax" },
100 { 0x10, "ISO/IEC 14496-2 Visual" },
101 { 0x11, "ISO/IEC 14496-3 Audio with the LATM transport syntax as defined in ISO/IEC 14496-3 / AMD 1" },
102 { 0x12, "ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in PES packets" },
103 { 0x13, "ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in ISO/IEC14496_sections" },
104 { 0x14, "ISO/IEC 13818-6 Synchronized Download Protocol" },
105 { 0x15, "Metadata carried in PES packets" },
106 { 0x16, "Metadata carried in metadata sections" },
107 { 0x17, "Metadata carried in ISO/IEC 13818-6 Data Carousel" },
108 { 0x18, "Metadata carried in ISO/IEC 13818-6 Object Carousel" },
109 { 0x19, "Metadata carried in ISO/IEC 13818-6 Synchronized Download Protocol" },
110 { 0x1A, "IPMP stream (defined in ISO/IEC 13818-11, MPEG-2 IPMP)" },
111 { 0x1B, "AVC video stream as defined in ITU-T Rec. H.264 | ISO/IEC 14496-10 Video" },
112 { 0x7F, "IPMP stream" },
113 { 0xA1, "ETV-AM BIF Data Stream" },
114 { 0xC0, "ETV-AM EISS Signaling" },
117 value_string_ext mpeg_pmt_stream_type_vals_ext = VALUE_STRING_EXT_INIT(mpeg_pmt_stream_type_vals);
120 dissect_mpeg_pmt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
123 guint offset = 0, length = 0;
124 guint prog_info_len, es_info_len;
128 proto_tree *mpeg_pmt_tree;
130 proto_tree *mpeg_pmt_stream_tree;
132 /* The TVB should start right after the section_length in the Section packet */
134 col_set_str(pinfo->cinfo, COL_INFO, "Program Map Table (PMT)");
136 ti = proto_tree_add_item(tree, proto_mpeg_pmt, tvb, offset, -1, ENC_NA);
137 mpeg_pmt_tree = proto_item_add_subtree(ti, ett_mpeg_pmt);
139 offset += packet_mpeg_sect_header(tvb, offset, mpeg_pmt_tree, &length, NULL);
142 proto_tree_add_item(mpeg_pmt_tree, hf_mpeg_pmt_program_number, tvb, offset, 2, ENC_BIG_ENDIAN);
145 proto_tree_add_item(mpeg_pmt_tree, hf_mpeg_pmt_reserved1, tvb, offset, 1, ENC_BIG_ENDIAN);
146 proto_tree_add_item(mpeg_pmt_tree, hf_mpeg_pmt_version_number, tvb, offset, 1, ENC_BIG_ENDIAN);
147 proto_tree_add_item(mpeg_pmt_tree, hf_mpeg_pmt_current_next_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
150 proto_tree_add_item(mpeg_pmt_tree, hf_mpeg_pmt_section_number, tvb, offset, 1, ENC_BIG_ENDIAN);
153 proto_tree_add_item(mpeg_pmt_tree, hf_mpeg_pmt_last_section_number, tvb, offset, 1, ENC_BIG_ENDIAN);
156 proto_tree_add_item(mpeg_pmt_tree, hf_mpeg_pmt_reserved2, tvb, offset, 2, ENC_BIG_ENDIAN);
157 proto_tree_add_item(mpeg_pmt_tree, hf_mpeg_pmt_pcr_pid, tvb, offset, 2, ENC_BIG_ENDIAN);
160 prog_info_len = tvb_get_ntohs(tvb, offset) & MPEG_PMT_PROGRAM_INFO_LENGTH_MASK;
161 proto_tree_add_item(mpeg_pmt_tree, hf_mpeg_pmt_reserved3, tvb, offset, 2, ENC_BIG_ENDIAN);
162 proto_tree_add_item(mpeg_pmt_tree, hf_mpeg_pmt_program_info_length, tvb, offset, 2, ENC_BIG_ENDIAN);
165 offset += proto_mpeg_descriptor_loop_dissect(tvb, offset, prog_info_len, mpeg_pmt_tree);
167 while (offset < length) {
169 pid = tvb_get_ntohs(tvb, offset + 1) & MPEG_PMT_STREAM_ELEMENTARY_PID_MASK;
170 es_info_len = tvb_get_ntohs(tvb, offset + 3) & MPEG_PMT_STREAM_ES_INFO_LENGTH_MASK;
172 si = proto_tree_add_text(mpeg_pmt_tree, tvb, offset, 5 + es_info_len, "Stream PID=0x%04hx", pid);
173 mpeg_pmt_stream_tree = proto_item_add_subtree(si, ett_mpeg_pmt_stream);
175 proto_tree_add_item(mpeg_pmt_stream_tree, hf_mpeg_pmt_stream_type, tvb, offset, 1, ENC_BIG_ENDIAN);
178 proto_tree_add_item(mpeg_pmt_stream_tree, hf_mpeg_pmt_stream_reserved1, tvb, offset, 2, ENC_BIG_ENDIAN);
179 proto_tree_add_item(mpeg_pmt_stream_tree, hf_mpeg_pmt_stream_elementary_pid, tvb, offset, 2, ENC_BIG_ENDIAN);
182 proto_tree_add_item(mpeg_pmt_stream_tree, hf_mpeg_pmt_stream_reserved2, tvb, offset, 2, ENC_BIG_ENDIAN);
183 proto_tree_add_item(mpeg_pmt_stream_tree, hf_mpeg_pmt_stream_es_info_length, tvb, offset, 2, ENC_BIG_ENDIAN);
186 offset += proto_mpeg_descriptor_loop_dissect(tvb, offset, es_info_len, mpeg_pmt_stream_tree);
189 offset += packet_mpeg_sect_crc(tvb, pinfo, mpeg_pmt_tree, 0, offset);
191 proto_item_set_len(ti, offset);
197 proto_register_mpeg_pmt(void)
200 static hf_register_info hf[] = {
202 { &hf_mpeg_pmt_program_number, {
203 "Program Number", "mpeg_pmt.pg_num",
204 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
207 { &hf_mpeg_pmt_reserved1, {
208 "Reserved", "mpeg_pmt.reserved1",
209 FT_UINT8, BASE_HEX, NULL, MPEG_PMT_RESERVED1_MASK, NULL, HFILL
212 { &hf_mpeg_pmt_version_number, {
213 "Version Number", "mpeg_pmt.version",
214 FT_UINT8, BASE_HEX, NULL, MPEG_PMT_VERSION_NUMBER_MASK, NULL, HFILL
217 { &hf_mpeg_pmt_current_next_indicator, {
218 "Current/Next Indicator", "mpeg_pmt.cur_next_ind",
219 FT_UINT8, BASE_HEX, VALS(mpeg_pmt_cur_next_vals), MPEG_PMT_CURRENT_NEXT_INDICATOR_MASK, NULL, HFILL
222 { &hf_mpeg_pmt_section_number, {
223 "Section Number", "mpeg_pmt.sect_num",
224 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
227 { &hf_mpeg_pmt_last_section_number, {
228 "Last Section Number", "mpeg_pmt.last_sect_num",
229 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
232 { &hf_mpeg_pmt_reserved2, {
233 "Reserved", "mpeg_pmt.reserved2",
234 FT_UINT16, BASE_HEX, NULL, MPEG_PMT_RESERVED2_MASK, NULL, HFILL
237 { &hf_mpeg_pmt_pcr_pid, {
238 "PCR PID", "mpeg_pmt.pcr_pid",
239 FT_UINT16, BASE_HEX, NULL, MPEG_PMT_PCR_PID_MASK, NULL, HFILL
242 { &hf_mpeg_pmt_reserved3, {
243 "Reserved", "mpeg_pmt.reserved3",
244 FT_UINT16, BASE_HEX, NULL, MPEG_PMT_RESERVED3_MASK, NULL, HFILL
247 { &hf_mpeg_pmt_program_info_length, {
248 "Program Info Length", "mpeg_pmt.prog_info_len",
249 FT_UINT16, BASE_HEX, NULL, MPEG_PMT_PROGRAM_INFO_LENGTH_MASK, NULL, HFILL
253 { &hf_mpeg_pmt_stream_type, {
254 "Stream type", "mpeg_pmt.stream.type",
255 FT_UINT8, BASE_HEX | BASE_EXT_STRING, &mpeg_pmt_stream_type_vals_ext, 0, NULL, HFILL
258 { &hf_mpeg_pmt_stream_reserved1, {
259 "Reserved", "mpeg_pmt.stream.reserved1",
260 FT_UINT16, BASE_HEX, NULL, MPEG_PMT_STREAM_RESERVED1_MASK, NULL, HFILL
263 { &hf_mpeg_pmt_stream_elementary_pid, {
264 "Elementary PID", "mpeg_pmt.stream.elementary_pid",
265 FT_UINT16, BASE_HEX, NULL, MPEG_PMT_STREAM_ELEMENTARY_PID_MASK, NULL, HFILL
268 { &hf_mpeg_pmt_stream_reserved2, {
269 "Reserved", "mpeg_pmt.stream.reserved2",
270 FT_UINT16, BASE_HEX, NULL, MPEG_PMT_STREAM_RESERVED2_MASK, NULL, HFILL
273 { &hf_mpeg_pmt_stream_es_info_length, {
274 "ES Info Length", "mpeg_pmt.stream.es_info_len",
275 FT_UINT16, BASE_HEX, NULL, MPEG_PMT_STREAM_ES_INFO_LENGTH_MASK, NULL, HFILL
280 static gint *ett[] = {
282 &ett_mpeg_pmt_stream,
285 proto_mpeg_pmt = proto_register_protocol("MPEG2 Program Map Table", "MPEG PMT", "mpeg_pmt");
287 proto_register_field_array(proto_mpeg_pmt, hf, array_length(hf));
288 proto_register_subtree_array(ett, array_length(ett));
290 new_register_dissector("mpeg_pmt", dissect_mpeg_pmt, proto_mpeg_pmt);
295 proto_reg_handoff_mpeg_pmt(void)
297 dissector_handle_t mpeg_pmt_handle;
299 mpeg_pmt_handle = find_dissector("mpeg_pmt");
301 dissector_add_uint("mpeg_sect.tid", MPEG_PMT_TID, mpeg_pmt_handle);
305 * Editor modelines - http://www.wireshark.org/tools/modelines.html
310 * indent-tabs-mode: nil
313 * vi: set shiftwidth=4 tabstop=8 expandtab:
314 * :indentSize=4:tabSize=8:noTabs=true: