Coverage Report

Created: 2025-02-15 06:25

/src/wireshark/epan/dissectors/packet-h221_nonstd.c
Line
Count
Source (jump to first uncovered line)
1
/* packet-h221_nonstd.c
2
 * Routines for H.221 nonstandard parameters disassembly
3
 *
4
 * Wireshark - Network traffic analyzer
5
 * By Gerald Combs <gerald@wireshark.org>
6
 * Copyright 1998 Gerald Combs
7
 *
8
 * SPDX-License-Identifier: GPL-2.0-or-later
9
 */
10
11
#include "config.h"
12
13
#include <epan/packet.h>
14
15
void proto_register_nonstd(void);
16
void proto_reg_handoff_nonstd(void);
17
18
static dissector_handle_t ms_nonstd_handle;
19
20
/* Define the nonstd proto */
21
static int proto_nonstd;
22
23
static int hf_h221_nonstd_netmeeting_codec;
24
static int hf_h221_nonstd_netmeeting_non_standard;
25
26
/*
27
 * Define the trees for nonstd
28
 * We need one for nonstd itself and one for the nonstd paramters
29
 */
30
static int ett_nonstd;
31
32
static const value_string ms_codec_vals[] = {
33
    {  0x0111, "L&H CELP 4.8k" },
34
    {  0x0200, "MS-ADPCM" },
35
    {  0x0211, "L&H CELP 8k" },
36
    {  0x0311, "L&H CELP 12k" },
37
    {  0x0411, "L&H CELP 16k" },
38
    {  0x1100, "IMA-ADPCM" },
39
    {  0x3100, "MS-GSM" },
40
    {  0xfeff, "E-AMR" },
41
    {  0, NULL }
42
};
43
44
static int
45
dissect_ms_nonstd(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
46
0
{
47
0
    proto_item *it;
48
0
    proto_tree *tr;
49
0
    uint32_t offset=0;
50
0
    int tvb_len;
51
0
    uint16_t codec_extra;
52
53
0
    it=proto_tree_add_protocol_format(tree, proto_nonstd, tvb, 0, tvb_reported_length(tvb), "Microsoft NonStd");
54
0
    tr=proto_item_add_subtree(it, ett_nonstd);
55
56
57
0
    tvb_len = tvb_reported_length(tvb);
58
59
    /*
60
     * XXX - why do this test?  Are there any cases where throwing
61
     * an exception if the tvbuff is too short causes subsequent stuff
62
     * in the packet not to be dissected (e.g., if the octet string
63
     * containing the non-standard data is too short for the data
64
     * supposedly contained in it, and is followed by more items)?
65
     *
66
     * If so, the right fix might be to catch ReportedBoundsError in
67
     * the dissector calling this dissector, and report a malformed
68
     * nonStandardData item, and rethrow other exceptions (as a
69
     * BoundsError means you really *have* run out of packet data).
70
     */
71
0
    if(tvb_len >= 23)
72
0
    {
73
74
0
        codec_extra = tvb_get_ntohs(tvb,offset+22);
75
76
0
        if(codec_extra == 0x0100)
77
0
        {
78
79
0
            proto_tree_add_item(tr, hf_h221_nonstd_netmeeting_codec, tvb, offset+20, 2, ENC_BIG_ENDIAN);
80
81
0
        }
82
0
        else
83
0
        {
84
85
0
            proto_tree_add_item(tr, hf_h221_nonstd_netmeeting_non_standard, tvb, offset, -1, ENC_NA);
86
87
0
        }
88
0
    }
89
0
    return tvb_captured_length(tvb);
90
0
}
91
92
/* Register all the bits needed with the filtering engine */
93
94
void
95
proto_register_nonstd(void)
96
14
{
97
14
    static hf_register_info hf[] = {
98
14
        { &hf_h221_nonstd_netmeeting_codec,
99
14
            { "Microsoft NetMeeting Codec", "h221nonstd.netmeeting.codec", FT_UINT32, BASE_HEX,
100
14
                VALS(ms_codec_vals), 0, NULL, HFILL }
101
14
        },
102
14
        { &hf_h221_nonstd_netmeeting_non_standard,
103
14
            { "Microsoft NetMeeting Non Standard", "h221nonstd.netmeeting.non_standard", FT_BYTES, BASE_NONE,
104
14
                NULL, 0, NULL, HFILL }
105
14
        },
106
14
    };
107
108
14
    static int *ett[] = {
109
14
        &ett_nonstd,
110
14
    };
111
112
14
    proto_nonstd = proto_register_protocol("H221NonStandard","h221nonstd", "h221nonstd");
113
114
14
    proto_register_subtree_array(ett, array_length(ett));
115
14
    proto_register_field_array(proto_nonstd, hf, array_length(hf));
116
117
14
    ms_nonstd_handle = register_dissector("h221nonstd", dissect_ms_nonstd, proto_nonstd);
118
14
}
119
120
/* The registration hand-off routine */
121
void
122
proto_reg_handoff_nonstd(void)
123
14
{
124
14
    dissector_add_uint("h245.nsp.h221",0xb500534c, ms_nonstd_handle);
125
14
    dissector_add_uint("h225.nsp.h221",0xb500534c, ms_nonstd_handle);
126
14
}
127
128
/*
129
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
130
 *
131
 * Local variables:
132
 * c-basic-offset: 4
133
 * tab-width: 8
134
 * indent-tabs-mode: nil
135
 * End:
136
 *
137
 * vi: set shiftwidth=4 tabstop=8 expandtab:
138
 * :indentSize=4:tabSize=8:noTabs=true:
139
 */