Coverage Report

Created: 2026-07-12 07:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/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
15
#define MPEG_CA_RESERVED_MASK                   0xFFFFC0
35
15
#define MPEG_CA_VERSION_NUMBER_MASK             0x00003E
36
15
#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
53
{
41
53
    unsigned offset = 0, length = 0;
42
43
53
    proto_item *ti;
44
53
    proto_tree *mpeg_ca_tree;
45
46
    /* The TVB should start right after the section_length in the Section packet */
47
48
53
    col_set_str(pinfo->cinfo, COL_INFO, "Conditional Access Table (CA)");
49
50
53
    ti = proto_tree_add_item(tree, proto_mpeg_ca, tvb, offset, -1, ENC_NA);
51
53
    mpeg_ca_tree = proto_item_add_subtree(ti, ett_mpeg_ca);
52
53
53
    offset += packet_mpeg_sect_header(tvb, offset, mpeg_ca_tree, &length, NULL);
54
53
    length -= 4;
55
56
53
    proto_tree_add_item(mpeg_ca_tree, hf_mpeg_ca_reserved, tvb, offset, 3, ENC_BIG_ENDIAN);
57
53
    proto_tree_add_item(mpeg_ca_tree, hf_mpeg_ca_version_number, tvb, offset, 3, ENC_BIG_ENDIAN);
58
53
    proto_tree_add_item(mpeg_ca_tree, hf_mpeg_ca_current_next_indicator, tvb, offset, 3, ENC_BIG_ENDIAN);
59
53
    offset += 3;
60
61
53
    proto_tree_add_item(mpeg_ca_tree, hf_mpeg_ca_section_number, tvb, offset, 1, ENC_BIG_ENDIAN);
62
53
    offset += 1;
63
64
53
    proto_tree_add_item(mpeg_ca_tree, hf_mpeg_ca_last_section_number, tvb, offset, 1, ENC_BIG_ENDIAN);
65
53
    offset += 1;
66
67
    /* Parse all the programs */
68
594
    while (offset < length)
69
541
        offset += proto_mpeg_descriptor_dissect(tvb, pinfo, offset, mpeg_ca_tree);
70
71
53
    offset += packet_mpeg_sect_crc(tvb, pinfo, mpeg_ca_tree, 0, offset);
72
73
53
    proto_item_set_len(ti, offset);
74
53
    return tvb_captured_length(tvb);
75
53
}
76
77
78
void
79
proto_register_mpeg_ca(void)
80
15
{
81
82
15
    static hf_register_info hf[] = {
83
84
15
        { &hf_mpeg_ca_reserved, {
85
15
            "Reserved", "mpeg_ca.reserved",
86
15
            FT_UINT24, BASE_HEX, NULL, MPEG_CA_RESERVED_MASK,
87
15
                        NULL, HFILL
88
15
        } },
89
90
15
        { &hf_mpeg_ca_version_number, {
91
15
            "Version Number", "mpeg_ca.version",
92
15
            FT_UINT24, BASE_HEX, NULL, MPEG_CA_VERSION_NUMBER_MASK,
93
15
                        NULL, HFILL
94
15
        } },
95
96
15
        { &hf_mpeg_ca_current_next_indicator, {
97
15
            "Current/Next Indicator", "mpeg_ca.cur_next_ind",
98
15
            FT_BOOLEAN, 24, TFS(&tfs_current_not_yet), MPEG_CA_CURRENT_NEXT_INDICATOR_MASK,
99
15
                        NULL, HFILL
100
15
        } },
101
102
15
        { &hf_mpeg_ca_section_number, {
103
15
            "Section Number", "mpeg_ca.sect_num",
104
15
            FT_UINT8, BASE_DEC, NULL, 0,
105
15
                        NULL, HFILL
106
15
        } },
107
108
15
        { &hf_mpeg_ca_last_section_number, {
109
15
            "Last Section Number", "mpeg_ca.last_sect_num",
110
15
            FT_UINT8, BASE_DEC, NULL, 0,
111
15
                        NULL, HFILL
112
15
        } },
113
114
15
    };
115
116
15
    static int *ett[] = {
117
15
        &ett_mpeg_ca,
118
15
    };
119
120
15
    proto_mpeg_ca = proto_register_protocol("MPEG2 Conditional Access Table", "MPEG CA", "mpeg_ca");
121
122
15
    proto_register_field_array(proto_mpeg_ca, hf, array_length(hf));
123
15
    proto_register_subtree_array(ett, array_length(ett));
124
125
15
    mpeg_ca_handle = register_dissector("mpeg_ca", dissect_mpeg_ca, proto_mpeg_ca);
126
15
}
127
128
129
void proto_reg_handoff_mpeg_ca(void)
130
15
{
131
15
    dissector_add_uint("mpeg_sect.tid", MPEG_CA_TID, mpeg_ca_handle);
132
15
}
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
 */