Coverage Report

Created: 2026-09-28 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-aruba-adp.c
Line
Count
Source
1
/* packet-aruba-adp.c
2
 * Routines for Aruba ADP header disassembly
3
 *
4
 * Giles Scott < gscott <at> arubanetworks dot 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
#include <epan/addr_resolv.h>
17
18
16
#define UDP_PORT_ADP 8200 /* Not IANA registered */
19
0
#define ADP_REQUEST 1
20
1
#define ADP_RESPONSE 2
21
22
void proto_register_aruba_adp(void);
23
void proto_reg_handoff_aruba_adp(void);
24
25
static dissector_handle_t adp_handle;
26
27
static int proto_aruba_adp;
28
static int ett_aruba_adp;
29
30
static int hf_adp_version;
31
static int hf_adp_type;
32
static int hf_adp_id;
33
static int hf_adp_mac;
34
static int hf_adp_switchip;
35
36
static const value_string adp_type_val[] =
37
{
38
    {1, "Request"},
39
    {2, "Response"},
40
    {0, NULL},
41
};
42
43
static int
44
dissect_aruba_adp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
45
3
{
46
3
    proto_tree *ti = NULL;
47
3
    proto_tree *aruba_adp_tree = NULL;
48
3
    uint16_t type;
49
3
    const char *mac_str;
50
3
    const char *switchip;
51
52
53
3
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "ADP");
54
3
    col_clear(pinfo->cinfo, COL_INFO);
55
56
57
3
    if (tree) {
58
3
        ti = proto_tree_add_item(tree, proto_aruba_adp, tvb, 0, -1, ENC_NA);
59
3
        aruba_adp_tree = proto_item_add_subtree(ti, ett_aruba_adp);
60
3
    }
61
62
3
    proto_tree_add_item(aruba_adp_tree, hf_adp_version, tvb, 0, 2, ENC_BIG_ENDIAN);
63
64
65
3
    proto_tree_add_item_ret_uint16(aruba_adp_tree, hf_adp_type, tvb, 2, 2, ENC_BIG_ENDIAN, &type);
66
67
3
    proto_tree_add_item(aruba_adp_tree, hf_adp_id, tvb, 4, 2, ENC_BIG_ENDIAN);
68
69
3
    switch(type){
70
0
        case ADP_REQUEST:
71
72
0
            proto_tree_add_item(aruba_adp_tree, hf_adp_mac, tvb, 6, 6, ENC_NA);
73
0
            mac_str = tvb_ether_to_str(pinfo->pool, tvb, 6);
74
75
0
            col_add_fstr(pinfo->cinfo, COL_INFO, "ADP Request Src MAC: %s", mac_str);
76
77
0
            proto_item_append_text(ti, ", Request Src MAC: %s", mac_str);
78
0
            break;
79
80
1
        case ADP_RESPONSE:
81
82
1
            proto_tree_add_item(aruba_adp_tree, hf_adp_switchip, tvb, 6, 4, ENC_BIG_ENDIAN);
83
1
            switchip = tvb_ip_to_str(pinfo->pool, tvb, 6);
84
85
1
            col_add_fstr(pinfo->cinfo, COL_INFO, "ADP Response Switch IP: %s", switchip);
86
87
1
            proto_item_append_text(ti, ", Response Switch IP: %s", switchip);
88
1
            break;
89
90
1
        default:
91
1
                break;
92
93
3
    }
94
2
    return tvb_captured_length(tvb);
95
3
}
96
97
void
98
proto_register_aruba_adp(void)
99
16
{
100
16
    static hf_register_info hf[] = {
101
16
        { &hf_adp_version,
102
16
        { "Version", "adp.version", FT_UINT16, BASE_DEC, NULL,0x0,
103
16
        "ADP version", HFILL}},
104
105
16
        { &hf_adp_type,
106
16
        { "Type", "adp.type", FT_UINT16, BASE_DEC, VALS(adp_type_val), 0x0,
107
16
        "ADP type", HFILL}},
108
109
16
        { &hf_adp_id,
110
16
        { "Transaction ID", "adp.id", FT_UINT16, BASE_DEC, NULL, 0x0,
111
16
        "ADP transaction ID", HFILL}},
112
113
16
        { &hf_adp_mac,
114
16
        { "MAC address", "adp.mac", FT_ETHER, BASE_NONE, NULL, 0x0,
115
16
        NULL, HFILL}},
116
117
16
        { &hf_adp_switchip,
118
16
        { "Switch IP", "adp.switch", FT_IPv4, BASE_NONE, NULL, 0x0,
119
16
        "Switch IP address", HFILL}},
120
121
16
        };
122
123
16
    static int *ett[] = {
124
16
        &ett_aruba_adp,
125
16
    };
126
127
16
    proto_aruba_adp = proto_register_protocol("Aruba Discovery Protocol",
128
16
                                        "ADP", "adp");
129
16
    proto_register_field_array(proto_aruba_adp, hf, array_length(hf));
130
16
    proto_register_subtree_array(ett, array_length(ett));
131
132
16
    adp_handle = register_dissector("adp", dissect_aruba_adp, proto_aruba_adp);
133
16
}
134
135
136
void
137
proto_reg_handoff_aruba_adp(void)
138
16
{
139
16
    dissector_add_uint_with_preference("udp.port", UDP_PORT_ADP, adp_handle);
140
16
}
141
142
/*
143
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
144
 *
145
 * Local variables:
146
 * c-basic-offset: 4
147
 * tab-width: 8
148
 * indent-tabs-mode: nil
149
 * End:
150
 *
151
 * vi: set shiftwidth=4 tabstop=8 expandtab:
152
 * :indentSize=4:tabSize=8:noTabs=true:
153
 */