2 * Routines for MPEG2 (ISO/ISO 13818-1) Conditional Access Table (CA) 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 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include <epan/packet.h>
16 #include <wsutil/array.h>
17 #include "packet-mpeg-sect.h"
18 #include "packet-mpeg-descriptor.h"
20 void proto_register_mpeg_ca(void);
21 void proto_reg_handoff_mpeg_ca(void);
23 static dissector_handle_t mpeg_ca_handle
;
25 static int proto_mpeg_ca
;
26 static int hf_mpeg_ca_reserved
;
27 static int hf_mpeg_ca_version_number
;
28 static int hf_mpeg_ca_current_next_indicator
;
29 static int hf_mpeg_ca_section_number
;
30 static int hf_mpeg_ca_last_section_number
;
32 static int ett_mpeg_ca
;
34 #define MPEG_CA_RESERVED_MASK 0xFFFFC0
35 #define MPEG_CA_VERSION_NUMBER_MASK 0x00003E
36 #define MPEG_CA_CURRENT_NEXT_INDICATOR_MASK 0x000001
39 dissect_mpeg_ca(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
41 unsigned offset
= 0, length
= 0;
44 proto_tree
*mpeg_ca_tree
;
46 /* The TVB should start right after the section_length in the Section packet */
48 col_set_str(pinfo
->cinfo
, COL_INFO
, "Conditional Access Table (CA)");
50 ti
= proto_tree_add_item(tree
, proto_mpeg_ca
, tvb
, offset
, -1, ENC_NA
);
51 mpeg_ca_tree
= proto_item_add_subtree(ti
, ett_mpeg_ca
);
53 offset
+= packet_mpeg_sect_header(tvb
, offset
, mpeg_ca_tree
, &length
, NULL
);
56 proto_tree_add_item(mpeg_ca_tree
, hf_mpeg_ca_reserved
, tvb
, offset
, 3, ENC_BIG_ENDIAN
);
57 proto_tree_add_item(mpeg_ca_tree
, hf_mpeg_ca_version_number
, tvb
, offset
, 3, ENC_BIG_ENDIAN
);
58 proto_tree_add_item(mpeg_ca_tree
, hf_mpeg_ca_current_next_indicator
, tvb
, offset
, 3, ENC_BIG_ENDIAN
);
61 proto_tree_add_item(mpeg_ca_tree
, hf_mpeg_ca_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
64 proto_tree_add_item(mpeg_ca_tree
, hf_mpeg_ca_last_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
67 /* Parse all the programs */
68 while (offset
< length
)
69 offset
+= proto_mpeg_descriptor_dissect(tvb
, offset
, mpeg_ca_tree
);
71 offset
+= packet_mpeg_sect_crc(tvb
, pinfo
, mpeg_ca_tree
, 0, offset
);
73 proto_item_set_len(ti
, offset
);
74 return tvb_captured_length(tvb
);
79 proto_register_mpeg_ca(void)
82 static hf_register_info hf
[] = {
84 { &hf_mpeg_ca_reserved
, {
85 "Reserved", "mpeg_ca.reserved",
86 FT_UINT24
, BASE_HEX
, NULL
, MPEG_CA_RESERVED_MASK
,
90 { &hf_mpeg_ca_version_number
, {
91 "Version Number", "mpeg_ca.version",
92 FT_UINT24
, BASE_HEX
, NULL
, MPEG_CA_VERSION_NUMBER_MASK
,
96 { &hf_mpeg_ca_current_next_indicator
, {
97 "Current/Next Indicator", "mpeg_ca.cur_next_ind",
98 FT_BOOLEAN
, 24, TFS(&tfs_current_not_yet
), MPEG_CA_CURRENT_NEXT_INDICATOR_MASK
,
102 { &hf_mpeg_ca_section_number
, {
103 "Section Number", "mpeg_ca.sect_num",
104 FT_UINT8
, BASE_DEC
, NULL
, 0,
108 { &hf_mpeg_ca_last_section_number
, {
109 "Last Section Number", "mpeg_ca.last_sect_num",
110 FT_UINT8
, BASE_DEC
, NULL
, 0,
116 static int *ett
[] = {
120 proto_mpeg_ca
= proto_register_protocol("MPEG2 Conditional Access Table", "MPEG CA", "mpeg_ca");
122 proto_register_field_array(proto_mpeg_ca
, hf
, array_length(hf
));
123 proto_register_subtree_array(ett
, array_length(ett
));
125 mpeg_ca_handle
= register_dissector("mpeg_ca", dissect_mpeg_ca
, proto_mpeg_ca
);
129 void proto_reg_handoff_mpeg_ca(void)
131 dissector_add_uint("mpeg_sect.tid", MPEG_CA_TID
, mpeg_ca_handle
);
135 * Editor modelines - https://www.wireshark.org/tools/modelines.html
140 * indent-tabs-mode: nil
143 * vi: set shiftwidth=4 tabstop=8 expandtab:
144 * :indentSize=4:tabSize=8:noTabs=true: