Coverage Report

Created: 2025-08-04 07:15

/src/wireshark/epan/dissectors/packet-opa-fe.c
Line
Count
Source (jump to first uncovered line)
1
/* packet-opa-fe.c
2
 * Routines for Omni-Path FE header dissection
3
 * Copyright (c) 2016, Intel Corporation.
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/prefs.h>
16
17
#include "packet-tls.h"
18
#include "packet-tcp.h"
19
20
void proto_reg_handoff_opa_fe(void);
21
void proto_register_opa_fe(void);
22
23
14
#define OPA_FE_TCP_RANGE "3245-3248" /* Not IANA registered */
24
14
#define OPA_FE_SSL_RANGE "3249-3252"
25
26
90
#define OPA_FE_HEADER_LEN 24
27
28
/* Wireshark ID */
29
static int proto_opa_fe;
30
31
/* Variables to hold expansion values between packets */
32
static int ett_fe;
33
34
/* SnC Fields */
35
static int hf_opa_fe_magicnumber;
36
static int hf_opa_fe_length_oob;
37
static int hf_opa_fe_headerversion;
38
static int hf_opa_fe_length;
39
static int hf_opa_fe_Reserved64;
40
41
/* Dissector Declarations */
42
static dissector_handle_t opa_fe_handle;
43
static dissector_handle_t opa_mad_handle;
44
45
static range_t *global_fe_ssl_range;
46
47
static range_t *fe_ssl_range;
48
49
static unsigned get_opa_fe_message_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
50
52
{
51
52
    return tvb_get_ntohl(tvb, offset + 4);
52
52
}
53
static int dissect_opa_fe_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
54
50
{
55
50
    int offset = 0;    /* Current Offset */
56
50
    proto_item *FE_item;
57
50
    proto_tree *FE_tree;
58
59
50
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "Omni-Path");
60
50
    col_clear(pinfo->cinfo, COL_INFO);
61
62
50
    tree = proto_tree_get_root(tree);
63
64
50
    FE_item = proto_tree_add_item(tree, proto_opa_fe, tvb, offset, OPA_FE_HEADER_LEN, ENC_NA);
65
50
    FE_tree = proto_item_add_subtree(FE_item, ett_fe);
66
67
50
    proto_tree_add_item(FE_tree, hf_opa_fe_magicnumber, tvb, offset, 4, ENC_BIG_ENDIAN);
68
50
    offset += 4;
69
50
    proto_tree_add_item(FE_tree, hf_opa_fe_length_oob, tvb, offset, 4, ENC_BIG_ENDIAN);
70
50
    offset += 4;
71
50
    proto_tree_add_item(FE_tree, hf_opa_fe_headerversion, tvb, offset, 4, ENC_BIG_ENDIAN);
72
50
    offset += 4;
73
50
    proto_tree_add_item(FE_tree, hf_opa_fe_length, tvb, offset, 4, ENC_BIG_ENDIAN);
74
50
    offset += 4;
75
50
    proto_tree_add_item(FE_tree, hf_opa_fe_Reserved64, tvb, offset, 8, ENC_BIG_ENDIAN);
76
50
    offset += 8;
77
78
    /* Pass to OPA MAD dissector */
79
50
    call_dissector(opa_mad_handle, tvb_new_subset_remaining(tvb, offset), pinfo, FE_tree);
80
50
    return tvb_captured_length(tvb);
81
50
}
82
83
static int dissect_opa_fe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
84
40
{
85
40
    tcp_dissect_pdus(tvb, pinfo, tree, true, OPA_FE_HEADER_LEN,
86
40
        get_opa_fe_message_len, dissect_opa_fe_message, data);
87
88
40
    return tvb_reported_length(tvb);
89
40
}
90
91
static void range_delete_fe_ssl_callback(uint32_t port, void *ptr _U_)
92
0
{
93
0
    ssl_dissector_delete(port, opa_fe_handle);
94
0
}
95
96
static void range_add_fe_ssl_callback(uint32_t port, void *ptr _U_)
97
56
{
98
56
    ssl_dissector_add(port, opa_fe_handle);
99
56
}
100
101
void proto_register_opa_fe(void)
102
14
{
103
14
    module_t *opa_fe_module;
104
105
14
    static hf_register_info hf[] = {
106
14
        { &hf_opa_fe_magicnumber, {
107
14
                "Magic Number", "opa.fe.magicnumber",
108
14
                FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
109
14
        },
110
14
        { &hf_opa_fe_length_oob, {
111
14
                "Length OOB", "opa.fe.lengthoob",
112
14
                FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
113
14
        },
114
14
        { &hf_opa_fe_headerversion, {
115
14
                "Header Version", "opa.fe.headerversion",
116
14
                FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
117
14
        },
118
14
        { &hf_opa_fe_length, {
119
14
                "Length", "opa.fe.length",
120
14
                FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
121
14
        },
122
14
        { &hf_opa_fe_Reserved64, {
123
14
                "Reserved (64 bits)", "opa.fe.reserved64",
124
14
                FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }
125
14
        }
126
14
    };
127
128
14
    static int *ett[] = {
129
14
        &ett_fe
130
14
    };
131
132
14
    proto_opa_fe = proto_register_protocol("Intel Omni-Path FE Header - Omni-Path Fabric Executive Header", "OPA FE", "opa.fe");
133
14
    opa_fe_handle = register_dissector("opa.fe", dissect_opa_fe, proto_opa_fe);
134
135
14
    proto_register_field_array(proto_opa_fe, hf, array_length(hf));
136
14
    proto_register_subtree_array(ett, array_length(ett));
137
138
14
    opa_fe_module = prefs_register_protocol(proto_opa_fe, proto_reg_handoff_opa_fe);
139
14
    range_convert_str(wmem_epan_scope(), &global_fe_ssl_range, OPA_FE_SSL_RANGE, 65535);
140
14
    prefs_register_range_preference(opa_fe_module, "tls.port", "SSL/TLS Ports",
141
14
        "SSL/TLS Ports range",
142
14
        &global_fe_ssl_range, 65535);
143
14
    prefs_register_obsolete_preference(opa_fe_module, "ssl.port");
144
14
}
145
146
void proto_reg_handoff_opa_fe(void)
147
14
{
148
14
    static bool initialized = false;
149
150
14
    if (!initialized)
151
14
    {
152
14
        opa_mad_handle = find_dissector("opa.mad");
153
14
        dissector_add_uint_range_with_preference("tcp.port", OPA_FE_TCP_RANGE, opa_fe_handle);
154
14
        initialized = true;
155
14
    }
156
157
14
    range_foreach(fe_ssl_range, range_delete_fe_ssl_callback, NULL);
158
14
    wmem_free(wmem_epan_scope(), fe_ssl_range);
159
14
    fe_ssl_range = range_copy(wmem_epan_scope(), global_fe_ssl_range);
160
14
    range_foreach(fe_ssl_range, range_add_fe_ssl_callback, NULL);
161
162
14
}
163
164
/*
165
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
166
 *
167
 * Local variables:
168
 * c-basic-offset: 4
169
 * tab-width: 8
170
 * indent-tabs-mode: nil
171
 * End:
172
 *
173
 * vi: set shiftwidth=4 tabstop=8 expandtab:
174
 * :indentSize=4:tabSize=8:noTabs=true:
175
 */