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-tls.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 int proto_opa_fe
;
31 /* Variables to hold expansion values between packets */
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
;
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
;
47 static range_t
*fe_ssl_range
;
49 static unsigned 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 int 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(uint32_t port
, void *ptr _U_
)
93 ssl_dissector_delete(port
, opa_fe_handle
);
96 static void range_add_fe_ssl_callback(uint32_t port
, void *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 int *ett
[] = {
132 proto_opa_fe
= proto_register_protocol("Intel Omni-Path FE Header - Omni-Path Fabric Executive Header", "OPA FE", "opa.fe");
133 opa_fe_handle
= register_dissector("opa.fe", dissect_opa_fe
, proto_opa_fe
);
135 proto_register_field_array(proto_opa_fe
, hf
, array_length(hf
));
136 proto_register_subtree_array(ett
, array_length(ett
));
138 opa_fe_module
= prefs_register_protocol(proto_opa_fe
, proto_reg_handoff_opa_fe
);
139 range_convert_str(wmem_epan_scope(), &global_fe_ssl_range
, OPA_FE_SSL_RANGE
, 65535);
140 prefs_register_range_preference(opa_fe_module
, "tls.port", "SSL/TLS Ports",
141 "SSL/TLS Ports range",
142 &global_fe_ssl_range
, 65535);
143 prefs_register_obsolete_preference(opa_fe_module
, "ssl.port");
146 void proto_reg_handoff_opa_fe(void)
148 static bool initialized
= false;
152 opa_mad_handle
= find_dissector("opa.mad");
153 dissector_add_uint_range_with_preference("tcp.port", OPA_FE_TCP_RANGE
, opa_fe_handle
);
157 range_foreach(fe_ssl_range
, range_delete_fe_ssl_callback
, NULL
);
158 wmem_free(wmem_epan_scope(), fe_ssl_range
);
159 fe_ssl_range
= range_copy(wmem_epan_scope(), global_fe_ssl_range
);
160 range_foreach(fe_ssl_range
, range_add_fe_ssl_callback
, NULL
);
165 * Editor modelines - https://www.wireshark.org/tools/modelines.html
170 * indent-tabs-mode: nil
173 * vi: set shiftwidth=4 tabstop=8 expandtab:
174 * :indentSize=4:tabSize=8:noTabs=true: