Coverage Report

Created: 2026-11-12 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-slowprotocols.c
Line
Count
Source
1
/* packet-slowprotocols.c
2
 * Routines for EtherType (0x8809) Slow Protocols disassembly.
3
 * IEEE Std 802.3, Annex 57A
4
 *
5
 * Copyright 2002 Steve Housley <steve_housley@3com.com>
6
 * Copyright 2005 Dominique Bastien <dbastien@accedian.com>
7
 * Copyright 2009 Artem Tamazov <artem.tamazov@telllabs.com>
8
 * Copyright 2010 Roberto Morro <roberto.morro[AT]tilab.com>
9
 * Copyright 2014 Philip Rosenberg-Watt <p.rosenberg-watt[at]cablelabs.com.>
10
 *
11
 * Wireshark - Network traffic analyzer
12
 * By Gerald Combs <gerald@wireshark.org>
13
 * Copyright 1998 Gerald Combs
14
 *
15
 * SPDX-License-Identifier: GPL-2.0-or-later
16
 */
17
18
#include "config.h"
19
20
#include <epan/packet.h>
21
#include <epan/etypes.h>
22
#include "packet-slowprotocols.h"
23
24
/* General declarations */
25
void proto_register_slow_protocols(void);
26
void proto_reg_handoff_slow_protocols(void);
27
28
static dissector_handle_t slow_protocols_handle;
29
30
static dissector_table_t slow_protocols_dissector_table;
31
32
static const value_string subtype_vals[] = {
33
    { LACP_SUBTYPE   , "LACP" },
34
    { MARKER_SUBTYPE , "Marker Protocol" },
35
    { OAM_SUBTYPE    , "OAM" },
36
    { OSSP_SUBTYPE   , "Organization Specific Slow Protocol" },
37
    { 0, NULL }
38
};
39
40
/* Initialise the protocol and registered fields */
41
static int proto_slow;
42
43
static int hf_slow_subtype;
44
45
/* Initialise the subtree pointers */
46
47
static int ett_slow;
48
49
/*
50
 * Name: dissect_slow_protocols
51
 *
52
 * Description:
53
 *    This function is used to dissect the slow protocols defined in IEEE802.3
54
 *    CSMA/CD. The current slow protocols subtypes are define in Annex 57A of
55
 *    the 802.3 document. In case of an unsupported slow protocol, we only
56
 *    fill the protocol and info columns.
57
 *
58
 * Input Arguments:
59
 *    tvb:   buffer associated with the rcv packet (see tvbuff.h).
60
 *    pinfo: structure associated with the rcv packet (see packet_info.h).
61
 *    tree:  the protocol tree associated with the rcv packet (see proto.h).
62
 *
63
 * Return Values:
64
 *    None
65
 */
66
static int
67
dissect_slow_protocols(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
68
252
{
69
252
    uint8_t     subtype;
70
252
    proto_tree *pdu_tree;
71
252
    proto_item *pdu_item;
72
252
    tvbuff_t   *next_tvb;
73
74
252
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "Slow Protocols");
75
252
    subtype = tvb_get_uint8(tvb, 0);
76
252
    col_add_fstr(pinfo->cinfo, COL_INFO, "Subtype = %u", subtype);
77
78
252
    if (tree)
79
252
    {
80
252
        pdu_item = proto_tree_add_item(tree, proto_slow, tvb, 0, 1, ENC_NA);
81
252
        pdu_tree = proto_item_add_subtree(pdu_item, ett_slow);
82
83
        /* Subtype */
84
252
        proto_tree_add_item(pdu_tree, hf_slow_subtype, tvb, 0, 1, ENC_BIG_ENDIAN);
85
252
    }
86
87
252
    next_tvb = tvb_new_subset_remaining(tvb, 1);
88
252
    if (!dissector_try_uint_with_data(slow_protocols_dissector_table, subtype,
89
252
                                next_tvb, pinfo, tree, true, NULL))
90
17
        call_data_dissector(next_tvb, pinfo, tree);
91
252
    set_actual_length(tvb, tvb_captured_length(next_tvb) + 1);
92
93
252
    return tvb_captured_length(tvb);
94
252
}
95
96
97
/* Register the protocol with Wireshark */
98
void
99
proto_register_slow_protocols(void)
100
16
{
101
/* Setup list of header fields */
102
103
16
    static hf_register_info hf[] = {
104
16
        { &hf_slow_subtype,
105
16
          { "Slow Protocols subtype",    "slow.subtype",
106
16
            FT_UINT8,    BASE_HEX,    VALS(subtype_vals),    0x0,
107
16
            NULL, HFILL }},
108
16
    };
109
110
    /* Setup protocol subtree array */
111
112
16
    static int *ett[] = {
113
16
        &ett_slow,
114
16
    };
115
116
117
    /* Register the protocol name and description */
118
119
16
    proto_slow = proto_register_protocol("802.3 Slow protocols", "Slow Protocols", "slow");
120
121
    /* Required function calls to register the header fields and subtrees used */
122
123
16
    proto_register_field_array(proto_slow, hf, array_length(hf));
124
16
    proto_register_subtree_array(ett, array_length(ett));
125
126
    /* Register the dissector handle */
127
16
    slow_protocols_handle = register_dissector("slow", dissect_slow_protocols, proto_slow);
128
129
    /* subdissector code */
130
16
    slow_protocols_dissector_table = register_dissector_table("slow.subtype",
131
16
                                                              "Slow protocol subtype",
132
16
                                                               proto_slow, FT_UINT8, BASE_DEC);
133
16
}
134
135
void
136
proto_reg_handoff_slow_protocols(void)
137
16
{
138
16
    dissector_add_uint("ethertype", ETHERTYPE_SLOW_PROTOCOLS, slow_protocols_handle);
139
16
}
140
141
/*
142
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
143
 *
144
 * Local variables:
145
 * c-basic-offset: 4
146
 * tab-width: 8
147
 * indent-tabs-mode: nil
148
 * End:
149
 *
150
 * vi: set shiftwidth=4 tabstop=8 expandtab:
151
 * :indentSize=4:tabSize=8:noTabs=true:
152
 */