Coverage Report

Created: 2025-08-04 07:15

/src/wireshark/epan/dissectors/packet-mpeg-ca.c
Line
Count
Source
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>
4
 *
5
 * Wireshark - Network traffic analyzer
6
 * By Gerald Combs <gerald@wireshark.org>
7
 * Copyright 1998 Gerald Combs
8
 *
9
 * SPDX-License-Identifier: GPL-2.0-or-later
10
 */
11
12
#include "config.h"
13
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"
19
20
void proto_register_mpeg_ca(void);
21
void proto_reg_handoff_mpeg_ca(void);
22
23
static dissector_handle_t mpeg_ca_handle;
24
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;
31
32
static int ett_mpeg_ca;
33
34
14
#define MPEG_CA_RESERVED_MASK                   0xFFFFC0
35
14
#define MPEG_CA_VERSION_NUMBER_MASK             0x00003E
36
14
#define MPEG_CA_CURRENT_NEXT_INDICATOR_MASK     0x000001
37
38
static int
39
dissect_mpeg_ca(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
40
39
{
41
39
    unsigned offset = 0, length = 0;
42
43
39
    proto_item *ti;
44
39
    proto_tree *mpeg_ca_tree;
45
46
    /* The TVB should start right after the section_length in the Section packet */
47
48
39
    col_set_str(pinfo->cinfo, COL_INFO, "Conditional Access Table (CA)");
49
50
39
    ti = proto_tree_add_item(tree, proto_mpeg_ca, tvb, offset, -1, ENC_NA);
51
39
    mpeg_ca_tree = proto_item_add_subtree(ti, ett_mpeg_ca);
52
53
39
    offset += packet_mpeg_sect_header(tvb, offset, mpeg_ca_tree, &length, NULL);
54
39
    length -= 4;
55
56
39
    proto_tree_add_item(mpeg_ca_tree, hf_mpeg_ca_reserved, tvb, offset, 3, ENC_BIG_ENDIAN);
57
39
    proto_tree_add_item(mpeg_ca_tree, hf_mpeg_ca_version_number, tvb, offset, 3, ENC_BIG_ENDIAN);
58
39
    proto_tree_add_item(mpeg_ca_tree, hf_mpeg_ca_current_next_indicator, tvb, offset, 3, ENC_BIG_ENDIAN);
59
39
    offset += 3;
60
61
39
    proto_tree_add_item(mpeg_ca_tree, hf_mpeg_ca_section_number, tvb, offset, 1, ENC_BIG_ENDIAN);
62
39
    offset += 1;
63
64
39
    proto_tree_add_item(mpeg_ca_tree, hf_mpeg_ca_last_section_number, tvb, offset, 1, ENC_BIG_ENDIAN);
65
39
    offset += 1;
66
67
    /* Parse all the programs */
68
511
    while (offset < length)
69
472
        offset += proto_mpeg_descriptor_dissect(tvb, pinfo, offset, mpeg_ca_tree);
70
71
39
    offset += packet_mpeg_sect_crc(tvb, pinfo, mpeg_ca_tree, 0, offset);
72
73
39
    proto_item_set_len(ti, offset);
74
39
    return tvb_captured_length(tvb);
75
39
}
76
77
78
void
79
proto_register_mpeg_ca(void)
80
14
{
81
82
14
    static hf_register_info hf[] = {
83
84
14
        { &hf_mpeg_ca_reserved, {
85
14
            "Reserved", "mpeg_ca.reserved",
86
14
            FT_UINT24, BASE_HEX, NULL, MPEG_CA_RESERVED_MASK,
87
14
                        NULL, HFILL
88
14
        } },
89
90
14
        { &hf_mpeg_ca_version_number, {
91
14
            "Version Number", "mpeg_ca.version",
92
14
            FT_UINT24, BASE_HEX, NULL, MPEG_CA_VERSION_NUMBER_MASK,
93
14
                        NULL, HFILL
94
14
        } },
95
96
14
        { &hf_mpeg_ca_current_next_indicator, {
97
14
            "Current/Next Indicator", "mpeg_ca.cur_next_ind",
98
14
            FT_BOOLEAN, 24, TFS(&tfs_current_not_yet), MPEG_CA_CURRENT_NEXT_INDICATOR_MASK,
99
14
                        NULL, HFILL
100
14
        } },
101
102
14
        { &hf_mpeg_ca_section_number, {
103
14
            "Section Number", "mpeg_ca.sect_num",
104
14
            FT_UINT8, BASE_DEC, NULL, 0,
105
14
                        NULL, HFILL
106
14
        } },
107
108
14
        { &hf_mpeg_ca_last_section_number, {
109
14
            "Last Section Number", "mpeg_ca.last_sect_num",
110
14
            FT_UINT8, BASE_DEC, NULL, 0,
111
14
                        NULL, HFILL
112
14
        } },
113
114
14
    };
115
116
14
    static int *ett[] = {
117
14
        &ett_mpeg_ca,
118
14
    };
119
120
14
    proto_mpeg_ca = proto_register_protocol("MPEG2 Conditional Access Table", "MPEG CA", "mpeg_ca");
121
122
14
    proto_register_field_array(proto_mpeg_ca, hf, array_length(hf));
123
14
    proto_register_subtree_array(ett, array_length(ett));
124
125
14
    mpeg_ca_handle = register_dissector("mpeg_ca", dissect_mpeg_ca, proto_mpeg_ca);
126
14
}
127
128
129
void proto_reg_handoff_mpeg_ca(void)
130
14
{
131
14
    dissector_add_uint("mpeg_sect.tid", MPEG_CA_TID, mpeg_ca_handle);
132
14
}
133
134
/*
135
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
136
 *
137
 * Local variables:
138
 * c-basic-offset: 4
139
 * tab-width: 8
140
 * indent-tabs-mode: nil
141
 * End:
142
 *
143
 * vi: set shiftwidth=4 tabstop=8 expandtab:
144
 * :indentSize=4:tabSize=8:noTabs=true:
145
 */