3 * Routines for ETV-AM EISS (OC-SP-ETV-AM1.0-I05)
4 * Copyright 2012, Weston Schmidt <weston_schmidt@alumni.purdue.edu>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include <epan/packet.h>
16 #include <epan/expert.h>
17 #include "packet-mpeg-sect.h"
19 void proto_register_eiss(void);
20 void proto_reg_handoff_eiss(void);
22 static int proto_eiss = -1;
24 static int hf_eiss_reserved2 = -1;
25 static int hf_eiss_section_number = -1;
26 static int hf_eiss_last_section_number = -1;
27 static int hf_eiss_protocol_version_major = -1;
28 static int hf_eiss_protocol_version_minor = -1;
29 static int hf_eiss_application_type = -1;
31 /* application_identifier() */
32 static int hf_eiss_organisation_id = -1;
33 static int hf_eiss_application_id = -1;
35 static int hf_eiss_platform_id_length = -1;
37 /* platform id information */
38 static int hf_pdtHWManufacturer = -1;
39 static int hf_pdtHWModel = -1;
40 static int hf_pdtHWVersionMajor = -1;
41 static int hf_pdtHWVersionMinor = -1;
42 static int hf_pdtSWManufacturer = -1;
43 static int hf_pdtSWModel = -1;
44 static int hf_pdtSWVersionMajor = -1;
45 static int hf_pdtSWVersionMinor = -1;
46 static int hf_pdtProfile = -1;
48 /* common to all eiss descriptors */
49 static int hf_eiss_descriptor_tag = -1;
50 static int hf_eiss_descriptor_length = -1;
52 /* application info descriptor */
53 static int hf_eiss_aid_app_control_code = -1;
54 static int hf_eiss_aid_app_version_major = -1;
55 static int hf_eiss_aid_app_version_minor = -1;
56 static int hf_eiss_aid_max_proto_version_major = -1;
57 static int hf_eiss_aid_max_proto_version_minor = -1;
58 static int hf_eiss_aid_test_flag = -1;
59 static int hf_eiss_aid_reserved = -1;
60 static int hf_eiss_aid_priority = -1;
61 static int hf_eiss_irl_type = -1;
62 static int hf_eiss_irl_length = -1;
63 static int hf_eiss_irl_string = -1;
65 /* media time descriptor */
66 static int hf_eiss_mtd_time_value = -1;
68 /* stream event descriptor */
69 static int hf_eiss_sed_time_value = -1;
70 static int hf_eiss_sed_reserved = -1;
71 static int hf_eiss_sed_descriptor_length = -1;
73 static gint ett_eiss = -1;
74 static gint ett_eiss_platform_id = -1;
75 static gint ett_eiss_desc = -1;
77 static expert_field ei_eiss_platform_id_length = EI_INIT;
78 static expert_field ei_eiss_invalid_section_length = EI_INIT;
79 static expert_field ei_eiss_invalid_section_syntax_indicator = EI_INIT;
80 static expert_field ei_eiss_unknown_descriptor = EI_INIT;
81 static expert_field ei_eiss_section_number = EI_INIT;
82 static expert_field ei_eiss_application_type = EI_INIT;
83 static expert_field ei_eiss_invalid_reserved_bits = EI_INIT;
85 #define MPEG_SECT_SYNTAX_INDICATOR_MASK 0x8000
86 #define MPEG_SECT_RESERVED_MASK 0x7000
87 #define MPEG_SECT_LENGTH_MASK 0x0FFF
89 static const value_string eiss_descriptor_values[] = {
90 { 0xe0, "ETV Application Information Descriptor" },
91 { 0xe1, "ETV Media Time Descriptor" },
92 { 0xe2, "ETV Stream Event Descriptor" },
96 static const range_string application_id_values[] = {
97 { 0x0000, 0x3fff, "Unsigned Application" },
98 { 0x4000, 0x3fff, "Signed Application" },
99 { 0x8000, 0xfffd, "Reserved by DVB" },
100 { 0xfffe, 0xfffe, "Wildcard for signed applications of an organisation" },
101 { 0xffff, 0xffff, "Wildcard for all applications of an organisation" },
105 static const range_string aid_control_code_values[] = {
106 { 0x00, 0x00, "Reserved" },
107 { 0x01, 0x01, "AUTOSTART" },
108 { 0x02, 0x02, "PRESENT" },
109 { 0x03, 0x03, "DESTROY" },
110 { 0x04, 0xff, "Reserved" },
115 dissect_etv_bif_platform_ids(tvbuff_t *tvb, proto_tree *tree, guint offset)
117 proto_tree *platform_tree;
119 platform_tree = proto_tree_add_subtree(tree, tvb, offset, 15, ett_eiss_platform_id, NULL, "Platform Id");
120 proto_tree_add_item(platform_tree, hf_pdtHWManufacturer, tvb, offset, 3, ENC_BIG_ENDIAN);
122 proto_tree_add_item(platform_tree, hf_pdtHWModel, tvb, offset, 2, ENC_BIG_ENDIAN);
124 proto_tree_add_item(platform_tree, hf_pdtHWVersionMajor, tvb, offset, 1, ENC_BIG_ENDIAN);
126 proto_tree_add_item(platform_tree, hf_pdtHWVersionMinor, tvb, offset, 1, ENC_BIG_ENDIAN);
128 proto_tree_add_item(platform_tree, hf_pdtSWManufacturer, tvb, offset, 3, ENC_BIG_ENDIAN);
130 proto_tree_add_item(platform_tree, hf_pdtSWModel, tvb, offset, 2, ENC_BIG_ENDIAN);
132 proto_tree_add_item(platform_tree, hf_pdtSWVersionMajor, tvb, offset, 1, ENC_BIG_ENDIAN);
134 proto_tree_add_item(platform_tree, hf_pdtSWVersionMinor, tvb, offset, 1, ENC_BIG_ENDIAN);
136 proto_tree_add_item(platform_tree, hf_pdtProfile, tvb, offset, 1, ENC_BIG_ENDIAN);
143 dissect_eiss_descriptors(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
145 proto_tree *sub_tree;
148 tag = tvb_get_guint8(tvb, offset);
153 total_length = tvb_get_guint8(tvb, offset+1);
154 sub_tree = proto_tree_add_subtree(tree, tvb, offset, (2+total_length),
155 ett_eiss_desc, NULL, "ETV Application Information Descriptor");
156 proto_tree_add_item(sub_tree, hf_eiss_descriptor_tag,
157 tvb, offset, 1, ENC_BIG_ENDIAN);
159 proto_tree_add_item(sub_tree, hf_eiss_descriptor_length, tvb,
160 offset, 1, ENC_BIG_ENDIAN);
162 proto_tree_add_item(sub_tree, hf_eiss_aid_app_control_code, tvb,
163 offset, 1, ENC_BIG_ENDIAN);
165 proto_tree_add_item(sub_tree, hf_eiss_aid_app_version_major, tvb,
166 offset, 1, ENC_BIG_ENDIAN);
168 proto_tree_add_item(sub_tree, hf_eiss_aid_app_version_minor, tvb,
169 offset, 1, ENC_BIG_ENDIAN);
171 proto_tree_add_item(sub_tree, hf_eiss_aid_max_proto_version_major,
172 tvb, offset, 1, ENC_BIG_ENDIAN);
174 proto_tree_add_item(sub_tree, hf_eiss_aid_max_proto_version_minor,
175 tvb, offset, 1, ENC_BIG_ENDIAN);
177 proto_tree_add_item(sub_tree, hf_eiss_aid_test_flag, tvb, offset,
180 proto_tree_add_item(sub_tree, hf_eiss_aid_reserved, tvb, offset,
183 proto_tree_add_item(sub_tree, hf_eiss_aid_priority, tvb, offset,
186 proto_tree_add_item(sub_tree, hf_eiss_irl_type, tvb, offset, 2,
188 proto_tree_add_item(sub_tree, hf_eiss_irl_length, tvb, offset,
191 proto_tree_add_item(sub_tree, hf_eiss_irl_string, tvb, offset, 2,
192 ENC_ASCII|ENC_BIG_ENDIAN);
193 return (2+total_length);
194 } else if (0xe1 == tag) {
195 sub_tree = proto_tree_add_subtree(tree, tvb, offset, 6,
196 ett_eiss_desc, NULL, "ETV Media Time Descriptor");
197 proto_tree_add_item(sub_tree, hf_eiss_descriptor_tag,
198 tvb, offset, 1, ENC_BIG_ENDIAN);
200 proto_tree_add_item(sub_tree, hf_eiss_descriptor_length, tvb,
201 offset, 1, ENC_BIG_ENDIAN);
203 proto_tree_add_item(sub_tree, hf_eiss_mtd_time_value, tvb,
204 offset, 4, ENC_BIG_ENDIAN);
206 } else if (0xe2 == tag) {
210 tmp = tvb_get_ntohs(tvb, offset+1);
211 sub_tree = proto_tree_add_subtree(tree, tvb, offset, (3+tmp),
212 ett_eiss_desc, NULL, "ETV Stream Event Descriptor");
213 proto_tree_add_item(sub_tree, hf_eiss_descriptor_tag,
214 tvb, offset, 1, ENC_BIG_ENDIAN);
216 proto_tree_add_item(sub_tree, hf_eiss_sed_reserved, tvb,
217 offset, 2, ENC_BIG_ENDIAN);
218 proto_tree_add_item(sub_tree, hf_eiss_sed_descriptor_length, tvb,
219 offset, 2, ENC_BIG_ENDIAN);
221 proto_tree_add_item(sub_tree, hf_eiss_sed_time_value, tvb,
222 offset, 4, ENC_BIG_ENDIAN);
225 payload = tvb_new_subset_length(tvb, offset, tmp-4);
226 call_data_dissector(payload, pinfo, sub_tree);
230 proto_tree_add_expert(tree, pinfo, &ei_eiss_unknown_descriptor, tvb, offset, -1);
232 /* skip the rest of the section... for now */
238 dissect_eiss(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
240 guint offset = 0, packet_length, sect_len;
243 proto_tree *eiss_tree;
244 proto_item *items[PACKET_MPEG_SECT_PI__SIZE];
248 guint8 sect_num, last_sect_num;
250 guint16 eiss_application_type;
251 guint8 platform_id_length;
253 col_set_str(pinfo->cinfo, COL_PROTOCOL, "EISS");
255 ti = proto_tree_add_item(tree, proto_eiss, tvb, offset, -1, ENC_NA);
256 eiss_tree = proto_item_add_subtree(ti, ett_eiss);
258 offset += packet_mpeg_sect_header_extra(tvb, offset, eiss_tree, §_len,
259 &reserved, &ssi, items);
261 packet_length = sect_len + 3 - 4; /* + for the header, - for the crc */
264 proto_item *msg_error;
265 msg_error = items[PACKET_MPEG_SECT_PI__SSI];
267 proto_item_set_generated(msg_error);
268 expert_add_info(pinfo, msg_error, &ei_eiss_invalid_section_syntax_indicator);
272 proto_item *msg_error;
273 msg_error = items[PACKET_MPEG_SECT_PI__RESERVED];
275 proto_item_set_generated(msg_error);
276 expert_add_info_format(pinfo, msg_error, &ei_eiss_invalid_reserved_bits, "Invalid reserved1 bits (should all be 0)");
279 if (1021 < sect_len) {
280 proto_item *msg_error;
281 msg_error = items[PACKET_MPEG_SECT_PI__LENGTH];
283 proto_item_set_generated(msg_error);
284 expert_add_info(pinfo, msg_error, &ei_eiss_invalid_section_length);
287 reserved2 = tvb_get_guint8(tvb, offset);
288 pi = proto_tree_add_item(eiss_tree, hf_eiss_reserved2, tvb, offset, 1, ENC_BIG_ENDIAN);
289 if (0 != reserved2) {
290 expert_add_info_format(pinfo, pi, &ei_eiss_invalid_reserved_bits, "Invalid reserved2 bits (should all be 0)");
294 sect_num = tvb_get_guint8(tvb, offset);
295 last_sect_num = tvb_get_guint8(tvb, offset + 1);
296 pi = proto_tree_add_item(eiss_tree, hf_eiss_section_number, tvb, offset, 1, ENC_BIG_ENDIAN);
297 if (last_sect_num < sect_num) {
298 expert_add_info(pinfo, pi, &ei_eiss_section_number);
301 proto_tree_add_item(eiss_tree, hf_eiss_last_section_number, tvb, offset, 1, ENC_BIG_ENDIAN);
303 proto_tree_add_item(eiss_tree, hf_eiss_protocol_version_major, tvb, offset, 1, ENC_BIG_ENDIAN);
305 proto_tree_add_item(eiss_tree, hf_eiss_protocol_version_minor, tvb, offset, 1, ENC_BIG_ENDIAN);
308 eiss_application_type = tvb_get_ntohs(tvb, offset);
309 pi = proto_tree_add_item(eiss_tree, hf_eiss_application_type, tvb, offset, 2, ENC_BIG_ENDIAN);
310 if (8 != eiss_application_type) {
311 expert_add_info(pinfo, pi, &ei_eiss_application_type);
314 proto_tree_add_item(eiss_tree, hf_eiss_organisation_id, tvb, offset, 4, ENC_BIG_ENDIAN);
316 proto_tree_add_item(eiss_tree, hf_eiss_application_id, tvb, offset, 2, ENC_BIG_ENDIAN);
319 platform_id_length = tvb_get_guint8(tvb, offset);
320 pi = proto_tree_add_item(eiss_tree, hf_eiss_platform_id_length, tvb, offset, 1, ENC_BIG_ENDIAN);
321 if (0 != platform_id_length % 15) {
322 expert_add_info(pinfo, pi, &ei_eiss_platform_id_length);
326 while (0 < platform_id_length) {
329 tmp = dissect_etv_bif_platform_ids(tvb, eiss_tree, offset);
331 if (platform_id_length < tmp) {
332 platform_id_length = 0;
335 platform_id_length -= tmp;
339 if (0 < packet_length) {
340 proto_tree *eiss_desc_tree;
341 eiss_desc_tree = proto_tree_add_subtree(eiss_tree, tvb, offset,
342 packet_length-offset, ett_eiss_desc, NULL, "EISS Descriptor(s)");
343 while (offset < packet_length) {
344 offset += dissect_eiss_descriptors(tvb, pinfo,
345 eiss_desc_tree, offset);
349 packet_mpeg_sect_crc(tvb, pinfo, eiss_tree, 0, sect_len - 1);
350 return tvb_captured_length(tvb);
355 proto_register_eiss(void)
358 static hf_register_info hf[] = {
359 { &hf_eiss_reserved2, {
360 "Reserved", "eiss.reserved",
361 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
364 { &hf_eiss_section_number, {
365 "Section Number", "eiss.sect_num",
366 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
369 { &hf_eiss_last_section_number, {
370 "Last Section Number", "eiss.last_sect_num",
371 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
374 { &hf_eiss_protocol_version_major, {
375 "Major Version Number", "eiss.version_major",
376 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
379 { &hf_eiss_protocol_version_minor, {
380 "Minor Version Number", "eiss.version_minor",
381 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
384 { &hf_eiss_application_type, {
385 "Application Type", "eiss.app_type",
386 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
389 { &hf_eiss_organisation_id, {
390 "Organisation Id", "eiss.org_id",
391 FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
394 { &hf_eiss_application_id, {
395 "Application Id", "eiss.app_id",
396 FT_UINT16, BASE_HEX|BASE_RANGE_STRING, RVALS(application_id_values), 0, NULL, HFILL
399 { &hf_eiss_platform_id_length, {
400 "Platform Id Length", "eiss.platform_id_length",
401 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
404 { &hf_pdtHWManufacturer, {
405 "Platform Hardware Manufacturer", "eiss.plat_hw_man",
406 FT_UINT24, BASE_HEX, NULL, 0, NULL, HFILL
410 "Platform Hardware Model", "eiss.plat_hw_model",
411 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
414 { &hf_pdtHWVersionMajor, {
415 "Platform Hardware Major Version", "eiss.plat_hw_major",
416 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
419 { &hf_pdtHWVersionMinor, {
420 "Platform Hardware Minor Version", "eiss.plat_hw_minor",
421 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
424 { &hf_pdtSWManufacturer, {
425 "Platform Software Manufacturer", "eiss.plat_sw_man",
426 FT_UINT24, BASE_HEX, NULL, 0, NULL, HFILL
430 "Platform Software Model", "eiss.plat_sw_model",
431 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
434 { &hf_pdtSWVersionMajor, {
435 "Platform Software Major Version", "eiss.plat_sw_major",
436 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
439 { &hf_pdtSWVersionMinor, {
440 "Platform Software Minor Version", "eiss.plat_sw_minor",
441 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
445 "Platform Profile", "eiss.plat_profile",
446 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
449 { &hf_eiss_descriptor_tag, {
450 "EISS Descriptor Tag", "eiss.desc.tag",
451 FT_UINT8, BASE_HEX, VALS(eiss_descriptor_values), 0, NULL, HFILL
454 { &hf_eiss_descriptor_length, {
455 "Descriptor Length", "eiss.desc.length",
456 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
459 { &hf_eiss_aid_app_control_code, {
460 "Application Control Code", "eiss.aid.app_control_code",
461 FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(aid_control_code_values), 0, NULL, HFILL
464 { &hf_eiss_aid_app_version_major, {
465 "Application Version Major", "eiss.aid.app_version_major",
466 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
469 { &hf_eiss_aid_app_version_minor, {
470 "Application Version Minor", "eiss.aid.app_version_minor",
471 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
474 { &hf_eiss_aid_max_proto_version_major, {
475 "Max Protocol Version Major", "eiss.aid.max_proto_version_major",
476 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
479 { &hf_eiss_aid_max_proto_version_minor, {
480 "Max Protocol Version Minor", "eiss.aid.max_proto_version_minor",
481 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
484 { &hf_eiss_aid_test_flag, {
485 "Application Test Flag", "eiss.aid.test_flag",
486 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
489 { &hf_eiss_aid_reserved, {
490 "Reserved", "eiss.aid.reserved",
491 FT_UINT24, BASE_HEX, NULL, 0, NULL, HFILL
494 { &hf_eiss_aid_priority, {
495 "Application Priority", "eiss.aid.priority",
496 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
499 { &hf_eiss_irl_type, {
500 "Initial Resource Locator Type", "eiss.aid.irl.type",
501 FT_UINT16, BASE_HEX, NULL, 0xfc00, NULL, HFILL
504 { &hf_eiss_irl_length, {
505 "Initial Resource Locator Length", "eiss.aid.irl.length",
506 FT_UINT16, BASE_DEC, NULL, 0x03ff, NULL, HFILL
509 { &hf_eiss_irl_string, {
510 "Initial Resource Locator String", "eiss.aid.irl.string",
511 FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
514 { &hf_eiss_mtd_time_value, {
515 "Time Value (ms)", "eiss.mtd.time_value",
516 FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
519 { &hf_eiss_sed_reserved, {
520 "Reserved", "eiss.sed.reserved",
521 FT_UINT16, BASE_DEC, NULL, 0xf000, NULL, HFILL
524 { &hf_eiss_sed_descriptor_length, {
525 "Descriptor Length", "eiss.desc.length",
526 FT_UINT16, BASE_DEC, NULL, 0x0fff, NULL, HFILL
529 { &hf_eiss_sed_time_value, {
530 "Time Value (ms)", "eiss.sed.time_value",
531 FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
535 static gint *ett[] = {
537 &ett_eiss_platform_id,
541 static ei_register_info ei[] = {
542 { &ei_eiss_unknown_descriptor, { "eiss.unknown_descriptor", PI_MALFORMED, PI_ERROR, "Unknown Descriptor", EXPFILL }},
543 { &ei_eiss_invalid_section_syntax_indicator, { "eiss.invalid_section_syntax_indicator", PI_MALFORMED, PI_ERROR, "Invalid section_syntax_indicator (should be 0)", EXPFILL }},
544 { &ei_eiss_invalid_reserved_bits, { "eiss.invalid_reserved_bits", PI_MALFORMED, PI_ERROR, "Invalid reserved bits", EXPFILL }},
545 { &ei_eiss_invalid_section_length, { "eiss.invalid_section_length", PI_MALFORMED, PI_ERROR, "Invalid section_length (must not exceed 1021)", EXPFILL }},
546 { &ei_eiss_section_number, { "eiss.sect_num.invalid", PI_MALFORMED, PI_ERROR, "Invalid section_number (must be <= last_section_number)", EXPFILL }},
547 { &ei_eiss_application_type, { "eiss.app_type.invalid", PI_MALFORMED, PI_ERROR, "Invalid application_type (must be 0x0008)", EXPFILL }},
548 { &ei_eiss_platform_id_length, { "eiss.platform_id_length.invalid", PI_MALFORMED, PI_ERROR, "Invalid platform_id_length (must be a multiple of sizeof(etv_bif_platform_ids) == 15)", EXPFILL }},
551 expert_module_t* expert_eiss;
553 proto_eiss = proto_register_protocol("ETV-AM EISS Section", "ETV-AM EISS", "eiss");
555 proto_register_field_array(proto_eiss, hf, array_length(hf));
556 proto_register_subtree_array(ett, array_length(ett));
557 expert_eiss = expert_register_protocol(proto_eiss);
558 expert_register_field_array(expert_eiss, ei, array_length(ei));
563 proto_reg_handoff_eiss(void)
565 dissector_handle_t eiss_handle;
567 eiss_handle = create_dissector_handle(dissect_eiss, proto_eiss);
568 dissector_add_uint("mpeg_sect.tid", EISS_SECTION_TID, eiss_handle);
572 * Editor modelines - https://www.wireshark.org/tools/modelines.html
577 * indent-tabs-mode: t
580 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
581 * :indentSize=8:tabSize=8:noTabs=false: