3 * Routines for ETV-AM from OC-SP-ETV-AM1.0-IO5
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_etv(void);
20 void proto_reg_handoff_etv(void);
22 static dissector_handle_t etv_dii_handle
;
23 static dissector_handle_t etv_ddb_handle
;
25 static int proto_etv_dii
;
26 static int proto_etv_ddb
;
28 static dissector_handle_t dsmcc_handle
;
30 static int hf_etv_dii_filter_info
;
31 static int hf_etv_dii_reserved
;
33 static expert_field ei_etv_dii_invalid_section_syntax_indicator
;
34 static expert_field ei_etv_dii_invalid_section_length
;
35 static expert_field ei_etv_dii_invalid_reserved_bits
;
36 static expert_field ei_etv_dii_filter_info
;
38 static int hf_etv_ddb_filter_info
;
39 static int hf_etv_ddb_reserved
;
41 static expert_field ei_etv_ddb_invalid_section_syntax_indicator
;
42 static expert_field ei_etv_ddb_invalid_section_length
;
43 static expert_field ei_etv_ddb_invalid_reserved_bits
;
44 static expert_field ei_etv_ddb_filter_info
;
47 static int ett_etv_payload
;
50 dissect_etv_common(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, int proto
,
51 int hf_filter_info
, int hf_reserved
,
52 expert_field
* ei_section_syntax_indicator
, expert_field
* ei_reserved
,
53 expert_field
* ei_section_length
, expert_field
* ei_filter_info
)
60 proto_item
*items
[PACKET_MPEG_SECT_PI__SIZE
];
67 ti
= proto_tree_add_item(tree
, proto
, tvb
, offset
, -1, ENC_NA
);
68 etv_tree
= proto_item_add_subtree(ti
, ett_etv
);
70 offset
+= packet_mpeg_sect_header_extra(tvb
, offset
, etv_tree
, §_len
,
71 &reserved
, &ssi
, items
);
74 proto_item
*msg_error
;
75 msg_error
= items
[PACKET_MPEG_SECT_PI__SSI
];
77 proto_item_set_generated(msg_error
);
78 expert_add_info(pinfo
, msg_error
, ei_section_syntax_indicator
);
82 proto_item
*msg_error
;
83 msg_error
= items
[PACKET_MPEG_SECT_PI__RESERVED
];
85 proto_item_set_generated(msg_error
);
86 expert_add_info(pinfo
, msg_error
, ei_reserved
);
89 col_append_fstr(pinfo
->cinfo
, COL_INFO
, ", Length: %u", sect_len
);
90 proto_item_append_text(ti
, " Length=%u", sect_len
);
91 if (1021 < sect_len
) {
92 proto_item
*msg_error
;
93 msg_error
= items
[PACKET_MPEG_SECT_PI__LENGTH
];
95 proto_item_set_generated(msg_error
);
96 expert_add_info(pinfo
, msg_error
, ei_section_length
);
99 filter_info
= tvb_get_ntohs(tvb
, offset
);
100 col_append_fstr(pinfo
->cinfo
, COL_INFO
, ", Filter: 0x%x", filter_info
);
101 proto_item_append_text(ti
, " Filter=0x%x", filter_info
);
102 pi
= proto_tree_add_item(etv_tree
, hf_filter_info
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
103 if ((proto_etv_dii
== proto
) && (0xFBFB != filter_info
)) {
104 expert_add_info_format(pinfo
, pi
, ei_filter_info
,
105 "Invalid filter_info value (must be 0xFBFB)");
106 } else if ((proto_etv_ddb
== proto
) &&
107 ((filter_info
< 1) || (0xfbef < filter_info
)))
109 expert_add_info_format(pinfo
, pi
, ei_filter_info
,
110 "Invalid filter_info value (must be [0x0001-0xFBEF] inclusive)");
114 reserved2
= tvb_get_uint8(tvb
, offset
);
115 pi
= proto_tree_add_item(etv_tree
, hf_reserved
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
116 if (0 != reserved2
) {
117 expert_add_info_format(pinfo
, pi
, ei_reserved
,
118 "Invalid reserved2 bits (should all be 0)");
122 sub_tvb
= tvb_new_subset_length(tvb
, offset
, sect_len
-7);
123 call_dissector(dsmcc_handle
, sub_tvb
, pinfo
, tree
);
125 sect_len
+= 3 - 4; /* add header, remove crc */
127 packet_mpeg_sect_crc(tvb
, pinfo
, etv_tree
, 0, sect_len
);
132 dissect_etv_ddb(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
134 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "ETV-DDB");
135 col_set_str(pinfo
->cinfo
, COL_INFO
, "ETV DDB");
137 dissect_etv_common(tvb
, pinfo
, tree
, proto_etv_ddb
, hf_etv_ddb_filter_info
,
138 hf_etv_ddb_reserved
, &ei_etv_ddb_invalid_section_syntax_indicator
,
139 &ei_etv_ddb_invalid_reserved_bits
, &ei_etv_ddb_invalid_section_length
,
140 &ei_etv_ddb_filter_info
);
141 return tvb_captured_length(tvb
);
146 dissect_etv_dii(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
148 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "ETV-DII");
149 col_set_str(pinfo
->cinfo
, COL_INFO
, "ETV DII");
150 dissect_etv_common(tvb
, pinfo
, tree
, proto_etv_dii
, hf_etv_dii_filter_info
,
151 hf_etv_dii_reserved
, &ei_etv_dii_invalid_section_syntax_indicator
,
152 &ei_etv_dii_invalid_reserved_bits
, &ei_etv_dii_invalid_section_length
,
153 &ei_etv_dii_filter_info
);
154 return tvb_captured_length(tvb
);
159 proto_register_etv(void)
161 static hf_register_info hf_ddb
[] = {
162 { &hf_etv_ddb_filter_info
, {
163 "Filter Info", "etv-ddb.filter_info",
164 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
167 { &hf_etv_ddb_reserved
, {
168 "Reserved", "etv-ddb.reserved",
169 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
173 static hf_register_info hf_dii
[] = {
174 { &hf_etv_dii_filter_info
, {
175 "Filter Info", "etv-dii.filter_info",
176 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
179 { &hf_etv_dii_reserved
, {
180 "Reserved", "etv-dii.reserved",
181 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
185 static int *ett
[] = {
190 static ei_register_info ei_ddb
[] = {
191 { &ei_etv_ddb_invalid_section_syntax_indicator
, { "etv-ddb.invalid_section_syntax_indicator", PI_MALFORMED
, PI_ERROR
, "Invalid section_syntax_indicator (should be 0)", EXPFILL
}},
192 { &ei_etv_ddb_invalid_reserved_bits
, { "etv-ddb.invalid_reserved_bits", PI_MALFORMED
, PI_ERROR
, "Invalid reserved bits", EXPFILL
}},
193 { &ei_etv_ddb_invalid_section_length
, { "etv-ddb.invalid_section_length", PI_MALFORMED
, PI_ERROR
, "Invalid section_length (must not exceed 1021)", EXPFILL
}},
194 { &ei_etv_ddb_filter_info
, { "etv-ddb.filter_info.invalid", PI_MALFORMED
, PI_ERROR
, "Invalid filter info", EXPFILL
}},
197 static ei_register_info ei_dii
[] = {
198 { &ei_etv_dii_invalid_section_syntax_indicator
, { "etv-dii.invalid_section_syntax_indicator", PI_MALFORMED
, PI_ERROR
, "Invalid section_syntax_indicator (should be 0)", EXPFILL
}},
199 { &ei_etv_dii_invalid_reserved_bits
, { "etv-dii.invalid_reserved_bits", PI_MALFORMED
, PI_ERROR
, "Invalid reserved bits", EXPFILL
}},
200 { &ei_etv_dii_invalid_section_length
, { "etv-dii.invalid_section_length", PI_MALFORMED
, PI_ERROR
, "Invalid section_length (must not exceed 1021)", EXPFILL
}},
201 { &ei_etv_dii_filter_info
, { "etv-dii.filter_info.invalid", PI_MALFORMED
, PI_ERROR
, "Invalid filter info", EXPFILL
}},
204 expert_module_t
* expert_etv_dii
;
205 expert_module_t
* expert_etv_ddb
;
207 proto_etv_dii
= proto_register_protocol("ETV-AM DII Section", "ETV-AM DII", "etv-dii");
208 proto_etv_ddb
= proto_register_protocol("ETV-AM DDB Section", "ETV-AM DDB", "etv-ddb");
210 proto_register_field_array(proto_etv_dii
, hf_dii
, array_length(hf_dii
));
211 proto_register_field_array(proto_etv_ddb
, hf_ddb
, array_length(hf_ddb
));
212 proto_register_subtree_array(ett
, array_length(ett
));
213 expert_etv_dii
= expert_register_protocol(proto_etv_dii
);
214 expert_register_field_array(expert_etv_dii
, ei_dii
, array_length(ei_dii
));
215 expert_etv_ddb
= expert_register_protocol(proto_etv_ddb
);
216 expert_register_field_array(expert_etv_ddb
, ei_ddb
, array_length(ei_ddb
));
218 etv_dii_handle
= register_dissector("etv-dii", dissect_etv_dii
, proto_etv_dii
);
219 etv_ddb_handle
= register_dissector("etv-ddb", dissect_etv_ddb
, proto_etv_ddb
);
224 proto_reg_handoff_etv(void)
226 dissector_add_uint("mpeg_sect.tid", ETV_TID_DII_SECTION
, etv_dii_handle
);
227 dissector_add_uint("mpeg_sect.tid", ETV_TID_DDB_SECTION
, etv_ddb_handle
);
228 dsmcc_handle
= find_dissector_add_dependency("mp2t-dsmcc", proto_etv_dii
);
229 find_dissector_add_dependency("mp2t-dsmcc", proto_etv_ddb
);
233 * Editor modelines - https://www.wireshark.org/tools/modelines.html
238 * indent-tabs-mode: t
241 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
242 * :indentSize=8:tabSize=8:noTabs=false: