2 * Routines for Omni-Path FE header dissection
3 * Copyright (c) 2016, Intel Corporation.
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include <epan/packet.h>
15 #include <epan/prefs.h>
17 #include "packet-ssl.h"
18 #include "packet-tcp.h"
20 void proto_reg_handoff_opa_fe(void);
21 void proto_register_opa_fe(void);
23 #define OPA_FE_TCP_RANGE "3245-3248" /* Not IANA registered */
24 #define OPA_FE_SSL_RANGE "3249-3252"
26 #define OPA_FE_HEADER_LEN 24
29 static gint proto_opa_fe = -1;
31 /* Variables to hold expansion values between packets */
32 static gint ett_fe = -1;
35 static gint hf_opa_fe_magicnumber = -1;
36 static gint hf_opa_fe_length_oob = -1;
37 static gint hf_opa_fe_headerversion = -1;
38 static gint hf_opa_fe_length = -1;
39 static gint hf_opa_fe_Reserved64 = -1;
41 /* Dissector Declarations */
42 static dissector_handle_t opa_fe_handle;
43 static dissector_handle_t opa_mad_handle;
45 static range_t *global_fe_ssl_range = NULL;
47 static range_t *fe_ssl_range = NULL;
49 static guint get_opa_fe_message_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
51 return tvb_get_ntohl(tvb, offset + 4);
53 static int dissect_opa_fe_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
55 gint offset = 0; /* Current Offset */
59 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Omni-Path");
60 col_clear(pinfo->cinfo, COL_INFO);
62 tree = proto_tree_get_root(tree);
64 FE_item = proto_tree_add_item(tree, proto_opa_fe, tvb, offset, OPA_FE_HEADER_LEN, ENC_NA);
65 FE_tree = proto_item_add_subtree(FE_item, ett_fe);
67 proto_tree_add_item(FE_tree, hf_opa_fe_magicnumber, tvb, offset, 4, ENC_BIG_ENDIAN);
69 proto_tree_add_item(FE_tree, hf_opa_fe_length_oob, tvb, offset, 4, ENC_BIG_ENDIAN);
71 proto_tree_add_item(FE_tree, hf_opa_fe_headerversion, tvb, offset, 4, ENC_BIG_ENDIAN);
73 proto_tree_add_item(FE_tree, hf_opa_fe_length, tvb, offset, 4, ENC_BIG_ENDIAN);
75 proto_tree_add_item(FE_tree, hf_opa_fe_Reserved64, tvb, offset, 8, ENC_BIG_ENDIAN);
78 /* Pass to OPA MAD dissector */
79 call_dissector(opa_mad_handle, tvb_new_subset_remaining(tvb, offset), pinfo, FE_tree);
80 return tvb_captured_length(tvb);
83 static int dissect_opa_fe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
85 tcp_dissect_pdus(tvb, pinfo, tree, TRUE, OPA_FE_HEADER_LEN,
86 get_opa_fe_message_len, dissect_opa_fe_message, data);
88 return tvb_reported_length(tvb);
91 static void range_delete_fe_ssl_callback(guint32 port, gpointer ptr _U_)
93 ssl_dissector_delete(port, opa_fe_handle);
96 static void range_add_fe_ssl_callback(guint32 port, gpointer ptr _U_)
98 ssl_dissector_add(port, opa_fe_handle);
101 void proto_register_opa_fe(void)
103 module_t *opa_fe_module;
105 static hf_register_info hf[] = {
106 { &hf_opa_fe_magicnumber, {
107 "Magic Number", "opa.fe.magicnumber",
108 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
110 { &hf_opa_fe_length_oob, {
111 "Length OOB", "opa.fe.lengthoob",
112 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
114 { &hf_opa_fe_headerversion, {
115 "Header Version", "opa.fe.headerversion",
116 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
118 { &hf_opa_fe_length, {
119 "Length", "opa.fe.length",
120 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
122 { &hf_opa_fe_Reserved64, {
123 "Reserved (64 bits)", "opa.fe.reserved64",
124 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }
128 static gint *ett[] = {
132 proto_opa_fe = proto_register_protocol(
133 "Intel Omni-Path FE Header - Omni-Path Fabric Excutive Header",
135 opa_fe_handle = register_dissector("opa.fe", dissect_opa_fe, proto_opa_fe);
137 proto_register_field_array(proto_opa_fe, hf, array_length(hf));
138 proto_register_subtree_array(ett, array_length(ett));
140 opa_fe_module = prefs_register_protocol(proto_opa_fe, proto_reg_handoff_opa_fe);
141 range_convert_str(wmem_epan_scope(), &global_fe_ssl_range, OPA_FE_SSL_RANGE, 65535);
142 prefs_register_range_preference(opa_fe_module, "tls.port", "SSL/TLS Ports",
143 "SSL/TLS Ports range",
144 &global_fe_ssl_range, 65535);
147 void proto_reg_handoff_opa_fe(void)
149 static gboolean initialized = FALSE;
153 opa_mad_handle = find_dissector("opa.mad");
154 dissector_add_uint_range_with_preference("tcp.port", OPA_FE_TCP_RANGE, opa_fe_handle);
158 range_foreach(fe_ssl_range, range_delete_fe_ssl_callback, NULL);
159 wmem_free(wmem_epan_scope(), fe_ssl_range);
160 fe_ssl_range = range_copy(wmem_epan_scope(), global_fe_ssl_range);
161 range_foreach(fe_ssl_range, range_add_fe_ssl_callback, NULL);
166 * Editor modelines - https://www.wireshark.org/tools/modelines.html
171 * indent-tabs-mode: nil
174 * vi: set shiftwidth=4 tabstop=8 expandtab:
175 * :indentSize=4:tabSize=8:noTabs=true: