Coverage Report

Created: 2025-02-15 06:25

/src/wireshark/epan/dissectors/packet-netgear-ensemble.c
Line
Count
Source (jump to first uncovered line)
1
/* packet-netgear-ensemble.c
2
 *
3
 * Routines for Netgear AP Ensemble Protocol
4
 * Charlie Lenahan <clenahan@sonicbison.com>
5
 *
6
 * Wireshark - Network traffic analyzer
7
 * By Gerald Combs <gerald@wireshark.org>
8
 * Copyright 1998 Gerald Combs
9
 *
10
 * SPDX-License-Identifier: GPL-2.0-or-later
11
 */
12
13
#include "config.h"
14
15
#include <epan/packet.h>
16
17
void proto_register_nge(void);
18
void proto_reg_handoff_nge(void);
19
20
static dissector_handle_t nge_handle;
21
22
#define NETGEAR_ENSEMBLE_PORT 4554
23
24
static int proto_nge;
25
26
static int hf_nge_version;
27
static int hf_nge_unknown;
28
static int hf_nge_unknown_int32;
29
static int hf_nge_sequence;
30
static int hf_nge_tlv_length;
31
static int hf_nge_ensemble_name;
32
static int hf_nge_firmware_name;
33
static int hf_nge_region_name;
34
static int hf_nge_firmware_version;
35
static int hf_nge_ap_name;
36
static int hf_nge_uptime;
37
static int hf_nge_mac;
38
static int hf_nge_ip;
39
static int hf_nge_uuid;
40
41
static int ett_nge;
42
static int ett_nge_lv;
43
static int ett_nge_ensemble;
44
45
46
static void
47
dissect_nge_esemble(tvbuff_t *tvb,proto_tree *tree, int offset)
48
0
{
49
0
    unsigned strLen=0;
50
51
0
    uint32_t length = tvb_get_uint32(tvb, offset,ENC_BIG_ENDIAN);
52
0
    proto_tree *ensemble_tree = proto_tree_add_subtree(tree, tvb, offset, length+4, ett_nge_ensemble, NULL,"Ensemble");
53
54
0
    proto_tree_add_uint(ensemble_tree, hf_nge_tlv_length, tvb, offset, 4, length);
55
0
    offset += 4;
56
57
0
    proto_tree_add_item(ensemble_tree, hf_nge_unknown, tvb, offset, 17, ENC_NA);
58
0
    offset += 17;
59
60
    /* type == 1 ? */
61
0
    proto_tree_add_item(ensemble_tree, hf_nge_unknown_int32, tvb, offset, 4, ENC_BIG_ENDIAN);
62
0
    offset += 4;
63
64
    /* uuid ? */
65
0
    proto_tree_add_item(ensemble_tree, hf_nge_uuid, tvb, offset, 16, ENC_BIG_ENDIAN);
66
0
    offset += 16;
67
68
0
    proto_tree_add_item(ensemble_tree, hf_nge_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
69
0
    offset += 4;
70
71
0
    proto_tree_add_item(ensemble_tree, hf_nge_unknown, tvb, offset, 20, ENC_NA);
72
0
    offset += 20;
73
74
0
    proto_tree_add_item(ensemble_tree, hf_nge_mac, tvb, offset, 6, ENC_NA);
75
0
    offset += 6;
76
77
    /* type == 2 ? */
78
0
    proto_tree_add_item(ensemble_tree, hf_nge_unknown_int32, tvb, offset, 4, ENC_BIG_ENDIAN);
79
0
    offset += 4;
80
81
0
    proto_tree_add_item_ret_length(ensemble_tree, hf_nge_ensemble_name, tvb, offset, 4, ENC_ASCII|ENC_BIG_ENDIAN, &strLen);
82
0
    offset += strLen;
83
84
0
    proto_tree_add_item_ret_length(ensemble_tree, hf_nge_firmware_name, tvb, offset, 4, ENC_ASCII|ENC_BIG_ENDIAN, &strLen);
85
0
    offset += strLen;
86
87
0
    proto_tree_add_item_ret_length(ensemble_tree, hf_nge_region_name, tvb, offset, 4, ENC_ASCII|ENC_BIG_ENDIAN, &strLen);
88
0
    offset += strLen;
89
90
    /* type == 0 ? */
91
0
    proto_tree_add_item(ensemble_tree, hf_nge_unknown_int32, tvb, offset, 4, ENC_BIG_ENDIAN);
92
0
    offset += 4;
93
94
0
    proto_tree_add_item_ret_length(ensemble_tree, hf_nge_firmware_version, tvb, offset, 4, ENC_ASCII|ENC_BIG_ENDIAN, &strLen);
95
0
    offset += strLen;
96
97
0
    proto_tree_add_item(ensemble_tree, hf_nge_unknown, tvb, offset, 16, ENC_NA);
98
0
    offset += 16;
99
100
    /* timestamp? */
101
0
    proto_tree_add_item(ensemble_tree, hf_nge_uptime, tvb, offset, 4, ENC_BIG_ENDIAN);
102
0
    offset += 4;
103
104
0
    proto_tree_add_item_ret_length(ensemble_tree, hf_nge_ap_name, tvb, offset, 4, ENC_ASCII|ENC_BIG_ENDIAN, &strLen);
105
0
    offset += strLen;
106
107
0
    proto_tree_add_item(ensemble_tree, hf_nge_unknown, tvb, offset, -1, ENC_NA);
108
109
0
}
110
111
static int
112
dissect_nge(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
113
0
{
114
0
    int offset = 0;
115
116
0
    proto_item *ti = proto_tree_add_item(tree, proto_nge, tvb, 0, -1, ENC_NA);
117
0
    proto_tree *nge_tree = proto_item_add_subtree(ti, ett_nge);
118
119
0
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NGE");
120
    /* Clear out stuff in the info column */
121
0
    col_clear(pinfo->cinfo,COL_INFO);
122
123
    /* presumed version */
124
0
    proto_tree_add_item(nge_tree, hf_nge_version, tvb, offset, 1, ENC_BIG_ENDIAN);
125
0
    offset += 1;
126
127
0
    proto_tree_add_item(nge_tree, hf_nge_unknown, tvb, offset, 3, ENC_NA);
128
0
    offset += 3;
129
130
0
    proto_tree_add_item(nge_tree, hf_nge_sequence, tvb, offset, 4, ENC_BIG_ENDIAN);
131
0
    offset += 4;
132
133
0
    dissect_nge_esemble(tvb, nge_tree, offset);
134
135
0
    return tvb_captured_length(tvb);
136
0
}
137
138
139
void
140
proto_register_nge(void)
141
14
{
142
14
    static hf_register_info hf[] = {
143
14
        { &hf_nge_version,
144
14
            { "Version", "nge.version",FT_UINT8, BASE_DEC,
145
14
                NULL, 0x0,NULL, HFILL }},
146
14
        { &hf_nge_unknown,
147
14
            { "Unknown", "nge.unknown", FT_BYTES, BASE_NONE,
148
14
                NULL, 0x0,NULL, HFILL }},
149
14
        { &hf_nge_unknown_int32,
150
14
            { "Unknown", "nge.unknown.int32", FT_UINT32, BASE_DEC,
151
14
                NULL, 0x0, NULL, HFILL }},
152
14
        { &hf_nge_sequence,
153
14
            { "Sequence", "nge.sequence", FT_UINT32, BASE_DEC,
154
14
                NULL, 0x0, NULL, HFILL }},
155
14
        { &hf_nge_uptime,
156
14
            { "Uptime", "nge.uptime", FT_UINT32, BASE_DEC,
157
14
                NULL, 0x0, NULL, HFILL }},
158
14
        { &hf_nge_mac,
159
14
            { "MAC", "nge.mac", FT_ETHER, BASE_NONE,
160
14
                NULL, 0x0,NULL, HFILL }},
161
14
        { &hf_nge_ip,
162
14
            { "IP", "nge.ip", FT_IPv4, BASE_NONE,
163
14
                NULL, 0x0,NULL, HFILL }},
164
14
        { &hf_nge_uuid,
165
14
            { "Device UUID", "nge.uuid", FT_GUID, BASE_NONE,
166
14
                NULL, 0x0,NULL, HFILL }},
167
14
        { &hf_nge_ensemble_name,
168
14
            { "Ensemble Name", "nge.ensemble_name", FT_UINT_STRING, BASE_NONE,
169
14
                NULL, 0x0, NULL, HFILL }},
170
14
        { &hf_nge_firmware_name,
171
14
            { "Firmware Name", "nge.firmware_name", FT_UINT_STRING, BASE_NONE,
172
14
                NULL, 0x0, NULL, HFILL }},
173
14
        { &hf_nge_region_name,
174
14
            { "Region Name", "nge.region_name", FT_UINT_STRING, BASE_NONE,
175
14
                NULL, 0x0, NULL, HFILL }},
176
14
        { &hf_nge_firmware_version,
177
14
            { "Firmware Version", "nge.firmware_version", FT_UINT_STRING, BASE_NONE,
178
14
                NULL, 0x0, NULL, HFILL }},
179
14
        { &hf_nge_ap_name,
180
14
            { "AP Name", "nge.ap_name", FT_UINT_STRING, BASE_NONE,
181
14
                NULL, 0x0, NULL, HFILL }},
182
14
        { &hf_nge_tlv_length,
183
14
            { "Length", "nge.tlv_len", FT_UINT32, BASE_DEC,
184
14
                NULL, 0x0, NULL, HFILL }},
185
14
    };
186
187
    /* Setup protocol subtree array */
188
14
    static int *ett[] = {
189
14
        &ett_nge,
190
14
        &ett_nge_lv,
191
14
        &ett_nge_ensemble
192
14
    };
193
194
14
    proto_nge = proto_register_protocol ("Netgear Ensemble Protocol", "NGE", "nge");
195
196
14
    proto_register_field_array(proto_nge, hf, array_length(hf));
197
14
    proto_register_subtree_array(ett, array_length(ett));
198
199
14
    nge_handle = register_dissector("nge", dissect_nge, proto_nge);
200
14
}
201
202
void
203
proto_reg_handoff_nge(void)
204
14
{
205
14
    dissector_add_for_decode_as_with_preference("udp.port", nge_handle);
206
14
}
207
208
/*
209
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
210
 *
211
 * Local variables:
212
 * c-basic-offset: 4
213
 * tab-width: 8
214
 * indent-tabs-mode: nil
215
 * End:
216
 *
217
 * vi: set shiftwidth=4 tabstop=8 expandtab:
218
 * :indentSize=4:tabSize=8:noTabs=true:
219
 */