MSWSP: fix dissect_mswsp_smb()
[wireshark-wip.git] / epan / dissectors / packet-mpeg-dsmcc.c
blob6cb22a9116e30a7a06658d8743074fb40153d5f2
1 /* packet-dsmcc.c
3 * Routines for ISO/IEC 13818-6 DSM-CC
4 * Copyright 2012, Weston Schmidt <weston_schmidt@alumni.purdue.edu>
6 * $Id$
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "config.h"
29 #include <glib.h>
31 #include <epan/packet.h>
32 #include <epan/prefs.h>
33 #include <epan/expert.h>
34 #include <epan/crc32-tvb.h>
35 #include <epan/dissectors/packet-mpeg-sect.h>
37 /* NOTE: Please try to keep this status comment up to date until the spec is
38 * completely implemented - there are a large number of tables in the spec.
40 * 13818-6 Table status:
42 * Missing tables:
43 * 3-1 3-2 3-3 3-4 3-6 3-7 3-8 3-9
44 * 4-1 4-7 4-8 4-9 4-10 4-11 4-12 4-13 4-14 4-15 4-*
45 * 5-*
46 * 6-4
47 * 7-5 7-8 7-10 7-12
48 * 8-2 8-3 8-4 8-6
49 * 9-5 9-6
50 * 10-*
51 * 11-*
52 * 12-*
54 * Dissected tables:
55 * 2-1 2-4 2-6 2-7
56 * 4-6 4-16 4-17 4-34 4-35 (partly)
57 * 6-1
58 * 7-6 7-7
59 * 9-2
61 * Validated (all parameters are checked) tables:
65 static int proto_dsmcc = -1;
66 static dissector_handle_t data_handle;
67 static gboolean dsmcc_sect_check_crc = FALSE;
69 /* NOTE: Please add values numerically according to 13818-6 so it is easier to
70 * keep track of what parameters/tables are associated with each other.
73 /* table 2-1 dsmccMessageHeader - start */
74 static int hf_dsmcc_protocol_discriminator = -1;
75 static int hf_dsmcc_type = -1;
76 static int hf_dsmcc_message_id = -1;
77 static int hf_dsmcc_transaction_id = -1;
78 static int hf_dsmcc_header_reserved = -1;
79 static int hf_dsmcc_adaptation_length = -1;
80 static int hf_dsmcc_message_length = -1;
81 /* table 2-1 dsmccMessageHeader - end */
83 /* table 2-4 dsmccAdaptationHeader - start */
84 static int hf_dsmcc_adaptation_type = -1;
85 /* table 2-4 dsmccAdaptationHeader - end */
87 /* table 2-6 dsmccConditionalAccess - start */
88 static int hf_dsmcc_adaptation_ca_reserved = -1;
89 static int hf_dsmcc_adaptation_ca_system_id = -1;
90 static int hf_dsmcc_adaptation_ca_length = -1;
91 /* table 2-6 dsmccConditionalAccess - end */
93 /* table 2-7 dsmccUserId - start */
94 static int hf_dsmcc_adaptation_user_id_reserved = -1;
95 /* table 2-7 dsmccUserId - end */
97 /* table 4-6 U-N user data format - start */
98 static int hf_dsmcc_un_sess_uu_data_len = -1;
99 static int hf_dsmcc_un_sess_uu_data = -1;
100 static int hf_dsmcc_un_sess_priv_data_len = -1;
101 static int hf_dsmcc_un_sess_priv_data = -1;
102 /* table 4-6 U-N user data format - end */
104 /* other tables in section 4.2 - start */
105 static int hf_dsmcc_un_sess_id = -1;
106 static int hf_dsmcc_un_sess_response = -1;
107 static int hf_dsmcc_un_sess_reason = -1;
108 /* other tables in section 4.2 - end */
110 /* table 6-1 compatabilityDescriptor - start */
111 static int hf_compat_desc_length = -1;
112 static int hf_compat_desc_count = -1;
113 static int hf_desc_type = -1;
114 static int hf_desc_length = -1;
115 static int hf_desc_spec_type = -1;
116 static int hf_desc_spec_data = -1;
117 static int hf_desc_model = -1;
118 static int hf_desc_version = -1;
119 static int hf_desc_sub_desc_count = -1;
120 static int hf_desc_sub_desc_type = -1;
121 static int hf_desc_sub_desc_len = -1;
122 /* table 6-1 compatabilityDescriptor - end */
124 /* table 7-3 dsmccDownloadDataHeader - start */
125 static int hf_dsmcc_dd_download_id = -1;
126 static int hf_dsmcc_dd_message_id = -1;
127 /* table 7-3 dsmccDownloadDataHeader - end */
129 /* table 7-6 dsmccDownloadInfoIndication/InfoResponse - start */
130 static int hf_dsmcc_dii_download_id = -1;
131 static int hf_dsmcc_dii_block_size = -1;
132 static int hf_dsmcc_dii_window_size = -1;
133 static int hf_dsmcc_dii_ack_period = -1;
134 static int hf_dsmcc_dii_t_c_download_window = -1;
135 static int hf_dsmcc_dii_t_c_download_scenario = -1;
136 static int hf_dsmcc_dii_number_of_modules = -1;
137 static int hf_dsmcc_dii_module_id = -1;
138 static int hf_dsmcc_dii_module_size = -1;
139 static int hf_dsmcc_dii_module_version = -1;
140 static int hf_dsmcc_dii_module_info_length = -1;
141 static int hf_dsmcc_dii_private_data_length = -1;
142 /* table 7-6 dsmccDownloadInfoIndication/InfoResponse - end */
144 /* table 7-7 dsmccDownloadDataBlock - start */
145 static int hf_dsmcc_ddb_module_id = -1;
146 static int hf_dsmcc_ddb_version = -1;
147 static int hf_dsmcc_ddb_reserved = -1;
148 static int hf_dsmcc_ddb_block_number = -1;
149 /* table 7-7 dsmccDownloadDataBlock - end */
151 /* table 9-2 dsmccSection - start */
152 static int hf_dsmcc_table_id = -1;
153 static int hf_dsmcc_section_syntax_indicator = -1;
154 static int hf_dsmcc_private_indicator = -1;
155 static int hf_dsmcc_reserved = -1;
156 static int hf_dsmcc_section_length = -1;
157 static int hf_dsmcc_table_id_extension = -1;
158 static int hf_dsmcc_reserved2 = -1;
159 static int hf_dsmcc_version_number = -1;
160 static int hf_dsmcc_current_next_indicator = -1;
161 static int hf_dsmcc_section_number = -1;
162 static int hf_dsmcc_last_section_number = -1;
163 static int hf_dsmcc_crc = -1;
164 static int hf_dsmcc_checksum = -1;
165 /* table 9-2 dsmccSection - end */
167 /* TODO: this should really live in the ETV dissector, but I'm not sure how
168 * to make the functionality work exactly right yet. Will work on a patch
169 * for this next.
171 static int hf_etv_module_abs_path = -1;
172 static int hf_etv_dii_authority = -1;
174 static gint ett_dsmcc = -1;
175 static gint ett_dsmcc_payload = -1;
176 static gint ett_dsmcc_header = -1;
177 static gint ett_dsmcc_adaptation_header = -1;
178 static gint ett_dsmcc_compat = -1;
179 static gint ett_dsmcc_compat_sub_desc = -1;
180 static gint ett_dsmcc_dii_module = -1;
182 static expert_field ei_dsmcc_invalid_value = EI_INIT;
183 static expert_field ei_dsmcc_crc_invalid = EI_INIT;
185 #define DSMCC_TID_LLCSNAP 0x3a
186 #define DSMCC_TID_UN_MSG 0x3b
187 #define DSMCC_TID_DD_MSG 0x3c
188 #define DSMCC_TID_DESC_LIST 0x3d
189 #define DSMCC_TID_PRIVATE 0x3e
191 #define DSMCC_TCP_PORT 13819
193 /* DSM-CC protocol discriminator, (table 2-1) */
194 #define DSMCC_PROT_DISC 0x11
196 #define DSMCC_SSI_MASK 0x8000
197 #define DSMCC_PRIVATE_MASK 0x4000
198 #define DSMCC_RESERVED_MASK 0x3000
199 #define DSMCC_LENGTH_MASK 0x0fff
201 #define DSMCC_RESERVED2_MASK 0xc0
202 #define DSMCC_VERSION_NUMBER_MASK 0x3e
203 #define DSMCC_CURRENT_NEXT_INDICATOR_MASK 0x01
205 #define DSMCC_UN_SESS_SRV_SESS_REL_REQ 0x8020
206 #define DSMCC_UN_SESS_SRV_SESS_REL_CNF 0x8021
207 #define DSMCC_UN_SESS_SRV_STAT_REQ 0x8060
208 #define DSMCC_UN_SESS_SRV_STAT_CNF 0x8061
210 static const range_string dsmcc_header_type_vals[] = {
211 { 0, 0, "ISO/IEC 13818-6 Reserved" },
212 { 0x01, 0x01, "ISO/IEC 13818-6 User-to-Network Configuration Message" },
213 { 0x02, 0x02, "ISO/IEC 13818-6 User-to-Network Session Message" },
214 { 0x03, 0x03, "ISO/IEC 13818-6 Download Message" },
215 { 0x04, 0x04, "ISO/IEC 13818-6 SDB Channel Change Protocol Message" },
216 { 0x05, 0x05, "ISO/IEC 13818-6 User-to-Network Pass-Thru Message" },
217 { 0x06, 0x7f, "ISO/IEC 13818-6 Reserved" },
218 { 0x80, 0xff, "User Defined Message Type" },
219 { 0, 0, NULL }
222 static const range_string dsmcc_adaptation_header_vals[] = {
223 { 0, 0, "ISO/IEC 13818-6 Reserved" },
224 { 0x01, 0x01, "DSM-CC Conditional Access Adaptation Format" },
225 { 0x02, 0x02, "DSM-CC User ID Adaptation Format" },
226 { 0x03, 0x7f, "ISO/IEC 13818-6 Reserved" },
227 { 0x80, 0xff, "User Defined Adaptation Type" },
228 { 0, 0, NULL }
231 static const value_string dsmcc_payload_name_vals[] = {
232 { DSMCC_TID_LLCSNAP, "LLCSNAP" },
233 { DSMCC_TID_UN_MSG, "User Network Message" },
234 { DSMCC_TID_DD_MSG, "Download Data Message" },
235 { DSMCC_TID_DESC_LIST, "Descriptor List" },
236 { DSMCC_TID_PRIVATE, "Private" },
237 { 0, NULL }
240 static const value_string dsmcc_dd_message_id_vals[] = {
241 { 0x1001, "Download Info Request" },
242 { 0x1002, "Download Info Indication" },
243 { 0x1003, "Download Data Block" },
244 { 0x1004, "Download Data Request" },
245 { 0x1005, "Download Data Cancel" },
246 { 0x1006, "Download Server Initiate" },
247 { 0, NULL }
250 static const value_string dsmcc_un_sess_message_id_vals[] = {
251 { DSMCC_UN_SESS_SRV_SESS_REL_REQ, "Server Session Release Request" },
252 { DSMCC_UN_SESS_SRV_SESS_REL_CNF, "Server Session Release Confirm" },
253 { DSMCC_UN_SESS_SRV_STAT_REQ, "Server Status Request" },
254 { DSMCC_UN_SESS_SRV_STAT_CNF, "Server Status Confirm" },
255 { 0, NULL }
258 static void
259 dissect_dsmcc_adaptation_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
261 tvbuff_t *sub_tvb;
262 guint offset = 0;
263 proto_item *pi;
264 proto_tree *sub_tree;
265 guint8 type, tmp;
266 guint16 ca_len;
268 type = tvb_get_guint8(tvb, offset);
270 if (1 == type) {
271 pi = proto_tree_add_text(tree, tvb, offset, -1, "Adaptation Header");
272 sub_tree = proto_item_add_subtree(pi, ett_dsmcc_adaptation_header);
273 proto_tree_add_item(sub_tree, hf_dsmcc_adaptation_type, tvb,
274 offset, 1, ENC_BIG_ENDIAN);
275 offset +=1;
276 tmp = tvb_get_guint8(tvb, offset);
277 pi = proto_tree_add_item(sub_tree, hf_dsmcc_adaptation_ca_reserved, tvb,
278 offset, 1, ENC_BIG_ENDIAN);
279 if (0xff != tmp) {
280 expert_add_info_format(pinfo, pi, &ei_dsmcc_invalid_value,
281 "Invalid value - should be 0xff");
283 offset +=1;
284 proto_tree_add_item(sub_tree, hf_dsmcc_adaptation_ca_system_id, tvb,
285 offset, 2, ENC_BIG_ENDIAN);
286 offset += 2;
287 ca_len = tvb_get_ntohs(tvb, offset);
288 proto_tree_add_item(sub_tree, hf_dsmcc_adaptation_ca_length, tvb,
289 offset, 2, ENC_BIG_ENDIAN);
290 offset += 2;
291 sub_tvb = tvb_new_subset(tvb, offset, ca_len, ca_len);
292 call_dissector(data_handle, sub_tvb, pinfo, tree);
293 } else if (2 == type) {
294 pi = proto_tree_add_text(tree, tvb, offset, -1, "Adaptation Header");
295 sub_tree = proto_item_add_subtree(pi, ett_dsmcc_adaptation_header);
296 proto_tree_add_item(sub_tree, hf_dsmcc_adaptation_type, tvb,
297 offset, 1, ENC_BIG_ENDIAN);
298 offset +=1;
299 tmp = tvb_get_guint8(tvb, offset);
300 pi = proto_tree_add_item(sub_tree, hf_dsmcc_adaptation_user_id_reserved, tvb,
301 offset, 1, ENC_BIG_ENDIAN);
302 if (0xff != tmp) {
303 expert_add_info_format(pinfo, pi, &ei_dsmcc_invalid_value,
304 "Invalid value - should be 0xff");
306 /*offset +=1;*/
307 /* TODO: handle the userId */
308 } else {
309 pi = proto_tree_add_text(tree, tvb, offset, -1, "Unknown Adaptation Header");
310 sub_tree = proto_item_add_subtree(pi, ett_dsmcc_adaptation_header);
311 proto_tree_add_item(sub_tree, hf_dsmcc_adaptation_type, tvb,
312 offset, 1, ENC_BIG_ENDIAN);
316 static guint
317 dissect_dsmcc_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset,
318 gboolean download_header)
320 tvbuff_t *sub_tvb;
321 proto_item *pi;
322 proto_tree *sub_tree;
323 guint8 prot_disc;
324 guint reserved;
325 guint8 adaptation_len;
326 guint offset_start;
327 int msg_id, tx_id;
329 offset_start = offset;
331 prot_disc = tvb_get_guint8(tvb, offset);
332 reserved = tvb_get_guint8(tvb, 8+offset);
333 adaptation_len = tvb_get_guint8(tvb, 9+offset);
335 pi = proto_tree_add_text(tree, tvb, offset, 12+adaptation_len, "DSM-CC Header");
336 sub_tree = proto_item_add_subtree(pi, ett_dsmcc_header);
337 pi = proto_tree_add_item(sub_tree, hf_dsmcc_protocol_discriminator, tvb,
338 offset, 1, ENC_BIG_ENDIAN);
339 if (DSMCC_PROT_DISC != prot_disc) {
340 expert_add_info_format(pinfo, pi, &ei_dsmcc_invalid_value,
341 "Invalid value - should be 0x11");
343 offset +=1;
344 proto_tree_add_item(sub_tree, hf_dsmcc_type, tvb,
345 offset, 1, ENC_BIG_ENDIAN);
346 offset +=1;
347 if (TRUE == download_header) {
348 msg_id = hf_dsmcc_dd_message_id;
349 tx_id = hf_dsmcc_dd_download_id;
350 } else {
351 msg_id = hf_dsmcc_message_id;
352 tx_id = hf_dsmcc_transaction_id;
354 proto_tree_add_item(sub_tree, msg_id, tvb,
355 offset, 2, ENC_BIG_ENDIAN);
356 offset += 2;
357 proto_tree_add_item(sub_tree, tx_id, tvb,
358 offset, 4, ENC_BIG_ENDIAN);
359 offset += 4;
360 pi = proto_tree_add_item(sub_tree, hf_dsmcc_header_reserved, tvb,
361 offset, 1, ENC_BIG_ENDIAN);
362 if (0xff != reserved) {
363 expert_add_info_format(pinfo, pi, &ei_dsmcc_invalid_value,
364 "Invalid value - should be 0xff");
366 offset +=1;
368 proto_tree_add_item(sub_tree, hf_dsmcc_adaptation_length, tvb,
369 offset, 1, ENC_BIG_ENDIAN);
370 offset +=1;
371 proto_tree_add_item(sub_tree, hf_dsmcc_message_length, tvb,
372 offset, 2, ENC_BIG_ENDIAN);
373 offset += 2;
375 if (0 < adaptation_len) {
376 sub_tvb = tvb_new_subset(tvb, offset, adaptation_len, adaptation_len);
377 dissect_dsmcc_adaptation_header(sub_tvb, pinfo, sub_tree);
378 offset += adaptation_len;
381 return offset-offset_start;
385 static guint
386 dissect_dsmcc_dii_compat_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
387 guint offset)
389 gint i, j;
390 guint8 sub_count, sub_len;
391 guint16 len, count;
392 proto_item *pi;
393 proto_tree *compat_tree;
394 proto_tree *desc_sub_tree;
396 len = tvb_get_ntohs(tvb, offset);
397 proto_tree_add_item(tree, hf_compat_desc_length, tvb, offset,
398 2, ENC_BIG_ENDIAN);
399 offset += 2;
401 if (0 < len) {
402 count = tvb_get_ntohs(tvb, offset);
403 proto_tree_add_item(tree, hf_compat_desc_count, tvb, offset,
404 2, ENC_BIG_ENDIAN);
405 offset += 2;
407 for (i = 0; i < count; i++) {
408 pi = proto_tree_add_text(tree, tvb, offset, len, "Compatibility Descriptor");
409 compat_tree = proto_item_add_subtree(pi, ett_dsmcc_compat);
410 proto_tree_add_item(compat_tree, hf_desc_type, tvb, offset,
411 1, ENC_BIG_ENDIAN);
412 offset +=1;
413 proto_tree_add_item(compat_tree, hf_desc_length, tvb, offset,
414 1, ENC_BIG_ENDIAN);
415 offset +=1;
416 proto_tree_add_item(compat_tree, hf_desc_spec_type, tvb, offset,
417 1, ENC_BIG_ENDIAN);
418 offset +=1;
419 proto_tree_add_item(compat_tree, hf_desc_spec_data, tvb, offset,
420 3, ENC_BIG_ENDIAN);
421 offset += 3;
422 proto_tree_add_item(compat_tree, hf_desc_model, tvb, offset,
423 2, ENC_BIG_ENDIAN);
424 offset += 2;
425 proto_tree_add_item(compat_tree, hf_desc_version, tvb, offset,
426 2, ENC_BIG_ENDIAN);
427 offset += 2;
429 sub_count = tvb_get_guint8(tvb, offset);
430 proto_tree_add_item(compat_tree, hf_desc_sub_desc_count, tvb, offset,
431 1, ENC_BIG_ENDIAN);
432 offset +=1;
434 for (j = 0; j < sub_count; j++) {
435 sub_len = tvb_get_guint8(tvb, offset+1);
437 pi = proto_tree_add_text(compat_tree, tvb, offset, sub_len+2, "Sub Descriptor");
438 desc_sub_tree = proto_item_add_subtree(pi, ett_dsmcc_compat_sub_desc);
439 proto_tree_add_item(desc_sub_tree, hf_desc_sub_desc_type, tvb, offset,
440 1, ENC_BIG_ENDIAN);
441 offset +=1;
442 proto_tree_add_item(desc_sub_tree, hf_desc_sub_desc_len, tvb, offset,
443 1, ENC_BIG_ENDIAN);
444 offset +=1;
446 offset += sub_len;
450 if( 1000 == offset ) {
451 expert_add_info( pinfo, NULL, &ei_dsmcc_crc_invalid);
455 return 2 + len;
458 static void
459 dissect_dsmcc_dii(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
460 guint offset)
462 guint8 module_info_len;
463 guint16 modules, private_data_len;
464 guint16 module_id;
465 guint8 module_version;
466 guint module_size;
467 guint i;
468 proto_item *pi;
469 proto_tree *mod_tree;
471 proto_tree_add_item(tree, hf_dsmcc_dii_download_id, tvb, offset, 4, ENC_BIG_ENDIAN);
472 offset += 4;
473 proto_tree_add_item(tree, hf_dsmcc_dii_block_size, tvb, offset, 2, ENC_BIG_ENDIAN);
474 offset += 2;
475 proto_tree_add_item(tree, hf_dsmcc_dii_window_size, tvb, offset, 1, ENC_BIG_ENDIAN);
476 offset +=1;
477 proto_tree_add_item(tree, hf_dsmcc_dii_ack_period, tvb, offset, 1, ENC_BIG_ENDIAN);
478 offset +=1;
479 proto_tree_add_item(tree, hf_dsmcc_dii_t_c_download_window, tvb, offset, 4, ENC_BIG_ENDIAN);
480 offset += 4;
481 proto_tree_add_item(tree, hf_dsmcc_dii_t_c_download_scenario, tvb, offset, 4, ENC_BIG_ENDIAN);
482 offset += 4;
483 offset += dissect_dsmcc_dii_compat_desc(tvb, pinfo, tree, offset);
484 proto_tree_add_item(tree, hf_dsmcc_dii_number_of_modules, tvb, offset, 2, ENC_BIG_ENDIAN);
485 modules = tvb_get_ntohs(tvb, offset);
486 offset += 2;
488 for (i = 0; i < modules; i++ ) {
489 module_id = tvb_get_ntohs(tvb, offset);
490 module_size = tvb_get_ntohl(tvb, 2+offset);
491 module_version = tvb_get_guint8(tvb, 6+offset);
493 pi = proto_tree_add_text(tree, tvb, offset, -1,
494 "Module Id: 0x%x, Version: %u, Size: %u",
495 module_id, module_version, module_size);
496 mod_tree = proto_item_add_subtree(pi, ett_dsmcc_dii_module);
497 proto_tree_add_item(mod_tree, hf_dsmcc_dii_module_id, tvb, offset, 2, ENC_BIG_ENDIAN);
498 offset += 2;
499 proto_tree_add_item(mod_tree, hf_dsmcc_dii_module_size, tvb, offset, 4, ENC_BIG_ENDIAN);
500 offset += 4;
501 proto_tree_add_item(mod_tree, hf_dsmcc_dii_module_version, tvb, offset, 1, ENC_BIG_ENDIAN);
502 offset +=1;
504 module_info_len = tvb_get_guint8(tvb, offset);
505 proto_tree_add_item(mod_tree, hf_dsmcc_dii_module_info_length, tvb, offset, 1, ENC_BIG_ENDIAN);
506 offset +=1;
507 if (0 < module_info_len) {
508 proto_tree_add_item(mod_tree, hf_etv_module_abs_path, tvb, offset, 1,
509 ENC_ASCII|ENC_NA);
510 offset += module_info_len;
514 private_data_len = tvb_get_ntohs(tvb, offset);
515 proto_tree_add_item(tree, hf_dsmcc_dii_private_data_length, tvb, offset, 2, ENC_BIG_ENDIAN);
516 offset += 2;
518 if (0 < private_data_len) {
519 proto_tree_add_item(tree, hf_etv_dii_authority, tvb, offset, 1,
520 ENC_ASCII|ENC_NA);
521 /*offset += private_data_len;*/
526 static void
527 dissect_dsmcc_ddb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
528 proto_tree *top_tree, guint offset)
530 tvbuff_t *sub_tvb;
531 proto_item *pi;
532 guint8 reserved;
534 proto_tree_add_item(tree, hf_dsmcc_ddb_module_id, tvb, offset, 2, ENC_BIG_ENDIAN);
535 offset += 2;
536 proto_tree_add_item(tree, hf_dsmcc_ddb_version, tvb, offset, 1, ENC_BIG_ENDIAN);
537 offset +=1;
538 reserved = tvb_get_guint8(tvb, offset);
539 pi = proto_tree_add_item(tree, hf_dsmcc_ddb_reserved, tvb,
540 offset, 1, ENC_BIG_ENDIAN);
541 if (0xff != reserved) {
542 expert_add_info_format(pinfo, pi, &ei_dsmcc_invalid_value,
543 "Invalid value - should be 0xff");
545 offset +=1;
546 proto_tree_add_item(tree, hf_dsmcc_ddb_block_number, tvb, offset, 2, ENC_BIG_ENDIAN);
547 offset += 2;
549 sub_tvb = tvb_new_subset_remaining(tvb, offset);
550 call_dissector(data_handle, sub_tvb, pinfo, top_tree);
554 static void
555 dissect_dsmcc_un_download(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
556 proto_tree *top_tree)
558 proto_item *pi;
559 proto_tree *sub_tree;
560 guint16 msg_id;
561 guint offset = 0;
563 msg_id = tvb_get_ntohs(tvb, offset+2);
565 pi = proto_tree_add_text(tree, tvb, 0, -1, "User Network Message - %s",
566 val_to_str(msg_id, dsmcc_dd_message_id_vals, "%u"));
567 sub_tree = proto_item_add_subtree(pi, ett_dsmcc_payload);
569 switch (msg_id) {
570 case 0x1001:
571 case 0x1002:
572 offset += dissect_dsmcc_header(tvb, pinfo, sub_tree, offset, FALSE);
573 dissect_dsmcc_dii(tvb, pinfo, sub_tree, offset);
574 break;
575 case 0x1003:
576 offset += dissect_dsmcc_header(tvb, pinfo, sub_tree, offset, TRUE);
577 dissect_dsmcc_ddb(tvb, pinfo, sub_tree, top_tree, offset);
578 break;
579 case 0x1004:
580 /* TODO: Add support */
581 break;
582 case 0x1005:
583 /* TODO: Add support */
584 break;
585 case 0x1006:
586 /* TODO: Add support */
587 break;
588 default:
589 break;
593 static guint dissect_dsmcc_un_session_user_data(
594 tvbuff_t *tvb, guint offset, packet_info *pinfo _U_, proto_tree *tree)
596 guint offset_start;
597 guint16 uu_len, priv_len;
599 offset_start = offset;
601 uu_len = tvb_get_ntohs(tvb, offset);
602 proto_tree_add_item(tree, hf_dsmcc_un_sess_uu_data_len,
603 tvb, offset, 2, ENC_BIG_ENDIAN);
604 offset += 2;
606 if (uu_len>0) {
607 proto_tree_add_item(tree, hf_dsmcc_un_sess_uu_data,
608 tvb, offset, uu_len, ENC_NA);
609 offset += uu_len;
612 priv_len = tvb_get_ntohs(tvb, offset);
613 proto_tree_add_item(tree, hf_dsmcc_un_sess_priv_data_len,
614 tvb, offset, 2, ENC_BIG_ENDIAN);
615 offset += 2;
617 if (priv_len>0) {
618 proto_tree_add_item(tree, hf_dsmcc_un_sess_priv_data,
619 tvb, offset, priv_len, ENC_NA);
620 offset += priv_len;
623 return offset-offset_start;
627 static void
628 dissect_dsmcc_un_session(tvbuff_t *tvb, packet_info *pinfo,
629 proto_tree *tree, proto_tree *top_tree _U_)
631 proto_item *pi;
632 proto_tree *sub_tree;
633 guint16 msg_id;
634 guint offset = 0;
636 msg_id = tvb_get_ntohs(tvb, offset+2);
638 pi = proto_tree_add_text(tree, tvb, offset, -1,
639 "User Network Message (Session) - %s",
640 val_to_str(msg_id, dsmcc_un_sess_message_id_vals, "0x%x"));
641 col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "%s",
642 val_to_str(msg_id, dsmcc_un_sess_message_id_vals, "0x%x"));
643 sub_tree = proto_item_add_subtree(pi, ett_dsmcc_payload);
645 switch (msg_id) {
646 case DSMCC_UN_SESS_SRV_SESS_REL_REQ:
647 offset += dissect_dsmcc_header(tvb, pinfo, sub_tree, offset, FALSE);
648 proto_tree_add_item(sub_tree, hf_dsmcc_un_sess_id,
649 tvb, offset, 10, ENC_NA);
650 offset += 10;
651 proto_tree_add_item(sub_tree, hf_dsmcc_un_sess_reason,
652 tvb, offset, 2, ENC_BIG_ENDIAN);
653 offset += 2;
654 offset += dissect_dsmcc_un_session_user_data(
655 tvb, offset, pinfo, sub_tree);
656 break;
657 case DSMCC_UN_SESS_SRV_SESS_REL_CNF:
658 offset += dissect_dsmcc_header(tvb, pinfo, sub_tree, offset, FALSE);
659 proto_tree_add_item(sub_tree, hf_dsmcc_un_sess_id,
660 tvb, offset, 10, ENC_NA);
661 offset += 10;
662 proto_tree_add_item(sub_tree, hf_dsmcc_un_sess_response,
663 tvb, offset, 2, ENC_BIG_ENDIAN);
664 offset += 2;
665 offset += dissect_dsmcc_un_session_user_data(
666 tvb, offset, pinfo, sub_tree);
667 break;
668 case DSMCC_UN_SESS_SRV_STAT_REQ:
669 offset += dissect_dsmcc_header(tvb, pinfo, sub_tree, offset, FALSE);
670 proto_tree_add_item(sub_tree, hf_dsmcc_un_sess_reason,
671 tvb, offset, 2, ENC_BIG_ENDIAN);
672 offset += 2;
673 /* TODO: add server id, status type, status count */
674 offset += 20;
675 /* TODO: skip status bytes */
676 break;
677 case DSMCC_UN_SESS_SRV_STAT_CNF:
678 offset += dissect_dsmcc_header(tvb, pinfo, sub_tree, offset, FALSE);
679 proto_tree_add_item(sub_tree, hf_dsmcc_un_sess_response,
680 tvb, offset, 2, ENC_BIG_ENDIAN);
681 offset += 2;
682 /* TODO: add status type, status count */
683 offset += 4;
684 /* TODO: skip status bytes */
685 break;
686 default:
687 break;
689 proto_item_set_len(pi, offset);
693 static void
694 dissect_dsmcc_un(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
695 proto_tree *top_tree)
697 guint8 type;
699 /* dsmccMessageHeader.dsmccType */
700 type = tvb_get_guint8(tvb, 1);
702 switch (type) {
703 case 1: /* user-to-network configuration */
704 /* TODO: Add support */
705 break;
706 case 2: /* user-to-network session */
707 dissect_dsmcc_un_session(tvb, pinfo, tree, top_tree);
708 break;
709 case 3: /* user-to-network download */
710 dissect_dsmcc_un_download(tvb, pinfo, tree, top_tree);
711 break;
712 case 4: /* sdb channel change protocol */
713 /* TODO: Add support */
714 break;
715 case 5: /* user-to-network pass-thru */
716 /* TODO: Add support */
717 break;
718 default:
719 break;
723 static int
724 dissect_dsmcc_ts(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree_in, void *data _U_)
726 proto_item *pi;
727 proto_tree *tree;
728 guint crc_len;
729 guint8 tid;
730 guint16 sect_len;
731 guint32 crc, calculated_crc;
732 const char *label;
733 tvbuff_t *sub_tvb;
734 guint16 ssi;
735 guint offset = 0;
737 pi = proto_tree_add_item(tree_in, proto_dsmcc, tvb, 0, -1, ENC_NA);
738 tree = proto_item_add_subtree(pi, ett_dsmcc);
740 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DSM-CC");
742 tid = tvb_get_guint8(tvb, offset);
743 proto_tree_add_item(tree, hf_dsmcc_table_id, tvb,
744 offset, 1, ENC_BIG_ENDIAN);
745 offset +=1;
746 ssi = tvb_get_ntohs(tvb, offset);
747 ssi &= DSMCC_SSI_MASK;
748 proto_tree_add_item(tree, hf_dsmcc_section_syntax_indicator, tvb,
749 offset, 2, ENC_BIG_ENDIAN);
750 proto_tree_add_item(tree, hf_dsmcc_private_indicator, tvb,
751 offset, 2, ENC_BIG_ENDIAN);
752 proto_tree_add_item(tree, hf_dsmcc_reserved, tvb,
753 offset, 2, ENC_BIG_ENDIAN);
754 proto_tree_add_item(tree, hf_dsmcc_section_length, tvb,
755 offset, 2, ENC_BIG_ENDIAN);
756 sect_len = tvb_get_ntohs(tvb, offset);
757 sect_len &= DSMCC_LENGTH_MASK;
758 offset += 2;
760 proto_tree_add_item(tree, hf_dsmcc_table_id_extension, tvb,
761 offset, 2, ENC_BIG_ENDIAN);
762 offset += 2;
763 proto_tree_add_item(tree, hf_dsmcc_reserved2, tvb,
764 offset, 1, ENC_BIG_ENDIAN);
765 proto_tree_add_item(tree, hf_dsmcc_version_number, tvb,
766 offset, 1, ENC_BIG_ENDIAN);
767 proto_tree_add_item(tree, hf_dsmcc_current_next_indicator, tvb,
768 offset, 1, ENC_BIG_ENDIAN);
769 offset +=1;
770 proto_tree_add_item(tree, hf_dsmcc_section_number, tvb,
771 offset, 1, ENC_BIG_ENDIAN);
772 offset +=1;
773 proto_tree_add_item(tree, hf_dsmcc_last_section_number, tvb,
774 offset, 1, ENC_BIG_ENDIAN);
775 offset +=1;
777 sub_tvb = tvb_new_subset(tvb, offset, sect_len-9, sect_len-9);
778 switch (tid) {
779 case DSMCC_TID_LLCSNAP:
780 /* TODO: Add support */
781 break;
782 case DSMCC_TID_UN_MSG:
783 case DSMCC_TID_DD_MSG:
784 dissect_dsmcc_un(sub_tvb, pinfo, tree, tree_in);
785 break;
786 case DSMCC_TID_DESC_LIST:
787 /* TODO: Add support */
788 break;
789 case DSMCC_TID_PRIVATE:
790 /* TODO: Add support */
791 break;
792 default:
793 break;
796 crc_len = 3 + sect_len - 4; /* Add the header, remove the crc */
797 if (ssi) {
798 crc = tvb_get_ntohl(tvb, crc_len);
800 calculated_crc = crc;
801 label = "Unverified";
802 if (dsmcc_sect_check_crc) {
803 label = "Verified";
804 calculated_crc = crc32_mpeg2_tvb_offset(tvb, 0, crc_len);
807 if (calculated_crc == crc) {
808 proto_tree_add_uint_format( tree, hf_dsmcc_crc, tvb,
809 crc_len, 4, crc, "CRC: 0x%08x [%s]", crc, label);
810 } else {
811 proto_item *msg_error;
813 msg_error = proto_tree_add_uint_format( tree, hf_dsmcc_crc, tvb,
814 crc_len, 4, crc,
815 "CRC: 0x%08x [Failed Verification (Calculated: 0x%08x)]",
816 crc, calculated_crc );
817 PROTO_ITEM_SET_GENERATED(msg_error);
818 expert_add_info( pinfo, msg_error, &ei_dsmcc_crc_invalid);
820 } else {
821 /* TODO: actually check the checksum */
822 proto_tree_add_item(tree, hf_dsmcc_checksum, tvb,
823 crc_len, 4, ENC_BIG_ENDIAN);
826 return tvb_reported_length(tvb);
830 static int dissect_dsmcc_tcp(tvbuff_t *tvb, packet_info *pinfo,
831 proto_tree *tree, void *data _U_)
833 proto_item *pi;
834 proto_tree *sub_tree;
836 if (tvb_get_guint8(tvb, 0) != DSMCC_PROT_DISC)
837 return 0;
839 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DSM-CC");
840 col_clear(pinfo->cinfo, COL_INFO);
842 pi = proto_tree_add_item(tree, proto_dsmcc, tvb, 0, -1, ENC_NA);
843 sub_tree = proto_item_add_subtree(pi, ett_dsmcc);
845 dissect_dsmcc_un(tvb, pinfo, sub_tree, tree);
847 return tvb_reported_length(tvb);
851 void
852 proto_register_dsmcc(void)
854 /* NOTE: Please add tables numerically according to 13818-6 so it is
855 * easier to keep track of what parameters/tables are associated with
856 * each other.
858 static hf_register_info hf[] = {
859 /* table 2-1 dsmccMessageHeader - start */
860 { &hf_dsmcc_protocol_discriminator, {
861 "Protocol Discriminator", "mpeg_dsmcc.protocol",
862 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
863 } },
865 { &hf_dsmcc_type, {
866 "Type", "mpeg_dsmcc.type",
867 FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(dsmcc_header_type_vals), 0, NULL, HFILL
868 } },
870 { &hf_dsmcc_message_id, {
871 "Message ID", "mpeg_dsmcc.message_id",
872 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
873 } },
875 { &hf_dsmcc_transaction_id, {
876 "Transaction ID", "mpeg_dsmcc.transaction_id",
877 FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
878 } },
880 { &hf_dsmcc_header_reserved, {
881 "Reserved", "mpeg_dsmcc.header_reserved",
882 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
883 } },
885 { &hf_dsmcc_adaptation_length, {
886 "Adaptation Length", "mpeg_dsmcc.adaptation_length",
887 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
888 } },
890 { &hf_dsmcc_message_length, {
891 "Message Length", "mpeg_dsmcc.message_length",
892 FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL
893 } },
894 /* table 2-1 dsmccMessageHeader - end */
897 /* table 2-4 dsmccAdaptationHeader - start */
898 { &hf_dsmcc_adaptation_type, {
899 "Adaptation Type", "mpeg_dsmcc.adaptation_header.type",
900 FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(dsmcc_adaptation_header_vals), 0, NULL, HFILL
901 } },
902 /* table 2-4 dsmccAdaptationHeader - end */
904 /* table 2-6 dsmccConditionalAccess - start */
905 { &hf_dsmcc_adaptation_ca_reserved, {
906 "Reserved", "mpeg_dsmcc.adaptation_header.ca.reserved",
907 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
908 } },
910 { &hf_dsmcc_adaptation_ca_system_id, {
911 "System ID", "mpeg_dsmcc.adaptation_header.ca.system_id",
912 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
913 } },
915 { &hf_dsmcc_adaptation_ca_length, {
916 "System ID", "mpeg_dsmcc.adaptation_header.ca.length",
917 FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL
918 } },
919 /* table 2-6 dsmccConditionalAccess - end */
922 /* table 2-7 dsmccUserId - start */
923 { &hf_dsmcc_adaptation_user_id_reserved, {
924 "Reserved", "mpeg_dsmcc.adaptation_header.uid.reserved",
925 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
926 } },
927 /* table 2-7 dsmccUserId - start */
929 /* table 4-6 U-N user data format - start */
930 { &hf_dsmcc_un_sess_uu_data_len, {
931 "User data length", "mpeg_dsmcc.un_sess.uu_data_len",
932 FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL
933 } },
935 { &hf_dsmcc_un_sess_uu_data, {
936 "User data", "mpeg_dsmcc.un_sess.uu_data",
937 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL
938 } },
940 { &hf_dsmcc_un_sess_priv_data_len, {
941 "Private data length", "mpeg_dsmcc.un_sess.priv_data_len",
942 FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL
943 } },
945 { &hf_dsmcc_un_sess_priv_data, {
946 "Private data", "mpeg_dsmcc.un_sess.priv_data",
947 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL
948 } },
949 /* table 4-6 U-N user data format - end */
951 /* other tables in section 4.2 - start */
952 { &hf_dsmcc_un_sess_id, {
953 "Session ID", "mpeg_dsmcc.un_sess.session_id",
954 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL
955 } },
957 { &hf_dsmcc_un_sess_response, {
958 "Response", "mpeg_dsmcc.un_sess.response",
959 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
960 } },
962 { &hf_dsmcc_un_sess_reason, {
963 "Reason", "mpeg_dsmcc.un_sess.reason",
964 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
965 } },
966 /* other tables in section 4.2 - end */
968 /* table 6-1 compatabilityDescriptor - start */
969 { &hf_compat_desc_length, {
970 "Compatibility Descriptor Length", "mpeg_dsmcc.dii.compat_desc_len",
971 FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL
972 } },
974 { &hf_compat_desc_count, {
975 "Descriptor Length", "mpeg_dsmcc.dii.compat_desc_count",
976 FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL
977 } },
979 { &hf_desc_type, {
980 "Descriptor Type", "mpeg_dsmcc.dii.compat.type",
981 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
982 } },
984 { &hf_desc_length, {
985 "Descriptor Length", "mpeg_dsmcc.dii.compat.length",
986 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
987 } },
989 { &hf_desc_spec_type, {
990 "Specifier Type", "mpeg_dsmcc.dii.compat.spec_type",
991 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
992 } },
994 { &hf_desc_spec_data, {
995 "Specifier Data", "mpeg_dsmcc.dii.compat.spec_data",
996 FT_UINT24, BASE_HEX, NULL, 0, NULL, HFILL
997 } },
999 { &hf_desc_model, {
1000 "Model", "mpeg_dsmcc.dii.compat.model",
1001 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
1002 } },
1004 { &hf_desc_version, {
1005 "Version", "mpeg_dsmcc.dii.compat.version",
1006 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
1007 } },
1009 { &hf_desc_sub_desc_count, {
1010 "Version", "mpeg_dsmcc.dii.compat.sub_count",
1011 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
1012 } },
1014 { &hf_desc_sub_desc_type, {
1015 "Type", "mpeg_dsmcc.dii.compat.sub_type",
1016 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
1017 } },
1019 { &hf_desc_sub_desc_len, {
1020 "Length", "mpeg_dsmcc.dii.compat.sub_len",
1021 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
1022 } },
1023 /* table 6-1 compatabilityDescriptor - end */
1026 /* table 7-3 dsmccDownloadDataHeader - start */
1027 { &hf_dsmcc_dd_download_id, {
1028 "Download ID", "mpeg_dsmcc.download_id",
1029 FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
1030 } },
1032 { &hf_dsmcc_dd_message_id, {
1033 "Message ID", "mpeg_dsmcc.message_id",
1034 FT_UINT16, BASE_HEX, VALS(dsmcc_dd_message_id_vals), 0, NULL, HFILL
1035 } },
1036 /* table 7-3 dsmccDownloadDataHeader - end */
1039 /* table 7-6 downloadInfoIndication - start */
1040 { &hf_dsmcc_dii_download_id, {
1041 "Download ID", "mpeg_dsmcc.dii.download_id",
1042 FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
1043 } },
1045 { &hf_dsmcc_dii_block_size, {
1046 "Block Size", "mpeg_dsmcc.dii.block_size",
1047 FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL
1048 } },
1050 { &hf_dsmcc_dii_window_size, {
1051 "Window Size", "mpeg_dsmcc.dii.window_size",
1052 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
1053 } },
1055 { &hf_dsmcc_dii_ack_period, {
1056 "ACK Period", "mpeg_dsmcc.dii.ack_period",
1057 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
1058 } },
1060 { &hf_dsmcc_dii_t_c_download_window, {
1061 "Carousel Download Window", "mpeg_dsmcc.dii.carousel_download_window",
1062 FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
1063 } },
1065 { &hf_dsmcc_dii_t_c_download_scenario, {
1066 "Carousel Download Scenario", "mpeg_dsmcc.dii.carousel_download_scenario",
1067 FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
1068 } },
1070 { &hf_dsmcc_dii_number_of_modules, {
1071 "Number of Modules", "mpeg_dsmcc.dii.module_count",
1072 FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL
1073 } },
1075 { &hf_dsmcc_dii_module_id, {
1076 "Module ID", "mpeg_dsmcc.dii.module_id",
1077 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
1078 } },
1080 { &hf_dsmcc_dii_module_size, {
1081 "Module Size", "mpeg_dsmcc.dii.module_size",
1082 FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
1083 } },
1085 { &hf_dsmcc_dii_module_version, {
1086 "Module Version", "mpeg_dsmcc.dii.module_version",
1087 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
1088 } },
1090 { &hf_dsmcc_dii_module_info_length, {
1091 "Module Info Length", "mpeg_dsmcc.dii.module_info_length",
1092 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
1093 } },
1095 { &hf_dsmcc_dii_private_data_length, {
1096 "Private Data Length", "mpeg_dsmcc.dii.private_data_length",
1097 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
1098 } },
1099 /* table 7-6 downloadInfoIndication - end */
1102 /* table 7-7 dsmccDownloadDataBlock - start */
1103 { &hf_dsmcc_ddb_module_id, {
1104 "Module ID", "mpeg_dsmcc.ddb.module_id",
1105 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
1106 } },
1108 { &hf_dsmcc_ddb_version, {
1109 "Version", "mpeg_dsmcc.ddb.version",
1110 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
1111 } },
1113 { &hf_dsmcc_ddb_reserved, {
1114 "Reserved", "mpeg_dsmcc.ddb.reserved",
1115 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
1116 } },
1118 { &hf_dsmcc_ddb_block_number, {
1119 "Block Number", "mpeg_dsmcc.ddb.block_num",
1120 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
1121 } },
1122 /* table 7-7 dsmccDownloadDataBlock - end */
1125 /* table 9-2 - start */
1126 { &hf_dsmcc_table_id, {
1127 "Table ID", "mpeg_sect.table_id",
1128 FT_UINT8, BASE_HEX, VALS(dsmcc_payload_name_vals), 0, NULL, HFILL
1129 } },
1131 { &hf_dsmcc_section_syntax_indicator, {
1132 "Session Syntax Indicator", "mpeg_sect.ssi",
1133 FT_UINT16, BASE_DEC, NULL, DSMCC_SSI_MASK, NULL, HFILL
1134 } },
1136 { &hf_dsmcc_private_indicator, {
1137 "Private Indicator", "mpeg_dsmcc.private_indicator",
1138 FT_UINT16, BASE_DEC, NULL, DSMCC_PRIVATE_MASK, NULL, HFILL
1139 } },
1141 { &hf_dsmcc_reserved, {
1142 "Reserved", "mpeg_sect.reserved",
1143 FT_UINT16, BASE_HEX, NULL, DSMCC_RESERVED_MASK, NULL, HFILL
1144 } },
1146 { &hf_dsmcc_section_length, {
1147 "Length", "mpeg_sect.section_length",
1148 FT_UINT16, BASE_DEC, NULL, DSMCC_LENGTH_MASK, NULL, HFILL
1149 } },
1151 { &hf_dsmcc_table_id_extension, {
1152 "Table ID Extension", "mpeg_dsmcc.table_id_extension",
1153 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
1154 } },
1156 { &hf_dsmcc_reserved2, {
1157 "Reserved", "mpeg_dsmcc.reserved2",
1158 FT_UINT8, BASE_HEX, NULL, DSMCC_RESERVED2_MASK, NULL, HFILL
1159 } },
1161 { &hf_dsmcc_version_number, {
1162 "Version Number", "mpeg_dsmcc.version_number",
1163 FT_UINT8, BASE_DEC, NULL, DSMCC_VERSION_NUMBER_MASK, NULL, HFILL
1164 } },
1166 { &hf_dsmcc_current_next_indicator, {
1167 "Current Next Indicator", "mpeg_dsmcc.current_next_indicator",
1168 FT_UINT8, BASE_DEC, NULL, DSMCC_CURRENT_NEXT_INDICATOR_MASK, NULL, HFILL
1169 } },
1171 { &hf_dsmcc_section_number, {
1172 "Section Number", "mpeg_dsmcc.section_number",
1173 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
1174 } },
1176 { &hf_dsmcc_last_section_number, {
1177 "Last Section Number", "mpeg_dsmcc.last_section_number",
1178 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
1179 } },
1181 { &hf_dsmcc_crc, {
1182 "CRC 32", "mpeg_sect.crc",
1183 FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
1184 } },
1186 { &hf_dsmcc_checksum, {
1187 "Checksum", "mpeg_dsmcc.checksum",
1188 FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
1189 } },
1190 /* table 9-2 - end */
1193 { &hf_etv_module_abs_path, {
1194 "Module Absolute Path", "etv.dsmcc.dii.module_abs_path",
1195 FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
1196 } },
1198 { &hf_etv_dii_authority, {
1199 "Authority", "etv.dsmcc.dii.authority",
1200 FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
1204 static gint *ett[] = {
1205 &ett_dsmcc,
1206 &ett_dsmcc_payload,
1207 &ett_dsmcc_adaptation_header,
1208 &ett_dsmcc_header,
1209 &ett_dsmcc_compat,
1210 &ett_dsmcc_compat_sub_desc,
1211 &ett_dsmcc_dii_module
1213 static ei_register_info ei[] = {
1214 { &ei_dsmcc_invalid_value, { "mpeg_dsmcc.invalid_value", PI_PROTOCOL, PI_WARN, "Invalid value", EXPFILL }},
1215 { &ei_dsmcc_crc_invalid, { "mpeg_sect.crc.invalid", PI_CHECKSUM, PI_WARN, "Invalid CRC", EXPFILL }},
1218 module_t *dsmcc_module;
1219 expert_module_t* expert_dsmcc;
1221 proto_dsmcc = proto_register_protocol("MPEG DSM-CC", "MPEG DSM-CC", "mpeg_dsmcc");
1223 proto_register_field_array(proto_dsmcc, hf, array_length(hf));
1224 proto_register_subtree_array(ett, array_length(ett));
1225 expert_dsmcc = expert_register_protocol(proto_dsmcc);
1226 expert_register_field_array(expert_dsmcc, ei, array_length(ei));
1227 new_register_dissector("mp2t-dsmcc", dissect_dsmcc_ts, proto_dsmcc);
1229 dsmcc_module = prefs_register_protocol(proto_dsmcc, NULL);
1231 prefs_register_bool_preference(dsmcc_module, "verify_crc",
1232 "Verify the section CRC or checksum",
1233 "Whether the section dissector should verify the CRC or checksum",
1234 &dsmcc_sect_check_crc);
1238 void
1239 proto_reg_handoff_dsmcc(void)
1241 dissector_handle_t dsmcc_ts_handle, dsmcc_tcp_handle;
1243 dsmcc_ts_handle = new_create_dissector_handle(dissect_dsmcc_ts, proto_dsmcc);
1244 dsmcc_tcp_handle = new_create_dissector_handle(dissect_dsmcc_tcp, proto_dsmcc);
1246 dissector_add_uint("mpeg_sect.tid", DSMCC_TID_LLCSNAP, dsmcc_ts_handle);
1247 dissector_add_uint("mpeg_sect.tid", DSMCC_TID_UN_MSG, dsmcc_ts_handle);
1248 dissector_add_uint("mpeg_sect.tid", DSMCC_TID_DD_MSG, dsmcc_ts_handle);
1249 dissector_add_uint("mpeg_sect.tid", DSMCC_TID_DESC_LIST, dsmcc_ts_handle);
1250 dissector_add_uint("mpeg_sect.tid", DSMCC_TID_PRIVATE, dsmcc_ts_handle);
1252 dissector_add_uint("tcp.port", DSMCC_TCP_PORT, dsmcc_tcp_handle);
1254 data_handle = find_dissector("data");
1258 * Editor modelines - http://www.wireshark.org/tools/modelines.html
1260 * Local variables:
1261 * c-basic-offset: 4
1262 * tab-width: 8
1263 * indent-tabs-mode: nil
1264 * End:
1266 * vi: set shiftwidth=4 tabstop=8 expandtab:
1267 * :indentSize=4:tabSize=8:noTabs=true: