Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-mpeg-ca.c
blob8e7a52ab70f2891589d6a38484360210c5ba454c
1 /* packet-mpeg-ca.c
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
12 #include "config.h"
14 #include <epan/packet.h>
15 #include <epan/tfs.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
38 static int
39 dissect_mpeg_ca(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
41 unsigned offset = 0, length = 0;
43 proto_item *ti;
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);
54 length -= 4;
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);
59 offset += 3;
61 proto_tree_add_item(mpeg_ca_tree, hf_mpeg_ca_section_number, tvb, offset, 1, ENC_BIG_ENDIAN);
62 offset += 1;
64 proto_tree_add_item(mpeg_ca_tree, hf_mpeg_ca_last_section_number, tvb, offset, 1, ENC_BIG_ENDIAN);
65 offset += 1;
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);
78 void
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,
87 NULL, HFILL
88 } },
90 { &hf_mpeg_ca_version_number, {
91 "Version Number", "mpeg_ca.version",
92 FT_UINT24, BASE_HEX, NULL, MPEG_CA_VERSION_NUMBER_MASK,
93 NULL, HFILL
94 } },
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,
99 NULL, HFILL
100 } },
102 { &hf_mpeg_ca_section_number, {
103 "Section Number", "mpeg_ca.sect_num",
104 FT_UINT8, BASE_DEC, NULL, 0,
105 NULL, HFILL
106 } },
108 { &hf_mpeg_ca_last_section_number, {
109 "Last Section Number", "mpeg_ca.last_sect_num",
110 FT_UINT8, BASE_DEC, NULL, 0,
111 NULL, HFILL
112 } },
116 static int *ett[] = {
117 &ett_mpeg_ca,
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
137 * Local variables:
138 * c-basic-offset: 4
139 * tab-width: 8
140 * indent-tabs-mode: nil
141 * End:
143 * vi: set shiftwidth=4 tabstop=8 expandtab:
144 * :indentSize=4:tabSize=8:noTabs=true: